Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gooddata-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
"brotli==1.2.1",
"requests>=2.33.0,<3.0.0",
"python-dotenv>=1.2.2,<2.0.0",
"gooddata-code-convertors>=11.70.0a1",
"gooddata-code-convertors>=11.71.0a1",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
3 changes: 3 additions & 0 deletions packages/gooddata-sdk/src/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
ExportRequest,
ExportSettings,
GrandTotalsPosition,
ImageExportRequest,
SlidesExportRequest,
VisualExportRequest,
)
Expand Down Expand Up @@ -597,6 +598,7 @@
"HLLType": "gooddata_sdk.catalog.organization.service",
"HLL_TYPE_SETTING_ID": "gooddata_sdk.catalog.organization.service",
"HLL_TYPE_SETTING_TYPE": "gooddata_sdk.catalog.organization.service",
"ImageExportRequest": "gooddata_sdk.catalog.export.request",
"InlineFilter": "gooddata_sdk.compute.model.filter",
"InlineMetric": "gooddata_sdk.compute.model.metric",
"KeyPairCredentials": "gooddata_sdk.catalog.entity",
Expand Down Expand Up @@ -875,6 +877,7 @@
"HLLType",
"HLL_TYPE_SETTING_ID",
"HLL_TYPE_SETTING_TYPE",
"ImageExportRequest",
"InlineFilter",
"InlineMetric",
"KeyPairCredentials",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
from __future__ import annotations

from typing import Literal
from warnings import warn

from attrs import define
from gooddata_api_client.model.custom_label import CustomLabel as ApiCustomLabel
from gooddata_api_client.model.custom_metric import CustomMetric as ApiCustomMetric
from gooddata_api_client.model.custom_override import CustomOverride as ApiCustomOverride
from gooddata_api_client.model.image_export_request import ImageExportRequest as ImageExportRequestApi
from gooddata_api_client.model.settings import Settings as ApiSettings
from gooddata_api_client.model.slides_export_request import SlidesExportRequest as SlidesExportRequestApi
from gooddata_api_client.model.tabular_export_request import TabularExportRequest
Expand Down Expand Up @@ -137,6 +139,8 @@ class SlidesExportRequest(Base):
dashboard_id (str): Dashboard identifier.
file_name (str): File name to be used for retrieving the PDF document.
metadata (Optional[Dict[str, bool]]): Optional dictionary containing settings for the export request.
template_id (Optional[str]): Export template identifier.
templateId (Optional[str]): Deprecated, use template_id.
"""

file_name: str
Expand All @@ -145,7 +149,16 @@ class SlidesExportRequest(Base):
widget_ids: list[str] | None = None
visualization_ids: list[str] | None = None
metadata: dict | None = None
template_id: str | None = None
templateId: str | None = None
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
timezone_id: str | None = None

def __attrs_post_init__(self) -> None:
if self.templateId is not None:
warn("templateId is deprecated, use template_id", DeprecationWarning, stacklevel=3)
if self.template_id is None:
self.template_id = self.templateId
self.templateId = None

@staticmethod
def client_class() -> type[SlidesExportRequestApi]:
Expand All @@ -155,3 +168,28 @@ def client_class() -> type[SlidesExportRequestApi]:
type[SlidesExportRequestApi]: SlidesExportRequestApi class
"""
return SlidesExportRequestApi


@define(kw_only=True)
class ImageExportRequest(Base):
"""
ImageExportRequest class is used to export dashboard widgets as images.
Attributes:
dashboard_id (str): Dashboard identifier.
file_name (str): File name of the exported image.
widget_ids (list[str]): Widgets to export.
format (str): Image format, PNG.
metadata (Optional[dict]): Free-form metadata of the request.
timezone_id (Optional[str]): Time zone the export evaluates dates in.
"""

dashboard_id: str
file_name: str
widget_ids: list[str]
format: Literal["PNG"] = "PNG"
metadata: dict | None = None
timezone_id: str | None = None

@staticmethod
def client_class() -> type[ImageExportRequestApi]:
return ImageExportRequestApi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
declarative_dataset_to_yaml,
declarative_date_instance_to_yaml,
declarative_metric_to_yaml,
declarative_parameter_to_yaml,
Comment thread
jeskepetr marked this conversation as resolved.
Resolved
declarative_plugin_to_yaml,
declarative_publisher_document_template_to_yaml_v2,
declarative_publisher_document_to_yaml_v2,
Expand All @@ -22,6 +23,7 @@
yaml_dataset_to_declarative,
yaml_date_dataset_to_declarative,
yaml_metric_to_declarative,
yaml_parameter_to_declarative,
yaml_plugin_to_declarative,
yaml_publisher_document_template_to_declarative_v2,
yaml_publisher_document_to_declarative_v2,
Expand Down Expand Up @@ -70,6 +72,7 @@
"dashboard",
"plugin",
"attribute_hierarchy",
"parameter",
"document",
"document_template",
"page_template",
Expand Down Expand Up @@ -196,6 +199,11 @@ def aac_dashboard_to_declarative(
return yaml_dashboard_to_declarative(ent, aac)


def aac_parameter_to_declarative(aac: dict[str, Any]) -> dict[str, Any]:
"""Convert an AAC parameter dict to declarative format."""
return yaml_parameter_to_declarative(aac)


def aac_plugin_to_declarative(aac: dict[str, Any]) -> dict[str, Any]:
"""Convert an AAC plugin dict to declarative format."""
return yaml_plugin_to_declarative(aac)
Expand Down Expand Up @@ -294,6 +302,11 @@ def declarative_dashboard_to_aac(
return declarative_dashboard_to_yaml(ent, declarative)


def declarative_parameter_to_aac(declarative: dict[str, Any]) -> dict[str, Any]:
"""Convert a declarative parameter dict to AAC format."""
return declarative_parameter_to_yaml(declarative)


def declarative_plugin_to_aac(declarative: dict[str, Any]) -> dict[str, Any]:
"""Convert a declarative plugin dict to AAC format."""
return declarative_plugin_to_yaml(declarative)
Expand Down Expand Up @@ -359,6 +372,7 @@ def detect_yaml_format(path: Path) -> Literal["aac", "declarative"]:
"dashboards",
"plugins",
"attributeHierarchies",
"parameters",
"documents",
"documentTemplates",
"pageTemplates",
Expand Down Expand Up @@ -436,6 +450,7 @@ def load_aac_workspace_from_disk(
analytical_dashboards: list[dict[str, Any]] = []
dashboard_plugins: list[dict[str, Any]] = []
attribute_hierarchies: list[dict[str, Any]] = []
parameters: list[dict[str, Any]] = []
documents: list[dict[str, Any]] = []
document_templates: list[dict[str, Any]] = []
page_templates: list[dict[str, Any]] = []
Expand All @@ -461,6 +476,8 @@ def load_aac_workspace_from_disk(
dashboard_plugins.append(aac_plugin_to_declarative(aac))
case "attribute_hierarchy":
attribute_hierarchies.append(aac_attribute_hierarchy_to_declarative(aac))
case "parameter":
parameters.append(aac_parameter_to_declarative(aac))
case "document":
documents.append(aac_document_to_declarative(aac))
case "document_template":
Expand Down Expand Up @@ -491,6 +508,8 @@ def load_aac_workspace_from_disk(
analytics["dashboardPlugins"] = dashboard_plugins
if attribute_hierarchies:
analytics["attributeHierarchyObjects"] = attribute_hierarchies
if parameters:
analytics["parameters"] = parameters
if documents:
analytics["documents"] = documents
if document_templates:
Expand Down Expand Up @@ -520,7 +539,7 @@ def store_aac_workspace_to_disk(model: CatalogDeclarativeWorkspaceModel, source_
"""Convert a declarative workspace model to AAC YAML files and write to disk.

Creates typed subdirectories (datasets/, metrics/, visualisations/, dashboards/,
plugins/, attributeHierarchies/, documents/, documentTemplates/, pageTemplates/)
plugins/, attributeHierarchies/, parameters/, documents/, documentTemplates/, pageTemplates/)
under source_dir.

Raises:
Expand Down Expand Up @@ -568,6 +587,10 @@ def store_aac_workspace_to_disk(model: CatalogDeclarativeWorkspaceModel, source_
result = declarative_attribute_hierarchy_to_aac(hierarchy)
_write_aac_file(source_dir, "attributeHierarchies", hierarchy["id"], result["content"])

for parameter in analytics.get("parameters", []):
Comment thread
jeskepetr marked this conversation as resolved.
Resolved
result = declarative_parameter_to_aac(parameter)
_write_aac_file(source_dir, "parameters", parameter["id"], result["content"])
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

for document_id, result in documents:
_write_aac_file(source_dir, "documents", document_id, result["content"])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
from typing import Any

from attrs import define, field
from gooddata_api_client.model.automation_external_recipient import AutomationExternalRecipient
from gooddata_api_client.model.automation_image_export import AutomationImageExport
from gooddata_api_client.model.automation_schedule import AutomationSchedule
from gooddata_api_client.model.automation_slides_export import AutomationSlidesExport
from gooddata_api_client.model.automation_tabular_export import AutomationTabularExport
from gooddata_api_client.model.automation_visual_export import AutomationVisualExport
from gooddata_api_client.model.declarative_automation import DeclarativeAutomation

from gooddata_sdk.catalog.base import Base
from gooddata_sdk.catalog.export.request import (
ExportRequest,
ImageExportRequest,
SlidesExportRequest,
VisualExportRequest,
)
from gooddata_sdk.catalog.identifier import (
CatalogDeclarativeAnalyticalDashboardIdentifier,
CatalogExportDefinitionIdentifier,
CatalogNotificationChannelIdentifier,
CatalogUserIdentifier,
Expand Down Expand Up @@ -51,6 +57,33 @@ def client_class() -> builtins.type[AutomationVisualExport]:
return AutomationVisualExport


@define(kw_only=True)
class CatalogAutomationImageExport(Base):
request_payload: ImageExportRequest

@staticmethod
def client_class() -> builtins.type[AutomationImageExport]:
return AutomationImageExport


@define(kw_only=True)
class CatalogAutomationSlidesExport(Base):
request_payload: SlidesExportRequest

@staticmethod
def client_class() -> builtins.type[AutomationSlidesExport]:
return AutomationSlidesExport


@define(kw_only=True)
class CatalogAutomationExternalRecipient(Base):
email: str

@staticmethod
def client_class() -> builtins.type[AutomationExternalRecipient]:
return AutomationExternalRecipient


@define(kw_only=True)
class CatalogDeclarativeAutomation(CatalogAnalyticsBaseMeta):
description: str | None = None
Expand All @@ -65,6 +98,11 @@ class CatalogDeclarativeAutomation(CatalogAnalyticsBaseMeta):
schedule: CatalogAutomationSchedule | None = None
tabular_exports: list[CatalogAutomationTabularExport] | None = None
visual_exports: list[CatalogAutomationVisualExport] | None = None
image_exports: list[CatalogAutomationImageExport] | None = None
slides_exports: list[CatalogAutomationSlidesExport] | None = None
external_recipients: list[CatalogAutomationExternalRecipient] | None = None
analytical_dashboard: CatalogDeclarativeAnalyticalDashboardIdentifier | None = None
evaluation_mode: str | None = None

@staticmethod
def client_class() -> builtins.type[DeclarativeAutomation]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any
from xml.etree import ElementTree as ET

import attrs
import yaml
from gooddata_sdk import (
BasicCredentials,
Expand Down Expand Up @@ -1081,7 +1082,8 @@ def test_layout_automations(test_config):
]
sdk.catalog_workspace.put_declarative_automations(workspace_id, automations_expected)
automations_o = sdk.catalog_workspace.get_declarative_automations(workspace_id)
assert automations_expected == automations_o
# The server fills in the default evaluation mode.
assert [attrs.evolve(a, evaluation_mode="PER_RECIPIENT") for a in automations_expected] == automations_o
finally:
safe_delete(sdk.catalog_workspace.put_declarative_automations, workspace_id, [])
safe_delete(sdk.catalog_organization.put_declarative_notification_channels, [])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# (C) 2026 GoodData Corporation
from __future__ import annotations

from pathlib import Path
from typing import Any

from gooddata_sdk.catalog.workspace.aac import load_aac_workspace_from_disk, store_aac_workspace_to_disk
from gooddata_sdk.catalog.workspace.declarative_model.workspace.workspace import CatalogDeclarativeWorkspaceModel
from gooddata_sdk.utils import read_layout_from_file

_STRING = {
"id": "scenario",
"title": "Scenario",
"description": "Planning scenario",
"tags": ["planning"],
"content": {"type": "STRING", "defaultValue": "Actual"},
}
_NUMBER = {
"id": "discount_rate",
"title": "Discount rate",
"description": "",
"tags": [],
"content": {"type": "NUMBER", "defaultValue": 0.5},
}
_PERIOD = {
"id": "last_13_months",
"title": "Last 13 months",
"description": "",
"tags": [],
"content": {"type": "DATE_RANGE", "defaultValue": {"granularity": "MONTH", "from": "2024-11", "to": "2025-11"}},
}
_OPEN_PERIOD = {
"id": "since_2024",
"title": "Since 2024",
"description": "",
"tags": [],
"content": {"type": "DATE_RANGE", "defaultValue": {"granularity": "YEAR", "from": "2024"}},
}
_CODE_PARAMETERS = [_STRING, _NUMBER, _PERIOD, _OPEN_PERIOD]


def _model(parameters: list[dict[str, Any]]) -> CatalogDeclarativeWorkspaceModel:
return CatalogDeclarativeWorkspaceModel.from_dict({"analytics": {"parameters": parameters}})


def _parameters(model: CatalogDeclarativeWorkspaceModel) -> list[dict[str, Any]]:
return model.to_dict(camel_case=True).get("analytics", {}).get("parameters", [])


def test_parameters_round_trip_through_aac(tmp_path: Path) -> None:
store_aac_workspace_to_disk(_model(_CODE_PARAMETERS), tmp_path)

for parameter in _CODE_PARAMETERS:
stored = read_layout_from_file(tmp_path / "parameters" / f"{parameter['id']}.yaml")
assert stored["type"] == "parameter"
assert stored["definition"]["type"] == parameter["content"]["type"]
loaded = sorted(_parameters(load_aac_workspace_from_disk(tmp_path)), key=lambda p: p["id"])
assert loaded == sorted(_CODE_PARAMETERS, key=lambda p: p["id"])
Loading
Loading