Skip to content

Commit e7d7845

Browse files
committed
feat(gooddata-pipelines): add ldm extension logic
1 parent 880b8de commit e7d7845

20 files changed

+1985
-0
lines changed

gooddata-pipelines/gooddata_pipelines/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
from .backup_and_restore.storage.local_storage import LocalStorage
1414
from .backup_and_restore.storage.s3_storage import S3Storage
1515

16+
# -------- LDM Extension --------
17+
from .ldm_extension.ldm_extension_manager import LdmExtensionManager
18+
from .ldm_extension.models.custom_data_object import (
19+
ColumnDataType,
20+
CustomDatasetDefinition,
21+
CustomFieldDefinition,
22+
CustomFieldType,
23+
)
24+
1625
# -------- Provisioning --------
1726
from .provisioning.entities.user_data_filters.models.udf_models import (
1827
UserDataFilterFullLoad,
@@ -65,5 +74,10 @@
6574
"UserDataFilterProvisioner",
6675
"UserDataFilterFullLoad",
6776
"EntityType",
77+
"LdmExtensionManager",
78+
"CustomDatasetDefinition",
79+
"CustomFieldDefinition",
80+
"ColumnDataType",
81+
"CustomFieldType",
6882
"__version__",
6983
]

gooddata-pipelines/gooddata_pipelines/api/gooddata_api.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,70 @@ def get_automations(self, workspace_id: str) -> requests.Response:
174174
)
175175
return self._get(endpoint)
176176

177+
def get_all_metrics(self, workspace_id: str) -> requests.Response:
178+
"""Get all metrics from the specified workspace.
179+
180+
Args:
181+
workspace_id (str): The ID of the workspace to retrieve metrics from.
182+
Returns:
183+
requests.Response: The response containing the metrics.
184+
"""
185+
endpoint = f"/entities/workspaces/{workspace_id}/metrics"
186+
headers = {**self.headers, "X-GDC-VALIDATE-RELATIONS": "true"}
187+
return self._get(endpoint, headers=headers)
188+
189+
def get_all_visualization_objects(
190+
self, workspace_id: str
191+
) -> requests.Response:
192+
"""Get all visualizations from the specified workspace.
193+
194+
Args:
195+
workspace_id (str): The ID of the workspace to retrieve visualizations from.
196+
Returns:
197+
requests.Response: The response containing the visualizations.
198+
"""
199+
endpoint = f"/entities/workspaces/{workspace_id}/visualizationObjects"
200+
headers = {**self.headers, "X-GDC-VALIDATE-RELATIONS": "true"}
201+
return self._get(endpoint, headers=headers)
202+
203+
def get_all_dashboards(self, workspace_id: str) -> requests.Response:
204+
"""Get all dashboards from the specified workspace.
205+
206+
Args:
207+
workspace_id (str): The ID of the workspace to retrieve dashboards from.
208+
Returns:
209+
requests.Response: The response containing the dashboards.
210+
"""
211+
endpoint = f"/entities/workspaces/{workspace_id}/analyticalDashboards"
212+
headers = {**self.headers, "X-GDC-VALIDATE-RELATIONS": "true"}
213+
return self._get(endpoint, headers=headers)
214+
215+
def get_workspace_layout(self, workspace_id: str) -> requests.Response:
216+
"""Get the layout of the specified workspace.
217+
218+
Args:
219+
workspace_id (str): The ID of the workspace to retrieve the layout for.
220+
Returns:
221+
requests.Response: The response containing the workspace layout.
222+
"""
223+
endpoint = f"/layout/workspaces/{workspace_id}"
224+
return self._get(endpoint)
225+
226+
def put_workspace_layout(
227+
self, workspace_id: str, layout: dict[str, Any]
228+
) -> requests.Response:
229+
"""Update the layout of the specified workspace.
230+
231+
Args:
232+
workspace_id (str): The ID of the workspace to update.
233+
layout (dict[str, Any]): The new layout to set for the workspace.
234+
Returns:
235+
requests.Response: The response from the server after updating the layout.
236+
"""
237+
endpoint = f"/layout/workspaces/{workspace_id}"
238+
headers = {**self.headers, "Content-Type": "application/json"}
239+
return self._put(endpoint, data=layout, headers=headers)
240+
177241
def _get(
178242
self, endpoint: str, headers: dict[str, str] | None = None
179243
) -> requests.Response:
@@ -253,3 +317,15 @@ def _delete(
253317
url = self._get_url(endpoint)
254318

255319
return requests.delete(url, headers=self.headers, timeout=TIMEOUT)
320+
321+
@staticmethod
322+
def raise_if_response_not_ok(*responses: requests.Response) -> None:
323+
"""Check if responses from API calls are OK.
324+
325+
Raises ValueError if any response is not OK (status code not 2xx).
326+
"""
327+
for response in responses:
328+
if not response.ok:
329+
raise ValueError(
330+
f"Request to {response.url} failed with status code {response.status_code}: {response.text}"
331+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# (C) 2025 GoodData Corporation

0 commit comments

Comments
 (0)