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 database file.
Parameters:
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
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |