|
1 | 1 | # stdlib |
2 | 2 | from collections import defaultdict |
3 | 3 | import logging |
| 4 | +from typing import Any |
4 | 5 |
|
5 | 6 | # syft absolute |
6 | 7 | import syft |
|
16 | 17 | from ...types.syft_object import SyftObject |
17 | 18 | from ...types.syft_object_registry import SyftObjectRegistry |
18 | 19 | from ...types.twin_object import TwinObject |
| 20 | +from ...types.uid import UID |
19 | 21 | from ..action.action_object import Action |
20 | 22 | from ..action.action_object import ActionObject |
21 | 23 | from ..action.action_permissions import ActionObjectPermission |
|
26 | 28 | from ..response import SyftSuccess |
27 | 29 | from ..service import AbstractService |
28 | 30 | from ..service import service_method |
| 31 | +from ..sync.sync_service import get_store |
| 32 | +from ..sync.sync_service import get_store_by_type |
29 | 33 | from ..user.user_roles import ADMIN_ROLE_LEVEL |
| 34 | +from ..user.user_roles import DATA_SCIENTIST_ROLE_LEVEL |
30 | 35 | from ..worker.utils import DEFAULT_WORKER_POOL_NAME |
31 | 36 | from .object_migration_state import MigrationData |
32 | 37 | from .object_migration_state import StoreMetadata |
@@ -493,3 +498,29 @@ def reset_and_restore( |
493 | 498 | ) |
494 | 499 |
|
495 | 500 | return SyftSuccess(message="Database reset successfully.") |
| 501 | + |
| 502 | + @service_method( |
| 503 | + path="migration._get_object", |
| 504 | + name="_get_object", |
| 505 | + roles=DATA_SCIENTIST_ROLE_LEVEL, |
| 506 | + ) |
| 507 | + def _get_object( |
| 508 | + self, context: AuthedServiceContext, uid: UID, object_type: type |
| 509 | + ) -> Any: |
| 510 | + return ( |
| 511 | + get_store_by_type(context, object_type) |
| 512 | + .get_by_uid(credentials=context.credentials, uid=uid) |
| 513 | + .unwrap() |
| 514 | + ) |
| 515 | + |
| 516 | + @service_method( |
| 517 | + path="migration._update_object", |
| 518 | + name="_update_object", |
| 519 | + roles=ADMIN_ROLE_LEVEL, |
| 520 | + ) |
| 521 | + def _update_object(self, context: AuthedServiceContext, object: Any) -> Any: |
| 522 | + return ( |
| 523 | + get_store(context, object) |
| 524 | + .update(credentials=context.credentials, obj=object) |
| 525 | + .unwrap() |
| 526 | + ) |
0 commit comments