@@ -60,12 +60,14 @@ def __init__(
60
60
filters : Optional [list [Filter ]],
61
61
dimensions : list [TableDimension ],
62
62
totals : Optional [list [TotalDefinition ]] = None ,
63
+ is_cancellable : bool = False ,
63
64
) -> None :
64
65
self ._attributes = attributes or []
65
66
self ._metrics = metrics or []
66
67
self ._filters = filters or []
67
68
self ._dimensions = [dim for dim in dimensions if dim .item_ids is not None ]
68
69
self ._totals = totals
70
+ self ._is_cancellable = is_cancellable
69
71
70
72
@property
71
73
def attributes (self ) -> list [Attribute ]:
@@ -98,6 +100,10 @@ def is_one_dim(self) -> bool:
98
100
def is_two_dim (self ) -> bool :
99
101
return len (self .dimensions ) == 2
100
102
103
+ @property
104
+ def is_cancellable (self ) -> bool :
105
+ return self ._is_cancellable
106
+
101
107
def _create_value_sort_key (self , sort_key : dict ) -> models .SortKey :
102
108
sort_key_value = sort_key ["value" ]
103
109
return models .SortKey (
@@ -296,13 +302,15 @@ def __init__(
296
302
api_client : GoodDataApiClient ,
297
303
workspace_id : str ,
298
304
execution_response : models .AfmExecutionResponse ,
305
+ cancel_token : Optional [str ] = None ,
299
306
):
300
307
self ._api_client = api_client
301
308
self ._actions_api = self ._api_client .actions_api
302
309
self ._workspace_id = workspace_id
303
310
304
311
self ._exec_response : models .ExecutionResponse = execution_response ["execution_response" ]
305
312
self ._afm_exec_response = execution_response
313
+ self ._cancel_token = cancel_token
306
314
307
315
@property
308
316
def workspace_id (self ) -> str :
@@ -316,6 +324,10 @@ def result_id(self) -> str:
316
324
def dimensions (self ) -> Any :
317
325
return self ._exec_response ["dimensions" ]
318
326
327
+ @property
328
+ def cancel_token (self ) -> Optional [str ]:
329
+ return self ._cancel_token
330
+
319
331
def read_result (self , limit : Union [int , list [int ]], offset : Union [None , int , list [int ]] = None ) -> ExecutionResult :
320
332
"""
321
333
Reads from the execution result.
@@ -335,6 +347,7 @@ def read_result(self, limit: Union[int, list[int]], offset: Union[None, int, lis
335
347
limit = _limit ,
336
348
_check_return_type = False ,
337
349
_return_http_data_only = False ,
350
+ ** ({"x_gdc_cancel_token" : self .cancel_token } if self .cancel_token else {}),
338
351
)
339
352
custom_headers = self ._api_client .custom_headers
340
353
if "X-GDC-TRACE-ID" in custom_headers and "X-GDC-TRACE-ID" in http_headers :
@@ -351,7 +364,7 @@ def __str__(self) -> str:
351
364
return self .__repr__ ()
352
365
353
366
def __repr__ (self ) -> str :
354
- return f"BareExecutionResponse(workspace_id={ self .workspace_id } , result_id={ self .result_id } )"
367
+ return f"BareExecutionResponse(workspace_id={ self .workspace_id } , result_id={ self .result_id } , cancel_token= { self . cancel_token } )"
355
368
356
369
357
370
class Execution :
@@ -367,12 +380,11 @@ def __init__(
367
380
workspace_id : str ,
368
381
exec_def : ExecutionDefinition ,
369
382
response : models .AfmExecutionResponse ,
383
+ cancel_token : Optional [str ] = None ,
370
384
):
371
385
self ._exec_def = exec_def
372
386
self ._bare_exec_response = BareExecutionResponse (
373
- api_client = api_client ,
374
- workspace_id = workspace_id ,
375
- execution_response = response ,
387
+ api_client = api_client , workspace_id = workspace_id , execution_response = response , cancel_token = cancel_token
376
388
)
377
389
378
390
@property
@@ -395,6 +407,10 @@ def result_id(self) -> str:
395
407
def dimensions (self ) -> Any :
396
408
return self .bare_exec_response ._exec_response ["dimensions" ]
397
409
410
+ @property
411
+ def cancel_token (self ) -> Optional [str ]:
412
+ return self .bare_exec_response .cancel_token
413
+
398
414
def get_labels_and_formats (self ) -> tuple [dict [str , str ], dict [str , str ]]:
399
415
"""
400
416
Extracts labels and custom measure formats from the execution response.
@@ -425,7 +441,9 @@ def __str__(self) -> str:
425
441
return self .__repr__ ()
426
442
427
443
def __repr__ (self ) -> str :
428
- return f"Execution(workspace_id={ self .workspace_id } , result_id={ self .bare_exec_response .result_id } )"
444
+ return (
445
+ f"Execution(workspace_id={ self .workspace_id } , result_id={ self .result_id } , cancel_token={ self .cancel_token } )"
446
+ )
429
447
430
448
431
449
# Originally ExecutionResponse contained also ExecutionDefinition which was not correct, therefore Execution class was
0 commit comments