apiVersion: "apiextensions.k8s.io/v1"
kind: "CustomResourceDefinition"
metadata:
  name: "components.oda.tmforum.org"
spec:
  scope: "Namespaced"
  group: "oda.tmforum.org"
  names:
    plural: "components"
    singular: "component"
    kind: "component"
  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: false
#   deprecated: true
#   deprecationWarning: "oda.tmforum.org/v1alpha1 Component is deprecated; Please upgrade to oda.tmforum.org/v1alpha2 see https://github.com/tmforum-oda/oda-canvas-charts/issues/9"
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:     
              coreFunction:
                type: object  
                properties:  
                  exposedAPIs:   
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        specification:
                          type: string
                        implementation:
                          type: string
                        path:
                          type: string
                        developerUI:
                          type: string
                        port:
                          type: integer
                  dependantAPIs:   
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        specification:
                          type: string
                        path:
                          type: string
              eventNotification:
                type: object  
                properties:  
                  publishedEvents: 
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        href:
                          type: string
                  subscribedEvents: 
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        href:
                          type: string
              management:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                    href:
                      type: string
                    specification:
                      type: string
              security:
                type: object  
                properties:
                  securitySchemes: 
                    type: object
                    x-kubernetes-preserve-unknown-fields: true                        
              version:
                type: string
              description:
                type: string
              type:
                type: string
              selector:
                type: object
                x-kubernetes-preserve-unknown-fields: true    
              componentKinds:
                type: array
                items:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true    
              maintainers:
                type: array
                items:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true    
              owners:
                type: array
                items:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true    
          status:
            type: object
            x-kubernetes-preserve-unknown-fields: true    
    additionalPrinterColumns:
    - name: exposed_APIs
      type: string
      description: list the endpoints for exposed APIs
      jsonPath: .status.exposedAPIsummary
    - name: developer_UI
      type: string
      description: list the Developer User Interface(s)
      jsonPath: .status.developerUIsummary
    - name: deployment_status
      type: string
      description: Deployment status [in progress, complete, failed]
      jsonPath: .status.deployment_status
  - name: "v1alpha2"
    # 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
#    deprecated: false
#    deprecationWarning: "oda.tmforum.org/v1alpha1 Component is deprecated; Please upgrade to oda.tmforum.org/v1alpha2 see https://github.com/tmforum-oda/oda-canvas-charts/issues/9"
    schema:
      openAPIV3Schema:
        type: object
        properties:
          spec:
            type: object
            properties:     
              coreFunction:
                type: object  
                properties:  
                  exposedAPIs:   
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        specification:
                          type: string
                        implementation:
                          type: string
                        path:
                          type: string
                        developerUI:
                          type: string
                        port:
                          type: integer
                  dependantAPIs:   
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        specification:
                          type: string
                        path:
                          type: string
              eventNotification:
                type: object  
                properties:  
                  publishedEvents: 
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        href:
                          type: string
                  subscribedEvents: 
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        href:
                          type: string
              management:
                type: array
                items:
                  type: object
                  properties:
                    name:
                      type: string
                    href:
                      type: string
                    specification:
                      type: string
              security:
                type: object  
                properties:  
                  securitySchemes: 
                    type: object
                    x-kubernetes-preserve-unknown-fields: true    
                  partyrole:
                    type: object
                    properties:
                      specification:
                        type: string
                      implementation:
                        type: string
                      path:
                        type: string
                      developerUI:
                        type: string
                      port:
                        type: integer                
              version:
                type: string
              description:
                type: string
              type:
                type: string
              selector:
                type: object
                x-kubernetes-preserve-unknown-fields: true    
              componentKinds:
                type: array
                items:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true    
              maintainers:
                type: array
                items:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true    
              owners:
                type: array
                items:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true    
          status:
            type: object
            x-kubernetes-preserve-unknown-fields: true    
    additionalPrinterColumns:
    - name: exposed_APIs
      type: string
      description: list the endpoints for exposed APIs
      jsonPath: .status.exposedAPIsummary
    - name: developer_UI
      type: string
      description: list the Developer User Interface(s)
      jsonPath: .status.developerUIsummary
    - name: deployment_status
      type: string
      description: Deployment status [in progress, complete, failed]
      jsonPath: .status.deployment_status
