From d200a1e249a8f21f9c4c5f9e171c014f3854dd03 Mon Sep 17 00:00:00 2001 From: AIDA Date: Thu, 12 Mar 2026 09:56:07 +0000 Subject: [PATCH] feat(gooddata-sdk): [AUTO] add grand_totals_position to ExportSettings Adds a new optional `grand_totals_position` field (GrandTotalsPosition TypeAlias) to ExportSettings, wiring through the grand-total position enum (pinnedBottom, pinnedTop, bottom, top) added to TabularExportRequest Settings in the upstream OpenAPI specs. Exports GrandTotalsPosition from the public SDK __init__.py for typed usage by callers. Co-Authored-By: Claude Sonnet 4.6 --- .../gooddata-sdk/src/gooddata_sdk/__init__.py | 1 + .../gooddata_sdk/catalog/export/request.py | 5 ++++- .../tests/export/test_export_service.py | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/gooddata-sdk/src/gooddata_sdk/__init__.py b/packages/gooddata-sdk/src/gooddata_sdk/__init__.py index 8313e2c38..447ab9210 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/__init__.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/__init__.py @@ -66,6 +66,7 @@ ExportCustomOverride, ExportRequest, ExportSettings, + GrandTotalsPosition, SlidesExportRequest, VisualExportRequest, ) diff --git a/packages/gooddata-sdk/src/gooddata_sdk/catalog/export/request.py b/packages/gooddata-sdk/src/gooddata_sdk/catalog/export/request.py index 35ea2d6d2..2d5e1907b 100644 --- a/packages/gooddata-sdk/src/gooddata_sdk/catalog/export/request.py +++ b/packages/gooddata-sdk/src/gooddata_sdk/catalog/export/request.py @@ -1,5 +1,5 @@ # (C) 2023 GoodData Corporation -from typing import Literal +from typing import Literal, Optional from attrs import define from gooddata_api_client.model.custom_label import CustomLabel as ApiCustomLabel @@ -12,6 +12,8 @@ from gooddata_sdk.catalog.base import Base +GrandTotalsPosition = Literal["pinnedBottom", "pinnedTop", "bottom", "top"] + @define(kw_only=True) class ExportCustomLabel(Base): @@ -46,6 +48,7 @@ def client_class() -> type[ApiCustomOverride]: class ExportSettings(Base): merge_headers: bool show_filters: bool + grand_totals_position: Optional[GrandTotalsPosition] = None @staticmethod def client_class() -> type[ApiSettings]: diff --git a/packages/gooddata-sdk/tests/export/test_export_service.py b/packages/gooddata-sdk/tests/export/test_export_service.py index e0d07e3aa..7e3c1bfed 100644 --- a/packages/gooddata-sdk/tests/export/test_export_service.py +++ b/packages/gooddata-sdk/tests/export/test_export_service.py @@ -6,6 +6,8 @@ import os from pathlib import Path +import pytest + from gooddata_sdk import ( Attribute, ExecutionDefinition, @@ -13,7 +15,9 @@ ExportCustomMetric, ExportCustomOverride, ExportRequest, + ExportSettings, GoodDataSdk, + GrandTotalsPosition, ObjId, SimpleMetric, TableDimension, @@ -89,6 +93,24 @@ def _tabular_by_visualization_id_base(test_config, export_format: str): _validate_clean(goal_path) +@pytest.mark.parametrize( + "grand_totals_position", + [None, "pinnedBottom", "pinnedTop", "bottom", "top"], +) +def test_export_settings_grand_totals_position(grand_totals_position: GrandTotalsPosition): + settings = ExportSettings( + merge_headers=True, + show_filters=False, + grand_totals_position=grand_totals_position, + ) + assert settings.grand_totals_position == grand_totals_position + snake_dict = settings._get_snake_dict() + if grand_totals_position is not None: + assert snake_dict["grand_totals_position"] == grand_totals_position + else: + assert "grand_totals_position" not in snake_dict + + @gd_vcr.use_cassette(str(_fixtures_dir / "test_export_csv.yaml")) def test_export_csv(test_config): _tabular_export_base(test_config, "CSV")