openapi: 3.0.0

info:
  version: '1.0.0'
  title: 'Akixi REST API'

paths:

  /session:
    post:
      security: []
      summary: 'Creates session.'
      operationId: 'sessionCreate'
      requestBody:
        content:
          application/json: {}
      responses:
        '200':
          description: 'Create session and session ID and nonce.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/session'
        default:
          $ref: '#/components/responses/errorResponseDef'

  /login:
    get:
      security:
      - basicAuth: []
        cookieAuth: []
      summary: 'Authenticates the session.'
      operationId: 'login'
      parameters:
        - in: query
          name: 'locale'
          description: 'The locale that session will be authenticated with.'
          required: false
          schema:
            type: string
      responses:
        '200':
          description: 'Login response with no content.'
        '401':
          $ref: '#/components/responses/unauthorizedResponseDef'
        default:
          $ref: '#/components/responses/errorResponseDef'

  /logout:
    get:
      security:
      - cookieAuth: []
      summary: 'Log out session.'
      operationId: 'logout'
      responses:
        '200':
          description: 'Logout response with no content.'
        default:
          $ref: '#/components/responses/errorResponseDef'

  /report:
    get:
      security:
        - cookieAuth: []
      summary: 'Retrieves all configured reports.'
      operationId: 'reportList'
      responses:
        '200':
          description: 'Report list.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/reportList'
        '401':
          $ref: '#/components/responses/unauthorizedResponseDef'
        default:
          $ref: '#/components/responses/errorResponseDef'

  /report/{ID}/exec:
    get:
      security:
        - cookieAuth: []
      summary: 'Executes the report and return report data.'
      operationId: 'reportExec'
      parameters:
        - in: path
          name: 'ID'
          description: 'The report identifier.'
          required: true
          schema:
            type: string
        - in: query
          name: 'rowID'
          description: 'The ID of the row to start from.'
          required: false
          schema:
            type: number
        - in: query
          name: 'rowsPerPage'
          description: 'The number of report rows to return in the response.'
          required: false
          schema:
            type: number
      responses:
        '200':
          description: 'Report content.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/reportData'
        '401':
          $ref: '#/components/responses/unauthorizedResponseDef'
        default:
          $ref: '#/components/responses/errorResponseDef'

components:

  schemas:

    reportList:
      type: array
      items:
        $ref: '#/components/schemas/reportInfo'

    reportInfo:
      type: object
      properties:
        ID:
          type: string
        Type:
          type: number
        Description:
          type: string
        Duration:
          type: string

    reportData:
      type: object
      properties:
        ID:
          type: string
        Type:
          type: number
        Description:
          type: string
        Duration:
          type: string
        ExecutionStatus:
          type: string
        ServerTimeZone:
          type: string
        UserTimeZone:
          type: string
        Header:
          $ref: '#/components/schemas/reportHeader'
        Body:
          $ref: '#/components/schemas/reportBody'
        Footer:
          $ref: '#/components/schemas/reportFooter'

    reportHeader:
      type: object
      properties:
        SortedBy:
          type: array
          items:
            type: string
        FieldDefinitions:
          type: array
          items:
            $ref: '#/components/schemas/fieldDefinition'

    fieldDefinition:
      type: object
      properties:
        ID:
          type: number
        DataType:
          type: string
        Description:
          type: string

    reportBody:
      type: object
      properties:
        Rows:
          type: array
          items:
            $ref: '#/components/schemas/reportBodyRow'

    reportBodyRow:
      $ref: '#/components/schemas/reportRow'

    reportRow:
      type: object
      properties:
        ID:
          type: string
        Description:
          type: string
        Statistics:
          type: array
          items:
            $ref: '#/components/schemas/reportStatistic'

    reportStatistic:
      type: object
      properties:
        ID:
          type: number
        Value:
          type: string

    reportFooter:
      $ref: '#/components/schemas/reportRow'

    session:
      type: object
      properties:
        SessionID:
          type: string
        Nonce:
          type: string

    genericErrorResponse:
      type: object
      properties:
        Message:
          type: string

  securitySchemes:

    cookieAuth:
      type: apiKey
      in: cookie
      name: 'JSESSIONID'
      description: 'The session identifier.'

    basicAuth:
      type: http
      scheme: basic

  responses:

    unauthorizedResponseDef:
      description: 'User is not authorized.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/genericErrorResponse'

    errorResponseDef:
      description: 'Generic error response with error text.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/genericErrorResponse'
servers:
  - description: Akixi Service
    url: https://{host}/CCS/API/v1/
    variables:
      host:
        default: nimbus.akixi.com
        description: URL of your Akixi service.
  - description: Akixi Test Service
    url: https://nimbus.akixi.com/CCS/API/v1/