diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..a20459d --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,23 @@ +# build and publish rust crate +name: Rust + +on: + push: + branches: [ main ] + pull_request: + branches: [ main, dz/1 ] + +jobs: + release: + name: Rust + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: stable + override: true + - uses: katyo/publish-crates@v2 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + path: crates/openapi-client diff --git a/src/docs/swagger.3.json b/src/docs/swagger.3.json new file mode 100644 index 0000000..98b7f34 --- /dev/null +++ b/src/docs/swagger.3.json @@ -0,0 +1,1204 @@ +{ + "components": { + "schemas": { + "health.ExecProbe": { + "properties": { + "command": { + "type": "string" + }, + "workingDir": { + "type": "string" + } + }, + "type": "object" + }, + "health.HttpProbe": { + "properties": { + "host": { + "type": "string" + }, + "numPort": { + "type": "integer" + }, + "path": { + "type": "string" + }, + "port": { + "type": "string" + }, + "scheme": { + "type": "string" + } + }, + "type": "object" + }, + "health.Probe": { + "properties": { + "exec": { + "$ref": "#/components/schemas/health.ExecProbe" + }, + "failureThreshold": { + "type": "integer" + }, + "httpGet": { + "$ref": "#/components/schemas/health.HttpProbe" + }, + "initialDelay": { + "type": "integer" + }, + "periodSeconds": { + "type": "integer" + }, + "successThreshold": { + "type": "integer" + }, + "timeoutSeconds": { + "type": "integer" + } + }, + "type": "object" + }, + "types.DependsOnConfig": { + "additionalProperties": { + "$ref": "#/components/schemas/types.ProcessDependency" + }, + "type": "object" + }, + "types.LogRotationConfig": { + "properties": { + "compress": { + "description": "Compress determines if the rotated log files should be compressed\nusing gzip. The default is not to perform compression.", + "type": "boolean" + }, + "directory": { + "description": "Directory to log to when filelogging is enabled", + "type": "string" + }, + "filename": { + "description": "Filename is the name of the logfile which will be placed inside the directory", + "type": "string" + }, + "maxAge": { + "description": "MaxAge the max age in days to keep a logfile", + "type": "integer" + }, + "maxBackups": { + "description": "MaxBackups the max number of rolled files to keep", + "type": "integer" + }, + "maxSize": { + "description": "MaxSize the max size in MB of the logfile before it's rolled", + "type": "integer" + } + }, + "type": "object" + }, + "types.LoggerConfig": { + "properties": { + "addTimestamp": { + "description": "AddTimestamp adds timestamp to log", + "type": "boolean" + }, + "disableJSON": { + "description": "DisableJSON disables log JSON formatting", + "type": "boolean" + }, + "fieldsOrder": { + "description": "FieldsOrder is the order in which fields are logged", + "items": { + "type": "string" + }, + "type": "array" + }, + "flushEachLine": { + "description": "FlushEachLine flushes the logger on each line", + "type": "boolean" + }, + "noColor": { + "description": "NoColor disables coloring", + "type": "boolean" + }, + "noMetadata": { + "description": "NoMetadata disables log metadata (process, replica)", + "type": "boolean" + }, + "rotation": { + "allOf": [ + { + "$ref": "#/components/schemas/types.LogRotationConfig" + } + ], + "description": "Rotation is the configuration for logging rotation" + }, + "timestampFormat": { + "description": "TimestampFormat is the format of the timestamp", + "type": "string" + } + }, + "type": "object" + }, + "types.MemoryState": { + "properties": { + "allocated": { + "type": "integer" + }, + "gcCycles": { + "type": "integer" + }, + "systemMemory": { + "type": "integer" + }, + "totalAllocated": { + "type": "integer" + } + }, + "type": "object" + }, + "types.ProcessConfig": { + "properties": { + "args": { + "items": { + "type": "string" + }, + "type": "array" + }, + "command": { + "type": "string" + }, + "dependsOn": { + "$ref": "#/components/schemas/types.DependsOnConfig" + }, + "description": { + "type": "string" + }, + "disableAnsiColors": { + "type": "boolean" + }, + "disabled": { + "type": "boolean" + }, + "entrypoint": { + "items": { + "type": "string" + }, + "type": "array" + }, + "environment": { + "items": { + "type": "string" + }, + "type": "array" + }, + "executable": { + "type": "string" + }, + "extensions": { + "additionalProperties": true, + "type": "object" + }, + "isDaemon": { + "type": "boolean" + }, + "isElevated": { + "type": "boolean" + }, + "isForeground": { + "type": "boolean" + }, + "isTty": { + "type": "boolean" + }, + "livenessProbe": { + "$ref": "#/components/schemas/health.Probe" + }, + "logLocation": { + "type": "string" + }, + "loggerConfig": { + "$ref": "#/components/schemas/types.LoggerConfig" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "readinessProbe": { + "$ref": "#/components/schemas/health.Probe" + }, + "readyLogLine": { + "type": "string" + }, + "replicaName": { + "type": "string" + }, + "replicaNum": { + "type": "integer" + }, + "replicas": { + "type": "integer" + }, + "restartPolicy": { + "$ref": "#/components/schemas/types.RestartPolicyConfig" + }, + "shutDownParams": { + "$ref": "#/components/schemas/types.ShutDownParams" + }, + "vars": { + "$ref": "#/components/schemas/types.Vars" + }, + "workingDir": { + "type": "string" + } + }, + "type": "object" + }, + "types.ProcessDependency": { + "properties": { + "condition": { + "type": "string" + }, + "extensions": { + "additionalProperties": true, + "type": "object" + } + }, + "type": "object" + }, + "types.ProcessPorts": { + "properties": { + "name": { + "type": "string" + }, + "tcp_ports": { + "items": { + "type": "integer" + }, + "type": "array" + }, + "udp_ports": { + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "type": "object" + }, + "types.ProcessState": { + "properties": { + "age": { + "type": "integer" + }, + "exit_code": { + "type": "integer" + }, + "isRunning": { + "type": "boolean" + }, + "is_elevated": { + "type": "boolean" + }, + "is_ready": { + "type": "string" + }, + "mem": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "password_provided": { + "type": "boolean" + }, + "pid": { + "type": "integer" + }, + "restarts": { + "type": "integer" + }, + "status": { + "type": "string" + }, + "system_time": { + "type": "string" + } + }, + "type": "object" + }, + "types.ProcessesState": { + "properties": { + "data": { + "items": { + "$ref": "#/components/schemas/types.ProcessState" + }, + "type": "array" + } + }, + "type": "object" + }, + "types.ProjectState": { + "properties": { + "fileNames": { + "items": { + "type": "string" + }, + "type": "array" + }, + "hostName": { + "type": "string" + }, + "memoryState": { + "$ref": "#/components/schemas/types.MemoryState" + }, + "processNum": { + "type": "integer" + }, + "runningProcessNum": { + "type": "integer" + }, + "startTime": { + "type": "string" + }, + "upTime": { + "type": "integer" + }, + "userName": { + "type": "string" + }, + "version": { + "type": "string" + } + }, + "type": "object" + }, + "types.RestartPolicyConfig": { + "properties": { + "backoffSeconds": { + "type": "integer" + }, + "exitOnEnd": { + "type": "boolean" + }, + "exitOnSkipped": { + "type": "boolean" + }, + "maxRestarts": { + "type": "integer" + }, + "restart": { + "type": "string" + } + }, + "type": "object" + }, + "types.ShutDownParams": { + "properties": { + "parentOnly": { + "type": "boolean" + }, + "shutDownCommand": { + "type": "string" + }, + "shutDownTimeout": { + "type": "integer" + }, + "signal": { + "type": "integer" + } + }, + "type": "object" + }, + "types.Vars": { + "additionalProperties": {}, + "type": "object" + } + } + }, + "externalDocs": { + "url": "https://f1bonacc1.github.io/process-compose/" + }, + "info": { + "contact": { + "name": "Process Compose Discord Channel", + "url": "https://discord.gg/S4xgmRSHdC" + }, + "description": "This is a sample server Process Compose server.", + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "title": "Swagger Process Compose API", + "version": "1.0" + }, + "openapi": "3.0.3", + "paths": { + "/hostname": { + "get": { + "description": "Get process compose hostname", + "operationId": "GetHostName", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Hostname" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Get Hostname", + "tags": [ + "Hostname" + ] + } + }, + "/live": { + "get": { + "description": "Check if server is responding", + "operationId": "IsAlive", + "responses": { + "200": { + "description": "OK" + } + }, + "summary": "Liveness Check", + "tags": [ + "Liveness" + ] + } + }, + "/process": { + "post": { + "description": "Update porcess", + "operationId": "UpdateProcess", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/types.ProcessConfig" + } + } + }, + "description": "Updated Process Config" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Updates process configuration", + "tags": [ + "Process" + ] + } + }, + "/process/info/{name}": { + "get": { + "description": "Retrieves the given process and its config", + "operationId": "GetProcessInfo", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/types.ProcessConfig" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Get process config", + "tags": [ + "Process" + ] + } + }, + "/process/logs/{name}/{endOffset}/{limit}": { + "get": { + "description": "Retrieves the process logs", + "operationId": "GetProcessLogs", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "Offset from the end of the log", + "in": "path", + "name": "endOffset", + "required": true, + "schema": { + "type": "integer" + } + }, + { + "description": "Limit of lines to get (0 will get all the lines till the end)", + "in": "path", + "name": "limit", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "type": "object" + } + } + }, + "description": "Process Logs" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Get process logs", + "tags": [ + "Process" + ] + } + }, + "/process/ports/{name}": { + "get": { + "description": "Retrieves process open ports", + "operationId": "GetProcessPorts", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/types.ProcessPorts" + } + } + }, + "description": "Process Ports" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Get process ports", + "tags": [ + "Process" + ] + } + }, + "/process/restart/{name}": { + "post": { + "description": "Restarts the process", + "operationId": "RestartProcess", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Restarted Process Name" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Restart a process", + "tags": [ + "Process" + ] + } + }, + "/process/scale/{name}/{scale}": { + "patch": { + "description": "Scale a process", + "operationId": "ScaleProcess", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "New amount of process replicas", + "in": "path", + "name": "scale", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Scaled Process Name" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Scale a process to a given replicas count", + "tags": [ + "Process" + ] + } + }, + "/process/start/{name}": { + "post": { + "description": "Starts the process if the state is not 'running' or 'pending'", + "operationId": "StartProcess", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Started Process Name" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Start a process", + "tags": [ + "Process" + ] + } + }, + "/process/stop/{name}": { + "patch": { + "description": "Sends kill signal to the process", + "operationId": "StopProcess", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Stopped Process Name" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Stop a process", + "tags": [ + "Process" + ] + } + }, + "/process/{name}": { + "get": { + "description": "Retrieves the given process and its status", + "operationId": "GetProcess", + "parameters": [ + { + "description": "Process Name", + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/types.ProcessState" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Get process state", + "tags": [ + "Process" + ] + } + }, + "/processes": { + "get": { + "description": "Retrieves all the configured processes and their status", + "operationId": "GetProcesses", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/types.ProcessesState" + } + } + }, + "description": "Processes Status" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Get all processes", + "tags": [ + "Process" + ] + } + }, + "/processes/stop": { + "patch": { + "description": "Sends kill signal to the processes list", + "operationId": "StopProcesses", + "requestBody": { + "content": { + "application/json": { + "schema": { + "items": { + "type": "string" + }, + "type": "array" + } + } + }, + "description": "Processes Names", + "required": true, + "x-originalParamName": "[]string" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Stopped Processes Names" + }, + "207": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Stopped Processes Names" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Stop processes", + "tags": [ + "Process" + ] + } + }, + "/project": { + "post": { + "description": "Update running project", + "operationId": "UpdateProject", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Update Project Status" + }, + "207": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Update Project Status" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Updates running processes", + "tags": [ + "Project" + ] + } + }, + "/project/configuration": { + "post": { + "description": "Reload project state from config", + "operationId": "ReloadProject", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Update Project Status" + }, + "207": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Update Project Status" + }, + "400": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Bad Request" + } + }, + "summary": "Reload project", + "tags": [ + "Project" + ] + } + }, + "/project/state": { + "get": { + "description": "Retrieves project state information", + "operationId": "GetProjectState", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/types.ProjectState" + } + } + }, + "description": "Project State" + }, + "500": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "Get project state", + "tags": [ + "Project" + ] + } + }, + "/project/stop": { + "post": { + "description": "Shuts down the server", + "operationId": "ShutDownProject", + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "additionalProperties": { + "type": "string" + }, + "type": "object" + } + } + }, + "description": "Stopped Server" + } + }, + "summary": "Stops all the processes and the server", + "tags": [ + "Project" + ] + } + } + } +}