Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

fix(tpu_v2alpha1): restrict the visibility of API ResetQueuedResource #226

Merged
merged 2 commits into from May 4, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions google/cloud/tpu_v2alpha1/__init__.py
Expand Up @@ -53,7 +53,6 @@
OperationMetadata,
QueuedResource,
QueuedResourceState,
ResetQueuedResourceRequest,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change however it part of an alpha API and was only recently added in version 1.10.0

RuntimeVersion,
SchedulingConfig,
ServiceAccount,
Expand Down Expand Up @@ -101,7 +100,6 @@
"OperationMetadata",
"QueuedResource",
"QueuedResourceState",
"ResetQueuedResourceRequest",
"RuntimeVersion",
"SchedulingConfig",
"ServiceAccount",
Expand Down
10 changes: 0 additions & 10 deletions google/cloud/tpu_v2alpha1/gapic_metadata.json
Expand Up @@ -80,11 +80,6 @@
"list_runtime_versions"
]
},
"ResetQueuedResource": {
"methods": [
"reset_queued_resource"
]
},
"SimulateMaintenanceEvent": {
"methods": [
"simulate_maintenance_event"
Expand Down Expand Up @@ -180,11 +175,6 @@
"list_runtime_versions"
]
},
"ResetQueuedResource": {
"methods": [
"reset_queued_resource"
]
},
"SimulateMaintenanceEvent": {
"methods": [
"simulate_maintenance_event"
Expand Down
117 changes: 0 additions & 117 deletions google/cloud/tpu_v2alpha1/services/tpu/async_client.py
Expand Up @@ -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,
Expand Down
117 changes: 0 additions & 117 deletions google/cloud/tpu_v2alpha1/services/tpu/client.py
Expand Up @@ -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,
Expand Down
14 changes: 0 additions & 14 deletions google/cloud/tpu_v2alpha1/services/tpu/transports/base.py
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 0 additions & 26 deletions google/cloud/tpu_v2alpha1/services/tpu/transports/grpc.py
Expand Up @@ -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,
Expand Down
28 changes: 0 additions & 28 deletions google/cloud/tpu_v2alpha1/services/tpu/transports/grpc_asyncio.py
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions google/cloud/tpu_v2alpha1/types/__init__.py
Expand Up @@ -47,7 +47,6 @@
OperationMetadata,
QueuedResource,
QueuedResourceState,
ResetQueuedResourceRequest,
RuntimeVersion,
SchedulingConfig,
ServiceAccount,
Expand Down Expand Up @@ -94,7 +93,6 @@
"OperationMetadata",
"QueuedResource",
"QueuedResourceState",
"ResetQueuedResourceRequest",
"RuntimeVersion",
"SchedulingConfig",
"ServiceAccount",
Expand Down