swagger: '2.0'
info:
  title: Service Manager API
  version: 0.1.0
basePath: /api
schemes:
  - https
produces:
  - application/json
consumes:
  - application/json
paths:
  /api/validate/service:
    post:
      security:
        - ApiKeyHeader: []
      tags:
        - validation
      summary: validate a commissioning file
      operationId: validateCommissioningFile
      parameters:
        - in: body
          name: body
          description: validate a commissioning file
          required: true
          schema:
            $ref: '#/definitions/ValidatePostServiceRequest'
      responses:
        '200':
          description: Validation Successful
        '400':
          description: Validation Error
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
        '406':
          description: Invalid Content
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
  /api/services:
    post:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Create a new service
      operationId: createService
      parameters:
        - in: body
          name: body
          description: Service to be created
          required: true
          schema:
            $ref: '#/definitions/ServicePostRequest'
      responses:
        '201':
          description: Created service
          schema:
            $ref: '#/definitions/ServiceStatus'
        '400':
          description: Validation Error
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
        '406':
          description: Invalid Content
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Read all services
      operationId: getServices
      responses:
        '200':
          description: Array of services
          schema:
            type: array
            items:
              $ref: '#/definitions/Service'
  /api/services/parametersSchema:
    post:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get the service schemas
      operationId: getServiceSchemas
      parameters:
        - in: body
          name: body
          description: Get the service parameters schemas
          required: true
          schema:
            $ref: '#/definitions/ServicePostSchemasRequest'
      responses:
        '201':
          description: Service schemas
          schema:
            $ref: '#/definitions/ServiceSchemas'
        '400':
          description: Validation Error
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
        '406':
          description: Invalid Content
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
  /api/services/status:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get status of all services
      operationId: getServicesStatus
      responses:
        '200':
          description: Map of service statuses
          schema:
            type: object
  /api/services/info:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get information of all services
      operationId: getServicesInfo
      responses:
        '200':
          description: Map of service information
          schema:
            type: object
  /api/services/instances:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get the instance names of the services
      operationId: getServicesInstances
      responses:
        '200':
          description: Map of service information
          schema:
            type: array
            items:
              type: string
  /api/services/{id}:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get a specific service
      operationId: getService
      parameters:
        - name: id
          in: path
          description: Id of service
          type: string
          required: true
      responses:
        '200':
          description: Service
          schema:
            $ref: '#/definitions/Service'
        '400':
          description: Invalid request
        '404':
          description: Service not found
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Update an existing service
      operationId: updateService
      parameters:
        - in: path
          description: Id of service
          name: id
          required: true
          type: string
        - in: body
          name: body
          description: Data required for updating a service
          schema:
            $ref: '#/definitions/UpdateServiceRequest'
      responses:
        '202':
          description: Accepted
        '400':
          description: Validation Error
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
        '406':
          description: Invalid Content
          schema:
            type: array
            items:
              $ref: '#/definitions/ValidationError'
    delete:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Delete an existing service
      operationId: deleteService
      parameters:
        - name: id
          in: path
          description: Id of service
          type: string
          required: true
      responses:
        '200':
          description: OK
          schema:
            type: object
            properties:
              id:
                type: string
                description: The id of the deleted service
        '404':
          description: Service not found
  /api/services/{id}/status:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get a specific service status
      operationId: getServiceStatus
      parameters:
        - name: id
          in: path
          description: Id of service
          type: string
          required: true
      responses:
        '200':
          description: Service
          schema:
            $ref: '#/definitions/ServiceStatus'
        '400':
          description: Invalid request
        '404':
          description: Service not found
  /api/services/{id}/dependencies:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get the service dependencies
      operationId: getServiceDependencies
      parameters:
        - name: id
          in: path
          description: Id of service
          type: string
          required: true
      responses:
        '200':
          description: Service dependencies
          schema:
            $ref: '#/definitions/ServiceDependencies'
        '400':
          description: Invalid request
        '404':
          description: Service not found
  /api/services/ingress-routes:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get all ingress routes
      operationId: getIngressRoutes
      responses:
        '200':
          description: Ingress routes
          schema:
            type: array
            items:
              $ref: '#/definitions/IngressRoute'
        '400':
          description: Invalid request
  /api/services/links:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - links
      summary: Get all Cybus::Link routes
      operationId: getLinks
      responses:
        '200':
          description: Links
          schema:
            type: array
            items:
              $ref: '#/definitions/Link'
        '400':
          description: Invalid request
  /api/services/all-links:
    get:
      tags:
        - services
        - links
      summary: Get all links by all services
      operationId: getAllLinks
      parameters: []
      responses:
        '200':
          description: Links
          schema:
            type: array
            items:
              $ref: '#/definitions/LinkedService'
        '400':
          description: Invalid request
      security:
        - ApiKeyHeader: []
  /api/services/{id}/operation:
    put:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Perform an operation on a service
      operationId: execute
      parameters:
        - name: id
          in: path
          description: Id of service
          type: string
          required: true
        - name: body
          in: body
          description: Operation to perform
          required: true
          schema:
            $ref: '#/definitions/ServiceOperationRequest'
      responses:
        '200':
          description: Service
          schema:
            $ref: '#/definitions/ServiceStatus'
        '400':
          description: Invalid request
        '404':
          description: Service not found
  /api/resources/schemas:
    get:
      security:
        - ApiKeyHeader: []
      tags:
        - services
      summary: Get all of the resource schemas
      operationId: getResourceSchemas
      responses:
        '200':
          description: Resource schemas in a JSON string
          schema:
            $ref: '#/definitions/AllSchemas'
        '400':
          description: Invalid request
        '500':
          description: Internal error
securityDefinitions:
  ApiKeyHeader:
    type: apiKey
    in: header
    name: Authorization
definitions:
  Service:
    type: object
    properties:
      id:
        type: string
      commissioningData:
        type: object
      resources:
        type: object
      targetState:
        type: string
      currentState:
        type: string
  ServiceStatus:
    type: object
    properties:
      id:
        type: string
        description: Unique identifier representing a specific service.
      targetState:
        type: string
        description: Target state of the service (user's wish).
      currentState:
        type: string
        description: Current state of the service.
  AllSchemas:
    type: object
    additionalProperties: true
    patternProperties:
      '[a-zA-Z0-9]+':
        type: object
  ServiceDependencies:
    type: object
    properties:
      dependent:
        description: Ids of dependent cross reference services
        type: array
        items:
          type: string
      dependsOn:
        description: Ids of depends on cross reference services
        type: array
        items:
          type: string
  ServicePostSchemasRequest:
    type: object
    required:
      - commissioningFile
    properties:
      commissioningFile:
        type: string
        description: >-
          The commissioning file of this service as base64 encoded content of a
          buffer
  ValidatePostServiceRequest:
    type: object
    required:
      - commissioningFile
    properties:
      commissioningFile:
        type: string
        description: >-
          The commissioning file of this service as base64 encoded content of a
          buffer
  ServiceSchemas:
    type: object
  ServicePostRequest:
    type: object
    required:
      - id
      - commissioningFile
    properties:
      id:
        type: string
        minLength: 4
      commissioningFile:
        type: string
        description: >-
          The commissioning file of this service as base64 encoded content of a
          buffer
      parameters:
        type: object
        description: The parameter values of this service as a JSON object
      marketplace:
        type: object
      targetState:
        type: string
        enum:
          - disabled
          - enabled
  UpdateServiceRequest:
    type: object
    properties:
      parameters:
        type: object
      commissioningFile:
        type: string
      marketplace:
        type: object
  ServiceOperationRequest:
    type: object
    properties:
      operation:
        type: string
        description: Disable and enable
  IngressRoute:
    type: object
    properties:
      id:
        type: string
      containerHost:
        type: string
      containerPort:
        type: integer
      containerPrefixRewrite:
        type: string
      ingressPort:
        type: integer
      ingressUrlPrefix:
        type: string
      type:
        type: string
      headers:
        type: array
        items:
          type: string
  LinkedService:
    type: object
    properties:
      id:
        type: string
      name:
        type: string
      links:
        type: array
        items:
          properties:
            name:
              type: string
            href:
              type: string
  Link:
    type: object
    properties:
      id:
        type: string
      ingressRoute:
        type: string
      name:
        type: string
      href:
        type: string
  ValidationError:
    type: object
    properties:
      message:
        type: string
