openapi: 3.0.0
info:
  title: operations API
  description: Set of endpoints related to operations over Aura
  contact:
    email: auradev@tid.es
tags:
  - name: operations
    description: Endpoints related to operations-api.
servers:
  - url: 'http://localhost:8989'
    description: Local server
  - url: 'https://svc-ap-current.auracognitive.com'
    description: ap-current
paths:
  /aura-services/v2/operations/data:
    post:
      tags:
        - operations-data
      description: Send an order to launch the process of generateBD
      operationId: postOperationsData
      x-router-controller: routes
      security:
        - ApiKeyHeaderAuth: [ ]
      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:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OperationsDataRequest"
            example:
              presetId: '79e2646a-a8bb-4355-b79f-42722c066155'
      responses:
        "200":
          $ref: "#/components/responses/ValidResponseOperationsData"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
  /aura-services/v2/operations/data/{presetId}/status:
    get:
      tags:
        - operations-data
      description: Get the status of job of generateBD for a given preset
      operationId: getOperationsDataStatus
      x-router-controller: routes
      security:
        - ApiKeyHeaderAuth: [ ]
      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
        - name: presetId
          in: path
          description: The identifier of the preset over which the job of generateBD was created
          required: true
          schema:
            type: string
            format: uuid
            example: '79e2646a-a8bb-4355-b79f-42722c066166'
      responses:
        "200":
          $ref: "#/components/responses/ValidResponseOperationsDataStatus"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
  /aura-services/v2/operations/data/{presetId}/logs:
    get:
      tags:
        - operations-data
      description: Get the logs of job of generateBD for a given preset
      operationId: getOperationsDataLogs
      x-router-controller: routes
      security:
        - ApiKeyHeaderAuth: [ ]
      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
        - name: presetId
          in: path
          description: The identifier of the preset over which the job of generateBD was created
          required: true
          schema:
            type: string
            format: uuid
            example: '79e2646a-a8bb-4355-b79f-42722c066166'
      responses:
        "200":
          $ref: "#/components/responses/ValidResponseOperationsDataLogs"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
  /aura-services/v2/operations/data/{presetId}:
    delete:
      tags:
        - operations-data
      description: Delete a job of generateBD for a given preset
      operationId: deleteOperationsData
      x-router-controller: routes
      security:
        - ApiKeyHeaderAuth: [ ]
      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
        - name: presetId
          in: path
          description: The identifier of the preset over which the job of generateBD was created
          required: true
          schema:
            type: string
            format: uuid
            example: '79e2646a-a8bb-4355-b79f-42722c066166'
      responses:
        "204":
          description: No content, the resource was successfully deleted and no response body is returned
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
components:
  responses:
    ValidResponseOperationsData:
      description: Incoming HTTP request format is valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string        
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OperationsDataResponse"
          example:
            jobId: '79e2646a-a8bb-4355-b79f-42722c066166'
            status: "running"
    ValidResponseOperationsDataStatus:
      description: Incoming HTTP request format is valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string        
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OperationsDataStatusResponse"
    ValidResponseOperationsDataLogs:
      description: Incoming HTTP request format is valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string        
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/OperationsDataLogsResponse"
          example:
            logs: 
              - msg: "Downloading files"
              - msg: "Blobs found"                
    InvalidRequest:
      description: Incoming HTTP request format is not valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
        x-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
        x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    NotFound:
      description: Incoming HTTP request is not found
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
        x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    InternalError:
      description: Incoming HTTP request produces an internal error
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
        x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
  securitySchemes:
    ApiKeyHeaderAuth:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    AuraError:
      type: object
      description: Error response
      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
    Status:
      type: string
      description: Status of the operation
      enum:
        - success
        - error
        - running
        - skipped
        - triggered
        - deleted
    OperationsDataRequest:
      type: object
      description: Contains the request to execute generateBD
      anyOf:
        - $ref: '#/components/schemas/OperationsDataRequestGenerateDB'
    OperationsDataRequestGenerateDB:
      type: object
      description: Contains the request to execute generateBD
      required:
        - presetId
      properties:
        presetId:
          type: string
          description: The identifier of the preset to use for this operation
          example: 79e2646a-a8bb-4355-b79f-42722c066155
          format: uuid
          pattern: ^(?!\s*$).+
          minLength: 1
    OperationsDataStatusResponse:
      anyOf:
        - $ref: '#/components/schemas/OperationsDataStatusResponseJob'
        - $ref: '#/components/schemas/OperationsDataStatusResponseCluster'
        - $ref: '#/components/schemas/OperationsDataStatusResponseError'
    OperationsDataStatusResponseJob:
      type: object
      description: Contains the status of the job created to execute the operation
      required:
        - status
        - presetName
        - msg
        - start
        - end
        - configDocs
      properties:
        presetName:
          type: string
          description: The name of the preset used for this operation
          example: project1
        status:
          $ref: '#/components/schemas/Status'
        msg:
          type: string
          description: Message with additional information about the operation status
          example: Skipping project project1 as no changes detected using hashes
        start:
          type: string
          format: date-time
          description: The start time of the operation in ISO 8601 format
          example: '2025-06-24T12:34:36.027745Z'
        end:
          type: string
          format: date-time
          description: The end time of the operation in ISO 8601 format
          example: '2025-06-24T12:35:09.264179Z'
        configDocs:
          type: array
          description: List of configuration documents related to the operation
          items:
            type: string
            description: Configuration document name
            example:
              - producto-rag-gpt-4o-mini/producto-gpt-4o-mini/pdf
    OperationsDataStatusResponseCluster:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/Status'
        startTime:
          type: string
          format: date-time
          example: '2025-07-07T07:28:35.286397Z'
    OperationsDataStatusResponseError:
      type: object
      properties:
        error:
          type: string
          example: Job failed
        status:
          type: object
          example:
            completionTime: '2025-07-03T11:16:29Z'
            conditions:
              - lastProbeTime: '2025-07-03T11:16:29Z'
                lastTransitionTime: '2025-07-03T11:16:29Z'
                message: Reached expected number of succeeded pods
                reason: CompletionsReached
                status: 'True'
                type: SuccessCriteriaMet
              - lastProbeTime: '2025-07-03T11:16:29Z'
                lastTransitionTime: '2025-07-03T11:16:29Z'
                message: Reached expected number of succeeded pods
                reason: CompletionsReached
                status: 'True'
                type: Complete
            ready: 0
            startTime: '2025-07-03T11:15:50Z'
            succeeded: 1
            terminating: 0
            uncountedTerminatedPods: {}         
    OperationsDataResponse:
      type: object
      description: Contains 
      required:
        - jobId
        - status
      properties:
        jobId:
          type: string
          description: The identifier of the job created to execute the operation
          example: '79e2646a-a8bb-4355-b79f-42722c066166'
          format: uuid
        status:
          $ref: "#/components/schemas/Status"
    OperationsDataLogsResponse:
      type: object
      description: Contains the logs of the job created to execute the operation
      required:
        - logs
      properties:
        logs:
          type: array
          description: List of logs related to the job created to execute the operation
          items:
            type: string
            description: Log message
            example: "Downloading files"
