database
dev_tool.services.portal.database
__all__ = ['DatabaseService', 'JobStatus']
module-attribute
JobStatus
Bases: StrEnum
COMPLETED = 'completed'
class-attribute
instance-attribute
FAILED = 'failed'
class-attribute
instance-attribute
DatabaseService
Bases: BaseService
A service class for managing portal database operations.
This class provides methods for creating database dumps, downloading files, decrypting content, and restoring databases from the portal.
The constructor for the DatabaseService class.
Parameters:
-
config(PortalServiceConfig) –The portal service configuration.
-
client(APIClientService) –The API client service for making requests.
Source code in dev_tool/services/portal/database/service.py
config = config
instance-attribute
client = client
instance-attribute
manager = PostgresManager(DockerPostgresDatabase(), CloudPostgresDatabase())
instance-attribute
task_manager = TaskManager()
instance-attribute
admin_create_dump
A method that creates an unrestricted admin database dump on the portal.
Parameters:
Returns:
Raises:
-
PortalDumpError–If the dump creation fails.
Source code in dev_tool/services/portal/database/service.py
backup_database
A method that backs up a database to a local .sql file as a background task.
Parameters:
-
project(str) –The project name from pyproject.toml.
-
database(str) –The name of the database to backup.
Returns:
-
str–The task ID for tracking the backup progress.
Source code in dev_tool/services/portal/database/service.py
create_dump
A method that creates a database dump on the portal.
Parameters:
Returns:
Raises:
-
PortalDumpError–If the dump creation fails.
Source code in dev_tool/services/portal/database/service.py
decrypt_content
A method that decrypts an encrypted file and returns the content.
Parameters:
-
file(Path) –The path to the encrypted file.
-
key_data(dict[str, str]) –The key data dictionary containing the hex-encoded key.
Returns:
-
str–The decrypted content as a string.
Raises:
-
PortalDecryptionError–If decryption fails.
Source code in dev_tool/services/portal/database/service.py
download_file
A method that downloads a file from the portal.
Parameters:
Returns:
-
Path–The path to the downloaded file.
Raises:
-
PortalDownloadError–If the download fails.
Source code in dev_tool/services/portal/database/service.py
get_decryption_key
A method that retrieves the decryption key from the portal.
Parameters:
-
identifier(str) –The key identifier.
Returns:
Raises:
-
PortalDecryptionError–If fetching the key fails.
Source code in dev_tool/services/portal/database/service.py
restore_database
A method that restores a database from the portal as a background task.
Parameters:
-
project(str) –The project name from pyproject.toml.
-
database(str) –The name of the database to restore.
Returns:
-
str–The task ID for tracking the restoration progress.
Source code in dev_tool/services/portal/database/service.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |