components:

    schemas:

        HsHostingAssetType:
            type: string
            enum:
                - CLOUD_SERVER
                - MANAGED_SERVER
                - MANAGED_WEBSPACE
                - UNIX_USER
                - DOMAIN_DNS_SETUP
                - DOMAIN_HTTP_SETUP
                - DOMAIN_EMAIL_SETUP
                - EMAIL_ALIAS
                - EMAIL_ADDRESS
                - PGSQL_USER
                - PGSQL_DATABASE
                - MARIADB_USER
                - MARIADB_DATABASE

        HsHostingAsset:
            type: object
            properties:
                uuid:
                    type: string
                    format: uuid
                type:
                    $ref: '#/components/schemas/HsHostingAssetType'
                identifier:
                    type: string
                caption:
                    type: string
                alarmContact:
                    $ref: '../hs-office/hs-office-contact-schemas.yaml#/components/schemas/HsOfficeContact'
                config:
                    $ref: '#/components/schemas/HsHostingAssetConfiguration'
            required:
                - type
                - ídentifier
                - uuid
                - config

        HsHostingAssetPatch:
            type: object
            properties:
                caption:
                    type: string
                    nullable: true
                alarmContactUuid:
                    type: string
                    format: uuid
                    nullable: true
                config:
                    $ref: '#/components/schemas/HsHostingAssetConfiguration'

        HsHostingAssetInsert:
            type: object
            properties:
                bookingItemUuid:
                    type: string
                    format: uuid
                    nullable: true
                parentAssetUuid:
                    type: string
                    format: uuid
                    nullable: true
                type:
                    $ref: '#/components/schemas/HsHostingAssetType'
                identifier:
                    type: string
                    minLength: 3
                    maxLength: 80
                    nullable: false
                caption:
                    type: string
                    minLength: 3
                    maxLength: 80
                    nullable: false
                alarmContactUuid:
                    type: string
                    format: uuid
                    nullable: true
                config:
                    $ref: '#/components/schemas/HsHostingAssetConfiguration'
            required:
                - type
                - identifier
                - caption
                - config
            additionalProperties: false

        HsHostingAssetConfiguration:
            # forces generating a java.lang.Object containing a Map, instead of class AssetConfiguration
            anyOf:
                - type: object
                    # single source of supported properties just via /api/hs/hosting/asset-types/{assetType}
                    # TODO.impl: later, we could generate the config types and their properties from the validation config
                  additionalProperties: true

        PropertyDescriptor:
            type: object
            properties:
                "type":
                    type: string
                    enum:
                        - integer
                        - boolean
                        - enumeration
                "propertyName":
                    type: string
                    pattern: "^[ a-zA-Z0-9_-]$"
                "required":
                    type: boolean
            required:
                - type
                - propertyName
                - required

        IntegerPropertyDescriptor:
            allOf:
                - $ref: '#/components/schemas/PropertyDescriptor'
                - type: object
                  properties:
                    "type":
                        type: string
                        enum:
                            - integer
                    "unit":
                        type: string
                    "min":
                        type: integer
                        minimum: 0
                    "max":
                        type: integer
                        minimum: 0
                    "step":
                        type: integer
                        minimum: 1
                  required:
                      - "type"
                      - "propertyName"
                      - "required"

        BooleanPropertyDescriptor:
            allOf:
                - $ref: '#/components/schemas/PropertyDescriptor'
                - type: object
                  properties:
                      "type":
                          type: string
                          enum:
                              - boolean
                      "falseIf":
                          type: object
                          anyOf:
                              - type: object
                                additionalProperties: true

        EnumerationPropertyDescriptor:
            allOf:
                - $ref: '#/components/schemas/PropertyDescriptor'
                - type: object
                  properties:
                    "type":
                        type: string
                        enum:
                            - enumeration
                    "values":
                          type: array
                          items:
                              type: string

        HsHostingAssetProps:
            anyOf:
                - $ref: '#/components/schemas/IntegerPropertyDescriptor'
                - $ref: '#/components/schemas/BooleanPropertyDescriptor'
                - $ref: '#/components/schemas/EnumerationPropertyDescriptor'