Skip to content
Closed
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
1 change: 1 addition & 0 deletions packages/gooddata-sdk/src/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
CatalogDeclarativeExportDefinitionRequestPayload,
)
from gooddata_sdk.catalog.workspace.declarative_model.workspace.automation import (
CatalogAutomationAlert,
CatalogAutomationSchedule,
CatalogDeclarativeAutomation,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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]:
Expand Down
28 changes: 28 additions & 0 deletions packages/gooddata-sdk/tests/catalog/test_catalog_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import yaml
from gooddata_sdk import (
BasicCredentials,
CatalogAutomationAlert,
CatalogAutomationSchedule,
CatalogDataSourcePostgres,
CatalogDeclarativeAutomation,
Expand Down Expand Up @@ -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"
Loading