gooddata-pipelines 1.49.1.dev2__py3-none-any.whl → 1.50.1.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of gooddata-pipelines might be problematic. Click here for more details.
- gooddata_pipelines/__init__.py +7 -1
- gooddata_pipelines/api/gooddata_api.py +0 -54
- gooddata_pipelines/backup_and_restore/backup_manager.py +42 -64
- gooddata_pipelines/backup_and_restore/constants.py +3 -7
- gooddata_pipelines/backup_and_restore/models/storage.py +4 -5
- gooddata_pipelines/provisioning/entities/users/models/permissions.py +23 -79
- gooddata_pipelines/provisioning/entities/users/models/user_groups.py +23 -50
- gooddata_pipelines/provisioning/entities/users/models/users.py +9 -49
- gooddata_pipelines/provisioning/entities/users/permissions.py +14 -6
- gooddata_pipelines/provisioning/entities/users/user_groups.py +7 -1
- gooddata_pipelines/provisioning/entities/users/users.py +3 -0
- gooddata_pipelines/provisioning/entities/workspaces/models.py +16 -15
- gooddata_pipelines/provisioning/entities/workspaces/workspace.py +52 -5
- gooddata_pipelines/provisioning/entities/workspaces/workspace_data_parser.py +9 -6
- gooddata_pipelines/provisioning/provisioning.py +24 -6
- gooddata_pipelines/provisioning/utils/context_objects.py +6 -6
- gooddata_pipelines/provisioning/utils/utils.py +3 -15
- gooddata_pipelines/utils/__init__.py +9 -0
- gooddata_pipelines/utils/rate_limiter.py +64 -0
- {gooddata_pipelines-1.49.1.dev2.dist-info → gooddata_pipelines-1.50.1.dev1.dist-info}/METADATA +2 -2
- {gooddata_pipelines-1.49.1.dev2.dist-info → gooddata_pipelines-1.50.1.dev1.dist-info}/RECORD +23 -21
- {gooddata_pipelines-1.49.1.dev2.dist-info → gooddata_pipelines-1.50.1.dev1.dist-info}/WHEEL +0 -0
- {gooddata_pipelines-1.49.1.dev2.dist-info → gooddata_pipelines-1.50.1.dev1.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -5,10 +5,8 @@ from typing import Any
|
|
|
5
5
|
from gooddata_sdk.catalog.user.entity_model.user import CatalogUser
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
|
|
8
|
-
from gooddata_pipelines.provisioning.utils.utils import SplitMixin
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
class BaseUser(BaseModel, SplitMixin):
|
|
9
|
+
class BaseUser(BaseModel):
|
|
12
10
|
"""Base class containing shared user fields and functionality."""
|
|
13
11
|
|
|
14
12
|
user_id: str
|
|
@@ -18,21 +16,6 @@ class BaseUser(BaseModel, SplitMixin):
|
|
|
18
16
|
auth_id: str | None
|
|
19
17
|
user_groups: list[str]
|
|
20
18
|
|
|
21
|
-
@classmethod
|
|
22
|
-
def _create_from_dict_data(
|
|
23
|
-
cls, user_data: dict[str, Any], delimiter: str = ","
|
|
24
|
-
) -> dict[str, Any]:
|
|
25
|
-
"""Helper method to extract common data from dict."""
|
|
26
|
-
user_groups = cls.split(user_data["user_groups"], delimiter=delimiter)
|
|
27
|
-
return {
|
|
28
|
-
"user_id": user_data["user_id"],
|
|
29
|
-
"firstname": user_data["firstname"],
|
|
30
|
-
"lastname": user_data["lastname"],
|
|
31
|
-
"email": user_data["email"],
|
|
32
|
-
"auth_id": user_data["auth_id"],
|
|
33
|
-
"user_groups": user_groups,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
19
|
@classmethod
|
|
37
20
|
def _create_from_sdk_data(cls, obj: CatalogUser) -> dict[str, Any]:
|
|
38
21
|
"""Helper method to extract common data from SDK object."""
|
|
@@ -68,47 +51,24 @@ class BaseUser(BaseModel, SplitMixin):
|
|
|
68
51
|
)
|
|
69
52
|
|
|
70
53
|
|
|
71
|
-
class
|
|
72
|
-
"""
|
|
73
|
-
|
|
74
|
-
is_active: bool
|
|
75
|
-
|
|
76
|
-
@classmethod
|
|
77
|
-
def from_list_of_dicts(
|
|
78
|
-
cls, data: list[dict[str, Any]], delimiter: str = ","
|
|
79
|
-
) -> list["UserIncrementalLoad"]:
|
|
80
|
-
"""Creates a list of User objects from list of dicts."""
|
|
81
|
-
converted_users = []
|
|
82
|
-
for user in data:
|
|
83
|
-
base_data = cls._create_from_dict_data(user, delimiter)
|
|
84
|
-
base_data["is_active"] = user["is_active"]
|
|
85
|
-
converted_users.append(cls(**base_data))
|
|
86
|
-
return converted_users
|
|
54
|
+
class UserFullLoad(BaseUser):
|
|
55
|
+
"""Input validator for full load of user provisioning."""
|
|
87
56
|
|
|
88
57
|
@classmethod
|
|
89
|
-
def from_sdk_obj(cls, obj: CatalogUser) -> "
|
|
58
|
+
def from_sdk_obj(cls, obj: CatalogUser) -> "UserFullLoad":
|
|
90
59
|
"""Creates GDUserTarget from CatalogUser SDK object."""
|
|
91
60
|
base_data = cls._create_from_sdk_data(obj)
|
|
92
|
-
base_data["is_active"] = True
|
|
93
61
|
return cls(**base_data)
|
|
94
62
|
|
|
95
63
|
|
|
96
|
-
class
|
|
97
|
-
"""
|
|
64
|
+
class UserIncrementalLoad(BaseUser):
|
|
65
|
+
"""Input validator for incremental load of user provisioning."""
|
|
98
66
|
|
|
99
|
-
|
|
100
|
-
def from_list_of_dicts(
|
|
101
|
-
cls, data: list[dict[str, Any]], delimiter: str = ","
|
|
102
|
-
) -> list["UserFullLoad"]:
|
|
103
|
-
"""Creates a list of User objects from list of dicts."""
|
|
104
|
-
converted_users = []
|
|
105
|
-
for user in data:
|
|
106
|
-
base_data = cls._create_from_dict_data(user, delimiter)
|
|
107
|
-
converted_users.append(cls(**base_data))
|
|
108
|
-
return converted_users
|
|
67
|
+
is_active: bool
|
|
109
68
|
|
|
110
69
|
@classmethod
|
|
111
|
-
def from_sdk_obj(cls, obj: CatalogUser) -> "
|
|
70
|
+
def from_sdk_obj(cls, obj: CatalogUser) -> "UserIncrementalLoad":
|
|
112
71
|
"""Creates GDUserTarget from CatalogUser SDK object."""
|
|
113
72
|
base_data = cls._create_from_sdk_data(obj)
|
|
73
|
+
base_data["is_active"] = True
|
|
114
74
|
return cls(**base_data)
|
|
@@ -6,10 +6,10 @@ from typing import TypeVar
|
|
|
6
6
|
|
|
7
7
|
from gooddata_pipelines.api.exceptions import GoodDataApiException
|
|
8
8
|
from gooddata_pipelines.provisioning.entities.users.models.permissions import (
|
|
9
|
+
EntityType,
|
|
9
10
|
PermissionDeclaration,
|
|
10
11
|
PermissionFullLoad,
|
|
11
12
|
PermissionIncrementalLoad,
|
|
12
|
-
PermissionType,
|
|
13
13
|
TargetsPermissionDict,
|
|
14
14
|
WSPermissionsDeclarations,
|
|
15
15
|
)
|
|
@@ -28,12 +28,18 @@ class PermissionProvisioner(
|
|
|
28
28
|
"""Provisioning class for user permissions in GoodData workspaces.
|
|
29
29
|
|
|
30
30
|
This class handles the provisioning of user permissions based on the provided
|
|
31
|
-
source data.
|
|
31
|
+
source data. Use the `full_load` or `incremental_load`
|
|
32
|
+
methods to run the provisioning.
|
|
32
33
|
"""
|
|
33
34
|
|
|
34
35
|
source_group_incremental: list[PermissionIncrementalLoad]
|
|
35
36
|
source_group_full: list[PermissionFullLoad]
|
|
36
37
|
|
|
38
|
+
FULL_LOAD_TYPE: type[PermissionFullLoad] = PermissionFullLoad
|
|
39
|
+
INCREMENTAL_LOAD_TYPE: type[PermissionIncrementalLoad] = (
|
|
40
|
+
PermissionIncrementalLoad
|
|
41
|
+
)
|
|
42
|
+
|
|
37
43
|
def _get_ws_declaration(self, ws_id: str) -> PermissionDeclaration:
|
|
38
44
|
users: TargetsPermissionDict = {}
|
|
39
45
|
user_groups: TargetsPermissionDict = {}
|
|
@@ -47,7 +53,7 @@ class PermissionProvisioner(
|
|
|
47
53
|
)
|
|
48
54
|
target_dict = (
|
|
49
55
|
users
|
|
50
|
-
if permission_type ==
|
|
56
|
+
if permission_type == EntityType.user.value
|
|
51
57
|
else user_groups
|
|
52
58
|
)
|
|
53
59
|
|
|
@@ -105,11 +111,13 @@ class PermissionProvisioner(
|
|
|
105
111
|
self, permission: PermissionFullLoad | PermissionIncrementalLoad
|
|
106
112
|
) -> None:
|
|
107
113
|
"""Validates if the permission is correctly defined."""
|
|
108
|
-
if permission.
|
|
109
|
-
self._api.get_user(
|
|
114
|
+
if permission.entity_type == EntityType.user:
|
|
115
|
+
self._api.get_user(
|
|
116
|
+
permission.entity_id, error_message="User not found"
|
|
117
|
+
)
|
|
110
118
|
else:
|
|
111
119
|
self._api.get_user_group(
|
|
112
|
-
permission.
|
|
120
|
+
permission.entity_id, error_message="User group not found"
|
|
113
121
|
)
|
|
114
122
|
|
|
115
123
|
self._api.get_workspace(
|
|
@@ -21,13 +21,19 @@ class UserGroupProvisioner(
|
|
|
21
21
|
"""Provisioning class for user groups in GoodData workspaces.
|
|
22
22
|
|
|
23
23
|
This class handles the creation, update, and deletion of user groups
|
|
24
|
-
based on the provided source data.
|
|
24
|
+
based on the provided source data. Use the `full_load` or `incremental_load`
|
|
25
|
+
methods to run the provisioning.
|
|
25
26
|
"""
|
|
26
27
|
|
|
27
28
|
source_group_incremental: list[UserGroupIncrementalLoad]
|
|
28
29
|
source_group_full: list[UserGroupFullLoad]
|
|
29
30
|
upstream_user_groups: list[CatalogUserGroup]
|
|
30
31
|
|
|
32
|
+
FULL_LOAD_TYPE: type[UserGroupFullLoad] = UserGroupFullLoad
|
|
33
|
+
INCREMENTAL_LOAD_TYPE: type[UserGroupIncrementalLoad] = (
|
|
34
|
+
UserGroupIncrementalLoad
|
|
35
|
+
)
|
|
36
|
+
|
|
31
37
|
@staticmethod
|
|
32
38
|
def _is_changed(
|
|
33
39
|
group: UserGroupModel, existing_group: CatalogUserGroup
|
|
@@ -30,6 +30,9 @@ class UserProvisioner(Provisioning[UserFullLoad, UserIncrementalLoad]):
|
|
|
30
30
|
source_group_incremental: list[UserIncrementalLoad]
|
|
31
31
|
source_group_full: list[UserFullLoad]
|
|
32
32
|
|
|
33
|
+
FULL_LOAD_TYPE: type[UserFullLoad] = UserFullLoad
|
|
34
|
+
INCREMENTAL_LOAD_TYPE: type[UserIncrementalLoad] = UserIncrementalLoad
|
|
35
|
+
|
|
33
36
|
def __init__(self, host: str, token: str) -> None:
|
|
34
37
|
super().__init__(host, token)
|
|
35
38
|
self.upstream_user_cache: dict[UserId, UserModel] = {}
|
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
# (C) 2025 GoodData Corporation
|
|
2
2
|
"""Module containing models related to workspace provisioning in GoodData Cloud."""
|
|
3
3
|
|
|
4
|
-
from dataclasses import dataclass, field
|
|
5
4
|
from typing import Literal
|
|
6
5
|
|
|
6
|
+
import attrs
|
|
7
7
|
from pydantic import BaseModel, ConfigDict
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
@
|
|
10
|
+
@attrs.define
|
|
11
11
|
class WorkspaceDataMaps:
|
|
12
12
|
"""Dataclass to hold various mappings related to workspace data."""
|
|
13
13
|
|
|
14
|
-
child_to_parent_id_map: dict[str, str] = field(
|
|
15
|
-
workspace_id_to_wdf_map: dict[str, dict[str, list[str]]] = field(
|
|
16
|
-
|
|
14
|
+
child_to_parent_id_map: dict[str, str] = attrs.field(factory=dict)
|
|
15
|
+
workspace_id_to_wdf_map: dict[str, dict[str, list[str]]] = attrs.field(
|
|
16
|
+
factory=dict
|
|
17
17
|
)
|
|
18
|
-
parent_ids: set[str] = field(
|
|
19
|
-
source_ids: set[str] = field(
|
|
20
|
-
workspace_id_to_name_map: dict[str, str] = field(
|
|
21
|
-
upstream_ids: set[str] = field(
|
|
18
|
+
parent_ids: set[str] = attrs.field(factory=set)
|
|
19
|
+
source_ids: set[str] = attrs.field(factory=set)
|
|
20
|
+
workspace_id_to_name_map: dict[str, str] = attrs.field(factory=dict)
|
|
21
|
+
upstream_ids: set[str] = attrs.field(factory=set)
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
class
|
|
25
|
-
"""Model representing input for provisioning of workspaces in GoodData Cloud."""
|
|
26
|
-
|
|
24
|
+
class WorkspaceBase(BaseModel):
|
|
27
25
|
model_config = ConfigDict(coerce_numbers_to_str=True)
|
|
28
26
|
|
|
29
27
|
parent_id: str
|
|
@@ -33,10 +31,13 @@ class WorkspaceFullLoad(BaseModel):
|
|
|
33
31
|
workspace_data_filter_values: list[str] | None = None
|
|
34
32
|
|
|
35
33
|
|
|
36
|
-
class
|
|
37
|
-
"""
|
|
34
|
+
class WorkspaceFullLoad(WorkspaceBase):
|
|
35
|
+
"""Input validator for full load of workspace provisioning."""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class WorkspaceIncrementalLoad(WorkspaceBase):
|
|
39
|
+
"""Input validator for incremental load of workspace provisioning."""
|
|
38
40
|
|
|
39
|
-
# TODO: double check that the model loads the data correctly, write a test
|
|
40
41
|
is_active: bool
|
|
41
42
|
|
|
42
43
|
|
|
@@ -35,11 +35,19 @@ class WorkspaceProvisioner(
|
|
|
35
35
|
source_group_full: list[WorkspaceFullLoad]
|
|
36
36
|
source_group_incremental: list[WorkspaceIncrementalLoad]
|
|
37
37
|
|
|
38
|
+
FULL_LOAD_TYPE: type[WorkspaceFullLoad] = WorkspaceFullLoad
|
|
39
|
+
INCREMENTAL_LOAD_TYPE: type[WorkspaceIncrementalLoad] = (
|
|
40
|
+
WorkspaceIncrementalLoad
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
upstream_group: list[CatalogWorkspace]
|
|
44
|
+
|
|
38
45
|
def __init__(self, *args: str, **kwargs: str) -> None:
|
|
39
46
|
"""Creates an instance of the WorkspaceProvisioner.
|
|
40
47
|
|
|
41
48
|
Calls the superclass constructor and initializes the validator, parser,
|
|
42
|
-
and maps for workspace data.
|
|
49
|
+
and maps for workspace data. Use the `full_load` or `incremental_load`
|
|
50
|
+
methods to run the provisioning.
|
|
43
51
|
"""
|
|
44
52
|
super().__init__(*args, **kwargs)
|
|
45
53
|
self.validator: WorkspaceDataValidator = WorkspaceDataValidator(
|
|
@@ -91,10 +99,11 @@ class WorkspaceProvisioner(
|
|
|
91
99
|
workspace_ids_to_update: set[str],
|
|
92
100
|
child_to_parent_map: dict[str, str],
|
|
93
101
|
workspace_id_to_wdf_map: dict[str, dict[str, list[str]]],
|
|
102
|
+
source_group: list[WorkspaceFullLoad] | list[WorkspaceIncrementalLoad],
|
|
94
103
|
) -> None:
|
|
95
104
|
action: Literal["CREATE", "UPDATE"]
|
|
96
105
|
|
|
97
|
-
for source_workspace in
|
|
106
|
+
for source_workspace in source_group:
|
|
98
107
|
if source_workspace.workspace_id in workspace_ids_to_update:
|
|
99
108
|
action = "UPDATE"
|
|
100
109
|
elif source_workspace.workspace_id in workspace_ids_to_create:
|
|
@@ -199,8 +208,8 @@ class WorkspaceProvisioner(
|
|
|
199
208
|
)
|
|
200
209
|
|
|
201
210
|
# Get upstream children of all parent workspaces.
|
|
202
|
-
self.upstream_group
|
|
203
|
-
self.
|
|
211
|
+
self.upstream_group = self._api.get_panther_children_workspaces(
|
|
212
|
+
self.maps.parent_ids
|
|
204
213
|
)
|
|
205
214
|
|
|
206
215
|
# Set maps that require upstream data.
|
|
@@ -234,6 +243,7 @@ class WorkspaceProvisioner(
|
|
|
234
243
|
self.ids_to_update,
|
|
235
244
|
self.maps.child_to_parent_id_map,
|
|
236
245
|
self.maps.workspace_id_to_wdf_map,
|
|
246
|
+
self.source_group_full,
|
|
237
247
|
)
|
|
238
248
|
|
|
239
249
|
# Check WDF settings of ignored workspaces.
|
|
@@ -259,5 +269,42 @@ class WorkspaceProvisioner(
|
|
|
259
269
|
|
|
260
270
|
def _provision_incremental_load(self) -> None:
|
|
261
271
|
"""Incremental workspace provisioning."""
|
|
272
|
+
# Set the maps based on the source data.
|
|
273
|
+
self.maps = self.parser.set_maps_based_on_source(
|
|
274
|
+
self.maps, self.source_group_incremental
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
# Get upstream children of all parent workspaces.
|
|
278
|
+
self.upstream_group = self._api.get_panther_children_workspaces(
|
|
279
|
+
self.maps.parent_ids
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
# Set maps that require upstream data.
|
|
283
|
+
self.maps = self.parser.set_maps_with_upstream_data(
|
|
284
|
+
self.maps, self.source_group_incremental, self.upstream_group
|
|
285
|
+
)
|
|
262
286
|
|
|
263
|
-
|
|
287
|
+
# Create an instance of WDF manager with the created maps.
|
|
288
|
+
self.wdf_manager = WorkspaceDataFilterManager(self._api, self.maps)
|
|
289
|
+
|
|
290
|
+
# Iterate through the source data and sort workspace ID to groups
|
|
291
|
+
ids_to_update: set[str] = set()
|
|
292
|
+
ids_to_delete: set[str] = set()
|
|
293
|
+
|
|
294
|
+
for workspace in self.source_group_incremental:
|
|
295
|
+
if workspace.is_active:
|
|
296
|
+
ids_to_update.add(workspace.workspace_id)
|
|
297
|
+
else:
|
|
298
|
+
ids_to_delete.add(workspace.workspace_id)
|
|
299
|
+
|
|
300
|
+
self._create_or_update_panther_workspaces(
|
|
301
|
+
set(),
|
|
302
|
+
ids_to_update,
|
|
303
|
+
self.maps.child_to_parent_id_map,
|
|
304
|
+
self.maps.workspace_id_to_wdf_map,
|
|
305
|
+
self.source_group_incremental,
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
self.delete_panther_workspaces(
|
|
309
|
+
ids_to_delete, self.maps.workspace_id_to_name_map
|
|
310
|
+
)
|
|
@@ -9,6 +9,7 @@ from gooddata_sdk.catalog.workspace.entity_model.workspace import (
|
|
|
9
9
|
from gooddata_pipelines.provisioning.entities.workspaces.models import (
|
|
10
10
|
WorkspaceDataMaps,
|
|
11
11
|
WorkspaceFullLoad,
|
|
12
|
+
WorkspaceIncrementalLoad,
|
|
12
13
|
)
|
|
13
14
|
|
|
14
15
|
|
|
@@ -17,7 +18,7 @@ class WorkspaceDataParser:
|
|
|
17
18
|
|
|
18
19
|
@staticmethod
|
|
19
20
|
def _get_id_to_name_map(
|
|
20
|
-
source_group: list[WorkspaceFullLoad],
|
|
21
|
+
source_group: list[WorkspaceFullLoad] | list[WorkspaceIncrementalLoad],
|
|
21
22
|
upstream_group: list[CatalogWorkspace],
|
|
22
23
|
) -> dict[str, str]:
|
|
23
24
|
"""Creates a map of workspace IDs to their names for all known workspaces."""
|
|
@@ -33,7 +34,7 @@ class WorkspaceDataParser:
|
|
|
33
34
|
|
|
34
35
|
@staticmethod
|
|
35
36
|
def _get_child_to_parent_map(
|
|
36
|
-
source_group: list[WorkspaceFullLoad],
|
|
37
|
+
source_group: list[WorkspaceFullLoad] | list[WorkspaceIncrementalLoad],
|
|
37
38
|
) -> dict[str, str]:
|
|
38
39
|
"""Creates a map of child workspace IDs to their parent workspace IDs."""
|
|
39
40
|
child_to_parent_map: dict[str, str] = {
|
|
@@ -45,7 +46,8 @@ class WorkspaceDataParser:
|
|
|
45
46
|
|
|
46
47
|
@staticmethod
|
|
47
48
|
def _get_set_of_ids_from_source(
|
|
48
|
-
source_group: list[WorkspaceFullLoad]
|
|
49
|
+
source_group: list[WorkspaceFullLoad] | list[WorkspaceIncrementalLoad],
|
|
50
|
+
column_name: str,
|
|
49
51
|
) -> set[str]:
|
|
50
52
|
"""Creates a set of unique parent workspace IDs."""
|
|
51
53
|
set_of_ids: set[str] = {
|
|
@@ -64,7 +66,8 @@ class WorkspaceDataParser:
|
|
|
64
66
|
return set_of_ids
|
|
65
67
|
|
|
66
68
|
def _get_child_to_wdfs_map(
|
|
67
|
-
self,
|
|
69
|
+
self,
|
|
70
|
+
source_group: list[WorkspaceFullLoad] | list[WorkspaceIncrementalLoad],
|
|
68
71
|
) -> dict[str, dict[str, list[str]]]:
|
|
69
72
|
"""Creates a map of child workspace IDs to their WDF IDs."""
|
|
70
73
|
# TODO: Use objects or a more transparent data structure instead of this.
|
|
@@ -88,7 +91,7 @@ class WorkspaceDataParser:
|
|
|
88
91
|
def set_maps_based_on_source(
|
|
89
92
|
self,
|
|
90
93
|
map_object: WorkspaceDataMaps,
|
|
91
|
-
source_group: list[WorkspaceFullLoad],
|
|
94
|
+
source_group: list[WorkspaceFullLoad] | list[WorkspaceIncrementalLoad],
|
|
92
95
|
) -> WorkspaceDataMaps:
|
|
93
96
|
"""Creates maps which are dependent on the source group only."""
|
|
94
97
|
map_object.child_to_parent_id_map = self._get_child_to_parent_map(
|
|
@@ -109,7 +112,7 @@ class WorkspaceDataParser:
|
|
|
109
112
|
def set_maps_with_upstream_data(
|
|
110
113
|
self,
|
|
111
114
|
map_object: WorkspaceDataMaps,
|
|
112
|
-
source_group: list[WorkspaceFullLoad],
|
|
115
|
+
source_group: list[WorkspaceFullLoad] | list[WorkspaceIncrementalLoad],
|
|
113
116
|
upstream_group: list[CatalogWorkspace],
|
|
114
117
|
) -> WorkspaceDataMaps:
|
|
115
118
|
"""Creates maps which are dependent on both the source group and upstream group."""
|
|
@@ -24,6 +24,9 @@ class Provisioning(Generic[TFullLoadSourceData, TIncrementalSourceData]):
|
|
|
24
24
|
source_group_full: list[TFullLoadSourceData]
|
|
25
25
|
source_group_incremental: list[TIncrementalSourceData]
|
|
26
26
|
|
|
27
|
+
FULL_LOAD_TYPE: type[TFullLoadSourceData]
|
|
28
|
+
INCREMENTAL_LOAD_TYPE: type[TIncrementalSourceData]
|
|
29
|
+
|
|
27
30
|
def __init__(self, host: str, token: str) -> None:
|
|
28
31
|
self.source_id: set[str] = set()
|
|
29
32
|
self.upstream_id: set[str] = set()
|
|
@@ -80,6 +83,17 @@ class Provisioning(Generic[TFullLoadSourceData, TIncrementalSourceData]):
|
|
|
80
83
|
ids_to_create=ids_to_create,
|
|
81
84
|
)
|
|
82
85
|
|
|
86
|
+
def _validate_source_data_type(
|
|
87
|
+
self,
|
|
88
|
+
source_data: list[TFullLoadSourceData] | list[TIncrementalSourceData],
|
|
89
|
+
model: type[TFullLoadSourceData] | type[TIncrementalSourceData],
|
|
90
|
+
) -> None:
|
|
91
|
+
"""Validates data type of the source data."""
|
|
92
|
+
if not all(isinstance(record, model) for record in source_data):
|
|
93
|
+
raise TypeError(
|
|
94
|
+
f"Not all elements in source data are instances of {model.__name__}"
|
|
95
|
+
)
|
|
96
|
+
|
|
83
97
|
def _provision_incremental_load(self) -> None:
|
|
84
98
|
raise NotImplementedError(
|
|
85
99
|
"Provisioning method to be implemented in the subclass."
|
|
@@ -100,11 +114,13 @@ class Provisioning(Generic[TFullLoadSourceData, TIncrementalSourceData]):
|
|
|
100
114
|
That means:
|
|
101
115
|
- All workspaces declared in the source data are created if missing, or
|
|
102
116
|
updated to match the source data
|
|
103
|
-
- All workspaces not declared
|
|
117
|
+
- All child workspaces not declared under the parent workspace in the
|
|
118
|
+
source data are deleted
|
|
104
119
|
"""
|
|
105
|
-
self.source_group_full = source_data
|
|
106
120
|
|
|
107
121
|
try:
|
|
122
|
+
self._validate_source_data_type(source_data, self.FULL_LOAD_TYPE)
|
|
123
|
+
self.source_group_full = source_data
|
|
108
124
|
self._provision_full_load()
|
|
109
125
|
self.logger.info("Provisioning completed.")
|
|
110
126
|
except Exception as e:
|
|
@@ -116,12 +132,14 @@ class Provisioning(Generic[TFullLoadSourceData, TIncrementalSourceData]):
|
|
|
116
132
|
"""Runs incremental provisioning workflow with the provided source data.
|
|
117
133
|
|
|
118
134
|
Incremental provisioning is used to modify a subset of the upstream workspaces
|
|
119
|
-
based on the source data provided.
|
|
135
|
+
based on the source data provided. Only changes requested in the source
|
|
136
|
+
data will be applied.
|
|
120
137
|
"""
|
|
121
|
-
# TODO: validate the data type of source group at runtime
|
|
122
|
-
self.source_group_incremental = source_data
|
|
123
|
-
|
|
124
138
|
try:
|
|
139
|
+
self._validate_source_data_type(
|
|
140
|
+
source_data, self.INCREMENTAL_LOAD_TYPE
|
|
141
|
+
)
|
|
142
|
+
self.source_group_incremental = source_data
|
|
125
143
|
self._provision_incremental_load()
|
|
126
144
|
self.logger.info("Provisioning completed.")
|
|
127
145
|
except Exception as e:
|
|
@@ -16,10 +16,10 @@ class WorkspaceContext:
|
|
|
16
16
|
wdf_id: str | None = None,
|
|
17
17
|
wdf_values: list[str] | None = None,
|
|
18
18
|
):
|
|
19
|
-
self.workspace_id
|
|
20
|
-
self.workspace_name
|
|
21
|
-
self.wdf_id
|
|
22
|
-
self.wdf_values
|
|
19
|
+
self.workspace_id = workspace_id if workspace_id else "NA"
|
|
20
|
+
self.workspace_name = workspace_name
|
|
21
|
+
self.wdf_id = wdf_id
|
|
22
|
+
self.wdf_values = wdf_values
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class UserContext:
|
|
@@ -28,5 +28,5 @@ class UserContext:
|
|
|
28
28
|
|
|
29
29
|
def __init__(self, user_id: str, user_groups: list[str]):
|
|
30
30
|
"""User context object, stringifies list of user groups"""
|
|
31
|
-
self.user_id
|
|
32
|
-
self.user_groups
|
|
31
|
+
self.user_id = user_id
|
|
32
|
+
self.user_groups = ",".join(user_groups)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"""Module for utilities used in GoodData Pipelines provisioning."""
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import attrs
|
|
6
6
|
from requests import Response
|
|
7
7
|
|
|
8
8
|
|
|
@@ -61,20 +61,8 @@ class AttributesMixin:
|
|
|
61
61
|
return attrs
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def split(string_value: str, delimiter: str = ",") -> list[str]:
|
|
67
|
-
"""
|
|
68
|
-
Splits a string by the given delimiter and returns a list of stripped values.
|
|
69
|
-
If the input is empty, returns an empty list.
|
|
70
|
-
"""
|
|
71
|
-
if not string_value:
|
|
72
|
-
return []
|
|
73
|
-
|
|
74
|
-
return [value.strip() for value in string_value.split(delimiter)]
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
class EntityGroupIds(BaseModel):
|
|
64
|
+
@attrs.define
|
|
65
|
+
class EntityGroupIds:
|
|
78
66
|
ids_in_both_systems: set[str]
|
|
79
67
|
ids_to_delete: set[str]
|
|
80
68
|
ids_to_create: set[str]
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# (C) 2025 GoodData Corporation
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
import threading
|
|
5
|
+
import functools
|
|
6
|
+
from typing import Callable, Any, Literal
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RateLimiter:
|
|
10
|
+
"""
|
|
11
|
+
Rate limiter usable as a decorator and as a context manager.
|
|
12
|
+
- Shared instance decorator: limiter = RateLimiter(); @limiter
|
|
13
|
+
- Per-function decorator: @RateLimiter(calls_per_second=2)
|
|
14
|
+
- Context manager: with RateLimiter(2): ...
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self, calls_per_second: float = 1.0) -> None:
|
|
18
|
+
if calls_per_second <= 0:
|
|
19
|
+
raise ValueError("calls_per_second must be greater than 0")
|
|
20
|
+
|
|
21
|
+
self.calls_per_second = calls_per_second
|
|
22
|
+
self.min_interval = 1.0 / calls_per_second
|
|
23
|
+
|
|
24
|
+
self._lock = threading.Lock()
|
|
25
|
+
self._last_call_time = 0.0
|
|
26
|
+
|
|
27
|
+
def wait_if_needed(self) -> float:
|
|
28
|
+
"""Sleep if needed to maintain the rate limit, return actual sleep time."""
|
|
29
|
+
with self._lock:
|
|
30
|
+
now = time.monotonic()
|
|
31
|
+
since_last = now - self._last_call_time
|
|
32
|
+
|
|
33
|
+
if since_last < self.min_interval:
|
|
34
|
+
sleep_time = self.min_interval - since_last
|
|
35
|
+
time.sleep(sleep_time)
|
|
36
|
+
self._last_call_time = time.monotonic()
|
|
37
|
+
return sleep_time
|
|
38
|
+
else:
|
|
39
|
+
self._last_call_time = now
|
|
40
|
+
return 0.0
|
|
41
|
+
|
|
42
|
+
# Decorator support
|
|
43
|
+
def __call__(self, func: Callable[..., Any]) -> Callable[..., Any]:
|
|
44
|
+
@functools.wraps(func)
|
|
45
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
46
|
+
self.wait_if_needed()
|
|
47
|
+
return func(*args, **kwargs)
|
|
48
|
+
|
|
49
|
+
return wrapper
|
|
50
|
+
|
|
51
|
+
# Context manager support
|
|
52
|
+
def __enter__(self) -> "RateLimiter":
|
|
53
|
+
self.wait_if_needed()
|
|
54
|
+
return self
|
|
55
|
+
|
|
56
|
+
def __exit__(
|
|
57
|
+
self, exc_type: Any, exc_val: Any, exc_tb: Any
|
|
58
|
+
) -> Literal[False]:
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
def reset(self) -> None:
|
|
62
|
+
"""Reset the limiter (useful in tests)."""
|
|
63
|
+
with self._lock:
|
|
64
|
+
self._last_call_time = 0.0
|
{gooddata_pipelines-1.49.1.dev2.dist-info → gooddata_pipelines-1.50.1.dev1.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gooddata-pipelines
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.50.1.dev1
|
|
4
4
|
Summary: GoodData Cloud lifecycle automation pipelines
|
|
5
5
|
Author-email: GoodData <support@gooddata.com>
|
|
6
6
|
License: MIT
|
|
@@ -8,7 +8,7 @@ License-File: LICENSE.txt
|
|
|
8
8
|
Requires-Python: >=3.10
|
|
9
9
|
Requires-Dist: boto3-stubs<2.0.0,>=1.39.3
|
|
10
10
|
Requires-Dist: boto3<2.0.0,>=1.39.3
|
|
11
|
-
Requires-Dist: gooddata-sdk~=1.
|
|
11
|
+
Requires-Dist: gooddata-sdk~=1.50.1.dev1
|
|
12
12
|
Requires-Dist: pydantic<3.0.0,>=2.11.3
|
|
13
13
|
Requires-Dist: requests<3.0.0,>=2.32.3
|
|
14
14
|
Requires-Dist: types-pyyaml<7.0.0,>=6.0.12.20250326
|