|
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 |
@@ -365,6 +366,16 @@ def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, lis |
365 | 366 | ) |
366 | 367 | return ExecutionResult(execution_result) |
367 | 368 |
|
| 369 | + def cancel(self) -> None: |
| 370 | + """ |
| 371 | + Cancels the execution backing this execution result. |
| 372 | + """ |
| 373 | + if self.cancel_token is not None: |
| 374 | + self._api_client.actions_api.cancel_executions( |
| 375 | + self._workspace_id, |
| 376 | + AfmCancelTokens({self.result_id: self.cancel_token}), |
| 377 | + ) |
| 378 | + |
368 | 379 | def __str__(self) -> str: |
369 | 380 | return self.__repr__() |
370 | 381 |
|
@@ -442,6 +453,12 @@ def get_labels_and_formats(self) -> tuple[dict[str, str], dict[str, str]]: |
442 | 453 | def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, list[int]] = None) -> ExecutionResult: |
443 | 454 | return self.bare_exec_response.read_result(limit, offset) |
444 | 455 |
|
| 456 | + def cancel(self) -> None: |
| 457 | + """ |
| 458 | + Cancels the execution. |
| 459 | + """ |
| 460 | + self.bare_exec_response.cancel() |
| 461 | + |
445 | 462 | def __str__(self) -> str: |
446 | 463 | return self.__repr__() |
447 | 464 |
|
|
0 commit comments