apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: vmpools.vmoperator.jdrupes.org
spec:
  group: vmoperator.jdrupes.org
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                retention:
                  description: >-
                    Defines the timeout for assignments. The time may be
                    specified as ISO 8601 time or duration. When specifying
                    a duration, it will be added to the last time the VM's 
                    console was used to obtain the timeout.
                  type: string
                  pattern: '^(?:\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d{1,9})?(?:Z|[+-](?:[01]\d|2[0-3])(?:|:?[0-5]\d))|P(?:\d+Y)?(?:\d+M)?(?:\d+W)?(?:\d+D)?(?:T(?:\d+[Hh])?(?:\d+[Mm])?(?:\d+(?:\.\d{1,9})?[Ss])?)?)$'
                  default: "PT1h"
                loginOnAssignment:
                  description: >-
                    If set to true, the user will be automatically logged in
                    to the VM's console when the VM is assigned to him.
                  type: boolean
                  default: false
                permissions:
                  type: array
                  description: >-
                    Defines permissions for accessing and manipulating the Pool.
                  items:
                    type: object
                    description: >-
                      Permissions can be granted to a user or to a role.
                    oneOf:
                    - required:
                      - user
                    - required:
                      - role
                    properties:
                      user:
                        type: string
                      role:
                        type: string
                      may:
                        type: array
                        items:
                          type: string
                          enum:
                          - start
                          - stop
                          - reset
                          - accessConsole
                          - "*"
                        default: ["accessConsole"]
              required:
              - permissions
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: vmpools
    # singular name to be used as an alias on the CLI and for display
    singular: vmpool
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: VmPool
    listKind: VmPoolList
