Skip to content

Commit 4bd433f

Browse files
committed
feat: add exections_cancellable to sdk.create and export Execution
- Execution() instances are needed for the new cancelation method risk: high
1 parent d08da67 commit 4bd433f

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
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

+9-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def create(
4646
host_: str,
4747
token_: str,
4848
extra_user_agent_: Optional[str] = None,
49+
*,
50+
executions_cancellable: bool = False,
4951
**custom_headers_: Optional[str],
5052
) -> GoodDataSdk:
5153
"""
@@ -56,7 +58,13 @@ def create(
5658
This is preferred way of creating GoodDataSdk, when no tweaks are needed.
5759
"""
5860
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_)
61+
client = GoodDataApiClient(
62+
host_,
63+
token_,
64+
custom_headers=filtered_headers,
65+
extra_user_agent=extra_user_agent_,
66+
executions_cancellable=executions_cancellable,
67+
)
6068
return cls(client)
6169

6270
def __init__(self, client: GoodDataApiClient) -> None:

Diff for: gooddata-sdk/tests/sdk/test_sdk.py

+32
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,35 @@ def test_non_existing_token(setenvvar):
7979
def test_corrupted_config():
8080
with pytest.raises(ValueError):
8181
GoodDataSdk.create_from_profile(profiles_path=CORRUPTED_PROFILES)
82+
83+
84+
def test_new_options(setenvvar):
85+
sdk1 = GoodDataSdk.create("host", "token", "agent_foo", header1="header1", header2="header2")
86+
assert sdk1._client._hostname == "host"
87+
assert sdk1._client._token == "token"
88+
assert sdk1._client._api_client.user_agent[-9:] == "agent_foo"
89+
assert sdk1._client._custom_headers == {"header1": "header1", "header2": "header2"}
90+
assert not sdk1._client.executions_cancellable
91+
92+
sdk2 = GoodDataSdk.create(
93+
"host", "token", "agent_foo", header1="header1", executions_cancellable=True, header2="header2"
94+
)
95+
assert sdk1._client._hostname == sdk2._client._hostname
96+
assert sdk1._client._token == sdk2._client._token
97+
assert sdk1._client._api_client.user_agent == sdk2._client._api_client.user_agent
98+
assert sdk1._client._custom_headers == sdk2._client._custom_headers
99+
assert sdk2._client.executions_cancellable
100+
101+
sdk3 = GoodDataSdk.create(
102+
"host", "token", "agent_foo", executions_cancellable=True, header1="header1", header2="header2"
103+
)
104+
assert sdk1._client._api_client.user_agent == sdk3._client._api_client.user_agent
105+
assert sdk1._client._custom_headers == sdk3._client._custom_headers
106+
assert sdk3._client.executions_cancellable
107+
108+
sdk4 = GoodDataSdk.create(
109+
"host", "token", "agent_foo", header1="header1", header2="header2", executions_cancellable=True
110+
)
111+
assert sdk1._client._api_client.user_agent == sdk4._client._api_client.user_agent
112+
assert sdk1._client._custom_headers == sdk4._client._custom_headers
113+
assert sdk4._client.executions_cancellable

0 commit comments

Comments
 (0)