8. Спецификация модуля асинхронной загрузки данных из сторонних источников

Данная спецификация описывает эндпоинты API REST-Uploader.

openapi: 3.0.1
info:
  title: Rest-uploader
  description: This is a rest-uploader service for datamart filling
  version: 2.0.0
paths:
  /v2/datamarts/{datamart_name}/tables/{table_name}/upload:
    post:
      summary: Add a new data to the datamart
      operationId: v2-datamarts-datamart_name-tables-table_name-upload
      description: Загрузка данных из внешних источников. К телу прикладывается файл csv, json или avro
      tags:
        - data
      parameters:
        - $ref: '#/components/parameters/datamartName'
        - $ref: '#/components/parameters/tableName'
        - $ref: '#/components/parameters/groupId'
        - $ref: '#/components/parameters/groupFileNum'
        - $ref: '#/components/parameters/groupFileCount'
      requestBody:
        $ref: '#/components/requestBodies/uploadData'
      responses:
        '200':
          description: OK
          headers:
            requestId:
              schema:
                $ref: '#/components/schemas/requestId'
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/requestId'
        '400':
          $ref: '#/components/responses/badRequest'
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/tables/{table_name}/modify:
    post:
      summary: Modify data in the datamart, add, update, delete from one file
      operationId: v2-datamarts-datamart_name-tables-table_name-modify
      description: Модификация данных из внешних источников. К телу прикладывается файл csv или avro, включая sys_op признак 0- для добавления, 1- для удаления записи
      tags:
        - data
      parameters:
        - $ref: '#/components/parameters/datamartName'
        - $ref: '#/components/parameters/tableName'
        - $ref: '#/components/parameters/groupId'
        - $ref: '#/components/parameters/groupFileNum'
        - $ref: '#/components/parameters/groupFileCount'
      requestBody:
        $ref: '#/components/requestBodies/modifyData'
      responses:
        '200':
          description: OK
          headers:
            requestId:
              schema:
                $ref: '#/components/schemas/requestId'
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/requestId'
        '400':
          $ref: '#/components/responses/badRequest'
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []

  /v2/requests/{request_id}/status:
    get:
      summary: Return request status
      description: Возвращение статуса запроса
      operationId: get-v2-request-request_id-status
      tags:
        - data
      parameters:
        - $ref: '#/components/parameters/requestId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - description
                  - errorMessage
                properties:
                  code:
                    type: integer
                    description: Код статуса
                  description:
                    type: string
                    description: Описание статуса
                  errorMessage:
                    type: string
                    description: Описание ошибки
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
  /v2/requests/{request_id}/reportFLK:
    get:
      summary: Return report FLK check
      description: Возвращает отчет по формато логическом контроле загружаемых данных
      operationId: get-v2-request-request_id-reportFLK
      tags:
        - report
      parameters:
        - $ref: '#/components/parameters/requestId'
      responses:
        '200':
          description: OK
          content:
            text/csv:
              schema:
                type: array
                items:
                  type: array
                  items:
                    type: string
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
  /v2/group/{groupId}/report:
    get:
      summary: Return report group
      description: Возвращает отчет по комплектности группы загружаемых файлов
      operationId: get-v2-group-groupId-report
      tags:
        - report
      parameters:
        - name: groupId
          in: path
          description: Identifier of group
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            text/csv:
              schema:
                type: array
                items:
                  type: array
                  items:
                    type: string
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/beginDelta:
    post:
      summary: begin delta
      operationId: post-v2-datamart_name-begin_delta
      tags:
        - delta
      parameters:
        - $ref: '#/components/parameters/datamartName'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  deltaNum:
                    type: integer
        '400':
          description: Bad Request
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: открытие дельты
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/commitDelta:
    post:
      summary: commit delta
      operationId: post-v2-datamart_name-commit_delta
      tags:
        - delta
      parameters:
        - $ref: '#/components/parameters/datamartName'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  deltaNum:
                    type: integer
                  deltaDate:
                    type: string
                  cnFrom:
                    type: integer
        '400':
          description: Bad Request
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: применение дельты
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/rollbackDelta:
    post:
      summary: rollback delta
      operationId: post-v2-datamart_name-rollback_delta
      tags:
        - delta
      parameters:
        - $ref: '#/components/parameters/datamartName'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  deltaNum:
                    type: integer
        '400':
          description: Bad Request
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: отмена дельты
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/getDeltaOk:
    get:
      summary: get delta ok
      operationId: get-v2-datamart_name-get_delta_ok
      tags:
        - delta
      parameters:
        - $ref: '#/components/parameters/datamartName'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  deltaNum:
                    type: integer
                  deltaDate:
                    type: string
                  cnFrom:
                    type: integer
        '400':
          description: Bad Request
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: получение примененной дельты
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/getDeltaHot:
    get:
      summary: get delta hot
      operationId: get-v2-datamart_name-get_delta_hot
      tags:
        - delta
      parameters:
        - $ref: '#/components/parameters/datamartName'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  deltaNum:
                    type: integer
                  cnFrom:
                    type: integer
                  cnMax:
                    type: integer
                  isRollingBack:
                    type: boolean
                  writeOpFinished:
                    type: string
        '400':
          description: Bad Request
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: получение открытой дельты
      security:
        - bearerAuth: []
  /v2/LengthFlkQueue:
    get:
      summary: get length flk queue
      operationId: get-v2-get_length_flk_queue
      tags:
        - data
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                type: integer
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: |-
        получение длины очереди ФЛК
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/LengthUploadQueue:
    get:
      summary: get length upload queue
      operationId: get-v2-get_length_upload_queue
      tags:
        - data
      parameters:
        - $ref: '#/components/parameters/datamartName'
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                type: integer
        '400':
          description: Bad Request
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: получение длины очереди загрузки данных в датамарт
      security:
        - bearerAuth: []
  /v2/datamarts/{datamart_name}/tables/{table_name}/delete:
    post:
      summary: Delete data by primary key array
      operationId: post-v2-datamart_name-tables-table_name-delete
      tags:
        - data
      parameters:
        - $ref: '#/components/parameters/datamartName'
        - $ref: '#/components/parameters/tableName'
      responses:
        '200':
          description: OK
          headers:
            requestId:
              schema:
                $ref: '#/components/schemas/requestId'
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/requestId'
        '400':
          $ref: '#/components/responses/badRequest'
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: Удаление данных по массиву первичных ключей
      security:
        - bearerAuth: []
      requestBody:
        $ref: '#/components/requestBodies/deleteData'
  /v2/datamarts/{datamart_name}/tables/{table_name}/truncate:
    post:
      summary: Delete historical data by primary key array
      operationId: post-v2-datamart_name-tables-table_name-truncate
      tags:
        - data
      parameters:
        - $ref: '#/components/parameters/datamartName'
        - $ref: '#/components/parameters/tableName'
        - $ref: '#/components/parameters/forSystemTime'
      responses:
        '200':
          description: OK
          headers:
            requestId:
              schema:
                $ref: '#/components/schemas/requestId'
          content:
            text/plain:
              schema:
                $ref: '#/components/schemas/requestId'
        '400':
          $ref: '#/components/responses/badRequest'
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      description: Удаление исторических данных по массиву первичных ключей
      security:
        - bearerAuth: [ ]
      requestBody:
        $ref: '#/components/requestBodies/deleteData'
  /v2/conditions/{datamart_name}/{table_name}:
    parameters:
      - $ref: '#/components/parameters/datamartName'
      - $ref: '#/components/parameters/tableName'
    post:
      summary: Create verification conditions
      description: Формирование правил проверки для датамарта/таблицы
      operationId: post-v2-conditions
      tags:
        - conditions
      requestBody:
        content:
          application/x-yaml: {}
      responses:
        '200':
          description: OK
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
    put:
      summary: Update verification conditions
      description: Обновление правил проверки для датамарта/таблицы
      operationId: put-v2-conditions
      tags:
        - conditions
      requestBody:
        content:
          application/x-yaml: {}
      responses:
        '200':
          description: OK
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
    get:
      summary: Return verification conditions
      description: Возвращение правил проверки для датамарта/таблицы
      operationId: get-v2-conditions
      tags:
        - conditions
      responses:
        '200':
          description: OK
          content:
            text/yaml: {}
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
    delete:
      summary: Delete verification conditions
      description: Удаление правил проверки для датамарта/таблицы
      operationId: delete-v2-conditions
      tags:
        - conditions
      responses:
        '200':
          description: OK
        '401':
          $ref: '#/components/responses/unauthorized'
        '500':
          $ref: '#/components/responses/internalServerError'
      security:
        - bearerAuth: []
components:
  requestBodies:
    uploadData:
      description: "загружаемые данные"
      required: true
      content:
        text/csv:
          schema:
            type: array
            items:
              type: array
              items:
                type: string
        application/json:
          schema:
            type: array
            items:
              type: array
              items:
                type: string
        avro/binary:
          schema:
            type: array
            items:
              type: array
              items:
                oneOf:
                  - type: boolean
                  - type: string
                  - type: integer #asyncapi
                  - type: number  #asyncapi
                  #- type: int  #Prostor
                  #- type: long #Prostor
                  #- type: float #Prostor
                  #- type: double #Prostor
        multipart/form-data:
          schema:
            required:
              - uploadData
            properties:
              uploadData:
                type: string
                description: Data for uploading
                format: binary
    modifyData:
      description: "загружаемые данные"
      required: true
      content:
        text/csv:
          schema:
            type: array
            items:
              type: array
              items:
                type: string
        avro/binary:
          schema:
            type: array
            items:
              type: array
              items:
                oneOf:
                  - type: boolean
                  - type: string
                  - type: integer #asyncapi
                  - type: number  #asyncapi
                  #- type: int  #Prostor
                  #- type: long #Prostor
                  #- type: float #Prostor
                  #- type: double #Prostor
        multipart/form-data:
          schema:
            required:
              - uploadData
            properties:
              uploadData:
                type: string
                description: Data for uploading
                format: binary
    deleteData:
      description: "Удаляемые данные, важны лишь ключевые поля, остальные могут отсутствовать или будут проигнорированы"
      required: true
      content:
        text/csv:
          schema:
            type: array
            items:
              type: array
              items:
                type: string
        application/json:
          schema:
            oneOf:
              - type: array
                items:
                  type: array
                  items:
                    type: string
              - type: object
                properties:
                  primaryKeys:
                    type: array
                    description: Массив первичных ключей
                    items:
                      type: array
                      items:
                        type: string
        avro/binary:
          schema:
            type: array
            items:
              type: array
              items:
                oneOf:
                  - type: boolean
                  - type: string
                  - type: integer #asyncapi
                  - type: number  #asyncapi
                  #- type: int  #Prostor
                  #- type: long #Prostor
                  #- type: float #Prostor
                  #- type: double #Prostor
        multipart/form-data:
          schema:
            required:
              - uploadData
            properties:
              uploadData:
                type: string
                description: Data for uploading
                format: binary
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    requestId:
      type: string
      description: Идентификатор запроса
      example: e5091d55-a0c8-4cc0-ba70-b89d03dde1a6
  parameters:
    datamartName:
      name: datamart_name
      in: path
      description: 'Мнемоника витрины данных'
      required: true
      schema:
        type: string
    tableName:
      name: table_name
      in: path
      description: 'Наименование таблицы'
      required: true
      schema:
        type: string
    groupId:
      name: group_id
      in: header
      description: 'Идентификатор группы'
      required: false
      schema:
        type: string
    groupFileNum:
      name: group_file_num
      in: header
      description: 'Номер файла в группе'
      required: false
      schema:
        type: integer
    groupFileCount:
      name: group_file_count
      in: header
      description: 'Число файлов в группе'
      required: false
      schema:
        type: integer
    requestId:
      name: request_id
      in: path
      description: Идентификатор запроса
      required: true
      schema:
        $ref: '#/components/schemas/requestId'
    forSystemTime:
      name: for_system_time
      in: header
      description: Метка времени для удаления истории операций
      required: false
      schema:
        type: string

  responses:
    badRequest:
      description: Bad request
      content:
        text/plain:
          schema:
            type: string
            description: Сообщение об ошибке
            example: Отсутствует целевая таблица passenger в модели данных univer
    internalServerError:
      description: Internal server error
      content:
        text/plain:
          schema:
            type: string
            description: Сообщение об ошибке
            example: Internal server error

    unauthorized:
      description: Unauthorized
      content:
        text/plain:
          schema:
            type: string
            description: Сообщение об ошибке
            example: Unauthorized
  examples: {}
security:
  - bearerAuth: []
tags:
  - name: data
    description: Загрузка и удаление данных из Витрины, получение статуса запроса
  - name: conditions
    description: Управление правилами проверок для таблицы
  - name: report
    description: Получение отчетов
  - name: delta
    description: Управление дельтами