Skip to content

Commit 18b3c0d

Browse files
feat: [google-cloud-kms] introduce Long-Running Operations (LRO) for KMS (#12661)
BEGIN_COMMIT_OVERRIDE feat: introduce Long-Running Operations (LRO) for KMS END_COMMIT_OVERRIDE - [ ] Regenerate this pull request now. PiperOrigin-RevId: 631049366 Source-Link: googleapis/googleapis@abe82f8 Source-Link: googleapis/googleapis-gen@17663bd Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWttcy8uT3dsQm90LnlhbWwiLCJoIjoiMTc2NjNiZDU5MmUzN2IwNTkzMDU4MDE5ZTdiYTFjOGNjY2UyYmRiNSJ9 BEGIN_NESTED_COMMIT feat: [google-cloud-kms] support the ED25519 asymmetric signing algorithm PiperOrigin-RevId: 630661612 Source-Link: googleapis/googleapis@245c0f5 Source-Link: googleapis/googleapis-gen@11beb7e Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWttcy8uT3dsQm90LnlhbWwiLCJoIjoiMTFiZWI3ZWMwYzhlZjhlOGRlNzM1NjAzNjViMjhjN2MyODhhYThjZCJ9 END_NESTED_COMMIT --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: ohmayr <omairnaveed@ymail.com>
1 parent 04a2214 commit 18b3c0d

18 files changed

Lines changed: 6420 additions & 844 deletions

File tree

packages/google-cloud-kms/google/cloud/kms/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.21.4" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-kms/google/cloud/kms_v1/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.21.4" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-kms/google/cloud/kms_v1/services/ekm_service/async_client.py

Lines changed: 125 additions & 96 deletions
Large diffs are not rendered by default.

packages/google-cloud-kms/google/cloud/kms_v1/services/ekm_service/client.py

Lines changed: 103 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import os
1818
import re
1919
from typing import (
20+
Callable,
2021
Dict,
2122
Mapping,
2223
MutableMapping,
@@ -583,7 +584,9 @@ def __init__(
583584
self,
584585
*,
585586
credentials: Optional[ga_credentials.Credentials] = None,
586-
transport: Optional[Union[str, EkmServiceTransport]] = None,
587+
transport: Optional[
588+
Union[str, EkmServiceTransport, Callable[..., EkmServiceTransport]]
589+
] = None,
587590
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
588591
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
589592
) -> None:
@@ -595,9 +598,11 @@ def __init__(
595598
credentials identify the application to the service; if none
596599
are specified, the client will attempt to ascertain the
597600
credentials from the environment.
598-
transport (Union[str, EkmServiceTransport]): The
599-
transport to use. If set to None, a transport is chosen
600-
automatically.
601+
transport (Optional[Union[str,EkmServiceTransport,Callable[..., EkmServiceTransport]]]):
602+
The transport to use, or a Callable that constructs and returns a new transport.
603+
If a Callable is given, it will be called with the same set of initialization
604+
arguments as used in the EkmServiceTransport constructor.
605+
If set to None, a transport is chosen automatically.
601606
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
602607
Custom options for the client.
603608
@@ -703,8 +708,15 @@ def __init__(
703708
api_key_value
704709
)
705710

706-
Transport = type(self).get_transport_class(cast(str, transport))
707-
self._transport = Transport(
711+
transport_init: Union[
712+
Type[EkmServiceTransport], Callable[..., EkmServiceTransport]
713+
] = (
714+
type(self).get_transport_class(transport)
715+
if isinstance(transport, str) or transport is None
716+
else cast(Callable[..., EkmServiceTransport], transport)
717+
)
718+
# initialize with the provided callable or the passed in class
719+
self._transport = transport_init(
708720
credentials=credentials,
709721
credentials_file=self._client_options.credentials_file,
710722
host=self._api_endpoint,
@@ -783,19 +795,17 @@ def sample_list_ekm_connections():
783795
784796
"""
785797
# Create or coerce a protobuf request object.
786-
# Quick check: If we got a request object, we should *not* have
787-
# gotten any keyword arguments that map to the request.
798+
# - Quick check: If we got a request object, we should *not* have
799+
# gotten any keyword arguments that map to the request.
788800
has_flattened_params = any([parent])
789801
if request is not None and has_flattened_params:
790802
raise ValueError(
791803
"If the `request` argument is set, then none of "
792804
"the individual field arguments should be set."
793805
)
794806

795-
# Minor optimization to avoid making a copy if the user passes
796-
# in a ekm_service.ListEkmConnectionsRequest.
797-
# There's no risk of modifying the input as we've already verified
798-
# there are no flattened fields.
807+
# - Use the request object if provided (there's no risk of modifying the input as
808+
# there are no flattened fields), or create one.
799809
if not isinstance(request, ekm_service.ListEkmConnectionsRequest):
800810
request = ekm_service.ListEkmConnectionsRequest(request)
801811
# If we have keyword arguments corresponding to fields on the
@@ -910,19 +920,17 @@ def sample_get_ekm_connection():
910920
911921
"""
912922
# Create or coerce a protobuf request object.
913-
# Quick check: If we got a request object, we should *not* have
914-
# gotten any keyword arguments that map to the request.
923+
# - Quick check: If we got a request object, we should *not* have
924+
# gotten any keyword arguments that map to the request.
915925
has_flattened_params = any([name])
916926
if request is not None and has_flattened_params:
917927
raise ValueError(
918928
"If the `request` argument is set, then none of "
919929
"the individual field arguments should be set."
920930
)
921931

922-
# Minor optimization to avoid making a copy if the user passes
923-
# in a ekm_service.GetEkmConnectionRequest.
924-
# There's no risk of modifying the input as we've already verified
925-
# there are no flattened fields.
932+
# - Use the request object if provided (there's no risk of modifying the input as
933+
# there are no flattened fields), or create one.
926934
if not isinstance(request, ekm_service.GetEkmConnectionRequest):
927935
request = ekm_service.GetEkmConnectionRequest(request)
928936
# If we have keyword arguments corresponding to fields on the
@@ -1046,19 +1054,17 @@ def sample_create_ekm_connection():
10461054
10471055
"""
10481056
# Create or coerce a protobuf request object.
1049-
# Quick check: If we got a request object, we should *not* have
1050-
# gotten any keyword arguments that map to the request.
1057+
# - Quick check: If we got a request object, we should *not* have
1058+
# gotten any keyword arguments that map to the request.
10511059
has_flattened_params = any([parent, ekm_connection_id, ekm_connection])
10521060
if request is not None and has_flattened_params:
10531061
raise ValueError(
10541062
"If the `request` argument is set, then none of "
10551063
"the individual field arguments should be set."
10561064
)
10571065

1058-
# Minor optimization to avoid making a copy if the user passes
1059-
# in a ekm_service.CreateEkmConnectionRequest.
1060-
# There's no risk of modifying the input as we've already verified
1061-
# there are no flattened fields.
1066+
# - Use the request object if provided (there's no risk of modifying the input as
1067+
# there are no flattened fields), or create one.
10621068
if not isinstance(request, ekm_service.CreateEkmConnectionRequest):
10631069
request = ekm_service.CreateEkmConnectionRequest(request)
10641070
# If we have keyword arguments corresponding to fields on the
@@ -1174,19 +1180,17 @@ def sample_update_ekm_connection():
11741180
11751181
"""
11761182
# Create or coerce a protobuf request object.
1177-
# Quick check: If we got a request object, we should *not* have
1178-
# gotten any keyword arguments that map to the request.
1183+
# - Quick check: If we got a request object, we should *not* have
1184+
# gotten any keyword arguments that map to the request.
11791185
has_flattened_params = any([ekm_connection, update_mask])
11801186
if request is not None and has_flattened_params:
11811187
raise ValueError(
11821188
"If the `request` argument is set, then none of "
11831189
"the individual field arguments should be set."
11841190
)
11851191

1186-
# Minor optimization to avoid making a copy if the user passes
1187-
# in a ekm_service.UpdateEkmConnectionRequest.
1188-
# There's no risk of modifying the input as we've already verified
1189-
# there are no flattened fields.
1192+
# - Use the request object if provided (there's no risk of modifying the input as
1193+
# there are no flattened fields), or create one.
11901194
if not isinstance(request, ekm_service.UpdateEkmConnectionRequest):
11911195
request = ekm_service.UpdateEkmConnectionRequest(request)
11921196
# If we have keyword arguments corresponding to fields on the
@@ -1292,19 +1296,17 @@ def sample_get_ekm_config():
12921296
12931297
"""
12941298
# Create or coerce a protobuf request object.
1295-
# Quick check: If we got a request object, we should *not* have
1296-
# gotten any keyword arguments that map to the request.
1299+
# - Quick check: If we got a request object, we should *not* have
1300+
# gotten any keyword arguments that map to the request.
12971301
has_flattened_params = any([name])
12981302
if request is not None and has_flattened_params:
12991303
raise ValueError(
13001304
"If the `request` argument is set, then none of "
13011305
"the individual field arguments should be set."
13021306
)
13031307

1304-
# Minor optimization to avoid making a copy if the user passes
1305-
# in a ekm_service.GetEkmConfigRequest.
1306-
# There's no risk of modifying the input as we've already verified
1307-
# there are no flattened fields.
1308+
# - Use the request object if provided (there's no risk of modifying the input as
1309+
# there are no flattened fields), or create one.
13081310
if not isinstance(request, ekm_service.GetEkmConfigRequest):
13091311
request = ekm_service.GetEkmConfigRequest(request)
13101312
# If we have keyword arguments corresponding to fields on the
@@ -1412,19 +1414,17 @@ def sample_update_ekm_config():
14121414
14131415
"""
14141416
# Create or coerce a protobuf request object.
1415-
# Quick check: If we got a request object, we should *not* have
1416-
# gotten any keyword arguments that map to the request.
1417+
# - Quick check: If we got a request object, we should *not* have
1418+
# gotten any keyword arguments that map to the request.
14171419
has_flattened_params = any([ekm_config, update_mask])
14181420
if request is not None and has_flattened_params:
14191421
raise ValueError(
14201422
"If the `request` argument is set, then none of "
14211423
"the individual field arguments should be set."
14221424
)
14231425

1424-
# Minor optimization to avoid making a copy if the user passes
1425-
# in a ekm_service.UpdateEkmConfigRequest.
1426-
# There's no risk of modifying the input as we've already verified
1427-
# there are no flattened fields.
1426+
# - Use the request object if provided (there's no risk of modifying the input as
1427+
# there are no flattened fields), or create one.
14281428
if not isinstance(request, ekm_service.UpdateEkmConfigRequest):
14291429
request = ekm_service.UpdateEkmConfigRequest(request)
14301430
# If we have keyword arguments corresponding to fields on the
@@ -1529,19 +1529,17 @@ def sample_verify_connectivity():
15291529
15301530
"""
15311531
# Create or coerce a protobuf request object.
1532-
# Quick check: If we got a request object, we should *not* have
1533-
# gotten any keyword arguments that map to the request.
1532+
# - Quick check: If we got a request object, we should *not* have
1533+
# gotten any keyword arguments that map to the request.
15341534
has_flattened_params = any([name])
15351535
if request is not None and has_flattened_params:
15361536
raise ValueError(
15371537
"If the `request` argument is set, then none of "
15381538
"the individual field arguments should be set."
15391539
)
15401540

1541-
# Minor optimization to avoid making a copy if the user passes
1542-
# in a ekm_service.VerifyConnectivityRequest.
1543-
# There's no risk of modifying the input as we've already verified
1544-
# there are no flattened fields.
1541+
# - Use the request object if provided (there's no risk of modifying the input as
1542+
# there are no flattened fields), or create one.
15451543
if not isinstance(request, ekm_service.VerifyConnectivityRequest):
15461544
request = ekm_service.VerifyConnectivityRequest(request)
15471545
# If we have keyword arguments corresponding to fields on the
@@ -1586,6 +1584,63 @@ def __exit__(self, type, value, traceback):
15861584
"""
15871585
self.transport.close()
15881586

1587+
def get_operation(
1588+
self,
1589+
request: Optional[operations_pb2.GetOperationRequest] = None,
1590+
*,
1591+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
1592+
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
1593+
metadata: Sequence[Tuple[str, str]] = (),
1594+
) -> operations_pb2.Operation:
1595+
r"""Gets the latest state of a long-running operation.
1596+
1597+
Args:
1598+
request (:class:`~.operations_pb2.GetOperationRequest`):
1599+
The request object. Request message for
1600+
`GetOperation` method.
1601+
retry (google.api_core.retry.Retry): Designation of what errors,
1602+
if any, should be retried.
1603+
timeout (float): The timeout for this request.
1604+
metadata (Sequence[Tuple[str, str]]): Strings which should be
1605+
sent along with the request as metadata.
1606+
Returns:
1607+
~.operations_pb2.Operation:
1608+
An ``Operation`` object.
1609+
"""
1610+
# Create or coerce a protobuf request object.
1611+
# The request isn't a proto-plus wrapped type,
1612+
# so it must be constructed via keyword expansion.
1613+
if isinstance(request, dict):
1614+
request = operations_pb2.GetOperationRequest(**request)
1615+
1616+
# Wrap the RPC method; this adds retry and timeout information,
1617+
# and friendly error handling.
1618+
rpc = gapic_v1.method.wrap_method(
1619+
self._transport.get_operation,
1620+
default_timeout=None,
1621+
client_info=DEFAULT_CLIENT_INFO,
1622+
)
1623+
1624+
# Certain fields should be provided within the metadata header;
1625+
# add these here.
1626+
metadata = tuple(metadata) + (
1627+
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1628+
)
1629+
1630+
# Validate the universe domain.
1631+
self._validate_universe_domain()
1632+
1633+
# Send the request.
1634+
response = rpc(
1635+
request,
1636+
retry=retry,
1637+
timeout=timeout,
1638+
metadata=metadata,
1639+
)
1640+
1641+
# Done; return the response.
1642+
return response
1643+
15891644
def get_location(
15901645
self,
15911646
request: Optional[locations_pb2.GetLocationRequest] = None,

packages/google-cloud-kms/google/cloud/kms_v1/services/ekm_service/transports/base.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ def verify_connectivity(
288288
]:
289289
raise NotImplementedError()
290290

291+
@property
292+
def get_operation(
293+
self,
294+
) -> Callable[
295+
[operations_pb2.GetOperationRequest],
296+
Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]],
297+
]:
298+
raise NotImplementedError()
299+
291300
@property
292301
def get_location(
293302
self,

0 commit comments

Comments
 (0)