
components:

    schemas:

        HsHostingAssetType:
            type: string
            enum:
                - CLOUD_SERVER
                - MANAGED_SERVER
                - MANAGED_WEBSPACE
                - UNIX_USER
                - DOMAIN_SETUP
                - DOMAIN_DNS_SETUP
                - DOMAIN_HTTP_SETUP
                - DOMAIN_SMTP_SETUP
                - DOMAIN_MBOX_SETUP
                - EMAIL_ALIAS
                - EMAIL_ADDRESS
                - PGSQL_INSTANCE
                - PGSQL_USER
                - PGSQL_DATABASE
                - MARIADB_INSTANCE
                - MARIADB_USER
                - MARIADB_DATABASE
                - IPV4_NUMBER
                - IPV6_NUMBER

        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
                alarmContact.uuid:
                    type: string
                    format: uuid
                    nullable: true
                config:
                    $ref: '#/components/schemas/HsHostingAssetConfiguration'
            additionalProperties: false

        HsHostingAssetInsert:
            type: object
            properties:
                bookingItem.uuid:
                    type: string
                    format: uuid
                    nullable: true
                parentAsset.uuid:
                    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
                alarmContact.uuid:
                    type: string
                    format: uuid
                    nullable: true
                config:
                    $ref: '#/components/schemas/HsHostingAssetConfiguration'
            required:
                - type
                - identifier
                - caption
            additionalProperties: false

        HsHostingAssetAutoInsert:
            type: object
            properties:
                parentAsset.uuid:
                    type: string
                    format: uuid
                    nullable: true
                assignedToAsset.uuid:
                    type: string
                    format: uuid
                type:
                    $ref: '#/components/schemas/HsHostingAssetType'
                identifier:
                    type: string
                    minLength: 3
                    maxLength: 80
                    nullable: false
                caption:
                    type: string
                    minLength: 3
                    maxLength: 80
                    nullable: false
                alarmContact.uuid:
                    type: string
                    format: uuid
                    nullable: true
                config:
                    $ref: '#/components/schemas/HsHostingAssetConfiguration'
                subHostingAssets:
                    type: array
                    items:
                        $ref: '#/components/schemas/HsHostingAssetSubInsert'
            required:
                - identifier
            additionalProperties: false

        HsHostingAssetSubInsert:
            type: object
            properties:
                type:
                    $ref: '#/components/schemas/HsHostingAssetType'
                identifier:
                    type: string
                    minLength: 3
                    maxLength: 80
                    nullable: false
                caption:
                    type: string
                    minLength: 3
                    maxLength: 80
                    nullable: false
                assignedToAsset.uuid:
                    type: string
                    format: uuid
                alarmContact.uuid:
                    type: string
                    format: uuid
                    nullable: true
                config:
                    $ref: '#/components/schemas/HsHostingAssetConfiguration'
            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'
