openapi: 3.0.2
info:
  title: Jazz sync Tool API
  description: API для утилиты синхронизации пользователей Jazz.
  version: '1.0'
servers:
- url: https://example.com
tags:
- name: Запрос статуса обработки итерации синхронизации
- name: Запуск итерации синхронизации
- name: Загрузка пользователей
- name: Завершение загрузки пользователей и начало синхронизации
paths:
  /{id}/status:
    get:
      tags:
        - Запрос статуса обработки итерации синхронизации
      summary: Статус синхронизации
      description: Возвращает объект с данными синхронизации в соответствии с указанным идентификатором.
      operationId: getResourceById
      parameters:
        - name: id
          description: Идентификатор, который был получен при запуске итерации.
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Статус итерации синхронизации успешно получен.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Status'
        '400':
          description: Bad Request.
        '401':
          description: Unauthorized.
        '404':
          description: Resource not found.
      security:
        - Authorization: []
  /sync/init:
    post:
      tags:
        - Запуск итерации синхронизации
      summary: Новая синхноризация
      description: Инициализирует новую итерацию синхронизации.
      operationId: createResource
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitialSyncRequest'
        required: true
      responses:
        '200':
          description: Успешное создание новой итерации.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitialSyncResponse'
        '401':
          description: Unauthorized.
        '500':
          description: Internal Server Error.
      security:
        - Authorization: []
  /sync/upload:
    post:
      tags:
        - Загрузка пользователей
      summary: Передать пользователей
      description: Передает список пользователей для синхронизации.
      operationId: createAnotherResource
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UploadUsersRequest'
        required: true
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadUsersResponse'
        '400':
          description: Bad Request.
        '409':
          description: Conflict.
      security:
        - Authorization: []
  /sync/finish:
    post:
      summary: Завершить синхронизацию
      tags:
        - Завершение загрузки пользователей и начало синхронизации
      operationId: finishSync
      description: Завершает загрузку пользователей в соответствии с переданным идентификатором и начинает синхронизацию.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: string
                  description: Идентификатор операции для завершения.
              required:
                - id
        required: true
      responses:
        '200':
          description: OK.
        '400':
          description: Bad Request.
        '401':
          description: Unauthorized.
        '409':
          description: Conflict.
        '500':
          description: Internal Server Error.
components:
  securitySchemes:
    Authorization:
      type: apiKey
      description: API key to authorize requests.
      name: Authorization
      in: header
  schemas:
    Status:
      type: object
      properties:
        done:
          type: boolean
        stat:
            type: object
            properties:
              updateCount:
                description: Количество обновленных пользователей.
                type: integer
              createCount:
                description: Количество созданных пользователей.
                type: integer
              deleteCount:
                description: Количество удаленных пользователей.
                type: integer
              failed:
                type: object
                properties:
                  update:
                    type: array
                    items:
                      type: object
                      properties:
                        email:
                          type: string
                          format: email
                        error:
                          type: string
                  delete:
                    type: array
                    items:
                      type: object
                      properties:
                        email:
                          type: string
                          format: email
                        error:
                          type: string
                  create:
                    type: array
                    items:
                      type: object
                      properties:
                        email:
                          type: string
                          format: email
                        error:
                          type: string 
    InitialSyncRequest:
      type: object
      properties:
        full:
          description: |
            Тип синка: false, если diff, или true, если full.
      required:
        - full
    InitialSyncResponse:
      type: object
      properties:
        id:
          type: string
          description: Идентификатор текущей итерации синка.
          example: 20240910150538_af50d8b7-6f60-4a59-9def-cd678e15ab68_full_sync
      required:
        - id
    UploadUsersRequest:
      type: object
      properties:
        id:
          description: Идентификатор операции.
          type: string
        users:
          description: Список пользователей.
          type: array
          items:
            type: object
            properties:
              email:
                description: Адрес электронной почты пользователя.
                type: string
                format: email
              firstName:
                description: Имя пользователя.
                type: string
              lastName:
                description: Фамилия пользователя.
                type: string
              uuid:
                description: Уникальный идентификатор пользователя.
                type: string
                format: uuid
              regSource:
                description: Уникальный идентификатор каталога, из которого синхронизируются пользователи.
                type: string
              customAttributes:
                description: Дополнительные атрибуты пользователя из Active Directory.
                type: object
                additionalProperties: true
              platformAttributes:
                description: Служебные атрибуты пользователя из Active Directory.
                type: object
                additionalProperties: true
            required:
              - email
              - firstName
              - uuid
      required:
        - id
        - users
    UploadUsersResponse: {}