Skip to content

Commit 57b3095

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 57b3095

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

gooddata-sdk/gooddata_sdk/__init__.py

Lines changed: 1 addition & 0 deletions
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,

gooddata-sdk/gooddata_sdk/sdk.py

Lines changed: 2 additions & 0 deletions
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=False,
4951
**custom_headers_: Optional[str],
5052
) -> GoodDataSdk:
5153
"""

gooddata-sdk/tests/sdk/test_sdk.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,34 @@ 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+
91+
sdk2 = GoodDataSdk.create(
92+
"host", "token", "agent_foo", header1="header1", executions_cancellable=True, header2="header2"
93+
)
94+
assert sdk1._client._hostname == sdk2._client._hostname
95+
assert sdk1._client._token == sdk2._client._token
96+
assert sdk1._client._api_client.user_agent == sdk2._client._api_client.user_agent
97+
assert sdk1._client._custom_headers == sdk2._client._custom_headers
98+
99+
sdk3 = GoodDataSdk.create(
100+
"host", "token", "agent_foo", executions_cancellable=True, header1="header1", header2="header2"
101+
)
102+
assert sdk1._client._api_client.user_agent == sdk3._client._api_client.user_agent
103+
assert sdk1._client._custom_headers == sdk3._client._custom_headers
104+
105+
sdk4 = GoodDataSdk.create(
106+
"host", "token", "agent_foo", header1="header1", header2="header2", executions_cancellable=True
107+
)
108+
assert sdk1._client._api_client.user_agent == sdk4._client._api_client.user_agent
109+
assert sdk1._client._custom_headers == sdk4._client._custom_headers
110+
111+
# this doesn't parse as expected
112+
# sdk5 = GoodDataSdk.create(executions_cancellable=True, "host", "token", "agent_foo", header1="header1", header2="header2")

0 commit comments

Comments
 (0)