swagger: '2.0'
info:
  description: >-
    This is Resource Manager API which used with WSO2 Stream Processor
    distributed deployment.
  version: v1
  title: SP Resource Manager
  contact:
    name: WSO2
    url: 'http://wso2.com/analytics'
    email: architecture@wso2.com
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
host: localhost
basePath: /resourceManager
tags:
  - name: ResourceManager
    description: >-
      ResourceManager will keep track of the resource pool. This can be used to
      add resources to the resource pool.
schemes:
  - https
  - http
paths:
  /resourceManager/heartbeat:
    post:
      tags:
        - ResourceManager
      summary: Register resource node and Updates Heartbeat.
      description: >-
        Resource nodes will call this endpoint to get them self registerd in the
        resource pool. Once registered, consecetive calls for this endpoints
        will be used as heartbeat from tose resource nodes.
      operationId: updateHeartbeat
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: body
          name: node
          description: >-
            Node object that needs to be registered or update heartbeats as the
            resource.
          required: true
          schema:
            $ref: '#/definitions/NodeConfig'
      responses:
        '200':
          description: Resource successfully added / Heartbeat updated.
          schema:
            $ref: '#/definitions/HeartbeatResponse'
        '301':
          description: Not the current leader (redir. to correct leader).
          schema:
            $ref: '#/definitions/HeartbeatResponse'
        '400':
          description: Leader not found
  /resourceManager/deployment:
    get:
      tags:
        - ResourceManager
      summary: Get the satus.
      description: Returns status of manager nodes cluster and the resourcepool.
      operationId: getDeployment
      produces:
        - application/json
      responses:
        '200':
          description: Successful operation
          schema:
            $ref: '#/definitions/Deployment'
definitions:
  InterfaceConfig:
    description: >-
      Represents a HTTP Interface configuration which consists of host and port
      of the node.
    properties:
      host:
        type: string
      port:
        type: integer
    required:
      - host
      - port
  NodeConfig:
    description: Representation of a Node which consists of an id and an InterfaceConfig
    properties:
      id:
        type: string
      state:
        type: string
        enum:
          - NEW
          - EXISTS
      httpsInterface:
        $ref: '#/definitions/InterfaceConfig'
    required:
      - id
      - httpsInterface
  HeartbeatResponse:
    description: Response for joining the resource pool or heartbeat update.
    properties:
      leader:
        $ref: '#/definitions/ManagerNodeConfig'
      connectedManagers:
        type: array
        items:
          $ref: '#/definitions/InterfaceConfig'
      joinedState:
        type: string
        enum:
          - NEW
          - EXISTS
          - REJECTED
    required:
      - leader
      - connectedManagers
      - joinedState
  ManagerNodeConfig:
    description: Representation of a Manager Node configuration
    properties:
      id:
        type: string
      httpsInterface:
        $ref: '#/definitions/InterfaceConfig'
      heartbeatInterval:
        type: integer
      heartbeatMaxRetry:
        type: integer
    required:
      - id
      - httspInterface
      - heartbeatInterval
      - heartbeatMaxRetry
  Deployment:
    description: Deployment details of the managers and the resource pool
    properties:
      leader:
        $ref: '#/definitions/ManagerNodeConfig'
      managers:
        type: array
        items:
          $ref: '#/definitions/InterfaceConfig'
      resources:
        type: array
        items:
          $ref: '#/definitions/NodeConfig'
    required:
      - leader
      - managers
      - resources
