swagger: '2.0'
info:
  description: >-
    This is the REST Micro Service for Siddhi Stores. A Siddhi query can be
    submitted and get the result records from the Siddhi Stores.
  version: 1.0.0
  title: Siddhi Store REST API
  termsOfService: 'http://wso2.com/terms'
  contact:
    email: dev@wso2.org
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
basePath: /v1.0
tags:
  - name: store
    description: Everything about querying Siddhi Stores
    externalDocs:
      description: Find out more about Siddhi Stores
      url: 'https://docs.wso2.com/display/SP400/Key+Concepts'
schemes:
  - http
paths:
  /stores/query:
    post:
      tags:
        - store
      summary: Submit a Siddhi query and get the result records from a store
      description: ''
      operationId: query
      consumes:
        - application/json
      produces:
        - application/json
      parameters:
        - in: body
          name: body
          description: >-
            Query object which contains the query which returns the store
            records
          required: true
          schema:
            $ref: '#/definitions/query'
      responses:
        '200':
          description: 'OK, query was successfully submitted'
          schema:
            $ref: '#/definitions/ApiResponse'
        '405':
          description: Invalid input
definitions:
  query:
    type: object
    required:
      - query
    properties:
      appName:
        description: "Name of the siddhi app from which the store is being queried"
        required: true
        type: string
        example: >-
          SweetFactoryApp
      query:
        type: string
        required: true
        description: "Query which is used to fetch the records from the store in the siddhi app given in 'appName'"
        example: >-
          from SweetProductionTable select name, amount

  ApiResponse:
    type: object
    description: "Contains an array of record values, where each record has its values in the same order the attributes
                  appears in the store/table definition"
    example:
      {
        records : [
          ["Sweet1", "1kg"], ["Sweet2", "2kg"]
          ]
      }
    properties:
      records:
        type: array
        items:
          type: array
