Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/google-cloud-batch/google/cloud/batch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
)
from google.cloud.batch_v1.services.batch_service.client import BatchServiceClient
from google.cloud.batch_v1.types.batch import (
CancelJobRequest,
CancelJobResponse,
CreateJobRequest,
DeleteJobRequest,
GetJobRequest,
Expand Down Expand Up @@ -58,6 +60,8 @@
__all__ = (
"BatchServiceClient",
"BatchServiceAsyncClient",
"CancelJobRequest",
"CancelJobResponse",
"CreateJobRequest",
"DeleteJobRequest",
"GetJobRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.17.33" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

from .services.batch_service import BatchServiceAsyncClient, BatchServiceClient
from .types.batch import (
CancelJobRequest,
CancelJobResponse,
CreateJobRequest,
DeleteJobRequest,
GetJobRequest,
Expand Down Expand Up @@ -56,6 +58,8 @@
"BatchServiceAsyncClient",
"AllocationPolicy",
"BatchServiceClient",
"CancelJobRequest",
"CancelJobResponse",
"ComputeResource",
"CreateJobRequest",
"DeleteJobRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"grpc": {
"libraryClient": "BatchServiceClient",
"rpcs": {
"CancelJob": {
"methods": [
"cancel_job"
]
},
"CreateJob": {
"methods": [
"create_job"
Expand Down Expand Up @@ -45,6 +50,11 @@
"grpc-async": {
"libraryClient": "BatchServiceAsyncClient",
"rpcs": {
"CancelJob": {
"methods": [
"cancel_job"
]
},
"CreateJob": {
"methods": [
"create_job"
Expand Down Expand Up @@ -80,6 +90,11 @@
"rest": {
"libraryClient": "BatchServiceClient",
"rpcs": {
"CancelJob": {
"methods": [
"cancel_job"
]
},
"CreateJob": {
"methods": [
"create_job"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.17.33" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,126 @@ async def sample_delete_job():
# Done; return the response.
return response

async def cancel_job(
self,
request: Optional[Union[batch.CancelJobRequest, dict]] = None,
*,
name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
) -> operation_async.AsyncOperation:
r"""Cancel a Job.

.. code-block:: python

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import batch_v1

async def sample_cancel_job():
# Create a client
client = batch_v1.BatchServiceAsyncClient()

# Initialize request argument(s)
request = batch_v1.CancelJobRequest(
name="name_value",
)

# Make the request
operation = client.cancel_job(request=request)

print("Waiting for operation to complete...")

response = (await operation).result()

# Handle the response
print(response)

Args:
request (Optional[Union[google.cloud.batch_v1.types.CancelJobRequest, dict]]):
The request object. CancelJob Request.
name (:class:`str`):
Required. Job name.
This corresponds to the ``name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
sent along with the request as metadata. Normally, each value must be of type `str`,
but for metadata keys ending with the suffix `-bin`, the corresponding values must
be of type `bytes`.

Returns:
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.

The result type for the operation will be
:class:`google.cloud.batch_v1.types.CancelJobResponse`
Response to the CancelJob request.

"""
# Create or coerce a protobuf request object.
# - Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, batch.CancelJobRequest):
request = batch.CancelJobRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if name is not None:
request.name = name

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[
self._client._transport.cancel_job
]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Wrap the response in an operation future.
response = operation_async.from_gapic(
response,
self._client._transport.operations_client,
batch.CancelJobResponse,
metadata_type=batch.OperationMetadata,
)

# Done; return the response.
return response

async def list_jobs(
self,
request: Optional[Union[batch.ListJobsRequest, dict]] = None,
Expand Down
Loading