From e0ab45a044740d6527103e815024b4fc9588cb5a Mon Sep 17 00:00:00 2001 From: Jan Kadlec Date: Fri, 21 Mar 2025 09:59:26 +0100 Subject: [PATCH] feat: add other params for InlineFilter JIRA: F1-1181 risk: low --- .../gooddata_sdk/compute/model/base.py | 4 ++-- .../gooddata_sdk/compute/model/filter.py | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gooddata-sdk/gooddata_sdk/compute/model/base.py b/gooddata-sdk/gooddata_sdk/compute/model/base.py index d350b64d7..753897313 100644 --- a/gooddata-sdk/gooddata_sdk/compute/model/base.py +++ b/gooddata-sdk/gooddata_sdk/compute/model/base.py @@ -71,10 +71,10 @@ def as_api_model(self) -> OpenApiModel: class Filter(ExecModelEntity): - def __init__(self) -> None: + def __init__(self, _apply_on_result: Optional[bool] = None) -> None: super().__init__() - self._apply_on_result = None + self._apply_on_result = _apply_on_result @property def apply_on_result(self) -> Union[bool, None]: diff --git a/gooddata-sdk/gooddata_sdk/compute/model/filter.py b/gooddata-sdk/gooddata_sdk/compute/model/filter.py index 3abe6d3d5..5cab5318c 100644 --- a/gooddata-sdk/gooddata_sdk/compute/model/filter.py +++ b/gooddata-sdk/gooddata_sdk/compute/model/filter.py @@ -3,7 +3,7 @@ from datetime import datetime from importlib.util import find_spec -from typing import Optional, Union +from typing import Any, Optional, Union from gooddata_api_client.model.inline_filter_definition_inline import InlineFilterDefinitionInline @@ -510,10 +510,10 @@ def description(self, labels: dict[str, str], format_locale: Optional[str] = Non class InlineFilter(Filter): """Filter using a custom MAQL expression. - Automatically decides, whether to create or update. + Automatically decides, whether to create or update. - Args: - maql (str): The MAQL expression string that defines the filter condition. + Args: + maql (str): The MAQL expression string that defines the filter condition. Example: ```python @@ -529,14 +529,22 @@ class InlineFilter(Filter): ``` """ - def __init__(self, maql: str): - super().__init__() + def __init__( + self, maql: str, apply_on_result: Optional[bool] = None, local_identifier: Optional[Union[ObjId, str]] = None + ) -> None: + super().__init__(apply_on_result) self.maql = maql + self.local_identifier = local_identifier def is_noop(self) -> bool: return False def as_api_model(self) -> afm_models.InlineFilterDefinition: - body = InlineFilterDefinitionInline(self.maql) + kwargs: dict[str, Any] = {} + if self.apply_on_result is not None: + kwargs["apply_on_result"] = self.apply_on_result + if self.local_identifier is not None: + kwargs["local_identifier"] = str(self.local_identifier) + body = InlineFilterDefinitionInline(self.maql, **kwargs) return afm_models.InlineFilterDefinition(body, _check_type=False)