swagger: '2.0'
######################################################
# Prolog
######################################################
info:
  version: "v1.0"
  title: "WSO2 Analytics for API Manager"
  description: |
    This document specifies a **RESTful API** for WSO2 Analytics for **API Manager** .

    It is written with [swagger 2](http://swagger.io/).

  contact:
    name: "WSO2"
    url: "https://github.com/wso2/analytics-apim/"
    email: "architecture@wso2.com"
  license:
    name: "Apache 2.0"
    url: "http://www.apache.org/licenses/LICENSE-2.0.html"

######################################################
# The fixed parts of the URLs of the API
######################################################

# The schemes supported by the API
schemes:
  - https
  - http

# The domain of the API.
# This is configured by the customer during deployment.
# The given host is just an example.
host: apis.wso2.com

# The base path of the API.
# Will be prefixed to all paths.
basePath: /analytics/v1.0

# The following media types can be passed as input in message bodies of the API.
# The actual media type must be specified in the Content-Type header field of the request.
# The default is json, i.e. the Content-Type header is not needed to
# be set, but supporting it serves extensibility.
consumes:
  - application/json

# The following media types may be passed as output in message bodies of the API.
# The media type(s) consumable by the requestor is specified in the Accept header field
# of the corresponding request.
# The actual media type returned will be specfied in the Content-Type header field
# of the of the response.
# The default of the Accept header is json, i.e. there is not needed to
# set the value, but supporting it serves extensibility.
produces:
  - application/json

x-wso2-security:
  apim:
    x-wso2-scopes:
      - description: ""
        roles: Internal/username
        name: apim:subscribe
        key: apim:subscribe

securityDefinitions:
  OAuth2Security:
    type: oauth2
    flow: password
    tokenUrl: https://localhost:9443/token

######################################################
# The "Upload zip" resource API
######################################################
paths:
  /usage/upload-file/:

#-----------------------------------------------------
# Upload analytics data as a zip archive
#-----------------------------------------------------
    post:
      consumes:
        - multipart/form-data
      security:
        - OAuth2Security:
      summary: |
        Uploading File
      description: |
        Reveives analytics data as a zip archive and upload it to persist in data base.
      parameters:
        - in: formData
          name: file
          description: zip archieve of the analytics data
          type: file
          required: true
      headers:
        FileName:
          description: |
            File name
          type:
            string
      responses:
        201:
          description: |
            Created.
            File uploaded successfully.
          headers:
            Location:
              description: |
                The URL of the newly created resource.
              type: string
        400:
          description: |
            Bad Request.
            Invalid request or validation error.
          schema:
            $ref: '#/definitions/Error'
        415:
          description: |
            Unsupported Media Type.
            The entity of the request was in a not supported format.
          schema:
            $ref: '#/definitions/Error'
definitions:
#-----------------------------------------------------
# The Error resource
#-----------------------------------------------------
  Error:
    title: Error object returned with 4XX HTTP lifeCycleStatus
    required:
      - code
      - message
    properties:
      code:
        type: integer
        format: int64
      message:
        type: string
        description: Error message.
      description:
        type: string
        description: |
          A detail description about the error message.
      moreInfo:
        type: string
        description: |
          Preferably an url with more details about the error.
      error:
        type: array
        description: |
          If there are more than one error list them out.
          For example, list out validation errors by each field.
        items:
          $ref: '#/definitions/ErrorListItem'

#-----------------------------------------------------
# The Error List Item resource
#-----------------------------------------------------
  ErrorListItem:
    title: Description of individual errors that may have occurred during a request.
    required:
      - code
      - message
    properties:
      code:
        type: string
      message:
        type: string
        description: |
          Description about individual errors occurred
#-----------------------------------------------------
# END-OF-FILE
#-----------------------------------------------------
