|
4 | 4 | from typing import Any, Callable, Optional, Union |
5 | 5 |
|
6 | 6 | from gooddata_api_client.exceptions import NotFoundException |
| 7 | +from gooddata_api_client.model.slides_export_request import SlidesExportRequest as SlidesExportRequestApi |
7 | 8 | from gooddata_api_client.model.tabular_export_request import TabularExportRequest |
8 | 9 | from gooddata_api_client.model.visual_export_request import VisualExportRequest |
9 | 10 |
|
10 | 11 | from gooddata_sdk.catalog.catalog_service_base import CatalogServiceBase |
11 | 12 | from gooddata_sdk.catalog.export.request import ( |
12 | 13 | ExportRequest, |
13 | 14 | ExportSettings, |
| 15 | + SlidesExportRequest, |
14 | 16 | ) |
15 | 17 | from gooddata_sdk.client import GoodDataApiClient |
16 | 18 | from gooddata_sdk.visualization import VisualizationService |
@@ -140,7 +142,7 @@ def _dashboard_id_exists(self, workspace_id: str, dashboard_id: str) -> bool: |
140 | 142 | def _export_common( |
141 | 143 | self, |
142 | 144 | workspace_id: str, |
143 | | - request: Union[VisualExportRequest, TabularExportRequest], |
| 145 | + request: Union[VisualExportRequest, TabularExportRequest, SlidesExportRequestApi], |
144 | 146 | file_path: Path, |
145 | 147 | create_func: Callable, |
146 | 148 | get_func: Callable, |
@@ -314,3 +316,33 @@ def export_tabular_by_visualization_id( |
314 | 316 | retry=retry, |
315 | 317 | max_retry=max_retry, |
316 | 318 | ) |
| 319 | + |
| 320 | + def export_slides( |
| 321 | + self, |
| 322 | + workspace_id: str, |
| 323 | + request: SlidesExportRequest, |
| 324 | + store_path: Union[str, Path] = Path.cwd(), |
| 325 | + timeout: float = 60.0, |
| 326 | + retry: float = 0.2, |
| 327 | + max_retry: float = 5.0, |
| 328 | + ) -> None: |
| 329 | + """ |
| 330 | + Exports slides based on slide export request. |
| 331 | +
|
| 332 | + Args: |
| 333 | + workspace_id (str): The workspace id from which the visualization is to be exported. |
| 334 | + request (SlidesExportRequest): The request object containing the export parameters. |
| 335 | + store_path (Union[str, Path], optional): The path to store the exported file. Default to Path.cwd(). |
| 336 | + timeout (float, optional): The maximum time to wait for the export to finish. Defaults to 60.0. |
| 337 | + retry (float, optional): |
| 338 | + Initial wait time (in seconds) before retrying to get the exported content. Defaults to 0.2. |
| 339 | + max_retry (float, optional): The maximum retry wait time (in seconds). Defaults to 5.0. |
| 340 | +
|
| 341 | + Returns: |
| 342 | + None |
| 343 | + """ |
| 344 | + store_path = store_path if isinstance(store_path, Path) else Path(store_path) |
| 345 | + file_path = store_path / f"{request.file_name}.{request.format.lower()}" |
| 346 | + create_func = self._actions_api.create_slides_export |
| 347 | + get_func = self._actions_api.get_slides_export |
| 348 | + self._export_common(workspace_id, request.to_api(), file_path, create_func, get_func, timeout, retry, max_retry) |
0 commit comments