openapi: 3.0.0
info:
  description: Aura configuration atria agents API definition.
  version: 1.0.0
  title: Aura configuration atria agents API Swagger
  contact:
    email: auradev@tid.es
servers:
  - url: https://localhost:8999
paths:
  /aura-services/v2/configuration/agents/{agentId}:
    get:
      tags:
        - Agents
      summary: Gets all the info associated to one agent
      description: Returns channel info by agentId
      operationId: getAgentById
      security:
        - apiKeyHeader: []
      parameters:
        - name: agentId
          in: path
          description: Unique Aura agent identifier
          required: true
          schema:
            type: string
        - name: excludeFields
          description: Filters to exclude some keys from the returned object. Only root values of agentConfiguration can be filtered
          in: query
          required: false
          schema:
            type: string
        - name: includeFields
          description: Set all the keys returned in the result object. Only root values of agentConfiguration can be filtered
          in: query
          required: false
          schema:
            type: string
        - name: correlator
          in: header
          description:
            Unique identifier of a request to be used as correlator in all
            systems
          required: false
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Successfully retrieved
          headers:
            correlator:
              description: Correlation id for the different services
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/AgentConfigurationPartial"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"
      x-swagger-router-controller: "modules"
    put:
      tags:
        - Agents
      summary: Updates all the info associated to one agent
      description: Updates all agent info
      operationId: updateAgent
      security:
        - apiKeyHeader: []
      parameters:
        - name: agentId
          in: path
          description: Unique Aura agent identifier
          required: true
          schema:
            type: string
        - name: correlator
          in: header
          description:
            Unique identifier of a request to be used as correlator in all systems
          required: false
          schema:
            type: string
            format: uuid
      requestBody:
        description: Input agentData to update
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AgentConfiguration"
      responses:
        "204":
          description: Successfully updated
          headers:
            correlator:
              description: Correlation id for the different services
              schema:
                type: string
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"
      x-swagger-router-controller: "modules"
    patch:
      tags:
        - Agents
      summary: Updates some info associated to one agent
      description: Updates some fields of agent info
      operationId: modifyAgent
      security:
        - apiKeyHeader: []
      parameters:
        - name: agentId
          in: path
          description: Unique Aura agent identifier
          required: true
          schema:
            type: string
        - name: correlator
          in: header
          description:
            Unique identifier of a request to be used as correlator in all
            systems
          required: false
          schema:
            type: string
            format: uuid
      requestBody:
        description: Input channelData to add
        required: true
        content:
          application/json:
            schema:              
              $ref: "#/components/schemas/AgentConfigurationPartial"
      responses:
        "204":
          description: Successfully updated
          headers:
            correlator:
              description: Correlation id for the different services
              schema:
                type: string
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"
      x-swagger-router-controller: "modules"
    delete:
      tags:
        - Agents
      summary: Delete one agent
      description: Delete agent info by id
      operationId: deleteAgentById
      security:
        - apiKeyHeader: []
      parameters:
        - name: agentId
          in: path
          description: Unique Aura agent identifier
          required: true
          schema:
            type: string
        - name: correlator
          in: header
          description:
            Unique identifier of a request to be used as correlator in all
            systems
          required: false
          schema:
            type: string
            format: uuid
      responses:
        "204":
          description: Successfully deleted
          headers:
            correlator:
              description: Correlation id for the different services
              schema:
                type: string
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "500":
          $ref: "#/components/responses/InternalError"
      x-swagger-router-controller: "modules"
  /aura-services/v2/configuration/agents:
    get:
      tags:
        - Agents
      summary: Gets all agents info
      description: Returns agents info
      operationId: getAllAgents
      security:
        - apiKeyHeader: []
      parameters:
        - name: excludeFields
          description: Filters to exclude some keys from the returned object. Only root values of agentConfiguration can be filtered
          in: query
          required: false
          schema:
            type: string
        - name: includeFields
          description: Set all the keys returned in the result object. Properties of private properties can't be filtered
          in: query
          required: false
          schema:
            type: string
        - name: correlator
          in: header
          description:
            Unique identifier of a request to be used as correlator in all
            systems
          required: false
          schema:
            type: string
            format: uuid
        - name: filter
          description: A list of key:value strings, comma separated to filter returned applications.
          in: query
          required: false
          schema:
            type: string
          example: deploymentName:my-deploy
      responses:
        "200":
          description: Successfully retrieved
          headers:
            correlator:
              description: Correlation id for the different services
              schema:
                type: string
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/AgentConfigurationPartial"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "500":
          $ref: "#/components/responses/InternalError"
      x-swagger-router-controller: "modules"
    post:
      tags:
        - Agents
      summary: Adds a new agent
      description: Adds a new agent
      operationId: addAgent
      security:
        - apiKeyHeader: []
      parameters:
        - name: correlator
          in: header
          description:
            Unique identifier of a request to be used as correlator in all
            systems
          required: false
          schema:
            type: string
            format: uuid
      requestBody:
        description: Input agentData to add
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AgentConfiguration"
      responses:
        "201":
          description: Successfully gathered
          headers:
            correlator:
              description: Correlation id for the different services
              schema:
                type: string
            location:
              description: URI to access this channel configuration
              schema:
                type: string
                format: url
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "409":
          $ref: "#/components/responses/Conflict"
        "500":
          $ref: "#/components/responses/InternalError"
      x-swagger-router-controller: "modules"
components:
  responses:
    InvalidRequest:
      description: Incoming HTTP request format is not valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    Unauthorized:
      description: Incoming HTTP request authorization is not valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    Conflict:
      description:
        The request could not be completed due to a conflict with the current
        state of the target resource.
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    TooManyRequests:
      description: The user has sent too many requests in a given amount of time
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    InternalError:
      description: Unexpected internal error
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    NotFound:
      description: Request resource not found
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
  securitySchemes:
    apiKeyHeader:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    AgentBase:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Contains the name that identifies the agent base univocally in Aura.
          pattern: '^\S.*$'
          minLength: 1
        configuration:
          type: object
          description: Contains the configuration of the agent flow.
    AgentConfigurationPartial:
      type: object
      required:
        - id
      additionalProperties: false
      properties:
        agentBase:
          $ref: '#/components/schemas/AgentBase'
        id:
          type: string
          format: uuid
          description: Contains the UUID that identifies the agent univocally in Aura.
        name:
          type: string
          description: Contains the name that identifies the agent univocally in Aura.
          pattern: '^\S.*$'
          minLength: 1
        description:
          type: string
          description: Contains the description of the agent.        
        communication:
          description: Contains the communication configuration of the agent.
          anyOf:
              - $ref: '#/components/schemas/AgentHttpCommunication'
          discriminator:
            propertyName: communicationType
            mapping:
              http: '#/components/schemas/AgentHttpCommunication'
        deploymentName:
          type: string
          description: Contains the name of the deployment where the agent is running.
        metadata:
          $ref: '#/components/schemas/DocumentMetadata'
    AgentConfiguration:
      type: object
      allOf:
        - $ref: '#/components/schemas/AgentConfigurationPartial'
        - required:
            - agentBase
            - id
            - name
            - communication
    AgentHttpCommunication:
      type: object
      description: Agent HTTP communication configuration
      required:
        - communicationType
      additionalProperties: false
      properties:
        endpoint:
          type: string
          description: Contains the HTTP endpoint where the agent is listening to.
        headers:
          type: object
          description: Contains the HTTP headers that the agent is associated with.
        communicationType:
          type: string
          description: Contains the communication type that the agent is associated with.
          enum:
            - http
        timeout:
          type: number
          description: Contains the timeout that the agent is associated with.
        retries:
          type: number
          description: Contains the number of retries that the agent is associated with.    
    AuraError:
      type: object
      description: Error response
      additionalProperties: false
      properties:
        code:
          type: string
          description: Unique id of the error
        message:
          type: string
          description: Specific and descriptive text of the error
        errors:
          description: With validation error. Swagger error information
          type: array
          items:
            type: object
    DocumentMetadata:
      type: object
      description: Metadata for configuration-api docs
      additionalProperties: true
      properties:
        version:
          type: string
          description: Document version
        createdAt:
          type: string
          description: Date when the content was created
          format: date-time
        updatedAt:
          type: string
          description: Date when the content was updated
          format: date-time