# Auto-generated from Cybus Connectware 2.5.0. See https://docs.cybus.io/ for the canonical source.

swagger: '2.0'
info:
  title: Container Manager API
  version: 0.1.0
basePath: /api
schemes:
  - https
produces:
  - application/json
consumes:
  - application/json
paths:
  /containers:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Get all service containers
      operationId: getContainers
      responses:
        '200':
          description: All service containers
          schema:
            $ref: '#/definitions/ContainersResponse'
        '404':
          description: Failed to get all service containers
  /containers/{name}/inspect:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Inspect service container
      operationId: inspectContainer
      parameters:
        - name: name
          in: path
          description: Name of the service container
          type: string
          required: true
      responses:
        '200':
          description: Service container inspect
          schema:
            $ref: '#/definitions/ContainerResponse'
        '404':
          description: Failed to inspect service container
  /containers/{name}/logs:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Get service container logs
      operationId: getContainerLogsStream
      parameters:
        - name: name
          in: path
          description: Name of the service container
          type: string
          required: true
        - in: query
          name: timestamps
          description: If the logs should yield timestamp
          type: string
          enum:
            - 'true'
            - 'false'
        - in: query
          name: tail
          description: Use 'all' to retrieve all, or a number for a limited set
          type: string
          default: all
        - in: query
          name: since
          description: Timestamp for the start
          type: string
          default: null
        - in: query
          name: until
          description: Timestamp for the end
          type: string
          default: null
      responses:
        '200':
          description: Service container logs
          schema:
            type: string
        '404':
          description: Failed to get container logs
  /containers/{name}/state:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Get container state
      operationId: getContainerState
      responses:
        '200':
          description: Service container state
          schema:
            type: object
        '404':
          description: Failed to get service container state
  /containers/orchestrator:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - meta
      summary: Returns info about orchestrator being used to run Connectware
      operationId: orchestrator
      responses:
        '200':
          description: Returns the name of the orchestrator being used to run Connectware
          schema:
            $ref: '#/definitions/OrchestratorResponse'
        '403':
          description: Access Forbidden
        '503':
          description: Network error
  /containers/{name}/operation:
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Perform an operation on a service container
      operationId: executeServiceContainerOperation
      parameters:
        - name: name
          in: path
          description: Name of the service container
          type: string
          required: true
        - in: body
          name: body
          description: Operation to perform on the service container
          required: true
          schema:
            type: object
            required:
              - operation
            properties:
              operation:
                type: string
                enum:
                  - start
                  - stop
                  - restart
      responses:
        '200':
          description: Service container inspection after operation is performed
          schema:
            type: object
        '400':
          description: Invalid request
        '404':
          description: Service container not found
  /core-containers:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Get all core containers
      operationId: getCoreContainers
      responses:
        '200':
          description: All core containers
          schema:
            $ref: '#/definitions/ContainersResponse'
  /core-containers/{name}/inspect:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Inspect core container
      operationId: inspectCoreContainer
      parameters:
        - name: name
          in: path
          description: Name of the core container
          type: string
          required: true
      responses:
        '200':
          description: Core container inspect
          schema:
            $ref: '#/definitions/ContainerResponse'
        '404':
          description: Failed to inspect core container
  /core-containers/{name}/logs:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Get core container logs
      operationId: getCoreContainerLogsStream
      parameters:
        - name: name
          in: path
          description: Name of the core container
          type: string
          required: true
        - in: query
          name: timestamps
          description: If the logs should yield timestamp
          type: string
          enum:
            - 'true'
            - 'false'
        - in: query
          name: tail
          description: Use 'all' to retrieve all, or a number for a limited set
          type: string
          default: all
        - in: query
          name: since
          description: Timestamp for the start
          type: string
          default: null
        - in: query
          name: until
          description: Timestamp for the end
          type: string
          default: null
      responses:
        '200':
          description: Core container logs
          schema:
            type: string
        '404':
          description: Failed to get core container logs
  /core-containers/{name}/state:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Get core container state
      operationId: getCoreContainerState
      responses:
        '200':
          description: Core Container state
          schema:
            type: object
        '404':
          description: Failed to get core container state
  /core-containers/orchestrator:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - meta
      summary: Returns info about orchestrator being used to run Connectware
      operationId: coreOrchestrator
      responses:
        '200':
          description: Returns the name of the orchestrator being used to run Connectware
          schema:
            $ref: '#/definitions/OrchestratorResponse'
        '503':
          description: Network error
  /core-containers/{name}/operation:
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - containers
      summary: Perform an operation on a core container
      operationId: executeCoreContainerOperation
      parameters:
        - name: name
          in: path
          description: Name of the core container
          type: string
          required: true
        - in: body
          name: body
          description: Operation to perform on the core container
          required: true
          schema:
            type: object
            required:
              - operation
            properties:
              operation:
                type: string
                enum:
                  - start
                  - stop
                  - restart
      responses:
        '200':
          description: Core container inspection after operation is performed
          schema:
            type: object
        '400':
          description: Invalid request
        '404':
          description: Core container not found
  /images:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - images
      summary: Get all images
      operationId: getImages
      responses:
        '200':
          description: All images
          schema:
            type: array
            items:
              type: object
        '404':
          description: Failed to get all images
  /images/{name}/inspect:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - images
      summary: Inspect a image
      operationId: inspectImages
      responses:
        '200':
          description: Image inspect
          schema:
            type: object
        '404':
          description: Failed to inspect image
  /networks:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - networks
      summary: Get all networks
      operationId: getNetworks
      responses:
        '200':
          description: All networks
          schema:
            type: array
            items:
              type: object
        '404':
          description: Failed to get all networks
  /networks/{name}/inspect:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - networks
      summary: Inspect a network
      operationId: inspectNetworks
      responses:
        '200':
          description: Network inspect
          schema:
            type: object
        '404':
          description: Failed to inspect network
  /volumes:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - volumes
      summary: Get all volumes
      operationId: getVolumes
      responses:
        '200':
          description: All volumes
          schema:
            $ref: '#/definitions/VolumesResponse'
  /volumes/{name}/inspect:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - volumes
      summary: Inspect a volume
      operationId: inspectVolumes
      parameters:
        - name: name
          in: path
          description: Name of the volume
          type: string
          required: true
      responses:
        '200':
          description: Volume inspect
          schema:
            $ref: '#/definitions/VolumeResponse'
        '404':
          description: Failed to inspect volume
securityDefinitions:
  ApiKeyHeader:
    type: apiKey
    in: header
    name: Authorization
definitions:
  OrchestratorResponse:
    type: object
    properties:
      orchestrator:
        $ref: '#/definitions/Orchestrator'
    required:
      - orchestrator
  Orchestrator:
    type: string
    enum:
      - Docker
      - Kubernetes
  ContainersResponse:
    oneOf:
      - $ref: '#/definitions/DockerContainersResponse'
      - $ref: '#/definitions/KubernetesContainersResponse'
  ContainerResponse:
    oneOf:
      - $ref: '#/definitions/DockerContainerResponse'
      - $ref: '#/definitions/KubernetesContainerResponse'
  VolumesResponse:
    oneOf:
      - $ref: '#/definitions/DockerVolumesResponse'
      - $ref: '#/definitions/KubernetesVolumesResponse'
  VolumeResponse:
    oneOf:
      - $ref: '#/definitions/DockerVolumeResponse'
  DockerContainersResponse:
    type: array
    items:
      type: object
      properties:
        Names:
          type: array
          items:
            type: string
        State:
          type: string
        Mounts:
          type: array
          items:
            allOf:
              - type: object
                properties:
                  Type:
                    type: string
                  Driver:
                    type: string
                required:
                  - Type
              - $ref: '#/definitions/DockerContainerMount'
      required:
        - Names
        - State
        - Mounts
  DockerContainerResponse:
    type: object
    properties:
      Name:
        type: string
      Created:
        type: string
      Id:
        type: string
      State:
        type: object
        properties:
          Status:
            type: string
          Dead:
            type: boolean
          FinishedAt:
            type: string
          Paused:
            type: boolean
          Restarting:
            type: boolean
          Running:
            type: boolean
          StartedAt:
            type: string
        required:
          - Status
          - Dead
          - FinishedAt
          - Paused
          - Restarting
          - Running
          - StartedAt
      Mounts:
        type: array
        items:
          $ref: '#/definitions/DockerContainerMount'
      Config:
        type: object
        properties:
          Env:
            type: array
            items:
              type: string
          Image:
            type: string
          WorkingDir:
            type: string
          ExposedPorts:
            type: object
            additionalProperties:
              type: object
              additionalProperties: false
          Labels:
            type: object
            additionalProperties:
              type: string
        required:
          - ExposedPorts
          - Env
          - Image
          - WorkingDir
          - Labels
      HostConfig:
        type: object
        properties:
          CapAdd:
            oneOf:
              - type: object
                additionalProperties: true
              - type: array
              - type: array
                items:
                  type: string
              - type: string
          Privileged:
            type: boolean
    required:
      - Name
      - Created
      - Id
      - State
      - Mounts
      - Config
      - HostConfig
  DockerContainerMount:
    type: object
    properties:
      Name:
        type: string
      Source:
        type: string
      Destination:
        type: string
      Mode:
        type: string
      RW:
        type: boolean
      Propagation:
        type: string
    required:
      - Source
      - Destination
      - Mode
      - Propagation
      - RW
  DockerVolumesResponse:
    type: object
    properties:
      Volumes:
        type: array
        items:
          $ref: '#/definitions/DockerVolumeResponse'
      Warnings:
        type: string
    required:
      - Volumes
      - Warnings
  DockerVolumeResponse:
    type: object
    properties:
      CreatedAt:
        type: string
      Name:
        type: string
      Labels:
        type: object
        additionalProperties:
          type: string
    required:
      - CreatedAt
      - Name
      - Labels
  KubernetesContainersResponse:
    type: array
    items:
      type: object
      properties:
        Id:
          type: string
        Names:
          type: array
          items:
            type:
              - string
              - 'null'
          maxItems: 1
        Image:
          type: string
          enum:
            - '?'
        ImageID:
          type: string
          enum:
            - '?'
        Command:
          type: string
          enum:
            - '?'
        State:
          type: string
        Mounts:
          type: array
          items:
            $ref: '#/definitions/KubernetesContainerMount'
      required:
        - Names
        - Image
        - ImageID
        - Command
        - Mounts
  KubernetesContainerResponse:
    type: object
    properties:
      Id:
        type:
          - string
          - 'null'
      Name:
        type: string
      Created:
        type:
          - string
          - 'null'
      Mounts:
        type: array
        items:
          $ref: '#/definitions/KubernetesContainerMount'
      Config:
        type: object
        properties:
          Image:
            type: string
          WorkingDir:
            type: string
          Labels:
            type: object
            additionalProperties: false
          ExposedPorts:
            type: object
            additionalProperties: false
          Env:
            type: array
            items:
              type: string
        required:
          - Image
          - WorkingDir
          - Labels
          - ExposedPorts
          - Env
      State:
        type: object
        properties:
          Status:
            type:
              - string
              - 'null'
        required:
          - Status
      HostConfig:
        type: object
        properties:
          CapAdd:
            type:
              - 'null'
          Privileged:
            type: boolean
            enum:
              - false
        required:
          - CapAdd
          - Privileged
    required:
      - Id
      - Name
      - Created
      - Mounts
      - Config
      - State
      - HostConfig
  KubernetesContainerMount:
    type: object
    properties:
      Type:
        type: string
        enum:
          - volume
      Name:
        type: string
      Source:
        type: string
        enum:
          - '?'
      Destination:
        type: string
        enum:
          - '?'
      Mode:
        type: string
        enum:
          - '?'
      RW:
        type: string
        enum:
          - '?'
      Propagation:
        type: string
        enum:
          - '?'
      Driver:
        type: string
        enum:
          - persistentVolumeClaim
          - secret
    required:
      - Type
      - Name
      - Source
      - Destination
      - Mode
      - RW
      - Propagation
  KubernetesVolumesResponse:
    type: object
    properties:
      Volumes:
        type: array
        maxItems: 0
      Warnings:
        type: 'null'
    required:
      - Volumes
      - Warnings
