feat(api): add endpoints for retrieving application logs and deployments

This commit is contained in:
Andras Bacsai
2025-03-31 17:38:54 +02:00
parent 799855ea28
commit 9f67633f2c
4 changed files with 246 additions and 80 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Console\Commands;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Process; use Illuminate\Support\Facades\Process;
use Symfony\Component\Yaml\Yaml;
class OpenApi extends Command class OpenApi extends Command
{ {
@@ -29,5 +30,10 @@ class OpenApi extends Command
$error = preg_replace('/^\h*\v+/m', '', $error); $error = preg_replace('/^\h*\v+/m', '', $error);
echo $error; echo $error;
echo $process->output(); echo $process->output();
$yaml = file_get_contents('openapi.yaml');
$json = json_encode(Yaml::parse($yaml), JSON_PRETTY_PRINT);
file_put_contents('openapi.json', $json);
echo "Converted OpenAPI YAML to JSON.\n";
} }
} }

View File

@@ -328,7 +328,7 @@ class DeployController extends Controller
summary: 'List application deployments', summary: 'List application deployments',
description: 'List application deployments by using the app uuid', description: 'List application deployments by using the app uuid',
path: '/deployments/applications/{uuid}', path: '/deployments/applications/{uuid}',
operationId: 'list-deployments', operationId: 'list-deployments-by-app-uuid',
security: [ security: [
['bearerAuth' => []], ['bearerAuth' => []],
], ],

View File

@@ -2105,6 +2105,70 @@
] ]
} }
}, },
"\/applications\/{uuid}\/logs": {
"get": {
"tags": [
"Applications"
],
"summary": "Get application logs.",
"description": "Get application logs by UUID.",
"operationId": "get-application-logs-by-uuid",
"parameters": [
{
"name": "uuid",
"in": "path",
"description": "UUID of the application.",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
},
{
"name": "lines",
"in": "query",
"description": "Number of lines to show from the end of the logs.",
"required": false,
"schema": {
"type": "integer",
"format": "int32",
"default": 100
}
}
],
"responses": {
"200": {
"description": "Get application logs by UUID.",
"content": {
"application\/json": {
"schema": {
"properties": {
"logs": {
"type": "string"
}
},
"type": "object"
}
}
}
},
"401": {
"$ref": "#\/components\/responses\/401"
},
"400": {
"$ref": "#\/components\/responses\/400"
},
"404": {
"$ref": "#\/components\/responses\/404"
}
},
"security": [
{
"bearerAuth": []
}
]
}
},
"\/applications\/{uuid}\/envs": { "\/applications\/{uuid}\/envs": {
"get": { "get": {
"tags": [ "tags": [
@@ -4481,7 +4545,7 @@
{ {
"name": "pr", "name": "pr",
"in": "query", "in": "query",
"description": "Pull request ID", "description": "Pull Request Id for deploying specific PR builds. Cannot be used with tag parameter.",
"schema": { "schema": {
"type": "integer" "type": "integer"
} }
@@ -4531,6 +4595,42 @@
] ]
} }
}, },
"\/deployments\/applications\/{uuid}": {
"get": {
"tags": [
"Deployments"
],
"summary": "List application deployments",
"description": "List application deployments by using the app uuid",
"operationId": "list-deployments-by-app-uuid",
"responses": {
"200": {
"description": "List application deployments by using the app uuid.",
"content": {
"application\/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#\/components\/schemas\/Application"
}
}
}
}
},
"401": {
"$ref": "#\/components\/responses\/401"
},
"400": {
"$ref": "#\/components\/responses\/400"
}
},
"security": [
{
"bearerAuth": []
}
]
}
},
"\/version": { "\/version": {
"get": { "get": {
"summary": "Version", "summary": "Version",
@@ -5862,8 +5962,8 @@
"tags": [ "tags": [
"Services" "Services"
], ],
"summary": "Create", "summary": "Create service",
"description": "Create a one-click service", "description": "Create a one-click \/ custom service",
"operationId": "create-service", "operationId": "create-service",
"requestBody": { "requestBody": {
"required": true, "required": true,
@@ -6013,7 +6113,7 @@
}, },
"responses": { "responses": {
"201": { "201": {
"description": "Create a service.", "description": "Service created successfully.",
"content": { "content": {
"application\/json": { "application\/json": {
"schema": { "schema": {
@@ -6185,6 +6285,114 @@
"bearerAuth": [] "bearerAuth": []
} }
] ]
},
"patch": {
"tags": [
"Services"
],
"summary": "Update",
"description": "Update service by UUID.",
"operationId": "update-service-by-uuid",
"requestBody": {
"description": "Service updated.",
"required": true,
"content": {
"application\/json": {
"schema": {
"required": [
"server_uuid",
"project_uuid",
"environment_name",
"environment_uuid",
"docker_compose_raw"
],
"properties": {
"name": {
"type": "string",
"description": "The service name."
},
"description": {
"type": "string",
"description": "The service description."
},
"project_uuid": {
"type": "string",
"description": "The project UUID."
},
"environment_name": {
"type": "string",
"description": "The environment name."
},
"environment_uuid": {
"type": "string",
"description": "The environment UUID."
},
"server_uuid": {
"type": "string",
"description": "The server UUID."
},
"destination_uuid": {
"type": "string",
"description": "The destination UUID."
},
"instant_deploy": {
"type": "boolean",
"description": "The flag to indicate if the service should be deployed instantly."
},
"connect_to_docker_network": {
"type": "boolean",
"default": false,
"description": "Connect the service to the predefined docker network."
},
"docker_compose_raw": {
"type": "string",
"description": "The Docker Compose raw content."
}
},
"type": "object"
}
}
}
},
"responses": {
"200": {
"description": "Service updated.",
"content": {
"application\/json": {
"schema": {
"properties": {
"uuid": {
"type": "string",
"description": "Service UUID."
},
"domains": {
"type": "array",
"items": {
"type": "string"
},
"description": "Service domains."
}
},
"type": "object"
}
}
}
},
"401": {
"$ref": "#\/components\/responses\/401"
},
"400": {
"$ref": "#\/components\/responses\/400"
},
"404": {
"$ref": "#\/components\/responses\/404"
}
},
"security": [
{
"bearerAuth": []
}
]
} }
}, },
"\/services\/{uuid}\/envs": { "\/services\/{uuid}\/envs": {

View File

@@ -3155,7 +3155,7 @@ paths:
- -
name: pr name: pr
in: query in: query
description: 'Pull request id' description: 'Pull Request Id for deploying specific PR builds. Cannot be used with tag parameter.'
schema: schema:
type: integer type: integer
responses: responses:
@@ -3174,6 +3174,29 @@ paths:
security: security:
- -
bearerAuth: [] bearerAuth: []
'/deployments/applications/{uuid}':
get:
tags:
- Deployments
summary: 'List application deployments'
description: 'List application deployments by using the app uuid'
operationId: list-deployments-by-app-uuid
responses:
'200':
description: 'List application deployments by using the app uuid.'
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Application'
'401':
$ref: '#/components/responses/401'
'400':
$ref: '#/components/responses/400'
security:
-
bearerAuth: []
/version: /version:
get: get:
summary: Version summary: Version
@@ -4001,80 +4024,9 @@ paths:
post: post:
tags: tags:
- Services - Services
summary: Create summary: 'Create service'
description: 'Create a service' description: 'Create a one-click / custom service'
operationId: create-service operationId: create-service
requestBody:
required: true
content:
application/json:
schema:
required:
- server_uuid
- project_uuid
- environment_name
- environment_uuid
- docker_compose_raw
properties:
name:
type: string
maxLength: 255
description: 'Name of the service.'
description:
type: string
nullable: true
description: 'Description of the service.'
project_uuid:
type: string
description: 'Project UUID.'
environment_name:
type: string
description: 'Environment name. You need to provide at least one of environment_name or environment_uuid.'
environment_uuid:
type: string
description: 'Environment UUID. You need to provide at least one of environment_name or environment_uuid.'
server_uuid:
type: string
description: 'Server UUID.'
destination_uuid:
type: string
description: 'Destination UUID. Required if server has multiple destinations.'
instant_deploy:
type: boolean
default: false
description: 'Start the service immediately after creation.'
connect_to_docker_network:
type: boolean
default: false
description: 'The flag to connect the service to the predefined Docker network.'
docker_compose_raw:
type: string
description: 'The Docker Compose raw content.'
type: object
responses:
'201':
description: 'Service created successfully.'
content:
application/json:
schema:
properties:
uuid: { type: string, description: 'Service UUID.' }
domains: { type: array, items: { type: string, nullable: true }, description: 'Service domains.' }
type: object
'401':
$ref: '#/components/responses/401'
'400':
$ref: '#/components/responses/400'
security:
-
bearerAuth: []
/services/one-click:
post:
tags:
- Services
summary: 'Create one-click'
description: 'Create a one-click service'
operationId: create-one-click-service
requestBody: requestBody:
required: true required: true
content: content:
@@ -4277,7 +4229,7 @@ paths:
connect_to_docker_network: connect_to_docker_network:
type: boolean type: boolean
default: false default: false
description: 'The flag to connect the service to the predefined Docker network.' description: 'Connect the service to the predefined docker network.'
docker_compose_raw: docker_compose_raw:
type: string type: string
description: 'The Docker Compose raw content.' description: 'The Docker Compose raw content.'