Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 559dea7

Browse files
feat: [google-cloud-batch] promote cancel job API to GA (#13511)
BEGIN_COMMIT_OVERRIDE feat: promote cancel job API to GA END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. PiperOrigin-RevId: 725297068 Source-Link: googleapis/googleapis@d383e2f Source-Link: googleapis/googleapis-gen@0b95922 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJhdGNoLy5Pd2xCb3QueWFtbCIsImgiOiIwYjk1OTIyYTE5YWQwZDQ4NzU4YmQ1ZjU1OTI0YzQ2NzAyMTI2ODcyIn0= --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent a0910dd commit 559dea7

25 files changed

+2571
-133
lines changed

packages/google-cloud-batch/google/cloud/batch/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
)
2424
from google.cloud.batch_v1.services.batch_service.client import BatchServiceClient
2525
from google.cloud.batch_v1.types.batch import (
26+
CancelJobRequest,
27+
CancelJobResponse,
2628
CreateJobRequest,
2729
DeleteJobRequest,
2830
GetJobRequest,
@@ -58,6 +60,8 @@
5860
__all__ = (
5961
"BatchServiceClient",
6062
"BatchServiceAsyncClient",
63+
"CancelJobRequest",
64+
"CancelJobResponse",
6165
"CreateJobRequest",
6266
"DeleteJobRequest",
6367
"GetJobRequest",

packages/google-cloud-batch/google/cloud/batch/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.17.33" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-batch/google/cloud/batch_v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
from .services.batch_service import BatchServiceAsyncClient, BatchServiceClient
2222
from .types.batch import (
23+
CancelJobRequest,
24+
CancelJobResponse,
2325
CreateJobRequest,
2426
DeleteJobRequest,
2527
GetJobRequest,
@@ -56,6 +58,8 @@
5658
"BatchServiceAsyncClient",
5759
"AllocationPolicy",
5860
"BatchServiceClient",
61+
"CancelJobRequest",
62+
"CancelJobResponse",
5963
"ComputeResource",
6064
"CreateJobRequest",
6165
"DeleteJobRequest",

packages/google-cloud-batch/google/cloud/batch_v1/gapic_metadata.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"grpc": {
1111
"libraryClient": "BatchServiceClient",
1212
"rpcs": {
13+
"CancelJob": {
14+
"methods": [
15+
"cancel_job"
16+
]
17+
},
1318
"CreateJob": {
1419
"methods": [
1520
"create_job"
@@ -45,6 +50,11 @@
4550
"grpc-async": {
4651
"libraryClient": "BatchServiceAsyncClient",
4752
"rpcs": {
53+
"CancelJob": {
54+
"methods": [
55+
"cancel_job"
56+
]
57+
},
4858
"CreateJob": {
4959
"methods": [
5060
"create_job"
@@ -80,6 +90,11 @@
8090
"rest": {
8191
"libraryClient": "BatchServiceClient",
8292
"rpcs": {
93+
"CancelJob": {
94+
"methods": [
95+
"cancel_job"
96+
]
97+
},
8398
"CreateJob": {
8499
"methods": [
85100
"create_job"

packages/google-cloud-batch/google/cloud/batch_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "0.17.33" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-batch/google/cloud/batch_v1/services/batch_service/async_client.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,126 @@ async def sample_delete_job():
658658
# Done; return the response.
659659
return response
660660

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+
661781
async def list_jobs(
662782
self,
663783
request: Optional[Union[batch.ListJobsRequest, dict]] = None,

0 commit comments

Comments
 (0)