apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: apintoservices.apinto.com
spec:
  group: apinto.com
  names:
    plural: apintoservices
    singular: apintoservice
    kind: ApintoService
    shortNames:
      - as
      - service
  scope: Namespaced
  versions:
    - name: v1beta
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              oneOf:
                - required: ["name", "driver", "upstream"]
                - required: ["name", "driver", "anonymous"]
              properties:
                name:
                  type: string
                  minLength: 1
                desc:
                  type: string
                driver:
                  type: string
                  enum: ["http"]
                timeout:
                  type: integer
                upstream:
                  type: string
                  pattern: '\w+(@upstream)$'
                anonymous:
                  type: object
                  properties:
                    type:
                      type: string
                      enum: ["round-robin"]
                    config:
                      type: string
                      minLength: 1
                  required:
                    - type
                    - config
                retry:
                  type: integer
                rewrite_url:
                  type: string
                  minLength: 1
                scheme:
                  type: string
                  default: http
                  enum: ["http","https"]
                plugins:
                  type: object
                  nullable: true
                  x-kubernetes-preserve-unknown-fields: true