# Copyright 2021 Contributors to the EdgeNet project.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tenantrequests.registration.edgenet.io
spec:
  group: registration.edgenet.io
  # list of versions supported by this CustomResourceDefinition
  versions:
    - name: v1alpha
      # 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: {}
      additionalPrinterColumns:
        - name: Official Name
          type: string
          jsonPath: .spec.fullname
        - name: Short Name
          type: string
          jsonPath: .spec.shortname
        - name: URL
          type: string
          jsonPath: .spec.url
        - name: City
          type: string
          jsonPath: .spec.address.city
        - name: Country
          type: string
          jsonPath: .spec.address.country
        - name: Expiry
          type: string
          jsonPath: .status.expiry
        - name: Age
          type: date
          jsonPath: .metadata.creationTimestamp
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              required:
                - fullname
                - shortname
                - url
                - address
                - contact
              properties:
                fullname:
                  type: string
                shortname:
                  type: string
                url:
                  type: string
                address:
                  type: object
                  required:
                    - street
                    - zip
                    - city
                    - country
                  properties:
                    street:
                      type: string
                    zip:
                      type: string
                    city:
                      type: string
                    region:
                      type: string
                      description: region or state
                    country:
                      type: string
                contact:
                  type: object
                  required:
                    - username
                    - firstname
                    - lastname
                    - email
                    - phone
                  properties:
                    username:
                      type: string
                      pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
                    firstname:
                      type: string
                    lastname:
                      type: string
                    email:
                      type: string
                    phone:
                      type: string
                approved:
                  type: boolean
            status:
              type: object
              properties:
                emailverified:
                  type: boolean
                expiry:
                  type: string
                  format: dateTime
                  nullable: true
                state:
                  type: string
                message:
                  type: array
                  items:
                    type: string
  scope: Cluster
  names:
    plural: tenantrequests
    singular: tenantrequest
    kind: TenantRequest
    shortNames:
      - trr
