OpenApi

View spec in html.

openapi: 3.0.0
info:
  version: 'v.0.1.19'
  title: 'Luna-Accounts'
  description: 'VisionLabs Luna Accounts API'

servers:
- description: SwaggerHub API Auto Mocking
  url: https://virtserver.swaggerhub.com/visionlabs/Luna3API/v.0.1.19


components:
  headers:
    application_json:
      schema:
        type: string
        enum:
        - application/json
      required: true
      description: content type is application/json

    luna_request_id:
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: request id. Helps to uniquely identify messages that correspond to particular requests, in system logs.
      required: true

    docs_content_type:
      schema:
        type: string
        enum:
          - application/x-yaml
          - text/html
      required: true
      description: Type of receiving data

    text_html:
      schema:
        type: string
        enum:
          - text/html
      required: true
      description: Content type is text/html

    config_accept_content_type:
      schema:
        type: string
        enum:
          - application/json
          - text/plain
      required: false
      description: The content type of the response body.
  parameters:
    page:
      in: query
      name: page
      schema:
        type: integer
        minimum: 1
        default: 1
      description: a page number.

    luna_request_id:
      in: header
      schema:
        type: string
        format: timestamp,uuid
        example: 1536751345,8b8b5937-2e9c-4e8b-a7a7-5caf86621b5a
        pattern: ^[0-9]{10},[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$
      description: |
        external request id. Helps to uniquely identify messages that correspond to particular requests, in system logs.
        If it was not set, system will set it in default format ("timestamp,UUID"). It will be returned with response.
      name: Luna-Request-Id

    page_size:
      in: query
      name: page_size
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 10
      description: the number of items on page.

    account_id:
      in: query
      name: account_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: account id
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    account_id_required:
      in: query
      name: account_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: account id
      required: true
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    include_luna_services:
      in: query
      name: include_luna_services
      schema:
        type: integer
        enum: [0, 1]
        default: 0
      description: whether to perform healthchecks for dependent luna services.

    accept_docs_handler:
      in: header
      name: Accept
      schema:
        $ref: '#/components/schemas/accept_docs_handler'
      required: true
      description: acceptable type of receiving data

    accept_config_handler:
      in: header
      name: Accept
      schema:
        type: string
        enum:
          - application/json
          - text/plain
        description: One of application/json, text/plain
      required: false
      description: acceptable type of receiving data

    account_id_path_required:
      in: path
      name: account_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: account id
      required: true
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    token_id_path_required:
      in: path
      name: token_id
      schema:
        $ref: '#/components/schemas/uuid'
      description: token id
      required: true
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    query_account_id_nonrequired:
      in: query
      name: account_id
      schema:
        $ref: "#/components/schemas/account_id"
      description: account id
      required: false
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    header_account_id_required:
      in: header
      name: Luna-Account-Id
      schema:
        $ref: "#/components/schemas/account_id"
      description: account id
      required: true
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    header_account_id_nonrequired:
      in: header
      name: Luna-Account-Id
      schema:
        $ref: "#/components/schemas/account_id"
      description: account id
      required: false
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    header_account_id_for_new_account:
      in: header
      name: Luna-Account-Id
      schema:
        $ref: "#/components/schemas/account_id"
      description: account id for new account creation
      required: false
      example: '8950722f-3fd4-4223-b48f-03f95f0e8dfb'

    login:
      in: query
      name: login
      schema:
        $ref: "#/components/schemas/login"
      description: account login
      required: false
      example: "user@visionlabs.ru"

    account_type:
      in: query
      name: account_type
      schema:
        $ref: "#/components/schemas/account_type"
      description: account type
      required: false
      example: user
  schemas:
    Error:
      type: object
      properties:
        error_code:
          type: integer
          description: error code.
        desc:
          type: string
          description: short error description.
        detail:
          type: string
          description: error details.
        link:
          type: string
          description: Link to the documentation website with the error description.
      required: [error_code, detail, desc, link]
      example:
        error_code: 1
        detail: internal server error
        desc: internal server error
        link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-1

    uuid:
      type: string
      format: uuid
      pattern: '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
      example: "557d54ec-29ad-4f3c-93b4-c9092ef12515"

    int_version:
      type: integer
      minimum: 0

    version:
      type: object
      properties:
        Version:
          type: object
          properties:
            api:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: an api version of service.
            major:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: a major version of service.
            minor:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: a minor version of service.
            patch:
              allOf:
                - $ref: '#/components/schemas/int_version'
              description: a patch version of service.
          required: [ api, major, minor, patch ]
      required: [ Version ]

      example:
        Version:
          api: 1
          major: 0
          minor: 0
          patch: 0

    accept_docs_handler:
      type: string
      enum: [application/x-yaml, text/html]

    health_ok:
      description: successful healthcheck execution info
      type: object
      properties:
        execution_time:
          type: number
          example: 0.123
          description: request execution time in seconds
      required: [execution_time]

    health_errors:
      type: object
      properties:
        errors:
          description: failed healthcheck execution info
          type: array
          items:
            type: object
            properties:
              component:
                description: component name
                type: string
              error:
                allOf:
                  - description: healthcheck error
                  - $ref: '#/components/schemas/Error'
              status:
                description: component health status
                type: integer
                enum: [0, 1]
            required: [component, error, status]
      required: [errors]
      example:
        errors:
          - component: accounts_db
            error:
              error_code: 10017
              desc: Database error
              detail: Database connection timeout error
              link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-10017
            status: 0

    account_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: account id

    token_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
      description: token id

    account_description:
      type: string
      maxLength: 128
      description: account description
      default: ""
      example: "main admin account"

    token_description:
      type: string
      maxLength: 128
      description: token description
      default: ""
      example: "main account token"

    login:
      type: string
      minLength: 3
      maxLength: 128
      pattern: ^[a-z0-9_'\+\-\.]+@[a-z0-9]+\.[a-z]{2,}$
      description: account username
      example: "mylogin@visionlabs.ru"

    password:
      type: string
      minLength: 3
      maxLength: 128
      description: account password

    account_type:
      type: string
      enum: ['admin', 'advanced_user', 'user']
      description: account type

    account_reply:
      type: object
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
        description:
          $ref: '#/components/schemas/account_description'
        login:
          $ref: '#/components/schemas/login'
        account_type:
          $ref: '#/components/schemas/account_type'
      required: [account_id, login, password, account_type]

    account_base:
      type: object
      properties:
        login:
          $ref: '#/components/schemas/login'
        password:
          $ref: '#/components/schemas/password'
        account_type:
          $ref: '#/components/schemas/account_type'
        description:
          $ref: '#/components/schemas/account_description'

    account_for_patch:
      allOf:
        - $ref: '#/components/schemas/account_base'
        - minProperties: 1

    account_to_create:
      allOf:
        - $ref: '#/components/schemas/account_base'
      required: [login, password, account_type]

    account_to_receive:
      type: object
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
        login:
          $ref: '#/components/schemas/login'
        account_type:
          $ref: '#/components/schemas/account_type'
        description:
          $ref: '#/components/schemas/account_description'
      required: [account_id, login, account_type, description]

    accounts_to_receive:
      type: object
      properties:
        accounts:
          type: array
          items:
            $ref: '#/components/schemas/account_to_receive'
        total_count:
          type: integer
          description: total accounts count in the system
          minimum: 0
          example: 50
      required: [accounts, total_count]

    account_creation_response:
      type: object
      properties:
        account_id:
          allOf:
            - $ref: '#/components/schemas/account_id'
          description: ID of the created account.
        url:
          type: string
          format: uri-reference
          description: relative URL of the created account.
      required: [account_id, url]
      example:
        account_id: 557d54ec-29ad-4f3c-93b4-c9092ef12515
        url: /1/accounts/557d54ec-29ad-4f3c-93b4-c9092ef12515

    time:
      type: string
      nullable: true
      format: date-time
      example: "2018-08-11T09:11:41.674Z"
      description: time in format RFC 3339

    permissions_template:
      type: array
      items:
        type: string
      minItems: 0

    face_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for face objects
        - type: array
          items:
            enum: [creation, view, modification, deletion, matching]
          default: []

    list_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for list objects
        - type: array
          items:
            enum: [creation, view, modification, deletion]
          default: []

    event_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for event objects
        - type: array
          items:
            enum: [creation, view, matching]
          default: []

    attribute_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for attribute objects
        - type: array
          items:
            enum: [creation, view, modification, deletion, matching]
          default: []

    handler_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for handler objects
        - type: array
          items:
            enum: [creation, view, modification, deletion]
          default: []

    verifier_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for verifier objects
        - type: array
          items:
            enum: [creation, view, modification, deletion]
          default: []

    task_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for task objects
        - type: array
          items:
            enum: [creation, view, modification, deletion]
          default: []

    sample_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - type: array
          items:
            enum: [creation, view, deletion]
          default: []

    face_sample_permissions:
      allOf:
        - $ref: "#/components/schemas/sample_permissions"
        - description: permissions for face sample objects

    body_sample_permissions:
      allOf:
        - $ref: "#/components/schemas/sample_permissions"
        - description: permissions for body sample objects

    token_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for token objects
        - type: array
          items:
            enum: [creation, view, modification, deletion]
          default: [view]

    images_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for image objects
        - type: array
          items:
            enum: [creation, view, deletion]
          default: []

    objects_permissions:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permissions for objects
        - type: array
          items:
            enum: [creation, view, deletion]
          default: []

    resources:
      allOf:
        - $ref: "#/components/schemas/permissions_template"
        - description: permission for using one or several listed resources
        - type: array
          items:
            enum: [iso, sdk, liveness]
          default: []

    handler_ids:
      type: array
      items:
        $ref: "#/components/schemas/uuid"
      nullable: true
      minItems: 1
      maxItems: 100

    emit_events:
      type: object
      description: |
        Handler IDs list for events generation request:
    
        - if `allowed` is `0`, all handlers will be denied for use

        - if *handler_id* is present in `black_list`, only its use will be prohibited

        - if *handler_id* is present in `white_list`, only its use will be allowed
      properties:
        allowed:
          type: integer
          enum: [0, 1]
          description: whether events generation requests are allowed
          default: 1
        white_list:
          allOf:
          - $ref: "#/components/schemas/handler_ids"
          - description: IDs of handlers allowed to use
        black_list:
          allOf:
          - $ref: "#/components/schemas/handler_ids"
          - description: IDs of handlers denied for use
      default:
        allowed: 1
        white_list: null
        black_list: null

    permissions:
      type: object
      description: token permissions
      properties:
        face:
          $ref: "#/components/schemas/face_permissions"
        list:
          $ref: "#/components/schemas/list_permissions"
        event:
          $ref: "#/components/schemas/event_permissions"
        attribute:
          $ref: "#/components/schemas/attribute_permissions"
        handler:
          $ref: "#/components/schemas/handler_permissions"
        verifier:
          $ref: "#/components/schemas/verifier_permissions"
        task:
          $ref: "#/components/schemas/task_permissions"
        face_sample:
          $ref: "#/components/schemas/face_sample_permissions"
        body_sample:
          $ref: "#/components/schemas/body_sample_permissions"
        token:
          $ref: "#/components/schemas/token_permissions"
        image:
          $ref: "#/components/schemas/images_permissions"
        object:
          $ref: "#/components/schemas/objects_permissions"
        resources:
          $ref: "#/components/schemas/resources"
        emit_events:
          $ref: "#/components/schemas/emit_events"

    visibility_area:
      type: string
      enum: [account, all]
      default: all
      description: |
        specifies data visible for the token. 

        `account` - only data related to token's account can be received using GET requests.

        `all` - data of all existing accounts can be received using GET requests. This option does not applicable for user account.

    token:
      type: object
      description: token
      properties:
        description:
          $ref: "#/components/schemas/token_description"
        expiration_time:
          allOf:
          - $ref: "#/components/schemas/time"
          description: expiration time if format RFC 3339. `null` for eternal token
        permissions:
          $ref: "#/components/schemas/permissions"
        visibility_area:
          $ref: "#/components/schemas/visibility_area"
      required: [permissions, expiration_time]

    jwt_token:
      type: string
      example: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbklkIjoiN2Q0MjYwNmEtZmM3NS00NDU4LWE3OGUtOWYzNGM2MjIyZWQyIiwiZXhwaXJhdGlvblRpbWUiOm51bGwsImFjY291bnRJZCI6IjdkYjUzNThiLWZjMzMtNDIwZC1hYTgzLTk5YTRkOWY0MGM0MSJ9.kDL5oLTJaxKyYbwmKV1lejxrzsFoFzx5VOzvTR-i90k
      description: JWT token. It containts `token_id`, `expiration_time`, `account_id` and `visibility_area`

    token_to_create:
      allOf:
        - $ref: "#/components/schemas/token"

    token_to_receive:
      allOf:
        - $ref: "#/components/schemas/token"
        - properties:
            token:
              $ref: '#/components/schemas/jwt_token'
            token_id:
              $ref: "#/components/schemas/token_id"
            permissions:
              properties:
                emit_events:
                  required: [allowed, black_list, white_list]
              required: [face, list, event, attribute, handler, verifier, task, face_sample, body_sample, image, object, token, resources, emit_events]
            account_id:
              $ref: "#/components/schemas/account_id"
      required: [description, expiration_time, permissions, token, token_id, account_id, visibility_area]

    tokens_to_receive:
      type: object
      description: tokens
      properties:
        tokens:
          type: array
          items:
            $ref: "#/components/schemas/token_to_receive"
      required: [tokens]

    token_creation_response:
      type: object
      properties:
        token:
          allOf:
            - $ref: '#/components/schemas/jwt_token'
          description: Created JWT token. It containts `token_id`, `expiration_time`, `account_id` and `visibility_area`
        token_id:
          allOf:
            - $ref: '#/components/schemas/token_id'
          description: ID of the created token.
        url:
          type: string
          format: uri-reference
          description: relative URL of the created token.
      required: [ token, token_id, url ]
      example:
        token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbklkIjoiN2Q0MjYwNmEtZmM3NS00NDU4LWE3OGUtOWYzNGM2MjIyZWQyIiwiZXhwaXJhdGlvblRpbWUiOm51bGwsImFjY291bnRJZCI6IjdkYjUzNThiLWZjMzMtNDIwZC1hYTgzLTk5YTRkOWY0MGM0MSJ9.kDL5oLTJaxKyYbwmKV1lejxrzsFoFzx5VOzvTR-i90k
        token_id: 557d54ec-29ad-4f3c-93b4-c9092ef12515
        url: /1/tokens/557d54ec-29ad-4f3c-93b4-c9092ef12515

    verifier_login_password:
      type: object
      properties:
        login:
          $ref: '#/components/schemas/login'
        password:
          $ref: '#/components/schemas/password'
      required: [login, password]

    verifier_jwt_token:
      type: object
      properties:
        token:
          $ref: '#/components/schemas/jwt_token'
      required: [token]

    verifier_account_id:
      type: object
      properties:
        account_id:
          $ref: '#/components/schemas/account_id'
      required: [account_id]

    verifier_post_data:
      oneOf:
        - $ref: '#/components/schemas/verifier_login_password'
        - $ref: '#/components/schemas/verifier_jwt_token'
        - $ref: '#/components/schemas/verifier_account_id'

    verification_response:
      type: object
      description: verification response
      properties:
        permissions:
          allOf:
            - $ref: "#/components/schemas/permissions"
            - required: [ face, event, attribute, handler, task, face_sample, body_sample, token, resources ]
        account_type:
          $ref: '#/components/schemas/account_type'
        account_id:
          $ref: '#/components/schemas/account_id'
      required: [account_type]

    accounts_count_response:
      type: object
      description: accounts count response
      properties:
        count:
          type: integer
          description: accounts count
          minimum: 0
          example: 50
      required: [count]
  responses:
    internal_server_error:
      description: internal server error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'

    server_timeout_error:
      description: server timeout error.
      headers:
        Content-Type:
          $ref: '#/components/headers/application_json'
        Luna-Request-Id:
          $ref: '#/components/headers/luna_request_id'
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/Error'
            example:
              error_code: 9
              detail: Request timeout
              desc: Request timeout on http://127.0.0.1:5170/{...}, method {...}
              link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-9
paths:

  /version:
    get:
      tags:
      - version

      summary: get version
      description: get version of service
      operationId: getVersion

      parameters:
      - $ref: '#/components/parameters/luna_request_id'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/version'
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/accounts:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
      - accounts

      summary: create account
      description: create a new account
      operationId: createAccount
      parameters:
      - $ref: '#/components/parameters/header_account_id_for_new_account'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/account_to_create'

      responses:
        '201':
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /3/accounts/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the account
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/account_creation_response'
        '400':
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                extra_fields:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''extra fields not permitted'''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: unexpected value'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"
        '409':
          description: Integrity Error
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                login_already_exists:
                  value:
                    error_code: 41001
                    desc: Integrity Error
                    detail: Account with login 'mylogin' already exists
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41001
                account_id_already_exists:
                  value:
                    error_code: 41002
                    desc: Integrity Error
                    detail: Account with account_id 'f8996094-9f1c-449a-b9d5-7e7279d345e9' already exists
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41002
        '500':
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - accounts

      summary: get accounts
      description: get accounts
      operationId: getAccounts
      parameters:
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'
      - $ref: '#/components/parameters/login'
      - $ref: '#/components/parameters/account_type'

      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accounts_to_receive'
        '400':
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'page'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/accounts/{account_id}:
    parameters:
      - $ref: '#/components/parameters/account_id_path_required'
      - $ref: '#/components/parameters/luna_request_id'

    get:
      tags:
      - accounts

      summary: get account
      description: get account by id
      operationId: getAccount

      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/account_to_receive'
        '404':
          description: account not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Account with id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-28001
        '500':
          $ref: '#/components/responses/internal_server_error'

    patch:
      tags:
      - accounts

      summary: patch account
      description: patch account by id. At least one field must be specified
      operationId: patchAccount

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/account_for_patch'

      responses:
        '204':
          description: Update success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        '400':
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                extra_fields:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: ''extra_field'',  message: ''extra fields not permitted'''
                no_fields:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''at least 1 field must be specified'''
        '403':
          description: Permission denied
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 41004
                    desc: Forbidden
                    detail: Account with account_id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' has admin type and its type can't be changed
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41004
        '404':
          description: account not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Account with id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-28001
        '409':
          description: Integrity Error
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                login_already_exists:
                  value:
                    error_code: 41001
                    desc: Integrity Error
                    detail: Account with login 'mylogin' already exists
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41001
        '500':
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
      - accounts

      summary: delete account
      description: delete account by id
      operationId: deleteAccount

      responses:
        '204':
          description: Delete success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        '404':
          description: account not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                account_not_found:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Account with id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-28001
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/accounts/count:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    get:
      tags:
      - accounts

      summary: get accounts count
      description: get total accounts count
      operationId: getAccountsCount

      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accounts_count_response'
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/tokens:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
      - tokens

      summary: create token
      description: create a new token
      operationId: createToken
      parameters:
        - $ref: '#/components/parameters/header_account_id_required'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/token_to_create'

      responses:
        '201':
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /3/tokens/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the token
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/token_creation_response'
        '400':
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                extra_fields:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''extra fields not permitted'''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: unexpected value'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                incorrect_permissions:
                  value:
                    error_code: 41009
                    desc: Bad/incomplete input data
                    detail: Specified permissions ('visibility_area') are unacceptable valid for 'user' account type
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41009
                account_id_not_found:
                  value:
                    error_code: 11066
                    desc: Bad/incomplete input data
                    detail: Luna-Account-Id header not found
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11066"
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"
        '500':
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - tokens

      summary: get tokens
      description: get tokens
      operationId: getTokens
      parameters:
      - $ref: '#/components/parameters/page'
      - $ref: '#/components/parameters/page_size'
      - $ref: '#/components/parameters/query_account_id_nonrequired'

      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/tokens_to_receive'
        '400':
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/tokens/{token_id}:
    parameters:
      - $ref: '#/components/parameters/token_id_path_required'
      - $ref: '#/components/parameters/luna_request_id'

    put:
      tags:
      - tokens

      summary: replace token
      description: Update token. You cannot update a part of the token, so you should specify all the fields for your token.
      operationId: putToken
      parameters:
        - $ref: '#/components/parameters/header_account_id_nonrequired'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/token_to_create'

      responses:
        '201':
          description: Create success.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                type: string
                format: url
                example: /3/tokens/b5d6fd45-fcca-453d-ac05-3e594054b813
              description: location of the token
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/token_creation_response'
        '400':
          description: Bad request.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                extra_fields:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: ''extra fields not permitted'''
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                bad_json:
                  value:
                    error_code: 12022
                    desc: Bad/incomplete input data
                    detail: 'Failed to validate input json. Path: '''',  message: unexpected value'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12022
                incorrect_permissions:
                  value:
                    error_code: 41009
                    desc: Bad/incomplete input data
                    detail: Specified permissions ('visibility_area') are unacceptable valid for 'user' account type
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41009
                bad_account_id:
                  value:
                    error_code: 11037
                    desc: Bad/incomplete input data
                    detail: "Luna-Account-Id header is not UUID, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
                    link: "https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11037"

        '404':
          description: token not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                not_found:
                  value:
                    error_code: 41003
                    desc: Object not found
                    detail: Token with id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41003
        '500':
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
      - tokens

      summary: get token
      description: get token by id
      operationId: getToken
      parameters:
        - $ref: '#/components/parameters/query_account_id_nonrequired'

      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/token_to_receive'
        '400':
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        '404':
          description: token not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 41003
                    desc: Object not found
                    detail: Token with id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41003
        '500':
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
      - tokens

      summary: delete token
      description: delete token by id
      operationId: deleteToken
      parameters:
        - $ref: '#/components/parameters/query_account_id_nonrequired'

      responses:
        '204':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        '400':
          description: bad request.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                bad_query_param:
                  value:
                    error_code: 12012
                    desc: Bad/incomplete input data
                    detail: Bad query parameters 'account_id'
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012
        '404':
          description: token not found.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_json'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                not_found:
                  value:
                    error_code: 41003
                    desc: Object not found
                    detail: Token with id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41003
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/verifier:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'

    post:
      tags:
      - verifier

      summary: verify credentials
      description: |
        Verify account or login with password or token
        
        In the case of success `account id` verification, `account_type` will be returned

        In the case of success `login`/`password` verification, `account_id` and `account_type` will be returned

        In the case of success `token` verification, `account_type` and token `permissions` will be returned

        In the case of failure verification, error will be returned

      operationId: verifyCredentials

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/verifier_post_data'

      responses:
        '200':
          description: Verification success
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/verification_response'
        '400':
          description: Bad input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                request_does_not_contain_json:
                  value:
                    error_code: 12002
                    desc: Bad/incomplete input data
                    detail: Request does not contain json
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12002
        '401':
          description: Verification failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                account_not_found:
                  value:
                    error_code: 28001
                    desc: Object not found
                    detail: Account with id '8950722f-3fd4-4223-b48f-03f95f0e8dfb' not found
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-28001
                token_not_found:
                  value:
                    error_code: 41005
                    desc: Object not found
                    detail: JWT token doesn't exist
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41005
                login_password_incorrect:
                  value:
                    error_code: 41006
                    desc: Account credentials wrong
                    detail: Login and password doesn't match any user
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41006
                expired:
                  value:
                    error_code: 41007
                    desc: Account credentials wrong
                    detail: Token has been expired
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-41007
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/docs/spec:
    get:
      tags:
        - documents
      summary: get openapi documentation
      description: |
        Get service OpenApi documentation. If *Accept* request header is of type `application/x-yaml`,
        returns documentation in `yaml` format or returns `html` documentation, if *Accept-Type* is `text/html`
      operationId: getSpec

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_docs_handler'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/docs_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/x-yaml:
              schema:
                type: string
                description: yaml format documentation
            text/html:
              schema:
                type: string
                description: html format documentation
        '415':
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: 'Bad/incomplete input data'
                    desc: "Unsupported media type"
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/docs/dev:
    get:
      tags:
        - documents
      summary: get development manual
      description: |
        Get sphinx documentation - *Development Manual*. After the request you will be redirected to the page `/docs/dev/index.html`
      operationId: getDevManual

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/text_html'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            text/html:
              schema:
                type: string
                description: html format documentation
        '500':
          $ref: '#/components/responses/internal_server_error'
  /1/config:
    get:
      tags:
        - config
      summary: get service configuration
      description: Get service configuration. Passwords and tokens will be hidden in the response.
      operationId: getConfig

      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/accept_config_handler'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/config_accept_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                type: object
                description: json format configuration
              example:
                INFLUX_MONITORING:
                  SEND_DATA_FOR_MONITORING: 0
                  VERSION: 2
                  ORGANIZATION: ORGANIZATION_NAME
                  TOKEN: '********'
                  BUCKET: luna_monitoring
                  HOST: 127.0.0.1
                  PORT: 8086
                  USE_SSL: 0
                  FLUSHING_PERIOD: 1.0
            text/plain:
              schema:
                type: string
                description: text format configuration
              example: |
                [INFLUX_MONITORING]
                SEND_DATA_FOR_MONITORING = 0
                VERSION = 2
                ORGANIZATION = ORGANIZATION_NAME
                TOKEN = ********
                BUCKET = luna_monitoring
                HOST = 127.0.0.1
                PORT = 8086
                USE_SSL = 0
                FLUSHING_PERIOD = 1.0
        '415':
          description: Unsupported Media Type
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                unsupported_media_type:
                  value:
                    error_code: 12024
                    detail: 'Bad/incomplete input data'
                    desc: "Unsupported media type"
                    link: https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12024
        '500':
          $ref: '#/components/responses/internal_server_error'
  /healthcheck:
    get:
      tags:
        - health
      summary: get health
      description: get health of service
      operationId: healthcheck
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/include_luna_services'
      responses:
        '200':
          description: OK
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_ok'
        '500':
          $ref: '#/components/responses/internal_server_error'
        '502':
          description: Unhealthy
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/health_errors'
        '504':
          $ref: '#/components/responses/server_timeout_error'