openapi: 3.0.0
info:
  title: Telco Cloud Automation Cluster Template API.
  description: Telco Cloud Automation Cluster Template API.
  termsOfService: https://www.vmware.com/help/legal.html
  contact:
    name: VMware
  license:
    name: Copyright (c) 2020-2021 VMware, Inc. All rights reserved.
  version: "1.0"
servers:
- url: https://{server}/hybridity/api/infra
  variables:
    server:
      description: server host name
      default: localhost
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
        properties:
          type: object
    clusterTemplate_clusterConfig_csi:
      required:
      - name
      type: object
      properties:
        name:
          type: string
          enum:
          - vsphere-csi
          - nfs_client
        properties:
          type: object
    clusterTemplate_clusterConfig_tools:
      required:
      - name
      - version
      type: object
      properties:
        name:
          type: string
          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
      - labels
      - 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:
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_networks'
        storage:
          minimum: 20
          type: integer
        replica:
          minimum: 1
          type: integer
        labels:
          minItems: 1
          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:
      type: object
      properties:
        cpuManagerPolicy:
          $ref: '#/components/schemas/clusterTemplate_config_cpuManagerPolicy'
    clusterTemplate_workerNodes:
      required:
      - cpu
      - labels
      - memory
      - name
      - networks
      - 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:
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/clusterTemplate_networks'
        storage:
          minimum: 20
          type: integer
        replica:
          minimum: 1
          type: integer
        labels:
          minItems: 1
          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
