From b9886efda35cc8db3ced24efc663ff1852d966c4 Mon Sep 17 00:00:00 2001 From: Serge Smertin <259697+nfx@users.noreply.github.com> Date: Fri, 11 Aug 2023 22:50:52 +0200 Subject: [PATCH] And now nightlies are passing (#80) --- src/uc_migration_toolkit/managers/group.py | 28 +++++-------------- .../managers/inventory/inventorizer.py | 10 +++++-- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/uc_migration_toolkit/managers/group.py b/src/uc_migration_toolkit/managers/group.py index bce693804d..332394ac09 100644 --- a/src/uc_migration_toolkit/managers/group.py +++ b/src/uc_migration_toolkit/managers/group.py @@ -37,24 +37,6 @@ def _find_eligible_groups(self) -> list[str]: logger.info(f"Found {len(eligible_groups)} eligible groups") return [g.display_name for g in eligible_groups] - @staticmethod - def _get_clean_group_info(group: Group, cleanup_keys: list[str] | None = None) -> dict: - """ - Returns a dictionary with group information, excluding some keys - :param group: Group object from SDK - :param cleanup_keys: default (with None) ["id", "externalId", "displayName"] - :return: dictionary with group information - """ - - cleanup_keys = cleanup_keys or ["id", "externalId", "displayName"] - group_info = group.as_dict() - - for key in cleanup_keys: - if key in group_info: - group_info.pop(key) - - return group_info - def _get_group(self, group_name, level: GroupLevel) -> Group | None: # TODO: calling this can cause issues for SCIM backend, cache groups instead method = self._ws.groups.list if level == GroupLevel.WORKSPACE else self._ws.list_account_level_groups @@ -76,9 +58,13 @@ def _get_or_create_backup_group(self, source_group_name: str, source_group: Grou logger.info(f"Backup group {backup_group_name} already exists, no action required") else: logger.info(f"Creating backup group {backup_group_name}") - new_group_payload = self._get_clean_group_info(source_group) - new_group_payload["displayName"] = backup_group_name - backup_group = self._ws.groups.create(**new_group_payload) + backup_group = self._ws.groups.create( + display_name=backup_group_name, + meta=source_group.meta, + entitlements=source_group.entitlements, + roles=source_group.roles, + members=source_group.members, + ) logger.info(f"Backup group {backup_group_name} successfully created") return backup_group diff --git a/src/uc_migration_toolkit/managers/inventory/inventorizer.py b/src/uc_migration_toolkit/managers/inventory/inventorizer.py index 496a6b7f99..e34f66b7e7 100644 --- a/src/uc_migration_toolkit/managers/inventory/inventorizer.py +++ b/src/uc_migration_toolkit/managers/inventory/inventorizer.py @@ -125,7 +125,10 @@ def __init__(self, ws: ImprovedWorkspaceClient): def _preload_tokens(self): try: - return self._ws.token_management.get_token_permissions().access_control_list + # TODO: rewrite with self._ws.token_management.get_token_permissions().access_control_list + return self._ws.api_client.do("GET", "/api/2.0/preview/permissions/authorization/tokens").get( + "access_control_list", [] + ) except DatabricksError as e: logger.warning("Cannot load token permissions due to error:") logger.warning(e) @@ -133,7 +136,10 @@ def _preload_tokens(self): def _preload_passwords(self): try: - return self._ws.users.get_password_permissions().access_control_list + # TODO: rewrite with return self._ws.users.get_password_permissions().access_control_list + return self._ws.api_client.do("GET", "/api/2.0/preview/permissions/authorization/passwords").get( + "access_control_list", [] + ) except DatabricksError as e: logger.error("Cannot load password permissions due to error:") logger.error(e)