openapi: 3.0.0
info:
  version: 'v.3.9.0'
  title: 'Luna-image-store'
  termsOfService: "http://api.luna.visionlabs.ru"
  description: |
      # Introduction

      The service is an abstraction for storing pictures and objects (currently supported objects types are plain/text
      and application/json) in some database. Now two types of databases are supported: *aws S3* and a hard disk.
      All images and objects are stored in *buckets*. Thus, to save a picture or an object, create a *bucket* and then
      put a picture or object into it. *Buckets* are disjoint namespaces.

      There are two ways to save the image in the system:

      1. Make the request by the `POST` method to the resource `/1/buckets/{bucket}/images`,
         put an image to the body of request. For the image, *id* will be generated in the *uuid* format,
         on which it will be possible in the future to receive this image.

      2. Make a request using the `PUT` method to the resource `/1/buckets/{bucket}/images/{id}`,
         put an image to the body of request. Further on the transmitted *id*, you can get this image.

      All pictures are converted to jpg format if they were not.

      There are two ways to save an object in the system:

      1. Make a request by the `POST` method to the resource `/1/buckets/{bucket}/objects`,
         put an object to the body of request. For the object, *id* will be generated in the *uuid* format,
         on which it will be possible in the future to receive this object.

      2. Make a request using the `PUT` method on the resource`/1/buckets/{bucket}/objects/{id}`,
         put an object to the body of request. Further on the passed *id* it is possible to receive this object.

      At the moment, the following types of objects are supported: plain/text, application/json, application/zip,
      application/pdf.

      The service provides following options:
        1. create * bucket *;
        2. save the image under your *id* in *uuid* format or under *id* issued by the system in the specified *bucket*;
        3. get the picture by it's ID from the specified *bucket*;
        4. generate small copies of the images for preview mappings during the image saving phase;
        5. delete a single image or several (up to 1000) together with small copies of the specified *bucket*.
        6. save the object under your *id* in *uuid* format or under *id* issued by the system in the specified *bucket*;
        7. get the object by it's id from the specified *bucket*;
        8. delete an individual object or several (up to 1000) from the specified *bucket*.

      Service have *api* version, actual is 1. All *url* above `/version`, must starts with *api* version.

      OpenAPI specification is the only valid document providing up-to-date information about the service API. 

      The specification can be used:

      - By documentation generation tools to visualize the API.
      - By code generation tools.

      All the documents and code generated using this specification can include inaccuracies and should be carefully checked.

      OpenAPI specification can be received using the "/docs/spec" resource. The "Accept" header should be set to "application/x-yaml".

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

    application_octed_stream:
      schema:
        type: string
        enum:
          - application/octet-stream
      required: true
      description: Content type is application/octed-stream.

    image_content_type:
      schema:
        type: string
        enum:
          - image/jpeg
          - image/png
      required: true
      description: Content type is image/jpeg or image/png.

    text_plain:
      schema:
        type: string
        enum:
          - text/plain
      required: true
      description: Content type is text/plain.

    content_type:
      schema:
        $ref: '#/components/schemas/content_type'
      required: true
      description: Type of receiving data.

    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}$
      required: true
      description: Request ID. Helps to uniquely identify messages that correspond to particular requests, in system logs.

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

    config_accept_content_type:
      schema:
        type: string
        enum:
          - application/json
          - text/plain
      required: false
      description: The content type of the response body.

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

    meta_headers:
      schema:
        type: string
        example: <user_defined_value>
      description: User-defined image metadata key-value that specified when the image were stored.

    content_disposition:
      schema:
        type: string
        description: |
          Attachment content-disposition header. Filename is generated based on object id and object mime type 
          and equal to `{object_id}.{extention}`. If mime type are not determined the file extension will 
          be set as `.bin`.
        example: attachment; filename='28b87262-43e2-4afc-ad1b-8308e2798b80.pdf'
      required: true

    object_content_type:
      schema:
        type: string
        description: |
          content type is determined as content type which user sent up into the saving request of  the object.
        example: appliction/pdf
      required: true
  parameters:
    bucket:
      in: query
      name: bucket
      schema:
        $ref: '#/components/schemas/bucket'
      description: Bucket name.
      required: true

    bucket_path:
      in: path
      name: bucket
      schema:
        $ref: '#/components/schemas/bucket'
      description: Bucket name.
      required: true

    content_images:
      in: header
      name: content-Type
      schema:
        type: string
        enum:
          - image/jpeg
          - image/png
          - image/bmp
          - image/tiff
          - image/gif
          - image/x-portable-pixmap
      description: Type of transmitting image.

    content_objects:
      in: header
      name: content-Type
      schema:
        type: string
      required: true
      description: |
        Type of transferring information.
        
        > **WARNING** A value of this header will be used as a `Сontent-Type` header value for requests 
        ["GET object"](#operation/getObject) and will be use for a mime type calculation. 

    image_id_with_thumbnail:
      in: path
      name: image_id_with_thumbnail
      schema:
        $ref: '#/components/schemas/image_id_with_thumbnail'
      required: true
      description: Image ID with thumbnail parameter. Thumbnail, possible only with methods `GET` and `HEAD`. Size of the maximum border in pixels.

    object_id:
      in: path
      name: object_id
      schema:
        $ref: '#/components/schemas/object_id'
      description: Object ID.
      required: true

    image_id:
      in: path
      name: image_id
      schema:
        $ref: '#/components/schemas/image_id'
      description: Image ID.
      required: true

    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

    applicationJsonContent:
      in: header
      name: content-Type
      schema:
        type: string
        enum:
          - application/json
      description: Content type is application/json.

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

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

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

    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.

    with_meta:
      in: query
      name: with_meta
      schema:
        type: integer
        enum: [ 0, 1 ]
        default: 0
      description: Whether to retrieve user-defined image metadata.
      example: 1

    meta_headers:
      in: header
      name: '* (X-Luna-Meta-<user_defined_key>)'
      schema:
        type: string
        example: <user_defined_value>
      description: User-defined image metadata key-value. To store metadata values for multiple keys, the multiple headers should be defined.
  schemas:
    application_json:
      type: string
      description: Content type is application/json.

    application_zip:
      type: string
      format: binary
      description: Content type is application/zip.

    application_pdf:
      type: string
      format: binary
      description: Content type is application/zip.

    accept:
      type: string
      enum:
        - application/json
        - text/plain
        - application/zip
        - application/pdf

    content_type:
      type: string
      enum:
        - application/json
        - text/plain
        - application/zip
        - application/pdf
      description: One of application/octed-stream, application/json, text/plain, application/zip, application/pdf.

    text_plain:
      type: string
      description: Content type is text/plain.

    bucket:
      type: string
      pattern: '^[a-z0-9-_]{1,255}$'
      description: Bucket name.
      example: image_store-bucket

    object_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - description: Object ID.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    image_id_with_thumbnail:
      type: string
      pattern: '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}[_][0-9]+$'
      description: Image ID with thumbnail parameter. Thumbnail, possible only with methods `GET` and `HEAD`. Size of the maximum border in pixels.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e_64"

    image_binary:
      type: string
      format: binary

    int_version:
      type: integer
      minimum: 0

    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

    image_id:
      allOf:
        - $ref: '#/components/schemas/uuid'
        - description: Image ID.
      example: "b668c4a5-2191-476e-a261-3b4f9ce2e25e"

    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: 1

    Buckets:
      type: array
      items:
        $ref: '#/components/schemas/bucket'

    Delete_obj:
      type: object
      properties:
        objects:
          type: array
          items:
            $ref: '#/components/schemas/object_id'

    Location_img:
      type: string
      pattern: '^/1/buckets/[a-z0-9-_]+/images/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$'
      description: Resource for managing image.
      example: /1/buckets/image_store-bucket/images/141d2706-8baf-433b-82eb-8c7fada847da

    Location_obj:
        type: string
        pattern: '^/1/buckets/[a-z0-9-_]+/objects/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$'
        description: Resource for managing object.
        example: /1/buckets/image_store-bucket/objects/141d2706-8baf-433b-82eb-8c7fada847da

    Location:
      type: string
      pattern: '^/1/buckets/[a-z0-9-_]+/images$'
      description: Resource for images saving.
      example: /1/buckets/image_store-bucket/images

    Images:
      type: object
      properties:
        image_id:
          $ref: '#/components/schemas/image_id'
        url:
          type: string
          format: uri-reference
          description: URL to resource.
          example: /1/buckets/{bucket}/images/{image_id}
        url32:
          type: string
          format: uri-reference
          description: URL to preview resource with size 32.
          example: /1/buckets/{bucket}/images/{image_id}_32
        url64:
          type: string
          format: uri-reference
          description: URL to preview resource with size 64.
          example: /1/buckets/{bucket}/images/{image_id}_64
        url96:
          type: string
          format: uri-reference
          description: URL to preview resource with size 96.
          example: /1/buckets/{bucket}/images/{image_id}_96
        url160:
          type: string
          format: uri-reference
          description: URL to preview resource with size 160.
          example: /1/buckets/{bucket}/images/{image_id}_160
      required: [image_id, url]
      example:
        image_id: 141d2706-8baf-433b-82eb-8c7fada847da
        url: /1/buckets/image_store-bucket/images/141d2706-8baf-433b-82eb-8c7fada847da
        url32: /1/buckets/image_store-bucket/images/141d2706-8baf-433b-82eb-8c7fada847da_32
        url64: /1/buckets/image_store-bucket/images/141d2706-8baf-433b-82eb-8c7fada847da_64
        url96: /1/buckets/image_store-bucket/images/141d2706-8baf-433b-82eb-8c7fada847da_96
        url160: /1/buckets/image_store-bucket/images/141d2706-8baf-433b-82eb-8c7fada847da_160

    Objects:
      type: object
      properties:
        object_id:
          $ref: '#/components/schemas/object_id'
        url:
          type: string
          format: uri-reference
          description: Location of a new object.
      required: [object_id, url]
      example:
        object_id: b5d6fd45-fcca-453d-ac05-3e594054b813
        url: /1/buckets/image_store-bucket/objects/b5d6fd45-fcca-453d-ac05-3e594054b813

    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: 11009
        detail: Internal server error
        desc: Internal server error
        link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-11009'

    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: # todo
          - component: S3
            error:
              error_code: 38001
              detail: Failed check connection to s3
              desc: Health check error
              link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-38001'
            status: 0
          - component: Redis
            error:
              error_code: 0
              desc: Success
              detail: Success
              link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-0'
            status: 1

    input_object:
      type: string
      format: binary
      description: some user defined bytes. The service saves the bytes `as is`.
  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'
          examples:
            error_response:
              value:
                error_code: 1
                detail: "Internal server error"
                desc: "Internal server error"
                link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-1'
paths:
  /version:
    get:
      tags:
      - version

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

      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/buckets:
    post:
      tags:
        - buckets
      summary: create a bucket with the provided name
      operationId: createBucket
      description: |
        Creation of *bucket*. *bucket* must have unique name. Name must comply storage's naming rules.
        If storage is hard drive, then *bucket* is a folder, if storage is *s3*, then *bucket* is present
        *bucket* in *s3* and it's name must comply the naming rules for *bucket* in *s3*
        (see https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).
      parameters:
        - $ref: '#/components/parameters/luna_request_id'
        - $ref: '#/components/parameters/applicationJsonContent'
        - $ref: '#/components/parameters/bucket'
      responses:
        201:
          description: Created.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_octed_stream'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                $ref: '#/components/schemas/Location'
              required: true

        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:
                bad_query_parameter:
                  value:
                    error_code: 12014
                    detail: "Bad/incomplete input data"
                    desc: "Required parameters 'bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12014'
        409:
          description: Bucket already exist.
          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_parameter:
                  value:
                    error_code: 13006
                    detail: "Unique constraint error"
                    desc: "Bucket with name 'image_store-bucket' already exist"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13006'
        500:
          $ref: '#/components/responses/internal_server_error'

    get:
      tags:
        - buckets
      summary: get bucket list
      operationId: getBuckets
      description: Receiving list of all existing buckets.
      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/Buckets'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/buckets/{bucket}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/bucket_path'
    delete:
      tags:
        - buckets
      summary: delete bucket
      operationId: deleteBucket
      description: Delete current bucket.
      responses:
        202:
          description: Accepted.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_octed_stream'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/buckets/{bucket}/objects:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/bucket_path'
    post:
      tags:
        - objects
      summary: create objects
      operationId: createObjects
      description: Save object with unique ID.
      parameters:
        - $ref: '#/components/parameters/content_objects'
        - $ref: '#/components/parameters/header_account_id_nonrequired'
      requestBody:
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/input_object'
      responses:
        201:
          description: Created.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                $ref: '#/components/schemas/Location_obj'
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Objects'
        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:
                not_contains_data:
                  value:
                    error_code: 12030
                    detail: "Bad/incomplete body"
                    desc: "Request does not contain data"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12030'
        404:
          description: Bucket 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:
                error_response:
                  value:
                    error_code: 13005
                    detail: "Object not found"
                    desc: "Bucket with name 'test_bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13005'
        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'

    delete:
      tags:
        - objects
      summary: delete objects
      operationId: deleteObjects
      description: Delete list of objects.
      parameters:
        - $ref: '#/components/parameters/account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Delete_obj'
            example:
              objects: ["141d2706-8baf-433b-82eb-8c7fada847da", "831d2706-8baf-433b-82eb-8c7fada847da"]
      responses:
        204:
          description: No content.
          headers:
            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:
                request_does_not_contain_json:
                  value:
                    error_code: 12002
                    detail: 'Bad/incomplete input data'
                    desc: "Request does not contain json"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12002'
                field_jsons_not_found_in_json:
                  value:
                    error_code: 12003
                    detail: 'Bad/incomplete input data'
                    desc: "Field 'objects' not found in json"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12003'
        404:
          description: Object either not found or access is prohibited.
          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:
                error_response:
                  value:
                    error_code: 13005
                    detail: "Object not found"
                    desc: "Bucket with name 'test_bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13005'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/buckets/{bucket}/objects/{object_id}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/bucket_path'
      - $ref: '#/components/parameters/object_id'
    put:
      tags:
      - object
      summary: put object
      operationId: putObject
      description: Save object with specified ID.
      parameters:
        - $ref: '#/components/parameters/content_objects'
        - $ref: '#/components/parameters/header_account_id_nonrequired'
      requestBody:
        content:
          '*/*':
            schema:
              $ref: '#/components/schemas/input_object'
      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/Objects'
              example:
                object_id: '28b87262-43e2-4afc-ad1b-8308e2798b80'
                url: '/1/buckets/luna_image_store-test-bucket/objects/28b87262-43e2-4afc-ad1b-8308e2798b80'
        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:
                not_contains_data:
                  value:
                    error_code: 12030
                    detail: 'Bad/incomplete body'
                    desc: 'Request does not contain data'
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12030'
        404:
          description: Bucket 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:
                error_response:
                  value:
                    error_code: 13005
                    detail: "Object not found"
                    desc: "Bucket with name 'test_bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13005'
        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'

    get:
      tags:
        - object
      summary: get object
      operationId: getObject
      description: Receiving objects.
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          description: OK.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              ref: '#/components/headers/object_content_type'
            Content-Disposition:
              $ref: '#/components/headers/content_disposition'
          required: true
          content:
            '*/*' :
              schema:
                type: string
                format: binary
                description: user uploaded bytes
        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:
                bad_content_type:
                  value:
                    error_code: 12017
                    detail: 'Bad/incomplete input data'
                    desc: "Bad content type"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017'
        404:
          description: Object 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:
                error_response:
                  value:
                    error_code: 13007
                    detail: "Object not found"
                    desc: "Object with id 'b668c4a5-2191-476e-a261-3b4f9ce2e25e' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13007'
        500:
          $ref: '#/components/responses/internal_server_error'

    head:
      tags:
        - object
      summary: head object
      operationId: checkObject
      description:  Check object exists.
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        200:
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              ref: '#/components/headers/object_content_type'
            Content-Disposition:
              $ref: '#/components/headers/content_disposition'
          description: No content
        404:
          description: Object not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - object
      summary: delete object
      operationId: deleteObject
      description: Delete object.
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          description: No content.
        404:
          description: Object either not found or access is prohibited.
          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:
                error_response:
                  value:
                    error_code: 13005
                    detail: "Object not found"
                    desc: "Bucket with name 'test_bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13005'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/buckets/{bucket}/images:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/bucket_path'
    post:
      tags:
        - images
      summary: create images
      operationId: createImages
      description: Save images with unique ID.
      parameters:
        - $ref: '#/components/parameters/content_images'
        - $ref: '#/components/parameters/header_account_id_nonrequired'
        - $ref: '#/components/parameters/meta_headers'
      requestBody:
        content:
          image/jpeg:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/png:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/bmp:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/tiff:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/gif:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/x-portable-pixmap:
            schema:
              $ref: '#/components/schemas/image_binary'
      responses:
        201:
          description: Created.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Location:
              schema:
                $ref: '#/components/schemas/Location_img'
              required: true
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Images'
        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:
                bad_query_parameter:
                  value:
                    error_code: 12012
                    detail: 'Bad/incomplete input data'
                    desc: "Bad query parameters 'thumbnails'"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012'
                bad_content_type:
                  value:
                    error_code: 12017
                    detail: "Bad/incomplete input data"
                    desc: "Bad content type"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017'
                failed_convert_to_jpg:
                  value:
                    error_code: 18002
                    detail: 'Bad/incomplete input data'
                    desc: "Failed convert bytes to jpg"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-18002'
        404:
          description: Bucket 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:
                error_response:
                  value:
                    error_code: 13005
                    detail: "Object not found"
                    desc: "Bucket with name 'test_bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13005'
        500:
          $ref: '#/components/responses/internal_server_error'

    delete:
      tags:
        - images
      summary: delete images
      operationId: deleteImages
      description: Delete a bundle of images from *bucket*.
      parameters:
        - $ref: '#/components/parameters/account_id'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/application_json'
            example:
              images: ["141d2706-8baf-433b-82eb-8c7fada847da", "831d2706-8baf-433b-82eb-8c7fada847da"]
      responses:
        204:
          description: No content.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            Content-Type:
              $ref: '#/components/headers/application_octed_stream'
        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:
                request_does_not_contain_json:
                  value:
                    error_code: 12002
                    detail: 'Bad/incomplete input data'
                    desc: "Request does not contain json"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12002'
                field_images_not_found_in_json:
                  value:
                    error_code: 12003
                    detail: 'Bad/incomplete input data'
                    desc: "Field 'images' not found in json."
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12003'
        404:
          description: Bucket 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:
                error_response:
                  value:
                    error_code: 13005
                    detail: "Object not found"
                    desc: "Bucket with name 'test_bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13005'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/buckets/{bucket}/images/{image_id}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/bucket_path'
      - $ref: '#/components/parameters/image_id'
    put:
      tags:
      - image
      summary: put image
      operationId: putImage
      description: Image saving with specified ID.
      parameters:
        - $ref: '#/components/parameters/content_images'
        - $ref: '#/components/parameters/header_account_id_nonrequired'
        - $ref: '#/components/parameters/meta_headers'
      requestBody:
        content:
          image/jpeg:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/png:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/bmp:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/tiff:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/gif:
            schema:
              $ref: '#/components/schemas/image_binary'
          image/x-portable-pixmap:
            schema:
              $ref: '#/components/schemas/image_binary'
      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/Images'
              example:
                url: '/1/buckets/image_store-bucket/images/141d2706-8baf-433b-82eb-8c7fada847da'
        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:
                bad_query_parameter:
                  value:
                    error_code: 12012
                    detail: Bad/incomplete input data
                    desc: "Bad query parameters 'thumbnails'"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012'
                bad_content_type:
                  value:
                    error_code: 12017
                    detail: "Bad/incomplete input data"
                    desc: "Bad content type"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12017'
                failed_convert_to_jpg:
                  value:
                    error_code: 18002
                    detail: 'Bad/incomplete input data'
                    desc: "Failed convert bytes to jpg"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-18002'
                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: Image 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:
                error_response:
                  value:
                    error_code: 13007
                    detail: "Object not found"
                    desc: "Object with id 'b668c4a5-2191-476e-a261-3b4f9ce2e25e' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13007'
        500:
          $ref: '#/components/responses/internal_server_error'
    head:
      tags:
        - image
      summary: head image
      operationId: checkImage
      description: Check image exists.
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/with_meta'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/image_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            '* (X-Luna-Meta-<user_defined_key>)':
              $ref: '#/components/headers/meta_headers'
        404:
          description: Image not found.
          headers:
            Content-Type:
              $ref: '#/components/headers/application_json'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        500:
          $ref: '#/components/responses/internal_server_error'
    delete:
      tags:
        - image
      summary: delete image
      operationId: deleteImage
      description: Delete an image with all preview copies.
      parameters:
        - $ref: '#/components/parameters/account_id'
      responses:
        204:
          description: No content.
          headers:
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
        404:
          description: Image either not found or access is prohibited.
          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:
                image_not_found:
                  value:
                    error_code: 13003
                    detail: "Object not found"
                    desc: "Image with id 'b668c4a5-2191-476e-a261-3b4f9ce2e25e' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13003'
                bucket_not_found:
                  value:
                    error_code: 13005
                    detail: "Object not found"
                    desc: "Bucket with name 'test_bucket' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13005'
        500:
          $ref: '#/components/responses/internal_server_error'
    get:
      tags:
        - image
      summary: get image
      operationId: getImage
      description: Receive an origin image.
      parameters:
        - $ref: '#/components/parameters/account_id'
        - $ref: '#/components/parameters/with_meta'
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/image_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
            '* (X-Luna-Meta-<user_defined_key>)':
              $ref: '#/components/headers/meta_headers'
          content:
            image/jpeg:
              schema:
                $ref: '#/components/schemas/image_binary'
            image/png:
              schema:
                $ref: '#/components/schemas/image_binary'
        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:
                bad_query_param:
                  value:
                    error_code: 12012
                    detail: 'Bad/incomplete input data'
                    desc: "Bad query parameters 'account_id'"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12012'
        404:
          description: Image 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:
                error_response:
                  value:
                    error_code: 13003
                    detail: "Object not found"
                    desc: "Image with id 'b668c4a5-2191-476e-a261-3b4f9ce2e25e' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13003'
        500:
          $ref: '#/components/responses/internal_server_error'
  /1/buckets/{bucket}/images/{image_id_with_thumbnail}:
    parameters:
      - $ref: '#/components/parameters/luna_request_id'
      - $ref: '#/components/parameters/bucket_path'
      - $ref: '#/components/parameters/image_id_with_thumbnail'
    get:
      tags:
        - imageThumbnail
      summary: get image as a thumbnail
      operationId: getImageThumbnails
      description: Receive an image as a thumbnail.
      responses:
        200:
          description: OK.
          headers:
            Content-Type:
              $ref: '#/components/headers/image_content_type'
            Luna-Request-Id:
              $ref: '#/components/headers/luna_request_id'
          content:
            image/jpeg:
              schema:
                $ref: '#/components/schemas/image_binary'
            image/png:
              schema:
                $ref: '#/components/schemas/image_binary'
        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:
                failed_resize_image:
                  value:
                    error_code: 18002
                    detail: 'Bad/incomplete input data'
                    desc: "Failed convert bytes to image size 1. The height and width of the output image must be > 0"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-12014'
        404:
          description: Image 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:
                error_response:
                  value:
                    error_code: 13003
                    detail: "Object not found"
                    desc: "Image with id 'b668c4a5-2191-476e-a261-3b4f9ce2e25e' not found"
                    link: 'https://docs.visionlabs.ai/info/luna/troubleshooting/errors-description/code-13003'
        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. If *Accept* request header is of type `application/json`,
        returns documentation in `json` format or returns `text` documentation, if *Accept-Type* is `text/plain`.
      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'
      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'
