openapi: 3.0.0
info:
  title: Telco Cloud Automation Cluster Template API.
  description: Telco Cloud Automation Cluster Template API.
  termsOfService: https://www.vmware.com/content/dam/digitalmarketing/vmware/en/pdf/product/vmware-product-guide.pdf
  contact:
    name: VMware
  license:
    name: Copyright (c) 2020-2021 VMware, Inc. All rights reserved.
  version: "1.0"
servers:
- url: /hybridity/api/infra
tags:
- name: ClusterTemplate
  description: Telco Cloud Automation Cluste Template API
paths:
  /cluster-templates:
    get:
      tags:
      - InfraClusterTemplate
      description: Api to get all cluster templates
      operationId: getClusterTemplates
      responses:
        "200":
          description: Get cluster templates
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/clusterTemplate'
    post:
      tags:
      - ClusterTemplates
      summary: Api to create a cluster template for Telco Cloud Automation
      description: Api to create a cluster template for Telco Cloud Automation
      operationId: createClusterTemplate
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/clusterTemplate'
        required: true
      responses:
        "200":
          description: Successfully created cluster template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clusterTemplate'
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errorResponse'
  /cluster-templates/{id}:
    get:
      tags:
      - InfraClusterTemplate
      description: Api to get all cluster template
      operationId: getClusterTemplate
      parameters:
      - name: id
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
      responses:
        "200":
          description: Get cluster template
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clusterTemplate'
    put:
      tags:
      - ClusterTemplates
      summary: Api to update a cluster template for Telco Cloud Automation
      description: Api to update a cluster template for Telco Cloud Automation
      operationId: updateClusterTemplate
      parameters:
      - name: id
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/clusterTemplate'
        required: true
      responses:
        "200":
          description: Successfully updated cluster template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clusterTemplate'
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errorResponse'
    delete:
      tags:
      - InfraClusterTemplate
      description: Api to delete all cluster templates
      operationId: deleteClusterTemplate
      parameters:
      - name: id
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
      responses:
        "200":
          description: Delete cluster template
  /cluster-templates/upload:
    post:
      tags:
      - ClusterTemplates
      summary: Api to upload a cluster template for Telco Cloud Automation
      description: Api to upload a cluster template for Telco Cloud Automation
      operationId: uploadClusterTemplate
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/body'
      responses:
        "200":
          description: Successfully created cluster template.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/clusterTemplate'
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errorResponse'
  /cluster-templates/{id}/download:
    get:
      tags:
      - ClusterTemplates
      summary: Api to download a cluster template for Telco Cloud Automation
      description: Api to download a cluster template for Telco Cloud Automation
      operationId: downloadClusterTemplate
      parameters:
      - name: id
        in: path
        required: true
        style: simple
        explode: false
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errorResponse'
components:
  schemas:
    clusterTemplate:
      required:
      - clusterConfig
      - clusterType
      - masterNodes
      - name
      type: object
      properties:
        clusterType:
          type: string
          enum:
          - MANAGEMENT
          - WORKLOAD
        clusterConfig:
          $ref: '#/components/schemas/clusterTemplate_clusterConfig'
        description:
          type: string
        masterNodes:
          maxItems: 1
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_masterNodes'
        name:
          type: string
        id:
          type: string
        tags:
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_tags'
        workerNodes:
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_workerNodes'
    errorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: ../../../api-common/swagger/1.0/components/schemas/error.yaml
    body:
      type: object
      properties:
        file:
          type: string
          format: binary
    clusterTemplate_clusterConfig_cni:
      required:
      - name
      type: object
      properties:
        name:
          type: string
          enum:
          - calico
          - multus
          - whereabouts
          - antrea
        properties:
          type: object
    clusterTemplate_clusterConfig_properties:
      type: object
      properties:
        name:
          type: string
          description: |
            Name of the storage class. Defaults to 'vsphere-sc' for type vsphere-csi. Defaults to 'nfs-client' for type nfs_client. Input can be given only if type is vsphere-csi (Optional)
        isDefault:
          type: boolean
          description: |
            Default storage class in k8s for pvc claim. Defaults to True for type vsphere-csi. Defaults to False for type nfs_client. Only one type of storage class can be default storage class. (Optional)
        timeout:
          type: string
          description: |
            Timeout of all calls to CSI driver. If not speified default value is 300 seconds. Valid only if type is vsphere-csi (Optional).
    clusterTemplate_clusterConfig_csi:
      required:
      - name
      type: object
      properties:
        name:
          type: string
          enum:
          - vsphere-csi
          - nfs_client
        properties:
          $ref: '#/components/schemas/clusterTemplate_clusterConfig_properties'
    clusterTemplate_clusterConfig_tools:
      required:
      - name
      - version
      type: object
      properties:
        name:
          type: string
          description: Specifying any version of helm is deprecated from 1.9. It is
            recommend to use TCA certified helm versions.
          enum:
          - helm
        version:
          type: string
    clusterTemplate_clusterConfig:
      required:
      - kubernetesVersion
      type: object
      properties:
        cni:
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_clusterConfig_cni'
        csi:
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_clusterConfig_csi'
        kubernetesVersion:
          type: string
        tools:
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_clusterConfig_tools'
    clusterTemplate_networks:
      required:
      - label
      type: object
      properties:
        label:
          type: string
    clusterTemplate_masterNodes:
      required:
      - cpu
      - memory
      - name
      - replica
      - storage
      type: object
      properties:
        cpu:
          minimum: 1
          type: integer
        memory:
          minimum: 2048
          type: integer
        name:
          pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9])'
          type: string
        networks:
          maxItems: 1
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_networks'
        storage:
          minimum: 50
          type: integer
        replica:
          minimum: 1
          type: integer
        labels:
          type: array
          items:
            type: string
        cloneMode:
          type: string
          enum:
          - fullClone
          - linkedClone
    clusterTemplate_tags:
      required:
      - autoCreated
      - name
      type: object
      properties:
        autoCreated:
          type: boolean
        name:
          type: string
    clusterTemplate_config_cpuManagerPolicy_properties_kubeReserved:
      type: object
      properties:
        cpu:
          minimum: 1
          type: integer
        memoryInGiB:
          minimum: 1
          type: integer
    clusterTemplate_config_cpuManagerPolicy_properties:
      type: object
      properties:
        kubeReserved:
          $ref: '#/components/schemas/clusterTemplate_config_cpuManagerPolicy_properties_kubeReserved'
        systemReserved:
          $ref: '#/components/schemas/clusterTemplate_config_cpuManagerPolicy_properties_kubeReserved'
    clusterTemplate_config_cpuManagerPolicy:
      type: object
      properties:
        type:
          type: string
          enum:
          - kubernetes
        policy:
          type: string
          enum:
          - static
          - default
        properties:
          $ref: '#/components/schemas/clusterTemplate_config_cpuManagerPolicy_properties'
    clusterTemplate_config_healthCheck_unhealthyConditions:
      required:
      - status
      - timeout
      - type
      type: object
      properties:
        type:
          type: string
          enum:
          - Ready
          - MemoryPressure
          - DiskPressure
          - PIDPressure
          - NetworkUnavailable
        status:
          type: string
          enum:
          - "True"
          - "False"
          - Unknown
        timeout:
          type: string
    clusterTemplate_config_healthCheck:
      required:
      - unhealthyConditions
      type: object
      properties:
        nodeStartupTimeout:
          type: string
          description: |
            NodeStartupTimeout determines how long a MachineHealthCheck should wait for a Node to join the cluster, before considering a Machine unhealthy
          default: 20m0s
        unhealthyConditions:
          minItems: 1
          type: array
          description: |
            Conditions to check on Nodes for matched Machines, if any condition is matched for the duration of its timeout, the Machine is considered unhealthy
          items:
            $ref: '#/components/schemas/clusterTemplate_config_healthCheck_unhealthyConditions'
    clusterTemplate_config:
      type: object
      properties:
        cpuManagerPolicy:
          $ref: '#/components/schemas/clusterTemplate_config_cpuManagerPolicy'
        healthCheck:
          $ref: '#/components/schemas/clusterTemplate_config_healthCheck'
    clusterTemplate_workerNodes:
      required:
      - cpu
      - memory
      - name
      - networks
      - replica
      - storage
      type: object
      properties:
        cpu:
          minimum: 2
          type: integer
        memory:
          minimum: 2048
          type: integer
        name:
          pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9])'
          type: string
        networks:
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_networks'
        storage:
          minimum: 50
          type: integer
        replica:
          minimum: 1
          type: integer
        labels:
          type: array
          items:
            type: string
        cloneMode:
          type: string
          enum:
          - fullClone
          - linkedClone
        config:
          $ref: '#/components/schemas/clusterTemplate_config'
  securitySchemes:
    x-hm-authorization:
      type: apiKey
      description: Obtained from /hybridity/api/session
      name: x-hm-authorization
      in: header
