{
  "openapi": "3.0.3",
  "info": {
    "title": "Buildomat",
    "version": "1.0"
  },
  "paths": {
    "/v1/control/hold": {
      "post": {
        "operationId": "control_hold",
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "enum": [
                    null
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/v1/control/resume": {
      "post": {
        "operationId": "control_resume",
        "responses": {
          "200": {
            "description": "successful operation"
          }
        }
      }
    },
    "/v1/task/{task}": {
      "get": {
        "operationId": "task_get",
        "parameters": [
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks": {
      "get": {
        "operationId": "tasks_get",
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "title": "Array_of_Task",
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Task"
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "task_submit",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TaskSubmit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "successful creation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskSubmitResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/{task}/events": {
      "get": {
        "operationId": "task_events_get",
        "parameters": [
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          },
          {
            "in": "query",
            "name": "minseq",
            "schema": {
              "type": "integer",
              "format": "uint",
              "minimum": 0
            },
            "style": "form"
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "title": "Array_of_TaskEvent",
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskEvent"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/{task}/outputs": {
      "get": {
        "operationId": "task_outputs_get",
        "parameters": [
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "title": "Array_of_TaskOutput",
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TaskOutput"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tasks/{task}/outputs/{output}": {
      "get": {
        "operationId": "task_output_download",
        "parameters": [
          {
            "in": "path",
            "name": "output",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          },
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          }
        ],
        "responses": {}
      }
    },
    "/v1/users": {
      "post": {
        "operationId": "user_create",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "successful creation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserCreateResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/whoami": {
      "get": {
        "operationId": "whoami",
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WhoamiResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/worker/bootstrap": {
      "post": {
        "operationId": "worker_bootstrap",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkerBootstrap"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "successful creation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerBootstrapResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/worker/ping": {
      "get": {
        "operationId": "worker_ping",
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkerPingResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/worker/task/{task}/append": {
      "post": {
        "operationId": "worker_task_append",
        "parameters": [
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkerAppendTask"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "successful creation"
          }
        }
      }
    },
    "/v1/worker/task/{task}/chunk": {
      "post": {
        "operationId": "worker_task_upload_chunk",
        "parameters": [
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          }
        ],
        "requestBody": {
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "successful creation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadedChunk"
                }
              }
            }
          }
        }
      }
    },
    "/v1/worker/task/{task}/complete": {
      "post": {
        "operationId": "worker_task_complete",
        "parameters": [
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkerCompleteTask"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "successful operation"
          }
        }
      }
    },
    "/v1/worker/task/{task}/output": {
      "post": {
        "operationId": "worker_task_add_output",
        "parameters": [
          {
            "in": "path",
            "name": "task",
            "required": true,
            "schema": {
              "type": "string"
            },
            "style": "simple"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WorkerAddOutput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "successful creation"
          }
        }
      }
    },
    "/v1/workers": {
      "get": {
        "operationId": "workers_list",
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkersResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/workers/recycle": {
      "post": {
        "operationId": "workers_recycle",
        "responses": {
          "200": {
            "description": "successful operation"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Task": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "output_rules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "script": {
            "type": "string"
          },
          "state": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "output_rules",
          "script",
          "state"
        ]
      },
      "TaskEvent": {
        "type": "object",
        "properties": {
          "payload": {
            "type": "string"
          },
          "seq": {
            "type": "integer",
            "format": "uint",
            "minimum": 0
          },
          "stream": {
            "type": "string"
          },
          "time": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "payload",
          "seq",
          "stream",
          "time"
        ]
      },
      "TaskOutput": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0
          }
        },
        "required": [
          "id",
          "path",
          "size"
        ]
      },
      "TaskSubmit": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "output_rules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "script": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "script"
        ]
      },
      "TaskSubmitResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ]
      },
      "UploadedChunk": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ]
      },
      "UserCreate": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "UserCreateResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "token": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "token"
        ]
      },
      "WhoamiResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "Worker": {
        "type": "object",
        "properties": {
          "deleted": {
            "type": "boolean"
          },
          "id": {
            "type": "string"
          },
          "instance_id": {
            "type": "string"
          },
          "lastping": {
            "type": "string",
            "format": "date-time"
          },
          "recycle": {
            "type": "boolean"
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WorkerTask"
            }
          }
        },
        "required": [
          "deleted",
          "id",
          "recycle",
          "tasks"
        ]
      },
      "WorkerAddOutput": {
        "type": "object",
        "properties": {
          "chunks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "path": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "format": "int64"
          }
        },
        "required": [
          "chunks",
          "path",
          "size"
        ]
      },
      "WorkerAppendTask": {
        "type": "object",
        "properties": {
          "payload": {
            "type": "string"
          },
          "stream": {
            "type": "string"
          },
          "time": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "payload",
          "stream",
          "time"
        ]
      },
      "WorkerBootstrap": {
        "type": "object",
        "properties": {
          "bootstrap": {
            "type": "string"
          },
          "token": {
            "type": "string"
          }
        },
        "required": [
          "bootstrap",
          "token"
        ]
      },
      "WorkerBootstrapResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ]
      },
      "WorkerCompleteTask": {
        "type": "object",
        "properties": {
          "failed": {
            "type": "boolean"
          }
        },
        "required": [
          "failed"
        ]
      },
      "WorkerPingResult": {
        "type": "object",
        "properties": {
          "poweroff": {
            "type": "boolean"
          },
          "task": {
            "$ref": "#/components/schemas/WorkerPingTask"
          }
        },
        "required": [
          "poweroff"
        ]
      },
      "WorkerPingTask": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "output_rules": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "script": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "output_rules",
          "script"
        ]
      },
      "WorkerTask": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "owner": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "owner"
        ]
      },
      "WorkersResult": {
        "type": "object",
        "properties": {
          "workers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Worker"
            }
          }
        },
        "required": [
          "workers"
        ]
      }
    }
  }
}