openapi: 3.0.3
info:
  title: cx-data-services-lambda-master-data-loads
  description: Existing master data loads operations endpoints documentation
  version: v2
  contact:
    email: sedataops@carlsberg.com
    name: DataOps Team
servers:
  - url: https://api-eu.carlsbergwebservices.com/data/dev/v2
    description: Master data loads lambda API server url
  - url: https://api-eu.carlsbergwebservices.com/data/tst/v2
    description: Master data loads lambda API server url
  - url: https://api-eu.carlsbergwebservices.com/data/stg/v2
    description: Master data loads lambda API server url
  - url: https://api-eu.carlsbergwebservices.com/data/prd/v2
    description: Master data loads lambda API server url
tags:
  - name: master-data-loads
    description: Master data loads lambda endpoints
paths:
  /hello:
    get:
      tags:
        - master-data-loads
      operationId: fetchHello
      summary: Get hello
      description: Endpoint to see if service is alive
      responses:
        '200':
          $ref: '#/components/responses/MasterDataLoadHello'
  /{env}/master-data-loads/{fileName}:
    get:
      tags:
        - master-data-loads
      operationId: fetchMasterDataLoad
      summary: Get master data load by file
      description: Concatenation of fields and the proper format (just fileName in this case)
      responses:
        '200':
          $ref: '#/components/responses/MasterDataLoad'
        '400':
          $ref: '#/components/responses/MasterDataLoadError'
    parameters:
      - $ref: '#/components/parameters/env'
      - $ref: '#/components/parameters/fileName'
  /{env}/master-data-loads:
    get:
      tags:
        - master-data-loads
      operationId: fetchAllMasterDataLoads
      summary: Get master data loads by env
      description: Retrieve a list of master data loads for a specific environment
      responses:
        '200':
          $ref: '#/components/responses/MasterDataLoadList'
        '400':
          $ref: '#/components/responses/MasterDataLoadError'
      parameters:
        - $ref: '#/components/parameters/fields'
        - $ref: '#/components/parameters/list'
        - $ref: '#/components/parameters/size'
        - $ref: '#/components/parameters/token'
        - $ref: '#/components/parameters/fileDate'
        - $ref: '#/components/parameters/app'
        - $ref: '#/components/parameters/service'
        - $ref: '#/components/parameters/tableName'
        - $ref: '#/components/parameters/status'
    parameters:
      - $ref: '#/components/parameters/env'
components:
  schemas:
    HelloModel:
      title: hello response
      x-stoplight:
        id: 18mahkbe4equ3
      description: This is the response structure when testing availability
      type: object
      properties:
        message:
          description: Content of greeting test message
          type: string
          example: Hello from CxDataOps Data Services !!!
    MasterDataLoadModel:
      title: Master data load schema
      x-stoplight:
        id: gpdvssray6c8s
      description: Body response of a master data load schema existing in DynamoDB
      type: object
      properties:
        fileName:
          type: string
          description: The name of the file being processed.
          example: example.csv
        env:
          type: string
          description: The environment where the file exists.
          example: dev
        country:
          type: string
          description: The country associated with the file data.
          example: GB
        creationDate:
          type: string
          description: The date the file was created.
          example: '2024-02-22'
        error:
          type: string
          description: A brief description of the error, in case of error.
          example: This is a sample error.
        fileDate:
          type: integer
          format: int32
          description: The date associated with the file data.
          example: 20240222
        filePath:
          type: string
          description: The path where the file is located.
          example: s3://path/to/storage/fileName
        fileTimestamp:
          type: string
          description: The timestamp when the file was last modified.
          example: '2024-02-22T01:34:01Z'
        inBronze:
          type: integer
          format: int32
          description: Indicator if file reached Bronze Layer.
          example: 1
        inLakehouse:
          type: integer
          format: int32
          description: Indicator if file reached Bronze Layer.
          example: 1
        isLoaded:
          type: boolean
          description: Indicator if file was loaded into Dropzone.
          example: true
        inDropzone:
          type: boolean
          description: Indicator if file was loaded into Dropzone.
          example: true
        num_rows:
          type: integer
          format: int32
          description: The number of rows in the file.
          example: 1000
        sep:
          type: string
          description: The separator used in the file.
          example: ','
        type:
          type: string
          description: The type of the file.
          example: csv
        size:
          type: integer
          format: int32
          description: The size of the file in bytes.
          example: 1024
        status:
          type: string
          description: The status of the file processing.
          example: processed
        app:
          type: string
          description: The app name correspondent to the service/interface.
          example: cadi
        tableName:
          type: string
          description: The name of the service/interface.
          example: debts
        service:
          type: string
          description: The name of the service/interface.
          example: debts
        error_log_path:
          type: string
          description: The path where the error file is going to be stored.
          example: path/to/error_file/storage
    MasterDataLoadsListModel:
      type: object
      x-stoplight:
        id: b156ebb8362db
      description: Body response of a list of master data loads schemas existing in DynamoDB
      properties:
        content:
          type: array
          description: Body response of a master data loads schema existing in DynamoBD
          items:
            $ref: '#/components/schemas/MasterDataLoadModel'
          example:
            - $ref: '#/components/schemas/MasterDataLoadModel'
        pagination:
          $ref: '#/components/schemas/TokenPaginationModel'
    ErrorResponseModel:
      title: error response
      x-stoplight:
        id: 66l5jrm31kutl
      description: This is a schema for response when there is an error
      type: object
      properties:
        title:
          description: Title of the failure
          type: string
          example: Bad Request
        status:
          description: Error type code form response
          type: integer
          format: int32
          example: 400
        detail:
          description: More detailed information about the error
          type: string
          example: 'record_id: XYZ, sales_org: 9999 not found'
    TokenPaginationModel:
      title: Token Pagination
      x-stoplight:
        id: wskpcubkmjgjl
      type: object
      description: Pagination metadata for using token page method
      properties:
        size:
          type: integer
          format: int32
          description: The size (number of elements) displayed per page
          example: 100
        token:
          type: string
          description: Token used to fetch next page data
          example: '%7B%27sortkey%27%3A+%271010%27%2C+%27env%27%3A+%27dev%27%2C+%27partkey%27%3A+%RECORD_ID_dev%27%7D'
      example:
        size: 100
        token: '%7B%27sortkey%27%3A+%271010%27%2C+%27env%27%3A+%27dev%27%2C+%27partkey%27%3A+%RECORD_ID_dev%27%7D'
  parameters:
    env:
      name: env
      in: path
      required: true
      schema:
        type: string
        example: prod
      description: The environment where the file is located.
    fileName:
      name: fileName
      in: path
      required: true
      schema:
        type: string
        example: fileName1.csv
      description: The name of the file being processed.
    fileDate:
      name: fileDate
      in: query
      required: true
      schema:
        type: string
        example: '2024-02-22'
      description: The date associated with the file data.
    app:
      name: app
      in: query
      required: true
      schema:
        type: string
        example: cadi
      description: The app name correspondent to the service/interface.
    service:
      name: service
      in: query
      required: true
      schema:
        type: string
        example: debts
      description: The name of the service/interface.
    tableName:
      name: tableName
      in: query
      required: true
      schema:
        type: string
        example: debts
      description: The name of the service/interface.
    status:
      name: status
      in: query
      required: true
      schema:
        type: string
        example: processed
      description: The status of the file being processed.
    token:
      name: token
      in: query
      required: false
      schema:
        type: string
        example: '%7B%27sortkey%27%3A+%271010%27%2C+%27env%27%3A+%27dev%27%2C+%27partkey%27%3A+%RECORD_ID_dev%27%7D'
      description: Token that retrieves the next page of results.
    size:
      name: size
      in: query
      required: false
      schema:
        type: integer
        format: int32
        example: 100
      description: Number of items to return
    fields:
      name: fields
      in: query
      required: false
      schema:
        type: string
        example: fields=env
      description: An attribute from the body
    list:
      name: list
      in: query
      required: false
      schema:
        type: string
        example: list=fileName1.csv, fileName2.csv
      description: List of partkeys (without "_<env>"). Limit of 100 elements.
  responses:
    MasterDataLoadHello:
      description: Retrieve a static message just to verify deployment
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/HelloModel'
    MasterDataLoad:
      description: Get master data load detail based in given env and fileName
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MasterDataLoadModel'
    MasterDataLoadList:
      description: Get master data loads detail list based in given env
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MasterDataLoadsListModel'
    MasterDataLoadError:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseModel'
x-stoplight:
  id: a1w0xt02n5yvb
