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

feat: add RetrieveLegacySecretKey method #311

Merged
merged 2 commits into from
Oct 14, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions google/cloud/recaptchaenterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
PrivatePasswordLeakVerification,
RelatedAccountGroup,
RelatedAccountGroupMembership,
RetrieveLegacySecretKeyRequest,
RetrieveLegacySecretKeyResponse,
RiskAnalysis,
ScoreDistribution,
ScoreMetrics,
Expand Down Expand Up @@ -86,6 +88,8 @@
"PrivatePasswordLeakVerification",
"RelatedAccountGroup",
"RelatedAccountGroupMembership",
"RetrieveLegacySecretKeyRequest",
"RetrieveLegacySecretKeyResponse",
"RiskAnalysis",
"ScoreDistribution",
"ScoreMetrics",
Expand Down
4 changes: 4 additions & 0 deletions google/cloud/recaptchaenterprise_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
PrivatePasswordLeakVerification,
RelatedAccountGroup,
RelatedAccountGroupMembership,
RetrieveLegacySecretKeyRequest,
RetrieveLegacySecretKeyResponse,
RiskAnalysis,
ScoreDistribution,
ScoreMetrics,
Expand Down Expand Up @@ -84,6 +86,8 @@
"RecaptchaEnterpriseServiceClient",
"RelatedAccountGroup",
"RelatedAccountGroupMembership",
"RetrieveLegacySecretKeyRequest",
"RetrieveLegacySecretKeyResponse",
"RiskAnalysis",
"ScoreDistribution",
"ScoreMetrics",
Expand Down
10 changes: 10 additions & 0 deletions google/cloud/recaptchaenterprise_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
"migrate_key"
]
},
"RetrieveLegacySecretKey": {
"methods": [
"retrieve_legacy_secret_key"
]
},
"SearchRelatedAccountGroupMemberships": {
"methods": [
"search_related_account_group_memberships"
Expand Down Expand Up @@ -125,6 +130,11 @@
"migrate_key"
]
},
"RetrieveLegacySecretKey": {
"methods": [
"retrieve_legacy_secret_key"
]
},
"SearchRelatedAccountGroupMemberships": {
"methods": [
"search_related_account_group_memberships"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,112 @@ async def sample_list_keys():
# Done; return the response.
return response

async def retrieve_legacy_secret_key(
self,
request: Union[recaptchaenterprise.RetrieveLegacySecretKeyRequest, dict] = None,
*,
key: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> recaptchaenterprise.RetrieveLegacySecretKeyResponse:
r"""Returns the secret key related to the specified
public key. You must use the legacy secret key only in a
3rd party integration with legacy reCAPTCHA.

.. 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 recaptchaenterprise_v1

async def sample_retrieve_legacy_secret_key():
# Create a client
client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient()

# Initialize request argument(s)
request = recaptchaenterprise_v1.RetrieveLegacySecretKeyRequest(
key="key_value",
)

# Make the request
response = await client.retrieve_legacy_secret_key(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyRequest, dict]):
The request object. The retrieve legacy secret key
request message.
key (:class:`str`):
Required. The public key name linked
to the requested secret key in the
format "projects/{project}/keys/{key}".

This corresponds to the ``key`` 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.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse:
Secret key is used only in legacy
reCAPTCHA. It must be used in a 3rd
party integration with legacy reCAPTCHA.

"""
# 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([key])
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 = recaptchaenterprise.RetrieveLegacySecretKeyRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if key is not None:
request.key = key

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

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def get_key(
self,
request: Union[recaptchaenterprise.GetKeyRequest, dict] = None,
Expand Down Expand Up @@ -1184,7 +1290,7 @@ async def list_related_account_group_memberships(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListRelatedAccountGroupMembershipsAsyncPager:
r"""Get the memberships in a group of related accounts.
r"""Get memberships in a group of related accounts.

.. code-block:: python

Expand Down Expand Up @@ -1339,8 +1445,8 @@ async def sample_search_related_account_group_memberships():
project (:class:`str`):
Required. The name of the project to
search related account group memberships
from, in the format
"projects/{project}".
from. Specify the project name in the
following format: "projects/{project}".

This corresponds to the ``project`` field
on the ``request`` instance; if ``request`` is provided, this
Expand All @@ -1349,7 +1455,8 @@ async def sample_search_related_account_group_memberships():
Optional. The unique stable hashed user identifier we
should search connections to. The identifier should
correspond to a ``hashed_account_id`` provided in a
previous CreateAssessment or AnnotateAssessment call.
previous ``CreateAssessment`` or ``AnnotateAssessment``
call.

This corresponds to the ``hashed_account_id`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,114 @@ def sample_list_keys():
# Done; return the response.
return response

def retrieve_legacy_secret_key(
self,
request: Union[recaptchaenterprise.RetrieveLegacySecretKeyRequest, dict] = None,
*,
key: str = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> recaptchaenterprise.RetrieveLegacySecretKeyResponse:
r"""Returns the secret key related to the specified
public key. You must use the legacy secret key only in a
3rd party integration with legacy reCAPTCHA.

.. 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 recaptchaenterprise_v1

def sample_retrieve_legacy_secret_key():
# Create a client
client = recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient()

# Initialize request argument(s)
request = recaptchaenterprise_v1.RetrieveLegacySecretKeyRequest(
key="key_value",
)

# Make the request
response = client.retrieve_legacy_secret_key(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyRequest, dict]):
The request object. The retrieve legacy secret key
request message.
key (str):
Required. The public key name linked
to the requested secret key in the
format "projects/{project}/keys/{key}".

This corresponds to the ``key`` 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.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse:
Secret key is used only in legacy
reCAPTCHA. It must be used in a 3rd
party integration with legacy reCAPTCHA.

"""
# 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([key])
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 recaptchaenterprise.RetrieveLegacySecretKeyRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, recaptchaenterprise.RetrieveLegacySecretKeyRequest):
request = recaptchaenterprise.RetrieveLegacySecretKeyRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if key is not None:
request.key = key

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[
self._transport.retrieve_legacy_secret_key
]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata((("key", request.key),)),
)

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def get_key(
self,
request: Union[recaptchaenterprise.GetKeyRequest, dict] = None,
Expand Down Expand Up @@ -1463,7 +1571,7 @@ def list_related_account_group_memberships(
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListRelatedAccountGroupMembershipsPager:
r"""Get the memberships in a group of related accounts.
r"""Get memberships in a group of related accounts.

.. code-block:: python

Expand Down Expand Up @@ -1624,8 +1732,8 @@ def sample_search_related_account_group_memberships():
project (str):
Required. The name of the project to
search related account group memberships
from, in the format
"projects/{project}".
from. Specify the project name in the
following format: "projects/{project}".

This corresponds to the ``project`` field
on the ``request`` instance; if ``request`` is provided, this
Expand All @@ -1634,7 +1742,8 @@ def sample_search_related_account_group_memberships():
Optional. The unique stable hashed user identifier we
should search connections to. The identifier should
correspond to a ``hashed_account_id`` provided in a
previous CreateAssessment or AnnotateAssessment call.
previous ``CreateAssessment`` or ``AnnotateAssessment``
call.

This corresponds to the ``hashed_account_id`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=600.0,
client_info=client_info,
),
self.retrieve_legacy_secret_key: gapic_v1.method.wrap_method(
self.retrieve_legacy_secret_key,
default_timeout=None,
client_info=client_info,
),
self.get_key: gapic_v1.method.wrap_method(
self.get_key,
default_timeout=600.0,
Expand Down Expand Up @@ -243,6 +248,18 @@ def list_keys(
]:
raise NotImplementedError()

@property
def retrieve_legacy_secret_key(
self,
) -> Callable[
[recaptchaenterprise.RetrieveLegacySecretKeyRequest],
Union[
recaptchaenterprise.RetrieveLegacySecretKeyResponse,
Awaitable[recaptchaenterprise.RetrieveLegacySecretKeyResponse],
],
]:
raise NotImplementedError()

@property
def get_key(
self,
Expand Down
Loading