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

Данная спецификация описывает возможность загрузки данных в витрину, получение статуса запроса, удаление данных из витрины.

Метод

URL

Назначение

POST

v2/datamarts/{datamart_name}/tables/{table_name}/upload

Загрузка данных в витрину с учетом реализации ФЛК

GET

v2/requests/{request_id}/status

Получение статуса запроса

DELETE

v2/datamarts/{datamart_name}/tables/{table_name}/delete

Удаление данных из витрины

POST

v2/conditions/{datamart}/{table}

запрос для загрузки списка правил для таблицы, для сохранения в Zookeeper

PUT

v2/conditions/{datamart}/{table}

запрос для добавления правил для таблицы, для сохранения в Zookeeper

GET

v2/conditions/{datamart}/{table}

запрос для получения списка проверок для таблицы, хранящийся в Zookeer

DELETE

v2/conditions/{datamart}/{table}

запрос для удаления всего списка проверок по таблице

GET

v2/requests/{request_id}/report

Возвращает отчет по форматно логическом контроле загружаемых данных в формате .csv

GET

v2/group/{group_id}/report

Запрос возвращает отчет по комплектности группы загружаемых файлов в формате .csv

openapi: 3.0.1
info:
  title: Rest-uploader
  description: This is a rest-uploader service for datamart filling
  version: 2.0.0
servers:
  - url: 'http://localhost:8081'
paths:
  '/v2/datamarts/{datamart_name}/tables/{table_name}/upload':
    post:
      summary: Add a new data to the datamart
      operationId: post-v2-datamarts-datamart_name-tables-table_name-upload
      parameters:
        - name: datamart_name
          in: path
          required: true
          schema:
            type: string
        - name: table_name
          in: path
          required: true
          schema:
            type: string
        - name: groupId
          in: header
          description: 'идентификатор группы'
          required: false
          schema:
            type: string
        - name: groupFileNum
          in: header
          description: 'номер файла в группе'
          required: false
          schema:
            type: integer
        - name: groupFileCount
          in: header
          description: 'число файлов в группе'
          required: false
          schema:
            type: integer
      requestBody:
        $ref: '#/components/requestBodies/uploadData'
      responses:
        '200':
          description: successful operation
          headers:
            requestId:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
        '400':
          description: Bad request
          headers:
            requestId:
              schema:
                type: string
          content:
            text/csv:
              schema:
                type: array
                items:
                  type: array
                  items:
                    type: string
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - data
      description: Загрузка данных из внешних источников. К телу прикладывается файл csv
    parameters:
      - schema:
          type: string
        name: datamart_name
        in: path
        required: true
      - schema:
          type: string
        name: table_name
        in: path
        required: true
  '/v2/requests/{request_id}/status':
    get:
      summary: Return request status
      description: Возвращение статуса запроса
      operationId: get-v2-request-request_id-status
      parameters:
        - name: request_id
          in: path
          description: Identifier of request
          required: true
          schema:
            type: string
      responses:
        '200':
          description: successful operation. При ошибочном ответе возвращается код и описание ошибки в соответствии с примером
          content:
            plain/text:
              schema:
                type: string
                example: "code: 4, description: Ошибка обработки запроса, errorMessage: Полный текст ошибки..."
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - data
    parameters:
      - schema:
          type: string
        name: request_id
        in: path
        required: true
  '/v2/requests/{request_id}/reportFLK':
    get:
      summary: Return report FLK check
      description: Возвращает отчет по формато логическом контроле загружаемых данных
      operationId: get-v2-request-request_id-reportFLK
      parameters:
        - name: request_id
          in: path
          description: Identifier of request
          required: true
          schema:
            type: string
      responses:
        '200':
          description: successful operation
          content:
            text/csv:
              schema:
                type: array
                items:
                  type: array
                  items:
                    type: string
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - report
  '/v2/group/{groupId}/report':
    get:
      summary: Return report group
      description: Возвращает отчет по комплектности группы загружаемых файлов
      operationId: get-v2-group-groupId-report
      parameters:
        - name: groupId
          in: path
          description: Identifier of group
          required: true
          schema:
            type: string
      responses:
        '200':
          description: successful operation
          content:
            text/csv:
              schema:
                type: array
                items:
                  type: array
                  items:
                    type: string
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '404':
          description: Not Found
          content:
            json:
              schema:
                type: string
                description: Сообщение об ошибке
                example: 'Report not found'
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - report

  '/v2/{datamart_name}/tables/{table_name}/delete':
    parameters:
      - schema:
          type: string
        name: datamart_name
        in: path
        required: true
      - schema:
          type: string
        name: table_name
        in: path
        required: true
      - name: groupId
        in: header
        description: 'идентификатор группы'
        required: false
        schema:
          type: string
      - name: groupFileNum
        in: header
        description: 'номер файла в группе'
        required: false
        schema:
          type: integer
      - name: groupFileCount
        in: header
        description: 'число файлов в группе'
        required: false
        schema:
          type: integer
    post:
      summary: Delete data by primary key array
      operationId: post-v2-datamart_name-tables-table_name-delete
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '401':
          description: Invalid token
        '403':
          description: Invalid identifier
        '500':
          description: Internal server error
          content: {}
      tags:
        - data
      description: Удаление данных по массиву первичных ключей. К телу прикладывается файл csv
      security:
        - bearerAuth: []
      requestBody:
        $ref: '#/components/requestBodies/deleteData'
  '/v2/conditions/{datamart}/{table}':
    post:
      summary: Create verification conditions
      description: Формирование правил проверки для датамарта/таблицы
      operationId: post-v2-conditions
      parameters:
        - name: datamart
          in: path
          description: Name of datamart
          required: true
          schema:
            type: string
        - name: table
          in: path
          description: Name of table
          required: true
          schema:
            type: string
      requestBody:
        content:
          form-data/yaml: {}
          form-data/json: {}
          application/json:
            schema: {}
            example: '
            fields:
              birthday:
              # ограничение на формат даты ГГГГ-ММ-ДД: 4 цифры года, 2 цифры месяца и 2 цифры дня   
              # Уникальность по одному полю
                match: "(\\d{4})\\-(\\d{2})\\-(\\d{2})"
                uniq: true
              # Уникальность по сочетанию полей
                uniq-with: [code,passport]
              code:
                in: ["1","2","3","4","5","6","7","8","9","10"]
                uniq: true'
      responses:
        '200':
          description: successful operation
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - conditions
    put:
      summary: Update verification conditions
      description: Обновление правил проверки для датамарта/таблицы
      operationId: put-v2-conditions
      parameters:
        - name: datamart
          in: path
          description: Name of datamart
          required: true
          schema:
            type: string
        - name: table
          in: path
          description: Name of table
          required: true
          schema:
            type: string
      requestBody:
        content:
          form-data/yaml: {}
          form-data/json: {}
          application/json:
            schema: {}
            example: '
            fields:
              birthday:
              # ограничение на формат даты ГГГГ-ММ-ДД: 4 цифры года, 2 цифры месяца и 2 цифры дня   
              # Уникальность по одному полю
                match: "(\\d{4})\\-(\\d{2})\\-(\\d{2})"
                uniq: true
              # Уникальность по сочетанию полей
                uniq-with: [code,passport]
              code:
                in: ["1","2","3","4","5","6","7","8","9","10"]
                uniq: true'
      responses:
        '200':
          description: successful operation
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - conditions
    get:
      summary: Return verification conditions
      description: Возвращение правил проверки для датамарта/таблицы
      operationId: get-v2-conditions
      parameters:
        - name: datamart
          in: path
          description: Name of datamart
          required: true
          schema:
            type: string
        - name: table
          in: path
          description: Name of table
          required: true
          schema:
            type: string
      responses:
        '200':
          description: successful operation
          content:
            form-data/yaml: {}
            form-data/json: {}
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - conditions
    delete:
      summary: Delete verification conditions
      description: Удаление правил проверки для датамарта/таблицы
      operationId: delete-v2-conditions
      parameters:
        - name: datamart
          in: path
          description: Name of datamart
          required: true
          schema:
            type: string
        - name: table
          in: path
          description: Name of table
          required: true
          schema:
            type: string
      responses:
        '200':
          description: successful operation
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Internal server error
          content: {}
      security:
        - bearerAuth: []
      tags:
        - conditions
components:
  requestBodies:
    uploadData:
      description: 'загружаемые данные'
      required: true
      content:
        text/csv:
          schema:
            type: array
            items:
              type: array
              items:
                type: string
        multipart/form-data:
          schema:
            required:
              - uploadData
            properties:
              uploadData:
                type: string
                description: Data for uploading
                format: binary
    deleteData:
      description: 'Удаляемые данные, важны лишь ключевые поля, остальные могут отсутствовать или будут проигнорированы'
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              primaryKeys:
                type: array
                description: Массив первичных ключей
                items:
                  type: array
                  items:
                    type: string
        text/csv:
          schema:
            type: array
            items:
              type: array
              items:
                type: string
        multipart/form-data:
          schema:
            required:
              - uploadData
            properties:
              uploadData:
                type: string
                description: Data for uploading
                format: binary
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  examples: {}

security:
  - bearerAuth: []

tags:
  - name: data
    description: Загрузка и удаление данных из Витрины, получение статуса запроса
  - name: conditions
    description: Управление правилами проверок для таблицы
  - name: report
    description: Получение отчетов