openapi: 3.0.3
info:
  version: "0.1"
  title: LAC Control API
  description: |-
    This API provides endpoints for retrieving information about LAC jobs and performing various actions related to them.
  contact:
    name: DMU Support
    email: support@dmu-gmbh.at
tags:
  - name: Jobs
    description: |-
      A job is a task assigned to the LAC that can be in different states based on its progress in the workflow.
servers:
  - url: https://machine-hostname/control/v1
  - url: https://localhost:8080
paths:
  /jobs:
    get:
      summary: View Jobs
      tags:
        - Jobs
      parameters:
        - name: status
          in: query
          description: Filter jobs by status
          required: false
          schema:
            $ref: "#/components/schemas/JobStatusName"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: "#/components/schemas/Job"
              examples:
                with-some-data:
                  summary: With some data
                  value:
                    items:
                      - id: 87125878-44f1-4743-b506-95e9a68245ad
                        origin_id: 7de2834f-bcb1-41ae-b0b1-3a6db48ef385
                        status:
                          name: prepared
                          code: null
                          message: null
                        selected: false
                        cutting_start_time: "2023-04-25T13:04:16.639000+00:00"
                        cutting_end_time: "2023-04-25T13:06:16.639000+00:00"
                        created_at: "2023-04-25T12:58:16.639000+00:00"
                        updated_at: "2023-04-25T13:00:16.639000+00:00"
                        data_source:
                          id: 12345678-abcd-1234-efgh-1234567890ab
                          name: Sample Data Source 1
                      - id: 602a6cf3-e4b4-4396-affe-f84efae260e2
                        origin_id: /path/to/resource/files
                        status:
                          name: done
                          code: null
                          message: null
                        selected: false
                        cutting_start_time: "2023-04-25T13:12:16.639000+00:00"
                        cutting_end_time: "2023-04-25T13:14:16.639000+00:00"
                        created_at: "2023-04-25T13:06:16.639000+00:00"
                        updated_at: "2023-04-25T13:08:16.639000+00:00"
                        data_source:
                          id: 98765432-dcba-4321-hgfe-0987654321ba
                          name: Sample Data Source 2
  /jobs/{id}:
    parameters:
      - schema:
          type: string
        name: id
        in: path
        required: true
        example: 9271aa24-92c7-4d5d-8a04-bcf2eb54370d
    get:
      summary: View Job
      tags:
        - Jobs
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Job"
              examples:
                with-some-data:
                  summary: With some data
                  value:
                    id: 87125878-44f1-4743-b506-95e9a68245ad
                    origin_id: 7de2834f-bcb1-41ae-b0b1-3a6db48ef385
                    status: prepared
                    selected: false
                    cutting_start_time: "2023-04-25T13:10:16.639000+00:00"
                    cutting_end_time: "2023-04-25T13:12:16.639000+00:00"
                    created_at: "2023-04-25T13:04:16.639000+00:00"
                    updated_at: "2023-04-25T13:06:16.639000+00:00"
                    data_source:
                      id: 12345678-abcd-1234-efgh-1234567890ab
                      name: Sample Data Source 1
    put:
      summary: Modify Job
      tags:
        - Jobs
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Job"
        "405":
          description: Method Not Allowed
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
              examples:
                with-some-data:
                  summary: With some data
                  value:
                    title: Method Not Allowed
                    status: 405
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                selected:
                  type: boolean

components:
  schemas:
    Job:
      type: object
      properties:
        id:
          type: string
          pattern: '[0-9a-fA-F\n]{36}$'
        origin_id:
          type: string
        status:
          type: object
          properties:
            name:
              $ref: "#/components/schemas/JobStatusName"
            code:
              type: string
              nullable: true
            message:
              type: string
              nullable: true
        data_source:
          type: object
          properties:
            id:
              type: string
              pattern: '[0-9a-fA-F\n]{36}$'
            name:
              type: string
        selected:
          type: boolean
        cutting_start_time:
          type: string
          format: date-time
          nullable: true
        cutting_end_time:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    JobStatusName:
      type: string
      enum:
        - new
        - queued
        - preparing
        - prepared
        - finalizing
        - finalized
        - active
        - done
        - failed
        - preparation_failed
    Problem:
      type: object
      properties:
        title:
          type: string
          description: Human-readable error title.
        status:
          type: integer
          description: HTTP status code
        detail:
          type: string
          description: Human-readable error details.
