apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  # name must match the spec fields below, and be in the form: <plural>.<group>
  name: orderreservations.ewm.sap.com
spec:
  group: ewm.sap.com
  # either Namespaced or Cluster
  scope: Namespaced
  names:
    # plural name to be used in the URL: /apis/<group>/<version>/<plural>
    plural: orderreservations
    # singular name to be used as an alias on the CLI and for display
    singular: orderreservation
    # kind is normally the CamelCased singular type. Your resource manifests use this.
    kind: OrderReservation
    # shortNames allow shorter string to match your resource on the CLI
    shortNames:
    - ordres
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1alpha1
      # Each version can be enabled/disabled by Served flag.
      served: true
      # One and only one version must be marked as the storage version.
      storage: true
      subresources:
        status: {}
      schema:
        openAPIV3Schema:
          type: object
          required:
            - spec
          properties:
            spec:
              type: object
              required:
                - orderrequest
              properties:
                orderrequest:
                  type: object
                  required:
                    - lgnum
                    - rsrctype
                    - rsrcgrp
                    - quantity
                  properties:
                    lgnum:
                      type: string
                    rsrctype:
                      type: string
                    rsrcgrp:
                      type: string
                    quantity:
                      type: integer
                      minimum: 1
                orderassignments:
                  type: array
                  items:
                    type: object
                    properties:
                      lgnum:
                        type: string
                      who:
                        type: string
                      rsrc:
                        type: string
            status:
              type: object
              properties:
                warehouseorders:
                  type: array
                  items:
                    type: object
                    required:
                      - lgnum
                      - who
                      - status
                      - areawho
                      - lgtyp
                      - lgpla
                      - queue
                      - rsrc
                      - lsd
                      - topwhoid
                      - refwhoid
                      - flgwho
                      - flgto
                      - warehousetasks
                    properties:
                      lgnum:
                        type: string
                      who:
                        type: string
                      status:
                        type: string
                      areawho:
                        type: string
                      lgtyp:
                        type: string
                      lgpla:
                        type: string
                      queue:
                        type: string
                      rsrc:
                        type: string
                      lsd:
                        type: integer
                      topwhoid:
                        type: string
                      refwhoid:
                        type: string
                      flgwho:
                        type: boolean
                      flgto:
                        type: boolean
                      warehousetasks:
                        type: array
                        items:
                          type: object
                          required: 
                            - flghuto
                            - lgnum
                            - nlber
                            - nlenr
                            - nlpla
                            - nltyp
                            - priority
                            - procty
                            - tanum
                            - tostat
                            - unitv
                            - unitw
                            - vlber
                            - vlenr
                            - vlpla
                            - vltyp
                            - volum
                            - weight
                            - who
                          properties:
                            flghuto:
                              type: boolean
                            lgnum:
                              type: string
                            nlber:
                              type: string
                            nlenr:
                              type: string
                            nlpla:
                              type: string
                            nltyp:
                              type: string
                            priority:
                              type: integer
                            procty:
                              type: string
                            tanum:
                              type: string
                            tostat:
                              type: string
                            unitv:
                              type: string
                            unitw:
                              type: string
                            vlber:
                              type: string
                            vlenr:
                              type: string
                            vlpla:
                              type: string
                            vltyp:
                              type: string
                            volum:
                              type: number
                            weight:
                              type: number
                            who:
                              type: string
                orderassignments:
                  type: array
                  items:
                    type: object
                    properties:
                      lgnum:
                        type: string
                      who:
                        type: string
                      rsrc:
                        type: string
                status:
                  type: string
                  enum:
                    - NEW
                    - ACCEPTED
                    - RESERVATIONS
                    - FAILED
                    - SUCCEEDED
                    - TIMEOUT
                message:
                  type: string
                validuntil:
                  type: string
      additionalPrinterColumns:
      - jsonPath: .status.status
        name: Status
        type: string
      - jsonPath: .status.validuntil
        name: Valid until
        type: string
      - jsonPath: .metadata.creationTimestamp
        description: |-
          CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC.

          Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
        name: Age
        type: date
