apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: reportdatasources.metering.openshift.io
spec:
  group: metering.openshift.io
  scope: Namespaced
  names:
    plural: reportdatasources
    singular: reportdatasource
    kind: ReportDataSource
    shortNames:
    - datasource
    - datasources
  versions:
  - name: v1
    served: true
    storage: true
    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
    schema:
      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:
                          type: string
                  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
              linkExistingTable:
                type: object
                required:
                - tableName
                properties:
                  tableName:
                    description: |
                      TableName is the fully-qualified table name (i.e. catalog.schema.table_name) of an existing Presto table.
                    type: string
                    minLength: 1
            oneOf:
            - required:
              - prometheusMetricsImporter
            - required:
              - reportQueryView
            - required:
              - awsBilling
            - required:
              - prestoTable
            - required:
              - linkExistingTable
          status:
            type: object
            properties:
              tableRef:
                type: object
                properties:
                  name:
                    type: string
              prometheusMetricsImportStatus:
                type: object
                properties:
                  lastImportTime:
                    type: string
                    format: date-time
                  importDataStartTime:
                    type: string
                    format: date-time
                  importDataEndTime:
                    type: string
                    format: date-time
                  earliestImportedMetricTime:
                    type: string
                    format: date-time
                  newestImportedMetricTime:
                    type: string
                    format: date-time
