diff --git a/packages/gooddata-sdk/src/gooddata_sdk/__init__.py b/packages/gooddata-sdk/src/gooddata_sdk/__init__.py index d268f9ebf..11b4753ee 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/__init__.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/__init__.py @@ -191,6 +191,7 @@ CatalogDeclarativeExportDefinitionRequestPayload, ) from gooddata_sdk.catalog.workspace.declarative_model.workspace.automation import ( + CatalogAutomationAlert, CatalogAutomationSchedule, CatalogDeclarativeAutomation, ) diff --git a/packages/gooddata-sdk/src/gooddata_sdk/catalog/workspace/declarative_model/workspace/automation.py b/packages/gooddata-sdk/src/gooddata_sdk/catalog/workspace/declarative_model/workspace/automation.py index 079fd90a8..facc3dcd7 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/catalog/workspace/declarative_model/workspace/automation.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/catalog/workspace/declarative_model/workspace/automation.py @@ -1,8 +1,11 @@ # (C) 2024 GoodData Corporation +from __future__ import annotations + import builtins from typing import Any from attrs import define, field +from gooddata_api_client.model.automation_alert import AutomationAlert from gooddata_api_client.model.automation_schedule import AutomationSchedule from gooddata_api_client.model.automation_tabular_export import AutomationTabularExport from gooddata_api_client.model.automation_visual_export import AutomationVisualExport @@ -21,6 +24,16 @@ from gooddata_sdk.catalog.workspace.declarative_model.workspace.analytics_model.base import CatalogAnalyticsBaseMeta +@define(kw_only=True) +class CatalogAutomationAlert(Base): + trigger: str | None = None + interval: str | None = None + + @staticmethod + def client_class() -> builtins.type[AutomationAlert]: + return AutomationAlert + + @define(kw_only=True) class CatalogAutomationSchedule(Base): cron: str @@ -65,6 +78,7 @@ class CatalogDeclarativeAutomation(CatalogAnalyticsBaseMeta): schedule: CatalogAutomationSchedule | None = None tabular_exports: list[CatalogAutomationTabularExport] | None = None visual_exports: list[CatalogAutomationVisualExport] | None = None + alert: CatalogAutomationAlert | None = None @staticmethod def client_class() -> builtins.type[DeclarativeAutomation]: diff --git a/packages/gooddata-sdk/tests/catalog/test_catalog_workspace.py b/packages/gooddata-sdk/tests/catalog/test_catalog_workspace.py index cd056817b..2840859b3 100644 --- a/packages/gooddata-sdk/tests/catalog/test_catalog_workspace.py +++ b/packages/gooddata-sdk/tests/catalog/test_catalog_workspace.py @@ -8,6 +8,7 @@ import yaml from gooddata_sdk import ( BasicCredentials, + CatalogAutomationAlert, CatalogAutomationSchedule, CatalogDataSourcePostgres, CatalogDeclarativeAutomation, @@ -1032,3 +1033,30 @@ def test_layout_filter_views(test_config): assert filter_views_expected == filter_views_o finally: safe_delete(sdk.catalog_workspace.put_declarative_filter_views, workspace_id, []) + + +def test_catalog_automation_alert_serialization(): + alert = CatalogAutomationAlert(trigger="ONCE_PER_INTERVAL", interval="DAY") + api_model = alert.to_api() + result = CatalogAutomationAlert.from_api(api_model.to_dict(camel_case=False)) + assert result.trigger == "ONCE_PER_INTERVAL" + assert result.interval == "DAY" + + +def test_catalog_automation_alert_defaults(): + alert = CatalogAutomationAlert() + assert alert.trigger is None + assert alert.interval is None + + +def test_catalog_declarative_automation_with_alert(): + automation = CatalogDeclarativeAutomation( + id="test-automation", + title="Test Automation", + alert=CatalogAutomationAlert(trigger="ONCE_PER_INTERVAL", interval="WEEK"), + ) + api_model = automation.to_api() + result = CatalogDeclarativeAutomation.from_api(api_model.to_dict(camel_case=False)) + assert result.alert is not None + assert result.alert.trigger == "ONCE_PER_INTERVAL" + assert result.alert.interval == "WEEK"