Skip to content

Commit

Permalink
feat: Adds Startup and Liveness probes to Cloud Run v2 API client lib…
Browse files Browse the repository at this point in the history
…raries (#60)

* feat: Adds Startup and Liveness probes to Cloud Run v2 API client libraries

For more information about this feature, visit https://cloud.google.com/run/docs/configuring/healthchecks

PiperOrigin-RevId: 481203788

Source-Link: googleapis/googleapis@778762c

Source-Link: googleapis/googleapis-gen@1479c7a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTQ3OWM3YTYzZmM3ZDViNWQ5OGM0OGU5YmExZDBiNmE5NGU5NTUxMyJ9

* 🦉 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Oct 14, 2022
1 parent 3a7e7c5 commit a2618da
Show file tree
Hide file tree
Showing 20 changed files with 3,019 additions and 73 deletions.
8 changes: 8 additions & 0 deletions packages/google-cloud-run/google/cloud/run_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
from .types.k8s_min import ContainerPort
from .types.k8s_min import EnvVar
from .types.k8s_min import EnvVarSource
from .types.k8s_min import HTTPGetAction
from .types.k8s_min import HTTPHeader
from .types.k8s_min import Probe
from .types.k8s_min import ResourceRequirements
from .types.k8s_min import SecretKeySelector
from .types.k8s_min import SecretVolumeSource
from .types.k8s_min import TCPSocketAction
from .types.k8s_min import VersionToPath
from .types.k8s_min import Volume
from .types.k8s_min import VolumeMount
Expand Down Expand Up @@ -69,11 +73,14 @@
"ExecutionEnvironment",
"GetRevisionRequest",
"GetServiceRequest",
"HTTPGetAction",
"HTTPHeader",
"IngressTraffic",
"ListRevisionsRequest",
"ListRevisionsResponse",
"ListServicesRequest",
"ListServicesResponse",
"Probe",
"ResourceRequirements",
"Revision",
"RevisionScaling",
Expand All @@ -83,6 +90,7 @@
"SecretVolumeSource",
"Service",
"ServicesClient",
"TCPSocketAction",
"TrafficTarget",
"TrafficTargetAllocationType",
"TrafficTargetStatus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
from google.api import launch_stage_pb2 # type: ignore
from google.api_core import operation # type: ignore
from google.api_core import operation_async # type: ignore
from google.cloud.location import locations_pb2 # type: ignore
from google.cloud.run_v2.services.revisions import pagers
from google.cloud.run_v2.types import condition
from google.cloud.run_v2.types import k8s_min
from google.cloud.run_v2.types import revision
from google.cloud.run_v2.types import vendor_settings
from google.longrunning import operations_pb2
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from .transports.base import RevisionsTransport, DEFAULT_CLIENT_INFO
Expand Down Expand Up @@ -559,6 +561,169 @@ async def sample_delete_revision():
# Done; return the response.
return response

async def list_operations(
self,
request: operations_pb2.ListOperationsRequest = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.ListOperationsResponse:
r"""Lists operations that match the specified filter in the request.
Args:
request (:class:`~.operations_pb2.ListOperationsRequest`):
The request object. Request message for
`ListOperations` method.
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:
~.operations_pb2.ListOperationsResponse:
Response message for ``ListOperations`` method.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.ListOperationsRequest(**request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._client._transport.list_operations,
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,
)

# Done; return the response.
return response

async def get_operation(
self,
request: operations_pb2.GetOperationRequest = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.
Args:
request (:class:`~.operations_pb2.GetOperationRequest`):
The request object. Request message for
`GetOperation` method.
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:
~.operations_pb2.Operation:
An ``Operation`` object.
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.GetOperationRequest(**request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._client._transport.get_operation,
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,
)

# Done; return the response.
return response

async def delete_operation(
self,
request: operations_pb2.DeleteOperationRequest = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes a long-running operation.
This method indicates that the client is no longer interested
in the operation result. It does not cancel the operation.
If the server doesn't support this method, it returns
`google.rpc.Code.UNIMPLEMENTED`.
Args:
request (:class:`~.operations_pb2.DeleteOperationRequest`):
The request object. Request message for
`DeleteOperation` method.
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:
None
"""
# Create or coerce a protobuf request object.
# The request isn't a proto-plus wrapped type,
# so it must be constructed via keyword expansion.
if isinstance(request, dict):
request = operations_pb2.DeleteOperationRequest(**request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method.wrap_method(
self._client._transport.delete_operation,
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.
await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

async def __aenter__(self):
return self

Expand Down
Loading

0 comments on commit a2618da

Please sign in to comment.