diff --git a/google/cloud/tpu_v2alpha1/__init__.py b/google/cloud/tpu_v2alpha1/__init__.py index 9760f13..09b9383 100644 --- a/google/cloud/tpu_v2alpha1/__init__.py +++ b/google/cloud/tpu_v2alpha1/__init__.py @@ -53,7 +53,6 @@ OperationMetadata, QueuedResource, QueuedResourceState, - ResetQueuedResourceRequest, RuntimeVersion, SchedulingConfig, ServiceAccount, @@ -101,7 +100,6 @@ "OperationMetadata", "QueuedResource", "QueuedResourceState", - "ResetQueuedResourceRequest", "RuntimeVersion", "SchedulingConfig", "ServiceAccount", diff --git a/google/cloud/tpu_v2alpha1/gapic_metadata.json b/google/cloud/tpu_v2alpha1/gapic_metadata.json index cb51745..4c5e3e7 100644 --- a/google/cloud/tpu_v2alpha1/gapic_metadata.json +++ b/google/cloud/tpu_v2alpha1/gapic_metadata.json @@ -80,11 +80,6 @@ "list_runtime_versions" ] }, - "ResetQueuedResource": { - "methods": [ - "reset_queued_resource" - ] - }, "SimulateMaintenanceEvent": { "methods": [ "simulate_maintenance_event" @@ -180,11 +175,6 @@ "list_runtime_versions" ] }, - "ResetQueuedResource": { - "methods": [ - "reset_queued_resource" - ] - }, "SimulateMaintenanceEvent": { "methods": [ "simulate_maintenance_event" diff --git a/google/cloud/tpu_v2alpha1/services/tpu/async_client.py b/google/cloud/tpu_v2alpha1/services/tpu/async_client.py index 8796e28..1a4649f 100644 --- a/google/cloud/tpu_v2alpha1/services/tpu/async_client.py +++ b/google/cloud/tpu_v2alpha1/services/tpu/async_client.py @@ -1475,123 +1475,6 @@ async def sample_delete_queued_resource(): # Done; return the response. return response - async def reset_queued_resource( - self, - request: Optional[Union[cloud_tpu.ResetQueuedResourceRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation_async.AsyncOperation: - r"""Resets a QueuedResource TPU instance - - .. 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 tpu_v2alpha1 - - async def sample_reset_queued_resource(): - # Create a client - client = tpu_v2alpha1.TpuAsyncClient() - - # Initialize request argument(s) - request = tpu_v2alpha1.ResetQueuedResourceRequest( - name="name_value", - ) - - # Make the request - operation = client.reset_queued_resource(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - - Args: - request (Optional[Union[google.cloud.tpu_v2alpha1.types.ResetQueuedResourceRequest, dict]]): - The request object. Request for - [ResetQueuedResource][google.cloud.tpu.v2alpha1.Tpu.ResetQueuedResource]. - name (:class:`str`): - Required. The name of the queued - resource. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - 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.tpu_v2alpha1.types.QueuedResource` A QueuedResource represents a request for resources that will be placed - in a queue and fulfilled when the necessary resources - are available. - - """ - # 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." - ) - - request = cloud_tpu.ResetQueuedResourceRequest(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 = gapic_v1.method_async.wrap_method( - self._client._transport.reset_queued_resource, - default_timeout=None, - client_info=DEFAULT_CLIENT_INFO, - ) - - # 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),)), - ) - - # 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, - cloud_tpu.QueuedResource, - metadata_type=cloud_tpu.OperationMetadata, - ) - - # Done; return the response. - return response - async def generate_service_identity( self, request: Optional[Union[cloud_tpu.GenerateServiceIdentityRequest, dict]] = None, diff --git a/google/cloud/tpu_v2alpha1/services/tpu/client.py b/google/cloud/tpu_v2alpha1/services/tpu/client.py index 2677b64..6e3a246 100644 --- a/google/cloud/tpu_v2alpha1/services/tpu/client.py +++ b/google/cloud/tpu_v2alpha1/services/tpu/client.py @@ -1772,123 +1772,6 @@ def sample_delete_queued_resource(): # Done; return the response. return response - def reset_queued_resource( - self, - request: Optional[Union[cloud_tpu.ResetQueuedResourceRequest, dict]] = None, - *, - name: Optional[str] = None, - retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), - ) -> operation.Operation: - r"""Resets a QueuedResource TPU instance - - .. 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 tpu_v2alpha1 - - def sample_reset_queued_resource(): - # Create a client - client = tpu_v2alpha1.TpuClient() - - # Initialize request argument(s) - request = tpu_v2alpha1.ResetQueuedResourceRequest( - name="name_value", - ) - - # Make the request - operation = client.reset_queued_resource(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - - Args: - request (Union[google.cloud.tpu_v2alpha1.types.ResetQueuedResourceRequest, dict]): - The request object. Request for - [ResetQueuedResource][google.cloud.tpu.v2alpha1.Tpu.ResetQueuedResource]. - name (str): - Required. The name of the queued - resource. - - This corresponds to the ``name`` field - on the ``request`` instance; if ``request`` is provided, this - should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, - should be retried. - timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - - Returns: - google.api_core.operation.Operation: - An object representing a long-running operation. - - The result type for the operation will be :class:`google.cloud.tpu_v2alpha1.types.QueuedResource` A QueuedResource represents a request for resources that will be placed - in a queue and fulfilled when the necessary resources - are available. - - """ - # 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." - ) - - # Minor optimization to avoid making a copy if the user passes - # in a cloud_tpu.ResetQueuedResourceRequest. - # There's no risk of modifying the input as we've already verified - # there are no flattened fields. - if not isinstance(request, cloud_tpu.ResetQueuedResourceRequest): - request = cloud_tpu.ResetQueuedResourceRequest(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._transport._wrapped_methods[self._transport.reset_queued_resource] - - # 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),)), - ) - - # Send the request. - response = rpc( - request, - retry=retry, - timeout=timeout, - metadata=metadata, - ) - - # Wrap the response in an operation future. - response = operation.from_gapic( - response, - self._transport.operations_client, - cloud_tpu.QueuedResource, - metadata_type=cloud_tpu.OperationMetadata, - ) - - # Done; return the response. - return response - def generate_service_identity( self, request: Optional[Union[cloud_tpu.GenerateServiceIdentityRequest, dict]] = None, diff --git a/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py b/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py index 8561a9e..2950eb9 100644 --- a/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py +++ b/google/cloud/tpu_v2alpha1/services/tpu/transports/base.py @@ -179,11 +179,6 @@ def _prep_wrapped_messages(self, client_info): default_timeout=None, client_info=client_info, ), - self.reset_queued_resource: gapic_v1.method.wrap_method( - self.reset_queued_resource, - default_timeout=None, - client_info=client_info, - ), self.generate_service_identity: gapic_v1.method.wrap_method( self.generate_service_identity, default_timeout=None, @@ -336,15 +331,6 @@ def delete_queued_resource( ]: raise NotImplementedError() - @property - def reset_queued_resource( - self, - ) -> Callable[ - [cloud_tpu.ResetQueuedResourceRequest], - Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], - ]: - raise NotImplementedError() - @property def generate_service_identity( self, diff --git a/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py b/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py index a1351ba..8df33ea 100644 --- a/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py +++ b/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py @@ -533,32 +533,6 @@ def delete_queued_resource( ) return self._stubs["delete_queued_resource"] - @property - def reset_queued_resource( - self, - ) -> Callable[[cloud_tpu.ResetQueuedResourceRequest], operations_pb2.Operation]: - r"""Return a callable for the reset queued resource method over gRPC. - - Resets a QueuedResource TPU instance - - Returns: - Callable[[~.ResetQueuedResourceRequest], - ~.Operation]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "reset_queued_resource" not in self._stubs: - self._stubs["reset_queued_resource"] = self.grpc_channel.unary_unary( - "/google.cloud.tpu.v2alpha1.Tpu/ResetQueuedResource", - request_serializer=cloud_tpu.ResetQueuedResourceRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["reset_queued_resource"] - @property def generate_service_identity( self, diff --git a/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py b/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py index e881668..c8e4d64 100644 --- a/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py +++ b/google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py @@ -547,34 +547,6 @@ def delete_queued_resource( ) return self._stubs["delete_queued_resource"] - @property - def reset_queued_resource( - self, - ) -> Callable[ - [cloud_tpu.ResetQueuedResourceRequest], Awaitable[operations_pb2.Operation] - ]: - r"""Return a callable for the reset queued resource method over gRPC. - - Resets a QueuedResource TPU instance - - Returns: - Callable[[~.ResetQueuedResourceRequest], - Awaitable[~.Operation]]: - A function that, when called, will call the underlying RPC - on the server. - """ - # Generate a "stub function" on-the-fly which will actually make - # the request. - # gRPC handles serialization and deserialization, so we just need - # to pass in the functions for each. - if "reset_queued_resource" not in self._stubs: - self._stubs["reset_queued_resource"] = self.grpc_channel.unary_unary( - "/google.cloud.tpu.v2alpha1.Tpu/ResetQueuedResource", - request_serializer=cloud_tpu.ResetQueuedResourceRequest.serialize, - response_deserializer=operations_pb2.Operation.FromString, - ) - return self._stubs["reset_queued_resource"] - @property def generate_service_identity( self, diff --git a/google/cloud/tpu_v2alpha1/types/__init__.py b/google/cloud/tpu_v2alpha1/types/__init__.py index a92b9cd..4788987 100644 --- a/google/cloud/tpu_v2alpha1/types/__init__.py +++ b/google/cloud/tpu_v2alpha1/types/__init__.py @@ -47,7 +47,6 @@ OperationMetadata, QueuedResource, QueuedResourceState, - ResetQueuedResourceRequest, RuntimeVersion, SchedulingConfig, ServiceAccount, @@ -94,7 +93,6 @@ "OperationMetadata", "QueuedResource", "QueuedResourceState", - "ResetQueuedResourceRequest", "RuntimeVersion", "SchedulingConfig", "ServiceAccount", diff --git a/google/cloud/tpu_v2alpha1/types/cloud_tpu.py b/google/cloud/tpu_v2alpha1/types/cloud_tpu.py index 797f7c1..0a4e2b0 100644 --- a/google/cloud/tpu_v2alpha1/types/cloud_tpu.py +++ b/google/cloud/tpu_v2alpha1/types/cloud_tpu.py @@ -52,7 +52,6 @@ "GetQueuedResourceRequest", "CreateQueuedResourceRequest", "DeleteQueuedResourceRequest", - "ResetQueuedResourceRequest", "ServiceIdentity", "GenerateServiceIdentityRequest", "GenerateServiceIdentityResponse", @@ -1330,21 +1329,6 @@ class DeleteQueuedResourceRequest(proto.Message): ) -class ResetQueuedResourceRequest(proto.Message): - r"""Request for - [ResetQueuedResource][google.cloud.tpu.v2alpha1.Tpu.ResetQueuedResource]. - - Attributes: - name (str): - Required. The name of the queued resource. - """ - - name: str = proto.Field( - proto.STRING, - number=1, - ) - - class ServiceIdentity(proto.Message): r"""The per-product per-project service identity for Cloud TPU service. diff --git a/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json b/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json index 6c664f7..0a659a0 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.tpu.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.10.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json b/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json index f2b69b5..9f7e7c8 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.10.0" + "version": "0.1.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json b/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json index 79a2e84..2512354 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.tpu.v2alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-tpu", - "version": "1.10.0" + "version": "0.1.0" }, "snippets": [ { @@ -2281,167 +2281,6 @@ ], "title": "tpu_v2alpha1_generated_tpu_list_runtime_versions_sync.py" }, - { - "canonical": true, - "clientMethod": { - "async": true, - "client": { - "fullName": "google.cloud.tpu_v2alpha1.TpuAsyncClient", - "shortName": "TpuAsyncClient" - }, - "fullName": "google.cloud.tpu_v2alpha1.TpuAsyncClient.reset_queued_resource", - "method": { - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ResetQueuedResource", - "service": { - "fullName": "google.cloud.tpu.v2alpha1.Tpu", - "shortName": "Tpu" - }, - "shortName": "ResetQueuedResource" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.tpu_v2alpha1.types.ResetQueuedResourceRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation_async.AsyncOperation", - "shortName": "reset_queued_resource" - }, - "description": "Sample for ResetQueuedResource", - "file": "tpu_v2alpha1_generated_tpu_reset_queued_resource_async.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "tpu_v2alpha1_generated_Tpu_ResetQueuedResource_async", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "tpu_v2alpha1_generated_tpu_reset_queued_resource_async.py" - }, - { - "canonical": true, - "clientMethod": { - "client": { - "fullName": "google.cloud.tpu_v2alpha1.TpuClient", - "shortName": "TpuClient" - }, - "fullName": "google.cloud.tpu_v2alpha1.TpuClient.reset_queued_resource", - "method": { - "fullName": "google.cloud.tpu.v2alpha1.Tpu.ResetQueuedResource", - "service": { - "fullName": "google.cloud.tpu.v2alpha1.Tpu", - "shortName": "Tpu" - }, - "shortName": "ResetQueuedResource" - }, - "parameters": [ - { - "name": "request", - "type": "google.cloud.tpu_v2alpha1.types.ResetQueuedResourceRequest" - }, - { - "name": "name", - "type": "str" - }, - { - "name": "retry", - "type": "google.api_core.retry.Retry" - }, - { - "name": "timeout", - "type": "float" - }, - { - "name": "metadata", - "type": "Sequence[Tuple[str, str]" - } - ], - "resultType": "google.api_core.operation.Operation", - "shortName": "reset_queued_resource" - }, - "description": "Sample for ResetQueuedResource", - "file": "tpu_v2alpha1_generated_tpu_reset_queued_resource_sync.py", - "language": "PYTHON", - "origin": "API_DEFINITION", - "regionTag": "tpu_v2alpha1_generated_Tpu_ResetQueuedResource_sync", - "segments": [ - { - "end": 55, - "start": 27, - "type": "FULL" - }, - { - "end": 55, - "start": 27, - "type": "SHORT" - }, - { - "end": 40, - "start": 38, - "type": "CLIENT_INITIALIZATION" - }, - { - "end": 45, - "start": 41, - "type": "REQUEST_INITIALIZATION" - }, - { - "end": 52, - "start": 46, - "type": "REQUEST_EXECUTION" - }, - { - "end": 56, - "start": 53, - "type": "RESPONSE_HANDLING" - } - ], - "title": "tpu_v2alpha1_generated_tpu_reset_queued_resource_sync.py" - }, { "canonical": true, "clientMethod": { diff --git a/samples/generated_samples/tpu_v2alpha1_generated_tpu_reset_queued_resource_async.py b/samples/generated_samples/tpu_v2alpha1_generated_tpu_reset_queued_resource_async.py deleted file mode 100644 index 6f9c423..0000000 --- a/samples/generated_samples/tpu_v2alpha1_generated_tpu_reset_queued_resource_async.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ResetQueuedResource -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-tpu - - -# [START tpu_v2alpha1_generated_Tpu_ResetQueuedResource_async] -# 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 tpu_v2alpha1 - - -async def sample_reset_queued_resource(): - # Create a client - client = tpu_v2alpha1.TpuAsyncClient() - - # Initialize request argument(s) - request = tpu_v2alpha1.ResetQueuedResourceRequest( - name="name_value", - ) - - # Make the request - operation = client.reset_queued_resource(request=request) - - print("Waiting for operation to complete...") - - response = (await operation).result() - - # Handle the response - print(response) - -# [END tpu_v2alpha1_generated_Tpu_ResetQueuedResource_async] diff --git a/samples/generated_samples/tpu_v2alpha1_generated_tpu_reset_queued_resource_sync.py b/samples/generated_samples/tpu_v2alpha1_generated_tpu_reset_queued_resource_sync.py deleted file mode 100644 index b0a8edc..0000000 --- a/samples/generated_samples/tpu_v2alpha1_generated_tpu_reset_queued_resource_sync.py +++ /dev/null @@ -1,56 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2022 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Generated code. DO NOT EDIT! -# -# Snippet for ResetQueuedResource -# NOTE: This snippet has been automatically generated for illustrative purposes only. -# It may require modifications to work in your environment. - -# To install the latest published package dependency, execute the following: -# python3 -m pip install google-cloud-tpu - - -# [START tpu_v2alpha1_generated_Tpu_ResetQueuedResource_sync] -# 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 tpu_v2alpha1 - - -def sample_reset_queued_resource(): - # Create a client - client = tpu_v2alpha1.TpuClient() - - # Initialize request argument(s) - request = tpu_v2alpha1.ResetQueuedResourceRequest( - name="name_value", - ) - - # Make the request - operation = client.reset_queued_resource(request=request) - - print("Waiting for operation to complete...") - - response = operation.result() - - # Handle the response - print(response) - -# [END tpu_v2alpha1_generated_Tpu_ResetQueuedResource_sync] diff --git a/scripts/fixup_tpu_v2alpha1_keywords.py b/scripts/fixup_tpu_v2alpha1_keywords.py index 9e95df2..b2f15db 100644 --- a/scripts/fixup_tpu_v2alpha1_keywords.py +++ b/scripts/fixup_tpu_v2alpha1_keywords.py @@ -53,7 +53,6 @@ class tpuCallTransformer(cst.CSTTransformer): 'list_nodes': ('parent', 'page_size', 'page_token', ), 'list_queued_resources': ('parent', 'page_size', 'page_token', ), 'list_runtime_versions': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'reset_queued_resource': ('name', ), 'simulate_maintenance_event': ('name', 'worker_ids', ), 'start_node': ('name', ), 'stop_node': ('name', ), diff --git a/tests/unit/gapic/tpu_v2alpha1/test_tpu.py b/tests/unit/gapic/tpu_v2alpha1/test_tpu.py index 62ebce1..b57f5a6 100644 --- a/tests/unit/gapic/tpu_v2alpha1/test_tpu.py +++ b/tests/unit/gapic/tpu_v2alpha1/test_tpu.py @@ -3527,246 +3527,6 @@ async def test_delete_queued_resource_flattened_error_async(): ) -@pytest.mark.parametrize( - "request_type", - [ - cloud_tpu.ResetQueuedResourceRequest, - dict, - ], -) -def test_reset_queued_resource(request_type, transport: str = "grpc"): - client = TpuClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reset_queued_resource), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.reset_queued_resource(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == cloud_tpu.ResetQueuedResourceRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -def test_reset_queued_resource_empty_call(): - # This test is a coverage failsafe to make sure that totally empty calls, - # i.e. request == None and no flattened fields passed, work. - client = TpuClient( - credentials=ga_credentials.AnonymousCredentials(), - transport="grpc", - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reset_queued_resource), "__call__" - ) as call: - client.reset_queued_resource() - call.assert_called() - _, args, _ = call.mock_calls[0] - assert args[0] == cloud_tpu.ResetQueuedResourceRequest() - - -@pytest.mark.asyncio -async def test_reset_queued_resource_async( - transport: str = "grpc_asyncio", request_type=cloud_tpu.ResetQueuedResourceRequest -): - client = TpuAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - transport=transport, - ) - - # Everything is optional in proto3 as far as the runtime is concerned, - # and we are mocking out the actual API, so just send an empty request. - request = request_type() - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reset_queued_resource), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - response = await client.reset_queued_resource(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == cloud_tpu.ResetQueuedResourceRequest() - - # Establish that the response is the type that we expect. - assert isinstance(response, future.Future) - - -@pytest.mark.asyncio -async def test_reset_queued_resource_async_from_dict(): - await test_reset_queued_resource_async(request_type=dict) - - -def test_reset_queued_resource_field_headers(): - client = TpuClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = cloud_tpu.ResetQueuedResourceRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reset_queued_resource), "__call__" - ) as call: - call.return_value = operations_pb2.Operation(name="operations/op") - client.reset_queued_resource(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -@pytest.mark.asyncio -async def test_reset_queued_resource_field_headers_async(): - client = TpuAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Any value that is part of the HTTP/1.1 URI should be sent as - # a field header. Set these to a non-empty value. - request = cloud_tpu.ResetQueuedResourceRequest() - - request.name = "name_value" - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reset_queued_resource), "__call__" - ) as call: - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/op") - ) - await client.reset_queued_resource(request) - - # Establish that the underlying gRPC stub method was called. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - assert args[0] == request - - # Establish that the field header was sent. - _, _, kw = call.mock_calls[0] - assert ( - "x-goog-request-params", - "name=name_value", - ) in kw["metadata"] - - -def test_reset_queued_resource_flattened(): - client = TpuClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reset_queued_resource), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - client.reset_queued_resource( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) == 1 - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -def test_reset_queued_resource_flattened_error(): - client = TpuClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - client.reset_queued_resource( - cloud_tpu.ResetQueuedResourceRequest(), - name="name_value", - ) - - -@pytest.mark.asyncio -async def test_reset_queued_resource_flattened_async(): - client = TpuAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.reset_queued_resource), "__call__" - ) as call: - # Designate an appropriate return value for the call. - call.return_value = operations_pb2.Operation(name="operations/op") - - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - operations_pb2.Operation(name="operations/spam") - ) - # Call the method with a truthy value for each flattened field, - # using the keyword arguments to the method. - response = await client.reset_queued_resource( - name="name_value", - ) - - # Establish that the underlying call was made with the expected - # request object values. - assert len(call.mock_calls) - _, args, _ = call.mock_calls[0] - arg = args[0].name - mock_val = "name_value" - assert arg == mock_val - - -@pytest.mark.asyncio -async def test_reset_queued_resource_flattened_error_async(): - client = TpuAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), - ) - - # Attempting to call a method with both a request object and flattened - # fields is an error. - with pytest.raises(ValueError): - await client.reset_queued_resource( - cloud_tpu.ResetQueuedResourceRequest(), - name="name_value", - ) - - @pytest.mark.parametrize( "request_type", [ @@ -5771,7 +5531,6 @@ def test_tpu_base_transport(): "get_queued_resource", "create_queued_resource", "delete_queued_resource", - "reset_queued_resource", "generate_service_identity", "list_accelerator_types", "get_accelerator_type",