apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: reportdatasources.metering.openshift.io
spec:
  group: metering.openshift.io
  version: v1
  versions:
  - name: v1
    served: true
    storage: true
  - name: v1alpha1
    served: true
    storage: false
  scope: Namespaced
  names:
    plural: reportdatasources
    singular: reportdatasource
    kind: ReportDataSource
    shortNames:
    - datasource
    - datasources
  additionalPrinterColumns:
  - name: Earliest Metric
    type: string
    JSONPath: .status.prometheusMetricsImportStatus.earliestImportedMetricTime
  - name: Newest Metric
    type: string
    JSONPath: .status.prometheusMetricsImportStatus.newestImportedMetricTime
  - name: Import Start
    type: string
    JSONPath: .status.prometheusMetricsImportStatus.importDataStartTime
  - name: Import End
    type: string
    JSONPath: .status.prometheusMetricsImportStatus.importDataEndTime
  - name: Last Import Time
    type: string
    JSONPath: .status.prometheusMetricsImportStatus.lastImportTime
  - name: Age
    type: date
    JSONPath: .metadata.creationTimestamp
  validation:
    openAPIV3Schema:
      type: object
      required:
      - spec
      properties:
        spec:
          type: object
          properties:
            prometheusMetricsImporter:
              type: object
              required:
              - query
              properties:
                query:
                  type: string
                  minLength: 1
                storage:
                  type: object
                  required:
                  - storageLocationName
                  properties:
                    storageLocationName:
                      type: string
                      minLength: 1
                prometheusConfig:
                  type: object
                  required:
                  - url
                  properties:
                    url:
                      type: string
                      format: uri
            reportQueryView:
              type: object
              required:
              - queryName
              properties:
                queryName:
                  type: string
                  minLength: 1
                inputs:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    required:
                    - name
                    - value
                    properties:
                      name:
                        type: string
                        minLength: 1
                      value: {}
                storage:
                  type: object
                  required:
                  - storageLocationName
                  properties:
                    storageLocationName:
                      type: string
                      minLength: 1
            awsBilling:
              type: object
              required:
              - source
              properties:
                source:
                  type: object
                  required:
                  - bucket
                  - region
                  properties:
                    bucket:
                      type: string
                      minLength: 1
                    prefix:
                      type: string
                    region:
                      type: string
                      minLength: 1
            prestoTable:
              type: object
              required:
              - tableRef
              properties:
                tableRef:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
                      minLength: 1
          oneOf:
          - required:
            - prometheusMetricsImporter
          - required:
            - reportQueryView
          - required:
            - awsBilling
          - required:
            - prestoTable

