Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit 2879fcb

Browse files
docs: clarification for deprecated fields (#108)
* docs: clarification for deprecated fields PiperOrigin-RevId: 506637342 Source-Link: googleapis/googleapis@9821393 Source-Link: https://github.com/googleapis/googleapis-gen/commit/d9d93e022548947045bef32a4245e3ba5c936808 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDlkOTNlMDIyNTQ4OTQ3MDQ1YmVmMzJhNDI0NWUzYmE1YzkzNjgwOCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent ceb4fa7 commit 2879fcb

File tree

7 files changed

+417
-70
lines changed

7 files changed

+417
-70
lines changed

google/cloud/optimization_v1/services/fleet_routing/async_client.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from google.api_core import operation_async # type: ignore
4747
from google.cloud.optimization_v1.types import async_model
4848
from google.cloud.optimization_v1.types import fleet_routing
49+
from google.longrunning import operations_pb2
4950
from .transports.base import FleetRoutingTransport, DEFAULT_CLIENT_INFO
5051
from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport
5152
from .client import FleetRoutingClient
@@ -463,6 +464,60 @@ async def sample_batch_optimize_tours():
463464
# Done; return the response.
464465
return response
465466

467+
async def get_operation(
468+
self,
469+
request: Optional[operations_pb2.GetOperationRequest] = None,
470+
*,
471+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
472+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
473+
metadata: Sequence[Tuple[str, str]] = (),
474+
) -> operations_pb2.Operation:
475+
r"""Gets the latest state of a long-running operation.
476+
477+
Args:
478+
request (:class:`~.operations_pb2.GetOperationRequest`):
479+
The request object. Request message for
480+
`GetOperation` method.
481+
retry (google.api_core.retry.Retry): Designation of what errors,
482+
if any, should be retried.
483+
timeout (float): The timeout for this request.
484+
metadata (Sequence[Tuple[str, str]]): Strings which should be
485+
sent along with the request as metadata.
486+
Returns:
487+
~.operations_pb2.Operation:
488+
An ``Operation`` object.
489+
"""
490+
# Create or coerce a protobuf request object.
491+
# The request isn't a proto-plus wrapped type,
492+
# so it must be constructed via keyword expansion.
493+
if isinstance(request, dict):
494+
request = operations_pb2.GetOperationRequest(**request)
495+
496+
# Wrap the RPC method; this adds retry and timeout information,
497+
# and friendly error handling.
498+
rpc = gapic_v1.method.wrap_method(
499+
self._client._transport.get_operation,
500+
default_timeout=None,
501+
client_info=DEFAULT_CLIENT_INFO,
502+
)
503+
504+
# Certain fields should be provided within the metadata header;
505+
# add these here.
506+
metadata = tuple(metadata) + (
507+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
508+
)
509+
510+
# Send the request.
511+
response = await rpc(
512+
request,
513+
retry=retry,
514+
timeout=timeout,
515+
metadata=metadata,
516+
)
517+
518+
# Done; return the response.
519+
return response
520+
466521
async def __aenter__(self):
467522
return self
468523

google/cloud/optimization_v1/services/fleet_routing/client.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from google.api_core import operation_async # type: ignore
5151
from google.cloud.optimization_v1.types import async_model
5252
from google.cloud.optimization_v1.types import fleet_routing
53+
from google.longrunning import operations_pb2
5354
from .transports.base import FleetRoutingTransport, DEFAULT_CLIENT_INFO
5455
from .transports.grpc import FleetRoutingGrpcTransport
5556
from .transports.grpc_asyncio import FleetRoutingGrpcAsyncIOTransport
@@ -669,6 +670,60 @@ def __exit__(self, type, value, traceback):
669670
"""
670671
self.transport.close()
671672

673+
def get_operation(
674+
self,
675+
request: Optional[operations_pb2.GetOperationRequest] = None,
676+
*,
677+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
678+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
679+
metadata: Sequence[Tuple[str, str]] = (),
680+
) -> operations_pb2.Operation:
681+
r"""Gets the latest state of a long-running operation.
682+
683+
Args:
684+
request (:class:`~.operations_pb2.GetOperationRequest`):
685+
The request object. Request message for
686+
`GetOperation` method.
687+
retry (google.api_core.retry.Retry): Designation of what errors,
688+
if any, should be retried.
689+
timeout (float): The timeout for this request.
690+
metadata (Sequence[Tuple[str, str]]): Strings which should be
691+
sent along with the request as metadata.
692+
Returns:
693+
~.operations_pb2.Operation:
694+
An ``Operation`` object.
695+
"""
696+
# Create or coerce a protobuf request object.
697+
# The request isn't a proto-plus wrapped type,
698+
# so it must be constructed via keyword expansion.
699+
if isinstance(request, dict):
700+
request = operations_pb2.GetOperationRequest(**request)
701+
702+
# Wrap the RPC method; this adds retry and timeout information,
703+
# and friendly error handling.
704+
rpc = gapic_v1.method.wrap_method(
705+
self._transport.get_operation,
706+
default_timeout=None,
707+
client_info=DEFAULT_CLIENT_INFO,
708+
)
709+
710+
# Certain fields should be provided within the metadata header;
711+
# add these here.
712+
metadata = tuple(metadata) + (
713+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
714+
)
715+
716+
# Send the request.
717+
response = rpc(
718+
request,
719+
retry=retry,
720+
timeout=timeout,
721+
metadata=metadata,
722+
)
723+
724+
# Done; return the response.
725+
return response
726+
672727

673728
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
674729
gapic_version=package_version.__version__

google/cloud/optimization_v1/services/fleet_routing/transports/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from google.oauth2 import service_account # type: ignore
2929

3030
from google.cloud.optimization_v1.types import fleet_routing
31+
from google.longrunning import operations_pb2
3132
from google.longrunning import operations_pb2 # type: ignore
3233

3334
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -190,6 +191,15 @@ def batch_optimize_tours(
190191
]:
191192
raise NotImplementedError()
192193

194+
@property
195+
def get_operation(
196+
self,
197+
) -> Callable[
198+
[operations_pb2.GetOperationRequest],
199+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
200+
]:
201+
raise NotImplementedError()
202+
193203
@property
194204
def kind(self) -> str:
195205
raise NotImplementedError()

google/cloud/optimization_v1/services/fleet_routing/transports/grpc.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import grpc # type: ignore
2727

2828
from google.cloud.optimization_v1.types import fleet_routing
29+
from google.longrunning import operations_pb2
2930
from google.longrunning import operations_pb2 # type: ignore
3031
from .base import FleetRoutingTransport, DEFAULT_CLIENT_INFO
3132

@@ -350,6 +351,23 @@ def batch_optimize_tours(
350351
def close(self):
351352
self.grpc_channel.close()
352353

354+
@property
355+
def get_operation(
356+
self,
357+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
358+
r"""Return a callable for the get_operation method over gRPC."""
359+
# Generate a "stub function" on-the-fly which will actually make
360+
# the request.
361+
# gRPC handles serialization and deserialization, so we just need
362+
# to pass in the functions for each.
363+
if "get_operation" not in self._stubs:
364+
self._stubs["get_operation"] = self.grpc_channel.unary_unary(
365+
"/google.longrunning.Operations/GetOperation",
366+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
367+
response_deserializer=operations_pb2.Operation.FromString,
368+
)
369+
return self._stubs["get_operation"]
370+
353371
@property
354372
def kind(self) -> str:
355373
return "grpc"

google/cloud/optimization_v1/services/fleet_routing/transports/grpc_asyncio.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from grpc.experimental import aio # type: ignore
2727

2828
from google.cloud.optimization_v1.types import fleet_routing
29+
from google.longrunning import operations_pb2
2930
from google.longrunning import operations_pb2 # type: ignore
3031
from .base import FleetRoutingTransport, DEFAULT_CLIENT_INFO
3132
from .grpc import FleetRoutingGrpcTransport
@@ -358,5 +359,22 @@ def batch_optimize_tours(
358359
def close(self):
359360
return self.grpc_channel.close()
360361

362+
@property
363+
def get_operation(
364+
self,
365+
) -> Callable[[operations_pb2.GetOperationRequest], operations_pb2.Operation]:
366+
r"""Return a callable for the get_operation method over gRPC."""
367+
# Generate a "stub function" on-the-fly which will actually make
368+
# the request.
369+
# gRPC handles serialization and deserialization, so we just need
370+
# to pass in the functions for each.
371+
if "get_operation" not in self._stubs:
372+
self._stubs["get_operation"] = self.grpc_channel.unary_unary(
373+
"/google.longrunning.Operations/GetOperation",
374+
request_serializer=operations_pb2.GetOperationRequest.SerializeToString,
375+
response_deserializer=operations_pb2.Operation.FromString,
376+
)
377+
return self._stubs["get_operation"]
378+
361379

362380
__all__ = ("FleetRoutingGrpcAsyncIOTransport",)

0 commit comments

Comments
 (0)