apiVersion: runtimeconditions.io/v1alpha1
kind: RuntimeConditionsExtensionDefinition
metadata:
  id: https://runtimeconditions.io/extensions/kubernetes/api/0.1.0/runtimeconditions.extension.yaml
  version: 0.1.0
  semanticSha256: 74325613d6fad555e7ab3fc195fe373b16c1f1a7ab77cedacee06a96c4353896
spec:
  kinds:
  - name: kubernetes.api
  interfaceTypes:
  - name: api
    targetKind: kubernetes.api
  interfaceFields:
  - name: operations
    targetKind: kubernetes.api
    targetType: api
  fieldValues:
  - field: interface.operations[].verb
    targetKind: kubernetes.api
    targetType: api
    values:
    - connect
    - create
    - delete
    - deletecollection
    - get
    - list
    - patch
    - update
    - watch
  - field: interface.operations[].scope
    targetKind: kubernetes.api
    targetType: api
    values: &id001
    - all_namespaces
    - cluster
    - namespaced
  - field: interface.operations[].method
    targetKind: kubernetes.api
    targetType: api
    values: &id002
    - delete
    - get
    - head
    - options
    - patch
    - post
    - put
    - trace
  schemas:
  - id: kubernetes-api-interface
    appliesToKind: kubernetes.api
    appliesToInterfaceType: api
    description: Validates Kubernetes resource, connect, and non-resource API requirements.
    schema:
      $schema: https://json-schema.org/draft/2020-12/schema
      type: object
      required:
      - kind
      - interface
      properties:
        kind:
          const: kubernetes.api
        interface:
          type: object
          required:
          - type
          - operations
          properties:
            type:
              const: api
            operations:
              type: array
              minItems: 1
              uniqueItems: true
              items:
                oneOf:
                - type: object
                  required:
                  - verb
                  - apiGroup
                  - apiVersion
                  - resource
                  - scope
                  properties:
                    verb:
                      enum:
                      - create
                      - delete
                      - deletecollection
                      - get
                      - list
                      - patch
                      - update
                      - watch
                    apiGroup: &id003
                      type: string
                      maxLength: 253
                      pattern: ^(?:|[a-z0-9](?:[-a-z0-9.]*[a-z0-9])?)$
                    apiVersion: &id004
                      type: string
                      maxLength: 63
                      pattern: ^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$
                    resource: &id005
                      type: string
                      maxLength: 63
                      pattern: ^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$
                    scope: &id006
                      enum: *id001
                    subresource: &id007
                      type: string
                      maxLength: 63
                      pattern: ^[a-z0-9](?:[-a-z0-9]*[a-z0-9])?$
                  additionalProperties: false
                - type: object
                  required:
                  - verb
                  - method
                  - apiGroup
                  - apiVersion
                  - resource
                  - scope
                  properties:
                    verb:
                      const: connect
                    method:
                      enum: *id002
                    apiGroup: *id003
                    apiVersion: *id004
                    resource: *id005
                    scope: *id006
                    subresource: *id007
                  additionalProperties: false
                - type: object
                  required:
                  - path
                  - method
                  properties:
                    path:
                      type: string
                      minLength: 1
                      pattern: ^/
                    method:
                      enum: *id002
                  additionalProperties: false
          additionalProperties: false
