swagger: '2.0'
info:
  version: 1.0.0
  title: Alvaria&trade; Cloud AutoFacilitate REST API
  contact:
    name: Alvaria Software
    url: 'https://www.alvaria.com'
    email: support@alvaria.com
  license:
    name: 'License: Creative Commons Attribution 4.0 International Public License'
    url: 'https://creativecommons.org/licenses/by/4.0/legalcode'
  description: |-
    ## Overview

    The Alvaria&trade; Cloud AutoFacilitate REST API, provided by the AutoFacilitate Server, facilitates easy integration
    with other systems by providing access to the endpoints needed to interact with the AutoFacilitate Feature

    In order to utilize the AutoFacilitate REST API the autofacilitateapi scope is required.

host: orgId.via.aspect-cloud.net
schemes:
  - https
consumes:
  - application/json
produces:
  - application/json
paths:
  '/via/v2/organizations/{orgId}/autoFacilitate/execute/{vsn}':
    post:
      tags:
        - Execute
      operationId: Execute
      summary: Execute Service
      description: Starts a service
      consumes:
        - application/json
        - application/xml
      produces:
        - application/json
      parameters:
        - name: orgId
          in: path
          description: Name of a customer organization
          required: true
          type: string
        - name: vsn
          in: path
          description: Service name to trigger
          required: true
          type: string
        - name: Authorization
          in: header
          description: |-
            Authentication token with the value: 'Bearer {accessToken}', where {accessToken} was returned from a call to the authorization endpoint
          required: true
          type: string
        - name: x-api-key
          in: header
          required: true
          type: string
          description: Alvaria-provided value used to track API endpoint usage
        - name: body
          description: JSON/XML Structure with trigger parameters
          required: true
          in: body
          schema:
            $ref: '#/definitions/triggerParameter'
      security:
        - oauth:
            - autofacilitateapi
      responses:
        '200':
          description: Successful response
          schema:
            $ref: '#/definitions/triggerResult'
        '400':
          description: Validation exception
          schema:
            $ref: '#/definitions/ErrorResponse'
        '401':
          description: Unauthorized
        '404':
          description: Dialog Id not found on the cluster
          schema:
            $ref: '#/definitions/ErrorResponse'
        '422':
          description: Unprocessable Entity
          schema:
            $ref: '#/definitions/ErrorResponse'
        '500':
          description: Internal server error
          schema:
            $ref: '#/definitions/ErrorResponse'
  '/via/v2/organizations/{orgId}/autoFacilitate/result/{vsn}/triggerUUID/{triggerUUID}':
    get:
      tags:
        - Result
      operationId: Get Result
      summary: Get Trigger result
      description: Call this endpoint to get the result from a finished service trigger
      parameters:
        - name: orgId
          in: path
          description: Name of a customer organization
          required: true
          type: string
        - name: vsn
          in: path
          description: Service name from where we want the result
          required: true
          type: string
        - name: triggerUUID
          in: path
          description: TriggerId of the Service result
          required: true
          type: string
        - name: Authorization
          in: header
          description: |-
            Authentication token with the value: 'Bearer {accessToken}', where {accessToken} was returned from a call to the authorization endpoint
          required: true
          type: string
        - name: x-api-key
          in: header
          required: true
          type: string
          description: Alvaria-provided value used to track API endpoint usage
      security:
        - oauth:
            - autofacilitateapi
      responses:
        '204':
          description: Successful response
        '400':
          description: Validation exception
          schema:
            $ref: '#/definitions/ErrorResponse'
        '401':
          description: Unauthorized
        '404':
          description: Dialog Id not found on the cluster
          schema:
            $ref: '#/definitions/ErrorResponse'
        '422':
          description: Unprocessable Entity
          schema:
            $ref: '#/definitions/ErrorResponse'
        '500':
          description: Internal server error
          schema:
            $ref: '#/definitions/ErrorResponse'
securityDefinitions:
  oauth:
    type: oauth2
    authorizationUrl: 'https://myaspect.{region}.id.aspect-cloud.net/tokenservice/oauth2/access_token?realm={orgId}'
    flow: implicit
    scopes:
      autofacilitateapi: manage the complete autofacilitate api
definitions:
  triggerParameter:
    type: "object"
    properties:
      triggerParameters:
        $ref: "#/definitions/triggerParameters"
      callbackUrls:
        $ref: "#/definitions/callbackUrls"
    xml:
      name: "root"
      attribute: false
  triggerParameters:
    type: "object"
    properties:
      key:
        type: "string"
        example: "value"
  callbackUrls:
    type: "array"
    items:
      $ref: "#/definitions/urls"
    xml:
      wrapped: true
  urls:
    type: string
    example: "https://mycompany.com/callbacks/id=123"
    xml:
      name: "callbackUrl"
  ErrorResponse:
    type: object
    properties:
      code:
        type: integer
        description: HTTP error status
        example: '400'
      message:
        type: string
        example: Validation exception
      errors:
        type: array
        items:
          $ref: '#/definitions/Error'
  Error:
    type: object
    properties:
      scope:
        type: string
        example: global
      reason:
        type: string
        example: Invalid request
      message:
        type: string
        example: The value for the channel is invalid
  triggerResult:
    type: object
    properties:
      message:
        type: "string"
        example: "Successfully triggered ServerName@orgId"
      triggerUUID:
        type: "integer"
        example: "1234"
