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

Commit

Permalink
feat: added VerifyConnectivity RPC (#388)
Browse files Browse the repository at this point in the history
* feat: added VerifyConnectivity RPC

PiperOrigin-RevId: 530991686

Source-Link: googleapis/googleapis@be2600e

Source-Link: https://github.com/googleapis/googleapis-gen/commit/7eadc0e0aaece2bccb4e561f3b29b0584fbcf906
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiN2VhZGMwZTBhYWVjZTJiY2NiNGU1NjFmM2IyOWIwNTg0ZmJjZjkwNiJ9

* 🦉 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 May 12, 2023
1 parent ffbc362 commit b265bd7
Show file tree
Hide file tree
Showing 16 changed files with 1,269 additions and 1 deletion.
4 changes: 4 additions & 0 deletions google/cloud/kms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
ListEkmConnectionsResponse,
UpdateEkmConfigRequest,
UpdateEkmConnectionRequest,
VerifyConnectivityRequest,
VerifyConnectivityResponse,
)
from google.cloud.kms_v1.types.resources import (
CryptoKey,
Expand Down Expand Up @@ -106,6 +108,8 @@
"ListEkmConnectionsResponse",
"UpdateEkmConfigRequest",
"UpdateEkmConnectionRequest",
"VerifyConnectivityRequest",
"VerifyConnectivityResponse",
"CryptoKey",
"CryptoKeyVersion",
"CryptoKeyVersionTemplate",
Expand Down
4 changes: 4 additions & 0 deletions google/cloud/kms_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
ListEkmConnectionsResponse,
UpdateEkmConfigRequest,
UpdateEkmConnectionRequest,
VerifyConnectivityRequest,
VerifyConnectivityResponse,
)
from .types.resources import (
CryptoKey,
Expand Down Expand Up @@ -151,4 +153,6 @@
"UpdateCryptoKeyVersionRequest",
"UpdateEkmConfigRequest",
"UpdateEkmConnectionRequest",
"VerifyConnectivityRequest",
"VerifyConnectivityResponse",
)
15 changes: 15 additions & 0 deletions google/cloud/kms_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"methods": [
"update_ekm_connection"
]
},
"VerifyConnectivity": {
"methods": [
"verify_connectivity"
]
}
}
},
Expand Down Expand Up @@ -74,6 +79,11 @@
"methods": [
"update_ekm_connection"
]
},
"VerifyConnectivity": {
"methods": [
"verify_connectivity"
]
}
}
},
Expand Down Expand Up @@ -109,6 +119,11 @@
"methods": [
"update_ekm_connection"
]
},
"VerifyConnectivity": {
"methods": [
"verify_connectivity"
]
}
}
}
Expand Down
110 changes: 110 additions & 0 deletions google/cloud/kms_v1/services/ekm_service/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,116 @@ async def sample_update_ekm_config():
# Done; return the response.
return response

async def verify_connectivity(
self,
request: Optional[Union[ekm_service.VerifyConnectivityRequest, 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]] = (),
) -> ekm_service.VerifyConnectivityResponse:
r"""Verifies that Cloud KMS can successfully connect to the external
key manager specified by an
[EkmConnection][google.cloud.kms.v1.EkmConnection]. If there is
an error connecting to the EKM, this method returns a
FAILED_PRECONDITION status containing structured information as
described at
https://cloud.google.com/kms/docs/reference/ekm_errors.
.. 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 kms_v1
async def sample_verify_connectivity():
# Create a client
client = kms_v1.EkmServiceAsyncClient()
# Initialize request argument(s)
request = kms_v1.VerifyConnectivityRequest(
name="name_value",
)
# Make the request
response = await client.verify_connectivity(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.cloud.kms_v1.types.VerifyConnectivityRequest, dict]]):
The request object. Request message for
[EkmService.VerifyConnectivity][google.cloud.kms.v1.EkmService.VerifyConnectivity].
name (:class:`str`):
Required. The
[name][google.cloud.kms.v1.EkmConnection.name] of the
[EkmConnection][google.cloud.kms.v1.EkmConnection] to
verify.
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.cloud.kms_v1.types.VerifyConnectivityResponse:
Response message for
[EkmService.VerifyConnectivity][google.cloud.kms.v1.EkmService.VerifyConnectivity].
"""
# 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 = ekm_service.VerifyConnectivityRequest(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.verify_connectivity,
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_location(
self,
request: Optional[locations_pb2.GetLocationRequest] = None,
Expand Down
110 changes: 110 additions & 0 deletions google/cloud/kms_v1/services/ekm_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,116 @@ def sample_update_ekm_config():
# Done; return the response.
return response

def verify_connectivity(
self,
request: Optional[Union[ekm_service.VerifyConnectivityRequest, 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]] = (),
) -> ekm_service.VerifyConnectivityResponse:
r"""Verifies that Cloud KMS can successfully connect to the external
key manager specified by an
[EkmConnection][google.cloud.kms.v1.EkmConnection]. If there is
an error connecting to the EKM, this method returns a
FAILED_PRECONDITION status containing structured information as
described at
https://cloud.google.com/kms/docs/reference/ekm_errors.
.. 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 kms_v1
def sample_verify_connectivity():
# Create a client
client = kms_v1.EkmServiceClient()
# Initialize request argument(s)
request = kms_v1.VerifyConnectivityRequest(
name="name_value",
)
# Make the request
response = client.verify_connectivity(request=request)
# Handle the response
print(response)
Args:
request (Union[google.cloud.kms_v1.types.VerifyConnectivityRequest, dict]):
The request object. Request message for
[EkmService.VerifyConnectivity][google.cloud.kms.v1.EkmService.VerifyConnectivity].
name (str):
Required. The
[name][google.cloud.kms.v1.EkmConnection.name] of the
[EkmConnection][google.cloud.kms.v1.EkmConnection] to
verify.
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.cloud.kms_v1.types.VerifyConnectivityResponse:
Response message for
[EkmService.VerifyConnectivity][google.cloud.kms.v1.EkmService.VerifyConnectivity].
"""
# 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 ekm_service.VerifyConnectivityRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, ekm_service.VerifyConnectivityRequest):
request = ekm_service.VerifyConnectivityRequest(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.verify_connectivity]

# 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,
)

# Done; return the response.
return response

def __enter__(self) -> "EkmServiceClient":
return self

Expand Down
17 changes: 17 additions & 0 deletions google/cloud/kms_v1/services/ekm_service/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.verify_connectivity: gapic_v1.method.wrap_method(
self.verify_connectivity,
default_timeout=None,
client_info=client_info,
),
}

def close(self):
Expand Down Expand Up @@ -266,6 +271,18 @@ def update_ekm_config(
]:
raise NotImplementedError()

@property
def verify_connectivity(
self,
) -> Callable[
[ekm_service.VerifyConnectivityRequest],
Union[
ekm_service.VerifyConnectivityResponse,
Awaitable[ekm_service.VerifyConnectivityResponse],
],
]:
raise NotImplementedError()

@property
def get_location(
self,
Expand Down
34 changes: 34 additions & 0 deletions google/cloud/kms_v1/services/ekm_service/transports/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,40 @@ def update_ekm_config(
)
return self._stubs["update_ekm_config"]

@property
def verify_connectivity(
self,
) -> Callable[
[ekm_service.VerifyConnectivityRequest], ekm_service.VerifyConnectivityResponse
]:
r"""Return a callable for the verify connectivity method over gRPC.
Verifies that Cloud KMS can successfully connect to the external
key manager specified by an
[EkmConnection][google.cloud.kms.v1.EkmConnection]. If there is
an error connecting to the EKM, this method returns a
FAILED_PRECONDITION status containing structured information as
described at
https://cloud.google.com/kms/docs/reference/ekm_errors.
Returns:
Callable[[~.VerifyConnectivityRequest],
~.VerifyConnectivityResponse]:
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 "verify_connectivity" not in self._stubs:
self._stubs["verify_connectivity"] = self.grpc_channel.unary_unary(
"/google.cloud.kms.v1.EkmService/VerifyConnectivity",
request_serializer=ekm_service.VerifyConnectivityRequest.serialize,
response_deserializer=ekm_service.VerifyConnectivityResponse.deserialize,
)
return self._stubs["verify_connectivity"]

@property
def set_iam_policy(
self,
Expand Down
Loading

0 comments on commit b265bd7

Please sign in to comment.