swagger: "2.0"
info:
  title: "The purpose of this application is to provide an API to access linked cluster functionality."
  version: "1.0.0"
schemes: 
  - http
  - https
consumes:
  - "application/json"
produces: 
  - "application/json"
tags:
  - name: "links"
basePath: "/cluster/v1"
paths: 
  /links: 
    get:
      tags: ["links"]
      summary: "Lists links that the user has the permissions to view."
      operationId: "listLinks"
      responses: 
        200: 
          description: "LinksResponse"
          schema: 
            $ref: "#/definitions/LinksResponse"
        400: 
          description: "errorResponse"
          schema: 
            $ref: "#/definitions/errorResponse"
        500: 
          description: "errorResponse"
          schema: 
            $ref: "#/definitions/errorResponse"
    post: 
      tags: ["links"]
      summary: "Links another cluster to this cluster."
      operationId: "createLink"
      parameters:
        - in: body
          name: "link"
          description: "The link data"
          schema:
            $ref: "#/definitions/Link"
      responses:
        200:
          description: "link was created"
          schema:
            $ref: "#/definitions/emptyResponse"
        400:
          description: "errorResponse"
          schema: 
            $ref: "#/definitions/errorResponse"
        409:
          description: "link already exists"
          schema:
            $ref: "#/definitions/emptyResponse"
        500:
          description: "errorResponse"
          schema: 
            $ref: "#/definitions/errorResponse"
  /links/{linkID}: 
    delete: 
      tags: ["links"]
      summary: "Unlinks a cluster from this cluster"
      operationId: "deleteLink"
      parameters: 
        - 
          type: "string"
          name: "linkID"
          in: "path"
          required: true
      responses: 
        200: 
          description: "success"
          schema: 
            $ref: "#/definitions/emptyResponse"
        404:
          description: "link could not be found"
          schema:
            $ref: "#/definitions/emptyResponse"
        400:
          description: "errorResponse"
          schema: 
            $ref: "#/definitions/errorResponse"
        500: 
          description: "errorResponse"
          schema: 
            $ref: "#/definitions/errorResponse"
definitions:
  LoginProvider:
    description: "Composes a provider ID and a provider type"
    type: object
    properties:
      id:
        type: "string"
      type:
        type: "string"
  LinksResponse: 
    description: "The response returned from GET /links"
    type: "object"
    properties: 
      links: 
        type: "array"
        items: 
          $ref: "#/definitions/Link"
  Link:
    type: "object"
    description: "A link to another cluster"
    properties: 
      id: 
        type: "string"
      name:
        type: "string"
      url:
        type: "string"
      login_provider:
        $ref: "#/definitions/LoginProvider"
  emptyResponse:
    type: "string"
  errorResponse:
    type: "string"