@@ -658,6 +658,126 @@ async def sample_delete_job():
658
658
# Done; return the response.
659
659
return response
660
660
661
+ async def cancel_job (
662
+ self ,
663
+ request : Optional [Union [batch .CancelJobRequest , dict ]] = None ,
664
+ * ,
665
+ name : Optional [str ] = None ,
666
+ retry : OptionalRetry = gapic_v1 .method .DEFAULT ,
667
+ timeout : Union [float , object ] = gapic_v1 .method .DEFAULT ,
668
+ metadata : Sequence [Tuple [str , Union [str , bytes ]]] = (),
669
+ ) -> operation_async .AsyncOperation :
670
+ r"""Cancel a Job.
671
+
672
+ .. code-block:: python
673
+
674
+ # This snippet has been automatically generated and should be regarded as a
675
+ # code template only.
676
+ # It will require modifications to work:
677
+ # - It may require correct/in-range values for request initialization.
678
+ # - It may require specifying regional endpoints when creating the service
679
+ # client as shown in:
680
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
681
+ from google.cloud import batch_v1
682
+
683
+ async def sample_cancel_job():
684
+ # Create a client
685
+ client = batch_v1.BatchServiceAsyncClient()
686
+
687
+ # Initialize request argument(s)
688
+ request = batch_v1.CancelJobRequest(
689
+ name="name_value",
690
+ )
691
+
692
+ # Make the request
693
+ operation = client.cancel_job(request=request)
694
+
695
+ print("Waiting for operation to complete...")
696
+
697
+ response = (await operation).result()
698
+
699
+ # Handle the response
700
+ print(response)
701
+
702
+ Args:
703
+ request (Optional[Union[google.cloud.batch_v1.types.CancelJobRequest, dict]]):
704
+ The request object. CancelJob Request.
705
+ name (:class:`str`):
706
+ Required. Job name.
707
+ This corresponds to the ``name`` field
708
+ on the ``request`` instance; if ``request`` is provided, this
709
+ should not be set.
710
+ retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
711
+ should be retried.
712
+ timeout (float): The timeout for this request.
713
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
714
+ sent along with the request as metadata. Normally, each value must be of type `str`,
715
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
716
+ be of type `bytes`.
717
+
718
+ Returns:
719
+ google.api_core.operation_async.AsyncOperation:
720
+ An object representing a long-running operation.
721
+
722
+ The result type for the operation will be
723
+ :class:`google.cloud.batch_v1.types.CancelJobResponse`
724
+ Response to the CancelJob request.
725
+
726
+ """
727
+ # Create or coerce a protobuf request object.
728
+ # - Quick check: If we got a request object, we should *not* have
729
+ # gotten any keyword arguments that map to the request.
730
+ has_flattened_params = any ([name ])
731
+ if request is not None and has_flattened_params :
732
+ raise ValueError (
733
+ "If the `request` argument is set, then none of "
734
+ "the individual field arguments should be set."
735
+ )
736
+
737
+ # - Use the request object if provided (there's no risk of modifying the input as
738
+ # there are no flattened fields), or create one.
739
+ if not isinstance (request , batch .CancelJobRequest ):
740
+ request = batch .CancelJobRequest (request )
741
+
742
+ # If we have keyword arguments corresponding to fields on the
743
+ # request, apply these.
744
+ if name is not None :
745
+ request .name = name
746
+
747
+ # Wrap the RPC method; this adds retry and timeout information,
748
+ # and friendly error handling.
749
+ rpc = self ._client ._transport ._wrapped_methods [
750
+ self ._client ._transport .cancel_job
751
+ ]
752
+
753
+ # Certain fields should be provided within the metadata header;
754
+ # add these here.
755
+ metadata = tuple (metadata ) + (
756
+ gapic_v1 .routing_header .to_grpc_metadata ((("name" , request .name ),)),
757
+ )
758
+
759
+ # Validate the universe domain.
760
+ self ._client ._validate_universe_domain ()
761
+
762
+ # Send the request.
763
+ response = await rpc (
764
+ request ,
765
+ retry = retry ,
766
+ timeout = timeout ,
767
+ metadata = metadata ,
768
+ )
769
+
770
+ # Wrap the response in an operation future.
771
+ response = operation_async .from_gapic (
772
+ response ,
773
+ self ._client ._transport .operations_client ,
774
+ batch .CancelJobResponse ,
775
+ metadata_type = batch .OperationMetadata ,
776
+ )
777
+
778
+ # Done; return the response.
779
+ return response
780
+
661
781
async def list_jobs (
662
782
self ,
663
783
request : Optional [Union [batch .ListJobsRequest , dict ]] = None ,
0 commit comments