Skip to content

Commit

Permalink
Merge pull request #845 from gooddata/snapshot-master-be0ea8ae-to-rel…
Browse files Browse the repository at this point in the history
…/dev

[bot] Merge master/be0ea8ae into rel/dev
  • Loading branch information
yenkins-admin authored Oct 15, 2024
2 parents f5276d9 + be0ea8a commit 68c794f
Show file tree
Hide file tree
Showing 11 changed files with 6,174 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .openapi-generator/custom_templates/model_utils.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
# Workaround for missing OneOf schema support by the generator
# Checks if the defined schema is a subset of received model
# This way we can ensure forward-compatibility support of new fields in API
assert set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())
assert len(set(model_kwargs.keys()).difference(set(oneof_class.openapi_types.keys()))) == 0 or set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())

else:
if issubclass(oneof_class, ModelSimple):
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ services:
GDC_FEATURES_VALUES_ENABLE_ANALYTICAL_DASHBOARD_PERMISSIONS: "true"
GDC_FEATURES_VALUES_ENABLE_METRIC_SQL_AND_DATA_EXPLAIN: 'ENABLED'
GDC_FEATURES_VALUES_ENABLE_ROLLUP_TOTALS: "true"
GDC_FEATURES_VALUES_ENABLE_ROLLUP_TOTALS_FOR_METRICS: "true"
GDC_FEATURES_VALUES_ENABLE_SCHEDULING: "true"
GDC_FEATURES_VALUES_ENABLE_ALERTING: "true"
GDC_FEATURES_VALUES_ENABLE_SMTP: "true"
# In the case of failing tests (HTTP 500), you can increase the memory for the metadata API
# METADATA_API_JAVA_OPTS: "-Xmx1024m -Xms512m"
gooddata-fdw:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ data_sources = sdk.catalog_data_source.list_data_sources()
# type='POSTGRESQL',
# schema='demo',
# url='jdbc:postgresql://localhost:5432/demo',
# enable_caching=False,
# cache_path=None,
# parameters=None,
# decoded_parameters=None,
Expand Down
2 changes: 1 addition & 1 deletion gooddata-api-client/gooddata_api_client/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,7 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
# Workaround for missing OneOf schema support by the generator
# Checks if the defined schema is a subset of received model
# This way we can ensure forward-compatibility support of new fields in API
assert set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())
assert len(set(model_kwargs.keys()).difference(set(oneof_class.openapi_types.keys()))) == 0 or set(oneof_class.openapi_types.keys()) <= set(model_kwargs.keys())

else:
if issubclass(oneof_class, ModelSimple):
Expand Down
4 changes: 4 additions & 0 deletions gooddata-sdk/gooddata_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@
CatalogDeclarativeAnalytics,
CatalogDeclarativeMetric,
)
from gooddata_sdk.catalog.workspace.declarative_model.workspace.analytics_model.export_definition import (
CatalogDeclarativeExportDefinition,
CatalogDeclarativeExportDefinitionRequestPayload,
)
from gooddata_sdk.catalog.workspace.declarative_model.workspace.logical_model.data_filter_references import (
CatalogDeclarativeWorkspaceDataFilterReferences,
)
Expand Down
2 changes: 1 addition & 1 deletion gooddata-sdk/gooddata_sdk/catalog/export/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class ExportRequest(Base):
"""

format: str
execution_result: str
file_name: str
execution_result: Optional[str] = None
settings: Optional[ExportSettings] = None
custom_override: Optional[ExportCustomOverride] = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from __future__ import annotations

from pathlib import Path
from typing import Any, Optional, TypeVar, Union
from typing import Any, Optional, Union

import attr
from attrs import define
from cattrs import global_converter, structure
from gooddata_api_client.model.declarative_analytical_dashboard import DeclarativeAnalyticalDashboard
from gooddata_api_client.model.declarative_analytical_dashboard_extension import DeclarativeAnalyticalDashboardExtension
Expand All @@ -17,14 +18,19 @@
from gooddata_api_client.model.declarative_visualization_object import DeclarativeVisualizationObject

from gooddata_sdk.catalog.base import Base
from gooddata_sdk.catalog.identifier import CatalogUserIdentifier
from gooddata_sdk.catalog.permission.declarative_model.permission import (
CatalogDeclarativeDashboardPermissionsForAssignee,
CatalogDeclarativeDashboardPermissionsForAssigneeRule,
)
from gooddata_sdk.utils import create_directory, get_sorted_yaml_files, read_layout_from_file, write_layout_to_file
from gooddata_sdk.catalog.workspace.declarative_model.workspace.analytics_model.base import (
CatalogAnalyticsBase,
CatalogAnalyticsObjectBase,
)
from gooddata_sdk.catalog.workspace.declarative_model.workspace.analytics_model.export_definition import (
CatalogDeclarativeExportDefinition,
)
from gooddata_sdk.utils import create_directory, get_sorted_yaml_files

T = TypeVar("T", bound="CatalogAnalyticsObjectBase")
AnalyticsObjects = Union[
DeclarativeAnalyticalDashboard,
DeclarativeDashboardPlugin,
Expand All @@ -41,6 +47,7 @@
LAYOUT_METRICS_DIR = "metrics"
LAYOUT_VISUALIZATION_OBJECTS_DIR = "visualization_objects"
ATTRIBUTE_HIERARCHY_OBJECTS_DIR = "attribute_hierarchy_objects"
EXPORT_DEFINITION_DIR = "export_definitions"


@attr.s(auto_attribs=True, kw_only=True)
Expand Down Expand Up @@ -70,7 +77,7 @@ class CatalogDeclarativeAnalyticsLayer(Base):
filter_contexts: list[CatalogDeclarativeFilterContext] = attr.field(factory=list)
metrics: list[CatalogDeclarativeMetric] = attr.field(factory=list)
visualization_objects: list[CatalogDeclarativeVisualizationObject] = attr.field(factory=list)
export_definitions: list[dict] = attr.field(factory=list)
export_definitions: list[CatalogDeclarativeExportDefinition] = attr.field(factory=list)

@staticmethod
def client_class() -> type[DeclarativeAnalyticsLayer]:
Expand Down Expand Up @@ -124,6 +131,12 @@ def get_attribute_hierarchy_folder(analytics_model_folder: Path) -> Path:
create_directory(folder)
return folder

@staticmethod
def get_export_definition_dif(analytics_model_folder: Path) -> Path:
folder = analytics_model_folder / EXPORT_DEFINITION_DIR
create_directory(folder)
return folder

def store_to_disk(self, workspace_folder: Path) -> None:
analytics_model_folder = self.get_analytics_model_folder(workspace_folder)

Expand All @@ -134,6 +147,7 @@ def store_to_disk(self, workspace_folder: Path) -> None:
metrics_folder = self.get_metrics_folder(analytics_model_folder)
visualization_objects_folder = self.get_visualization_objects_folder(analytics_model_folder)
attribute_hierarchy_folder = self.get_attribute_hierarchy_folder(analytics_model_folder)
export_definition_folder = self.get_export_definition_dif(analytical_dashboards_folder)

for analytical_dashboard in self.analytical_dashboards:
analytical_dashboard.store_to_disk(analytical_dashboards_folder)
Expand All @@ -156,6 +170,9 @@ def store_to_disk(self, workspace_folder: Path) -> None:
for attribute_hierarchy in self.attribute_hierarchies:
attribute_hierarchy.store_to_disk(attribute_hierarchy_folder)

for export_definition in self.export_definitions:
export_definition.store_to_disk(export_definition_folder)

@classmethod
def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeAnalyticsLayer:
analytics_model_folder = cls.get_analytics_model_folder(workspace_folder)
Expand All @@ -166,6 +183,7 @@ def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeAnalyticsLa
metrics_folder = cls.get_metrics_folder(analytics_model_folder)
visualization_objects_folder = cls.get_visualization_objects_folder(analytics_model_folder)
attribute_hierarchy_folder = cls.get_attribute_hierarchy_folder(analytics_model_folder)
export_definition_folder = cls.get_export_definition_dif(analytical_dashboards_folder)

analytical_dashboard_files = get_sorted_yaml_files(analytical_dashboards_folder)
analytical_dashboard_extension_files = get_sorted_yaml_files(analytical_dashboard_extensions_folder)
Expand All @@ -174,6 +192,7 @@ def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeAnalyticsLa
metric_files = get_sorted_yaml_files(metrics_folder)
visualization_object_files = get_sorted_yaml_files(visualization_objects_folder)
attribute_hierarchy_files = get_sorted_yaml_files(attribute_hierarchy_folder)
export_definition_files = get_sorted_yaml_files(export_definition_folder)

analytical_dashboards = [
CatalogDeclarativeAnalyticalDashboard.load_from_disk(analytical_dashboard_file)
Expand All @@ -200,6 +219,10 @@ def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeAnalyticsLa
CatalogDeclarativeAttributeHierarchy.load_from_disk(attribute_hierarchy_file)
for attribute_hierarchy_file in attribute_hierarchy_files
]
export_definitions = [
CatalogDeclarativeExportDefinition.load_from_disk(export_definition_file)
for export_definition_file in export_definition_files
]
return cls(
analytical_dashboards=analytical_dashboards,
analytical_dashboard_extensions=analytical_dashboard_extensions,
Expand All @@ -208,41 +231,12 @@ def load_from_disk(cls, workspace_folder: Path) -> CatalogDeclarativeAnalyticsLa
filter_contexts=filter_contexts,
metrics=metrics,
visualization_objects=visualization_objects,
export_definitions=export_definitions,
)


@attr.s(auto_attribs=True, kw_only=True)
class CatalogAnalyticsObjectBase(Base):
id: str

def store_to_disk(self, analytics_folder: Path) -> None:
analytics_file = analytics_folder / f"{self.id}.yaml"
write_layout_to_file(analytics_file, self.to_api().to_dict(camel_case=True))

@classmethod
def load_from_disk(cls: type[T], analytics_file: Path) -> T:
analytics_layout = read_layout_from_file(analytics_file)
return cls.from_dict(analytics_layout)


@attr.s(auto_attribs=True, kw_only=True)
class CatalogAnalyticsBase(CatalogAnalyticsObjectBase):
title: str
content: dict[str, Any]
description: Optional[str] = None
tags: Optional[list[str]] = None


@attr.s(auto_attribs=True, kw_only=True)
class CatalogAnalyticsBaseMeta(CatalogAnalyticsBase):
created_at: Optional[str] = None
created_by: Optional[CatalogUserIdentifier] = None
modified_at: Optional[str] = None
modified_by: Optional[CatalogUserIdentifier] = None


@attr.s(auto_attribs=True, kw_only=True)
class CatalogDeclarativeAnalyticalDashboard(CatalogAnalyticsBaseMeta):
@define(auto_attribs=True, kw_only=True)
class CatalogDeclarativeAnalyticalDashboard(CatalogAnalyticsBase):
permissions: Optional[
list[
Union[
Expand Down Expand Up @@ -274,7 +268,7 @@ def structure_permissions(


@attr.s(auto_attribs=True, kw_only=True)
class CatalogDeclarativeDashboardPlugin(CatalogAnalyticsBaseMeta):
class CatalogDeclarativeDashboardPlugin(CatalogAnalyticsBase):
@staticmethod
def client_class() -> type[DeclarativeDashboardPlugin]:
return DeclarativeDashboardPlugin
Expand All @@ -299,21 +293,21 @@ def client_class() -> type[DeclarativeFilterContext]:


@attr.s(auto_attribs=True, kw_only=True)
class CatalogDeclarativeMetric(CatalogAnalyticsBaseMeta):
class CatalogDeclarativeMetric(CatalogAnalyticsBase):
@staticmethod
def client_class() -> type[DeclarativeMetric]:
return DeclarativeMetric


@attr.s(auto_attribs=True, kw_only=True)
class CatalogDeclarativeVisualizationObject(CatalogAnalyticsBaseMeta):
class CatalogDeclarativeVisualizationObject(CatalogAnalyticsBase):
@staticmethod
def client_class() -> type[DeclarativeVisualizationObject]:
return DeclarativeVisualizationObject


@attr.s(auto_attribs=True, kw_only=True)
class CatalogDeclarativeAttributeHierarchy(CatalogAnalyticsBaseMeta):
class CatalogDeclarativeAttributeHierarchy(CatalogAnalyticsBase):
@staticmethod
def client_class() -> type[DeclarativeAttributeHierarchy]:
return DeclarativeAttributeHierarchy
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# (C) 2024 GoodData Corporation
from pathlib import Path
from typing import Any, Optional, TypeVar

from attrs import define

from gooddata_sdk.catalog.base import Base
from gooddata_sdk.catalog.identifier import CatalogUserIdentifier
from gooddata_sdk.utils import read_layout_from_file, write_layout_to_file

T = TypeVar("T", bound="CatalogAnalyticsObjectBase")


@define(auto_attribs=True, kw_only=True)
class CatalogAnalyticsObjectBase(Base):
id: str

def store_to_disk(self, analytics_folder: Path) -> None:
analytics_file = analytics_folder / f"{self.id}.yaml"
write_layout_to_file(analytics_file, self.to_api().to_dict(camel_case=True))

@classmethod
def load_from_disk(cls: type[T], analytics_file: Path) -> T:
analytics_layout = read_layout_from_file(analytics_file)
return cls.from_dict(analytics_layout)


@define(auto_attribs=True, kw_only=True)
class CatalogAnalyticsBaseMeta(CatalogAnalyticsObjectBase):
created_at: Optional[str] = None
created_by: Optional[CatalogUserIdentifier] = None
modified_at: Optional[str] = None
modified_by: Optional[CatalogUserIdentifier] = None


@define(auto_attribs=True, kw_only=True)
class CatalogAnalyticsBase(CatalogAnalyticsBaseMeta):
title: str
content: dict[str, Any]
description: Optional[str] = None
tags: Optional[list[str]] = None
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# (C) 2024 GoodData Corporation
from typing import Optional

from attrs import define
from gooddata_api_client.model.declarative_export_definition import DeclarativeExportDefinition
from gooddata_api_client.model.declarative_export_definition_request_payload import (
DeclarativeExportDefinitionRequestPayload,
)

from gooddata_sdk import ExportCustomOverride, ExportSettings
from gooddata_sdk.catalog.base import Base
from gooddata_sdk.catalog.workspace.declarative_model.workspace.analytics_model.base import CatalogAnalyticsBaseMeta


@define(auto_attribs=True, kw_only=True)
class CatalogDeclarativeExportDefinitionRequestPayload(Base):
custom_override: Optional[ExportCustomOverride] = None
execution_result: Optional[str] = None
metadata: Optional[dict] = None
related_dashboard_id: Optional[str] = None
settings: Optional[ExportSettings] = None
visualization_object: Optional[str] = None
visualization_object_custom_filters: Optional[list[dict]] = None
file_name: Optional[str] = None
format: Optional[str] = None
dashboard_id: Optional[str] = None

@staticmethod
def client_class() -> type[DeclarativeExportDefinitionRequestPayload]:
return DeclarativeExportDefinitionRequestPayload


@define(auto_attribs=True, kw_only=True)
class CatalogDeclarativeExportDefinition(CatalogAnalyticsBaseMeta):
id: str
title: str
request_payload: CatalogDeclarativeExportDefinitionRequestPayload
description: Optional[str] = None
tags: Optional[list[str]] = None

@staticmethod
def client_class() -> type[DeclarativeExportDefinition]:
return DeclarativeExportDefinition
Loading

0 comments on commit 68c794f

Please sign in to comment.