|
5 | 5 | from frinx.common.worker.task_def import TaskInput |
6 | 6 | from frinx.common.worker.task_result import TaskResult |
7 | 7 | from frinx.common.worker.worker import WorkerImpl |
| 8 | +from frinx_api.topology_discovery import CreateBackupMutation |
| 9 | +from frinx_api.topology_discovery import CreateBackupResponse |
8 | 10 | from frinx_api.topology_discovery import SyncMutation |
9 | 11 | from frinx_api.topology_discovery import SyncResponse |
10 | 12 | from frinx_api.topology_discovery import TopologyType |
@@ -65,3 +67,31 @@ def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: |
65 | 67 | query = self._sync_topology.render() |
66 | 68 | response: TopologyOutput = execute_graphql_operation(query=query.query, variables=query.variable) |
67 | 69 | return response_handler(query, response) |
| 70 | + |
| 71 | + class CreateBackup(WorkerImpl): |
| 72 | + _create_backup: CreateBackupMutation = CreateBackupMutation( |
| 73 | + payload=CreateBackupResponse( |
| 74 | + dbName=True, |
| 75 | + ) |
| 76 | + ) |
| 77 | + |
| 78 | + class ExecutionProperties(TaskExecutionProperties): |
| 79 | + exclude_empty_inputs: bool = True |
| 80 | + |
| 81 | + class WorkerDefinition(TaskDefinition): |
| 82 | + name: str = "TOPOLOGY_create_backup" |
| 83 | + description: str = "Create backup from the current state of the topology database" |
| 84 | + labels: ListStr = ["BASIC", "TOPOLOGY"] |
| 85 | + timeout_seconds: int = 3600 |
| 86 | + response_timeout_seconds: int = 3600 |
| 87 | + |
| 88 | + class WorkerInput(TaskInput): |
| 89 | + ... |
| 90 | + |
| 91 | + class WorkerOutput(TopologyWorkerOutput): |
| 92 | + ... |
| 93 | + |
| 94 | + def execute(self, worker_input: WorkerInput) -> TaskResult[WorkerOutput]: |
| 95 | + query = self._create_backup.render() |
| 96 | + response: TopologyOutput = execute_graphql_operation(query=query.query, variables=query.variable) |
| 97 | + return response_handler(query, response) |
0 commit comments