Skip to content

Commit 4619eb3

Browse files
committed
feat: add create_with_options and export Execution
- there's no way to pass executions_cancellable without a config file right now - we cannot extend .create without a breaking change for the variadic argument - that's why create_with_options is added - Execution() instances are needed for the new cancelation method risk: high
1 parent d08da67 commit 4619eb3

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Diff for: gooddata-sdk/gooddata_sdk/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
from gooddata_sdk.compute.model.base import ExecModelEntity, ObjId
232232
from gooddata_sdk.compute.model.execution import (
233233
BareExecutionResponse,
234+
Execution,
234235
ExecutionDefinition,
235236
ExecutionResponse,
236237
ExecutionResult,

Diff for: gooddata-sdk/gooddata_sdk/sdk.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import annotations
33

44
from pathlib import Path
5-
from typing import Optional
5+
from typing import Any, Optional
66

77
from gooddata_sdk.catalog.data_source.service import CatalogDataSourceService
88
from gooddata_sdk.catalog.export.service import ExportService
@@ -22,6 +22,21 @@
2222
class GoodDataSdk:
2323
"""Top-level class that wraps all the functionality together."""
2424

25+
@classmethod
26+
def create_with_options(cls, options: dict[str, Any]):
27+
"""
28+
Initialize the SDK with the given options for GoodDataApiClient.
29+
30+
Args:
31+
options (dict):
32+
Options dictionary to be passed to the GooddataApiClient constructor.
33+
34+
Returns:
35+
GoodDataSdk:
36+
Initialized SDK.
37+
"""
38+
return cls(GoodDataApiClient(**options))
39+
2540
@classmethod
2641
def create_from_profile(cls, profile: str = "default", profiles_path: Path = PROFILES_FILE_PATH) -> GoodDataSdk:
2742
"""Convenient method to initialize the SDK from config file.
@@ -36,9 +51,7 @@ def create_from_profile(cls, profile: str = "default", profiles_path: Path = PRO
3651
GoodDataSdk:
3752
Initialized SDK.
3853
"""
39-
content = profile_content(profile, profiles_path)
40-
client = GoodDataApiClient(**content)
41-
return cls(client)
54+
return cls.create_with_options(profile_content(profile, profiles_path))
4255

4356
@classmethod
4457
def create(
@@ -56,8 +69,9 @@ def create(
5669
This is preferred way of creating GoodDataSdk, when no tweaks are needed.
5770
"""
5871
filtered_headers = {key: value for key, value in custom_headers_.items() if value is not None}
59-
client = GoodDataApiClient(host_, token_, custom_headers=filtered_headers, extra_user_agent=extra_user_agent_)
60-
return cls(client)
72+
return cls.create_with_options(
73+
{"host": host_, "token": token_, "custom_headers": filtered_headers, "extra_user_agent": extra_user_agent_}
74+
)
6175

6276
def __init__(self, client: GoodDataApiClient) -> None:
6377
"""Take instance of GoodDataApiClient and return new GoodDataSdk instance.

0 commit comments

Comments
 (0)