|
8 | 8 | from attrs import define, field |
9 | 9 | from gooddata_api_client import models |
10 | 10 | from gooddata_api_client.model.afm import AFM |
| 11 | +from gooddata_api_client.model.afm_cancel_tokens import AfmCancelTokens |
11 | 12 | from gooddata_api_client.model.result_spec import ResultSpec |
12 | 13 |
|
13 | 14 | from gooddata_sdk.client import GoodDataApiClient |
@@ -360,6 +361,16 @@ def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, lis |
360 | 361 | ) |
361 | 362 | return ExecutionResult(execution_result) |
362 | 363 |
|
| 364 | + def cancel(self) -> None: |
| 365 | + """ |
| 366 | + Cancels the execution backing this execution result. |
| 367 | + """ |
| 368 | + if self.cancel_token is not None: |
| 369 | + self._api_client.actions_api.cancel_executions( |
| 370 | + self._workspace_id, |
| 371 | + AfmCancelTokens({self.result_id: self.cancel_token}), |
| 372 | + ) |
| 373 | + |
363 | 374 | def __str__(self) -> str: |
364 | 375 | return self.__repr__() |
365 | 376 |
|
@@ -437,6 +448,12 @@ def get_labels_and_formats(self) -> tuple[dict[str, str], dict[str, str]]: |
437 | 448 | def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, list[int]] = None) -> ExecutionResult: |
438 | 449 | return self.bare_exec_response.read_result(limit, offset) |
439 | 450 |
|
| 451 | + def cancel(self) -> None: |
| 452 | + """ |
| 453 | + Cancels the execution. |
| 454 | + """ |
| 455 | + self.bare_exec_response.cancel() |
| 456 | + |
440 | 457 | def __str__(self) -> str: |
441 | 458 | return self.__repr__() |
442 | 459 |
|
|
0 commit comments