mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00:00
An all-databases MySQL/MariaDB restore also restored the mysql system database, so after the next restart the root and app passwords were the source ones and the MariaDB health check failed. The restore now skips mysql, sys, performance_schema and information_schema by default. The new option "Restore users and privileges" (restore_mysql_users in the API) keeps the old behaviour.
113 lines
8.2 KiB
PHP
113 lines
8.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use OpenApi\Attributes as OA;
|
|
|
|
#[OA\Info(title: 'Coolify', version: '0.1')]
|
|
#[OA\Server(url: 'https://app.coolify.io/api/v1', description: 'Coolify Cloud API. Change the host to your own instance if you are self-hosting.')]
|
|
#[OA\SecurityScheme(
|
|
type: 'http',
|
|
scheme: 'bearer',
|
|
securityScheme: 'bearerAuth',
|
|
description: 'Go to `Keys & Tokens` / `API tokens` and create a new token. Use the token as the bearer token.')]
|
|
#[OA\Components(
|
|
schemas: [
|
|
new OA\Schema(
|
|
schema: 'DatabaseImportRequest',
|
|
oneOf: [
|
|
new OA\Schema(required: ['source', 'upload_id'], additionalProperties: false, properties: [new OA\Property(property: 'source', type: 'string', enum: ['upload']), new OA\Property(property: 'upload_id', type: 'string', format: 'uuid'), new OA\Property(property: 'dump_all', type: 'boolean', default: false), new OA\Property(property: 'replace_existing', description: 'Drop matching PostgreSQL objects before restoring a single-database archive.', type: 'boolean', default: false), new OA\Property(property: 'keep_owners', description: 'Restore object owners and privileges from a single-database PostgreSQL archive. By default they are skipped, because the roles of another server usually do not exist.', type: 'boolean', default: false), new OA\Property(property: 'restore_mysql_users', description: 'MySQL and MariaDB backups containing all databases: also restore the mysql system database (users, passwords, and privileges). By default the system databases are skipped, so the database keeps its own users and passwords.', type: 'boolean', default: false), new OA\Property(property: 'sqlite_database', description: 'SQLite: the database file to restore into. Must be one of the database files. Defaults to the file named in the backup file name, else the first file.', type: 'string', example: 'app.db')]),
|
|
new OA\Schema(required: ['source', 's3_storage_uuid', 'path'], additionalProperties: false, properties: [new OA\Property(property: 'source', type: 'string', enum: ['s3']), new OA\Property(property: 's3_storage_uuid', type: 'string'), new OA\Property(property: 'path', type: 'string'), new OA\Property(property: 'dump_all', type: 'boolean', default: false), new OA\Property(property: 'replace_existing', description: 'Drop matching PostgreSQL objects before restoring a single-database archive.', type: 'boolean', default: false), new OA\Property(property: 'keep_owners', description: 'Restore object owners and privileges from a single-database PostgreSQL archive. By default they are skipped, because the roles of another server usually do not exist.', type: 'boolean', default: false), new OA\Property(property: 'restore_mysql_users', description: 'MySQL and MariaDB backups containing all databases: also restore the mysql system database (users, passwords, and privileges). By default the system databases are skipped, so the database keeps its own users and passwords.', type: 'boolean', default: false), new OA\Property(property: 'sqlite_database', description: 'SQLite: the database file to restore into. Must be one of the database files. Defaults to the file named in the backup file name, else the first file.', type: 'string', example: 'app.db')]),
|
|
new OA\Schema(required: ['source', 'path'], additionalProperties: false, properties: [new OA\Property(property: 'source', type: 'string', enum: ['server']), new OA\Property(property: 'path', type: 'string', example: '/var/backups/database.sql.gz'), new OA\Property(property: 'dump_all', type: 'boolean', default: false), new OA\Property(property: 'replace_existing', description: 'Drop matching PostgreSQL objects before restoring a single-database archive.', type: 'boolean', default: false), new OA\Property(property: 'keep_owners', description: 'Restore object owners and privileges from a single-database PostgreSQL archive. By default they are skipped, because the roles of another server usually do not exist.', type: 'boolean', default: false), new OA\Property(property: 'restore_mysql_users', description: 'MySQL and MariaDB backups containing all databases: also restore the mysql system database (users, passwords, and privileges). By default the system databases are skipped, so the database keeps its own users and passwords.', type: 'boolean', default: false), new OA\Property(property: 'sqlite_database', description: 'SQLite: the database file to restore into. Must be one of the database files. Defaults to the file named in the backup file name, else the first file.', type: 'string', example: 'app.db')]),
|
|
],
|
|
type: 'object',
|
|
),
|
|
new OA\Schema(
|
|
schema: 'DatabaseImportStatus',
|
|
type: 'object',
|
|
properties: [
|
|
new OA\Property(property: 'id', type: 'integer'),
|
|
new OA\Property(property: 'status', type: 'string', enum: ['queued', 'in_progress', 'finished', 'error', 'killed', 'cancelled', 'closed']),
|
|
new OA\Property(property: 'exit_code', type: 'integer', nullable: true),
|
|
new OA\Property(property: 'output', type: 'string'),
|
|
new OA\Property(property: 'created_at', type: 'string', format: 'date-time'),
|
|
new OA\Property(property: 'updated_at', type: 'string', format: 'date-time'),
|
|
new OA\Property(property: 'finished_at', type: 'string', format: 'date-time', nullable: true),
|
|
],
|
|
),
|
|
],
|
|
responses: [
|
|
new OA\Response(
|
|
response: 400,
|
|
description: 'Invalid token.',
|
|
content: new OA\JsonContent(
|
|
type: 'object',
|
|
properties: [
|
|
new OA\Property(property: 'message', type: 'string', example: 'Invalid token.'),
|
|
]
|
|
)),
|
|
new OA\Response(
|
|
response: 401,
|
|
description: 'Unauthenticated.',
|
|
content: new OA\JsonContent(
|
|
type: 'object',
|
|
properties: [
|
|
new OA\Property(property: 'message', type: 'string', example: 'Unauthenticated.'),
|
|
]
|
|
)),
|
|
new OA\Response(
|
|
response: 404,
|
|
description: 'Resource not found.',
|
|
content: new OA\JsonContent(
|
|
type: 'object',
|
|
properties: [
|
|
new OA\Property(property: 'message', type: 'string', example: 'Resource not found.'),
|
|
]
|
|
)),
|
|
new OA\Response(
|
|
response: 422,
|
|
description: 'Validation error.',
|
|
content: new OA\JsonContent(
|
|
type: 'object',
|
|
properties: [
|
|
new OA\Property(property: 'message', type: 'string', example: 'Validation error.'),
|
|
new OA\Property(
|
|
property: 'errors',
|
|
type: 'object',
|
|
additionalProperties: new OA\AdditionalProperties(
|
|
type: 'array',
|
|
items: new OA\Items(type: 'string')
|
|
),
|
|
example: [
|
|
'name' => ['The name field is required.'],
|
|
'api_url' => ['The api url field is required.', 'The api url format is invalid.'],
|
|
]
|
|
),
|
|
]
|
|
)),
|
|
new OA\Response(
|
|
response: 429,
|
|
description: 'Rate limit exceeded.',
|
|
headers: [
|
|
new OA\Header(
|
|
header: 'Retry-After',
|
|
description: 'Number of seconds to wait before retrying.',
|
|
schema: new OA\Schema(type: 'integer', example: 60)
|
|
),
|
|
],
|
|
content: new OA\JsonContent(
|
|
type: 'object',
|
|
properties: [
|
|
new OA\Property(property: 'message', type: 'string', example: 'Rate limit exceeded. Please try again later.'),
|
|
]
|
|
)),
|
|
],
|
|
)]
|
|
class OpenApi
|
|
{
|
|
// This class is used to generate OpenAPI documentation
|
|
// for the Coolify API. It is not a controller and does
|
|
// not contain any routes. It is used to define the
|
|
// OpenAPI metadata and security scheme for the API.
|
|
}
|