@@ -256,6 +256,7 @@ def list(
256256 scheduled = schedule_defined ,
257257 schedule_id = scheduled_job_name ,
258258 ** self ._kwargs ,
259+ ** kwargs ,
259260 )
260261
261262 def _handle_rest_errors (self , job_object ):
@@ -312,7 +313,7 @@ def show_services(self, name: str, node_index: int = 0) -> Dict[str, ServiceInst
312313
313314 @distributed_trace
314315 # @monitor_with_activity(logger, "Job.Cancel", ActivityType.PUBLICAPI)
315- def begin_cancel (self , name : str ) -> LROPoller [None ]:
316+ def begin_cancel (self , name : str , ** kwargs ) -> LROPoller [None ]:
316317 """Cancel job resource.
317318
318319 :param str name: Name of the job.
@@ -322,12 +323,30 @@ def begin_cancel(self, name: str) -> LROPoller[None]:
322323 :rtype: ~azure.core.polling.LROPoller[None]
323324 :raise: ResourceNotFoundError if can't find a job matching provided name.
324325 """
325- return self ._operation_2022_12_preview .begin_cancel (
326- id = name ,
327- resource_group_name = self ._operation_scope .resource_group_name ,
328- workspace_name = self ._workspace_name ,
329- ** self ._kwargs ,
330- )
326+ tag = kwargs .get ("tag" , None ) if kwargs else None
327+
328+ if not tag :
329+ return self ._operation_2022_12_preview .begin_cancel (
330+ id = name ,
331+ resource_group_name = self ._operation_scope .resource_group_name ,
332+ workspace_name = self ._workspace_name ,
333+ ** self ._kwargs ,
334+ ** kwargs ,
335+ )
336+
337+ # Note: Below batch cancel is experimental and for private usage
338+ results = []
339+ jobs = self .list (tag = tag )
340+ # TODO: Do we need to show error message when no jobs is returned for the given tag?
341+ for job in jobs :
342+ result = self ._operation_2022_12_preview .begin_cancel (
343+ id = job .name ,
344+ resource_group_name = self ._operation_scope .resource_group_name ,
345+ workspace_name = self ._workspace_name ,
346+ ** self ._kwargs ,
347+ )
348+ results .append (result )
349+ return results
331350
332351 def _try_get_compute_arm_id (self , compute : Union [Compute , str ]):
333352 # TODO: Remove in PuP with native import job/component type support in MFE/Designer
0 commit comments