---
openapi: 3.1.0
components:
  schemas:
    AnalyticsQueryRequest:
      type: object
      properties:
        useCaseId:
          $ref: "#/components/schemas/UUID"
        businessId:
          $ref: "#/components/schemas/UUID"
        knowledgeAssetId:
          $ref: "#/components/schemas/UUID"
        sql:
          type: string
        format:
          type: string
        filename:
          type: string
        spreadsheetMetadata:
          type: object
          additionalProperties: {}
    BatchStatusRequest:
      type: object
      properties:
        ids:
          type: array
          items:
            type: string
    RetrievalRequestDto:
      type: object
      properties:
        query:
          type: string
        businessId:
          $ref: "#/components/schemas/UUID"
        useCaseId:
          $ref: "#/components/schemas/UUID"
        conversationId:
          $ref: "#/components/schemas/UUID"
        documentId:
          $ref: "#/components/schemas/UUID"
        chunkType:
          type: string
        topK:
          type: integer
          format: int32
        similarityThreshold:
          type: number
          format: double
        contextWindow:
          type: integer
          format: int32
        diversityFactor:
          type: number
          format: double
    RetryRequest:
      type: object
      properties:
        useCaseId:
          $ref: "#/components/schemas/UUID"
    UUID:
      type: string
      format: uuid
      pattern: "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"
    UseCaseKnowledgeConfigRequest:
      type: object
      properties:
        assetId:
          $ref: "#/components/schemas/UUID"
        chunkSize:
          type: integer
          format: int32
        chunkOverlap:
          type: integer
          format: int32
        chunkStrategy:
          type: string
        mode:
          $ref: "#/components/schemas/UseCaseKnowledgeMode"
        enabled:
          type: boolean
        metadata:
          type: object
          additionalProperties: {}
        estimatedTokenCount:
          type: integer
          format: int32
    UseCaseKnowledgeConfigStatusRequest:
      type: object
      properties:
        enabled:
          type: boolean
    UseCaseKnowledgeMode:
      type: string
      enum:
      - RAG
      - PROMPT_INLINE
  securitySchemes:
    SecurityScheme:
      type: openIdConnect
      description: Authentication
paths:
  /api/analytics/query:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AnalyticsQueryRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Query
      tags:
      - Analytics Resource
      security:
      - SecurityScheme:
        - business-owner
        - business-admin
        - business-attendant
        - fsaap-admin
  /api/analytics/schema/{assetId}:
    get:
      parameters:
      - name: assetId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      - name: businessId
        in: query
        schema:
          $ref: "#/components/schemas/UUID"
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Get Schema
      tags:
      - Analytics Schema Resource
      security:
      - SecurityScheme:
        - business-owner
        - business-admin
        - business-attendant
        - fsaap-admin
  /api/ingest-chat:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                files:
                  type: array
                  items:
                    type: string
                    format: binary
                useCaseId:
                  type: string
                conversationId:
                  type: string
                contentType:
                  type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Upload
      tags:
      - Ingest Chat Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/knowledge-assets:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                useCaseId:
                  type: string
                conversationId:
                  type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Upload
      tags:
      - Knowledge Asset Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/knowledge-assets/ownership-remediation:
    get:
      parameters:
      - name: limit
        in: query
        schema:
          type: integer
          format: int32
          default: 50
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: List Ownership Remediation
      tags:
      - Knowledge Asset Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/knowledge-assets/statuses/batch:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BatchStatusRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: List Statuses By Ids
      tags:
      - Knowledge Asset Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/knowledge-assets/{id}:
    delete:
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Delete
      tags:
      - Knowledge Asset Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/knowledge-assets/{id}/retry:
    post:
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RetryRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Retry
      tags:
      - Knowledge Asset Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/knowledge-assets/{id}/retry-diagnostics:
    get:
      parameters:
      - name: id
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      - name: useCaseId
        in: query
        schema:
          $ref: "#/components/schemas/UUID"
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Retry Diagnostics
      tags:
      - Knowledge Asset Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/retrieval/search:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RetrievalRequestDto"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Search
      tags:
      - Retrieval Resource
      security:
      - SecurityScheme:
        - business-owner
        - business-admin
        - business-attendant
        - fsaap-admin
  /api/use-cases/{useCaseId}/knowledge-config:
    post:
      parameters:
      - name: useCaseId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UseCaseKnowledgeConfigRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create
      tags:
      - Use Case Knowledge Config Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/use-cases/{useCaseId}/knowledge-config/{configId}:
    put:
      parameters:
      - name: configId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      - name: useCaseId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UseCaseKnowledgeConfigRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Update
      tags:
      - Use Case Knowledge Config Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
    delete:
      parameters:
      - name: configId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      - name: useCaseId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Delete
      tags:
      - Use Case Knowledge Config Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
  /api/use-cases/{useCaseId}/knowledge-config/{configId}/status:
    patch:
      parameters:
      - name: configId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      - name: useCaseId
        in: path
        required: true
        schema:
          $ref: "#/components/schemas/UUID"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UseCaseKnowledgeConfigStatusRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json: {}
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Patch Status
      tags:
      - Use Case Knowledge Config Resource
      security:
      - SecurityScheme:
        - fsaap-admin
        - business-owner
        - business-admin
        - business-attendant
info:
  title: fsaap-rag API
  version: 1.0.0-SNAPSHOT
servers:
- url: http://localhost:8080
  description: Auto generated value
- url: http://0.0.0.0:8080
  description: Auto generated value
