This repository has been archived by the owner on Aug 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YACHT-1094: Fixed TestTableRestoreService
- Loading branch information
1 parent
6b8728b
commit b745d69
Showing
2 changed files
with
10 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
import logging | ||
import uuid | ||
|
||
from src.backup.datastore.backup_finder import BackupFinder | ||
from src.restore.list.backup_list_restore_service import \ | ||
BackupListRestoreRequest, BackupItem, BackupListRestoreService | ||
from src.restore.status.restoration_job_status_service import \ | ||
RestorationJobStatusService | ||
from src.backup.datastore.backup_finder import BackupFinder | ||
|
||
|
||
class TableRestoreService(object): | ||
@classmethod | ||
def restore(cls, table_reference, target_dataset_id, restoration_datetime): | ||
backup = BackupFinder.for_table(table_reference, restoration_datetime) | ||
|
||
restore_request = BackupListRestoreRequest([BackupItem(backup.key)], | ||
target_dataset_id) | ||
|
||
restoration_job_id = str(uuid.uuid4()) | ||
logging.info("Created restoration_job_id: %s", restoration_job_id) | ||
restore_request = BackupListRestoreRequest( | ||
[BackupItem(backup.key)], None, target_dataset_id, None, None) | ||
|
||
BackupListRestoreService().restore(restoration_job_id, restore_request) | ||
restoration_job_id = BackupListRestoreService().restore(restore_request) | ||
logging.info("Scheduled restoration job: %s", restoration_job_id) | ||
|
||
restore_data = { | ||
return { | ||
'restorationJobId': restoration_job_id, | ||
'restorationStatusEndpoint': | ||
RestorationJobStatusService.get_status_endpoint( | ||
restoration_job_id), | ||
'restorationWarningsOnlyStatusEndpoint': | ||
RestorationJobStatusService.get_warnings_only_status_endpoint( | ||
restoration_job_id) | ||
'restorationStatusEndpoint': RestorationJobStatusService.get_status_endpoint(restoration_job_id), | ||
'restorationWarningsOnlyStatusEndpoint': RestorationJobStatusService.get_warnings_only_status_endpoint(restoration_job_id) | ||
} | ||
return restore_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters