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

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

Метод

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
x-stoplight:
  id: yhkpcls7yqrkm
info:
  title: Rest-uploader
  description: This is a rest-uploader service for datamart filling
  contact:
    email: okononov@it-one.ru
  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: v1-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: Invalid idetifier
          content: {}
      security:
        - bearerAuth: []
      tags:
        - rest-uploader
      description: |-
        Загрузка данных из внешних источников
        curl -vvv -X POST -F upload=@/home/centos/file1.csv   http://localhost:8081/v1/datamarts/EDUEJD_SANDBOX_SGK_TEST_REST_UPLOADER/tables/TEST_NULL_TABLE2/upload
    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-v1-request-request_id-dtatus
      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
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Invalid idetifier
          content: {}          
      security:
        - bearerAuth: []
      tags:
        - rest-uploader
    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-v1-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: Invalid idetifier
          content: {}          
      security:
        - bearerAuth: []
      tags:
        - rest-uploader
  '/v2/group/{groupId}/report':
    get:
      summary: Return report group
      description: Возвращает отчет по комплектности группы загружаемых файлов
      operationId: get-v1-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: {}
        '500':
          description: Invalid idetifier
          content: {}          
      security:
        - bearerAuth: []
      tags:
        - rest-uploader
        
  '/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-v1-datamart_name-tables-table_name-delete
      responses:
        '200':
          description: OK
        '400':
          description: Bad Request
        '401':
          description: Invalid token
        '403':
          description: Invalid identifier
        '500':
          description: Invalid idetifier
          content: {}          
      tags:
        - rest-uploader
      description: |-
        Удаление данных по массиву первичных ключей

        curl -vvv -X POST -d "
        {\"primaryKeys\": [[\"1\"]]}
        http://localhost:8081/v1/datamarts/EDUEJD_SANDBOX_SGK_TEST_REST_UPLOADER/tables/TEST_NULL_TABLE2/delete

        curl -vvv -X POST -F del={путь к файлу}.csv http://хост:порт/v1/datamarts/{datamart_name}/tables/{table_name}/delete
      security:
        - bearerAuth: []
      requestBody:
        $ref: '#/components/requestBodies/deleteData'
  '/v2/conditions/{datamart}/{table}':
    post:
      summary: Create verification conditions
      description: Формирование правил проверки для датамарта/таблицы
      operationId: post-v1-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:
          application/x-yaml: {}
      responses:
        '200':
          description: successful operation
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Invalid idetifier
          content: {} 
      security:
        - bearerAuth: []
      tags:
        - rest-uploader        
    put:
      summary: Update verification conditions
      description: Обновление правил проверки для датамарта/таблицы
      operationId: put-v1-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:
          application/x-yaml: {}
      responses:
        '200':
          description: successful operation
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Invalid idetifier
          content: {} 
      security:
        - bearerAuth: []
      tags:
        - rest-uploader        
    get:
      summary: Return verification conditions
      description: Возвращение правил проверки для датамарта/таблицы
      operationId: get-v1-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:
            application/x-yaml: {}
        '401':
          description: Invalid token
          content: {}
        '403':
          description: Invalid idetifier
          content: {}
        '500':
          description: Invalid idetifier
          content: {}          
      security:
        - bearerAuth: []
      tags:
        - rest-uploader        
    delete:
      summary: Delete verification conditions
      description: Удаление правил проверки для датамарта/таблицы
      operationId: delete-v1-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: Invalid idetifier
          content: {}          
      security:
        - bearerAuth: []
      tags:
        - rest-uploader                
components:
  requestBodies:
    uploadData:
      description: "загружаемые данные"
      required: true
      content:
#        application/json:
#          schema:
#            type: array
#            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
    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: rest-uploader