swagger: '2.0'
info:
  version: 1.0.0
  title: 'DC/OS Licensing Component'
schemes:
  - https
basePath: '/licensing/v1'
paths:
  /ping:
    get:
      summary: Return 'pong' if service is up.
      description: Return 'pong' if service is up.
      responses:
        200:
          description: Response body contains pong response.
        503:
          description: Service Unavailable.
  /version:
    get:
      summary: Return service version.
      description: Return service version.
      responses:
        200:
          description: Response body contains service version.
        503:
          description: Service Unavailable.
  /licenses:
    get:
      summary: Read all licenses.
      description: Read all licenses.
      produces:
        - application/json
      responses:
        200:
          description: Response body contains a list of license documents.
          schema:
            $ref: "#/definitions/Licenses"
        403:
          description: Forbidden.
    post:
      summary: Post a new license.
      description: Post a new active license.
      consumes:
        - application/octet-stream
      parameters:
        - name: License document.
          description: License base64 encoded encrypted document.
          in: body
          required: true
          schema:
            $ref: "#/definitions/License"
      responses:
        204:
          description: License updated.
        403:
          description: Forbidden.
  /licenses/{id}:
    get:
      summary: Read a license document by id.
      description: Read a license document by id.
      produces:
        - application/json
      parameters:
        - name: id
          description: The license id.
          in: path
          required: true
          type: string
      responses:
        200:
          description: Response body contains license document corresponding to the path id.
          schema:
            $ref: "#/definitions/License"
        403:
          description: Forbidden.
        404:
          description: License not found.
  /licenses/active:
    get:
      summary: Read the active license document.
      description: Read the active license document.
      produces:
        - application/json
      responses:
        200:
          description: Response body contains the active license document.
          schema:
            $ref: "#/definitions/License"
        403:
          description: Forbidden.
        404:
          description: License not found.
  /status:
    get:
      summary: Returns summary of licensing state.
      produces:
        - application/json
      responses:
        200:
          description: License events summary.
          schema:
            $ref: "#/definitions/Status"
  /audit:
    get:
      summary: Get all audit data in an archive tar file.
      produces:
        - application/x-tar
      parameters:
        - name: decrypt
          description: Include decrypted public license
          in: query
          type: integer
      responses:
        200:
          description: Response contains all history of license data.
  /audit/{id}:
    get:
      summary: Get license audit file by Id.
      produces:
        - application/x-tar
      parameters: 
        - name: id
          description: The license id.
          in: path
          required: true
          type: string
        - name: decrypt
          description: Include decrypted public license
          in: query
          type: integer
      responses:
        200:
          description: Response contains all license data by id.
  /audit/active:
    get:
      summary: Get license audit file for active license.
      produces:
        - application/x-tar
      parameters:
        - name: decrypt
          description: Include decrypted public license
          in: query
          type: integer
      responses:
        200:
          description: Response contains all license data for active license.
      
definitions:
  License:
    type: object
    properties:
      id:
        type: string
        description: License unique Id.
      version:
        type: string
        description: License version.
      license_terms:
        type: object
        properties:
          node_capacity:
            type: integer
            description: Maximum number of nodes allowed.
          end_timestamp:
            type: string
            format: date-time
            description: License expiraton timestamp.
          start_timestamp:
            type: string
            format: date-time
            description: License start timestamp.
      decryption_key:
        type: string
        format: base64
        description: License audit data checksum decryption key.
    additionalProperties: false
  Licenses:
    type: array
    items:
      type: object
      properties:
        schema:
          $ref: "#/definitions/License"
  Status:
    type: object
    properties:
      active_id:
        type: string
        description: Active license uuid.
      number_of_breaches:
        type: integer
        description: Number of breach of license terms.
      number_of_nodes:
        type: integer
        description: Current number of nodes.
      node_capacity:
        type: integer
        description: Maximum number of nodes allowed.
      end_timestamp:
        type: string
        format: date-time
        description: License expiraton timestamp.
      start_timestamp:
        type: string
        format: date-time
        description: License start timestamp.
      current_timestamp:
        type: string
        format: date-time
        description: Server response timestamp.
