diff --git a/google/cloud/recaptchaenterprise/__init__.py b/google/cloud/recaptchaenterprise/__init__.py index 0578867..af83cc7 100644 --- a/google/cloud/recaptchaenterprise/__init__.py +++ b/google/cloud/recaptchaenterprise/__init__.py @@ -46,6 +46,8 @@ PrivatePasswordLeakVerification, RelatedAccountGroup, RelatedAccountGroupMembership, + RetrieveLegacySecretKeyRequest, + RetrieveLegacySecretKeyResponse, RiskAnalysis, ScoreDistribution, ScoreMetrics, @@ -86,6 +88,8 @@ "PrivatePasswordLeakVerification", "RelatedAccountGroup", "RelatedAccountGroupMembership", + "RetrieveLegacySecretKeyRequest", + "RetrieveLegacySecretKeyResponse", "RiskAnalysis", "ScoreDistribution", "ScoreMetrics", diff --git a/google/cloud/recaptchaenterprise_v1/__init__.py b/google/cloud/recaptchaenterprise_v1/__init__.py index 58da012..63684c0 100644 --- a/google/cloud/recaptchaenterprise_v1/__init__.py +++ b/google/cloud/recaptchaenterprise_v1/__init__.py @@ -44,6 +44,8 @@ PrivatePasswordLeakVerification, RelatedAccountGroup, RelatedAccountGroupMembership, + RetrieveLegacySecretKeyRequest, + RetrieveLegacySecretKeyResponse, RiskAnalysis, ScoreDistribution, ScoreMetrics, @@ -84,6 +86,8 @@ "RecaptchaEnterpriseServiceClient", "RelatedAccountGroup", "RelatedAccountGroupMembership", + "RetrieveLegacySecretKeyRequest", + "RetrieveLegacySecretKeyResponse", "RiskAnalysis", "ScoreDistribution", "ScoreMetrics", diff --git a/google/cloud/recaptchaenterprise_v1/gapic_metadata.json b/google/cloud/recaptchaenterprise_v1/gapic_metadata.json index a170c7f..c44d903 100644 --- a/google/cloud/recaptchaenterprise_v1/gapic_metadata.json +++ b/google/cloud/recaptchaenterprise_v1/gapic_metadata.json @@ -60,6 +60,11 @@ "migrate_key" ] }, + "RetrieveLegacySecretKey": { + "methods": [ + "retrieve_legacy_secret_key" + ] + }, "SearchRelatedAccountGroupMemberships": { "methods": [ "search_related_account_group_memberships" @@ -125,6 +130,11 @@ "migrate_key" ] }, + "RetrieveLegacySecretKey": { + "methods": [ + "retrieve_legacy_secret_key" + ] + }, "SearchRelatedAccountGroupMemberships": { "methods": [ "search_related_account_group_memberships" diff --git a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py index 240a5df..4393ba4 100644 --- a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py +++ b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/async_client.py @@ -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, @@ -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 @@ -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 @@ -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 diff --git a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py index e3c9a2a..7488b20 100644 --- a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py +++ b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py @@ -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, @@ -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 @@ -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 @@ -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 diff --git a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py index 1000e4d..a7ecc60 100644 --- a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py +++ b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/base.py @@ -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, @@ -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, diff --git a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py index 4994487..d349e12 100644 --- a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py +++ b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc.py @@ -344,6 +344,37 @@ def list_keys( ) return self._stubs["list_keys"] + @property + def retrieve_legacy_secret_key( + self, + ) -> Callable[ + [recaptchaenterprise.RetrieveLegacySecretKeyRequest], + recaptchaenterprise.RetrieveLegacySecretKeyResponse, + ]: + r"""Return a callable for the retrieve legacy secret key method over gRPC. + + 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. + + Returns: + Callable[[~.RetrieveLegacySecretKeyRequest], + ~.RetrieveLegacySecretKeyResponse]: + 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 "retrieve_legacy_secret_key" not in self._stubs: + self._stubs["retrieve_legacy_secret_key"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RetrieveLegacySecretKey", + request_serializer=recaptchaenterprise.RetrieveLegacySecretKeyRequest.serialize, + response_deserializer=recaptchaenterprise.RetrieveLegacySecretKeyResponse.deserialize, + ) + return self._stubs["retrieve_legacy_secret_key"] + @property def get_key( self, @@ -520,7 +551,7 @@ def list_related_account_group_memberships( r"""Return a callable for the list related account group memberships method over gRPC. - Get the memberships in a group of related accounts. + Get memberships in a group of related accounts. Returns: Callable[[~.ListRelatedAccountGroupMembershipsRequest], diff --git a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py index 4e443f7..6aaaa67 100644 --- a/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py +++ b/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/transports/grpc_asyncio.py @@ -353,6 +353,37 @@ def list_keys( ) return self._stubs["list_keys"] + @property + def retrieve_legacy_secret_key( + self, + ) -> Callable[ + [recaptchaenterprise.RetrieveLegacySecretKeyRequest], + Awaitable[recaptchaenterprise.RetrieveLegacySecretKeyResponse], + ]: + r"""Return a callable for the retrieve legacy secret key method over gRPC. + + 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. + + Returns: + Callable[[~.RetrieveLegacySecretKeyRequest], + Awaitable[~.RetrieveLegacySecretKeyResponse]]: + 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 "retrieve_legacy_secret_key" not in self._stubs: + self._stubs["retrieve_legacy_secret_key"] = self.grpc_channel.unary_unary( + "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RetrieveLegacySecretKey", + request_serializer=recaptchaenterprise.RetrieveLegacySecretKeyRequest.serialize, + response_deserializer=recaptchaenterprise.RetrieveLegacySecretKeyResponse.deserialize, + ) + return self._stubs["retrieve_legacy_secret_key"] + @property def get_key( self, @@ -537,7 +568,7 @@ def list_related_account_group_memberships( r"""Return a callable for the list related account group memberships method over gRPC. - Get the memberships in a group of related accounts. + Get memberships in a group of related accounts. Returns: Callable[[~.ListRelatedAccountGroupMembershipsRequest], diff --git a/google/cloud/recaptchaenterprise_v1/types/__init__.py b/google/cloud/recaptchaenterprise_v1/types/__init__.py index a2973e4..8ace7cf 100644 --- a/google/cloud/recaptchaenterprise_v1/types/__init__.py +++ b/google/cloud/recaptchaenterprise_v1/types/__init__.py @@ -39,6 +39,8 @@ PrivatePasswordLeakVerification, RelatedAccountGroup, RelatedAccountGroupMembership, + RetrieveLegacySecretKeyRequest, + RetrieveLegacySecretKeyResponse, RiskAnalysis, ScoreDistribution, ScoreMetrics, @@ -77,6 +79,8 @@ "PrivatePasswordLeakVerification", "RelatedAccountGroup", "RelatedAccountGroupMembership", + "RetrieveLegacySecretKeyRequest", + "RetrieveLegacySecretKeyResponse", "RiskAnalysis", "ScoreDistribution", "ScoreMetrics", diff --git a/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py b/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py index 42820c3..7fb2f69 100644 --- a/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py +++ b/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py @@ -23,21 +23,23 @@ "CreateAssessmentRequest", "AnnotateAssessmentRequest", "AnnotateAssessmentResponse", + "PrivatePasswordLeakVerification", "Assessment", "Event", "RiskAnalysis", "TokenProperties", "AccountDefenderAssessment", - "PrivatePasswordLeakVerification", "CreateKeyRequest", "ListKeysRequest", "ListKeysResponse", + "RetrieveLegacySecretKeyRequest", "GetKeyRequest", "UpdateKeyRequest", "DeleteKeyRequest", "MigrateKeyRequest", "GetMetricsRequest", "Metrics", + "RetrieveLegacySecretKeyResponse", "Key", "TestingOptions", "WebKeySettings", @@ -100,12 +102,12 @@ class AnnotateAssessmentRequest(proto.Message): Optional. Optional reasons for the annotation that will be assigned to the Event. hashed_account_id (bytes): - Optional. Optional unique stable hashed user identifier to - apply to the assessment. This is an alternative to setting - the hashed_account_id in CreateAssessment, for example when - the account identifier is not yet known in the initial - request. It is recommended that the identifier is hashed - using hmac-sha256 with stable secret. + Optional. Unique stable hashed user identifier to apply to + the assessment. This is an alternative to setting the + hashed_account_id in CreateAssessment, for example when the + account identifier is not yet known in the initial request. + It is recommended that the identifier is hashed using + hmac-sha256 with stable secret. """ class Annotation(proto.Enum): @@ -124,12 +126,17 @@ class Reason(proto.Enum): CHARGEBACK = 1 CHARGEBACK_FRAUD = 8 CHARGEBACK_DISPUTE = 9 + REFUND = 10 + REFUND_FRAUD = 11 + TRANSACTION_ACCEPTED = 12 + TRANSACTION_DECLINED = 13 PAYMENT_HEURISTICS = 2 INITIATED_TWO_FACTOR = 7 PASSED_TWO_FACTOR = 3 FAILED_TWO_FACTOR = 4 CORRECT_PASSWORD = 5 INCORRECT_PASSWORD = 6 + SOCIAL_SPAM = 14 name = proto.Field( proto.STRING, @@ -155,6 +162,49 @@ class AnnotateAssessmentResponse(proto.Message): r"""Empty response for AnnotateAssessment.""" +class PrivatePasswordLeakVerification(proto.Message): + r"""Private password leak verification info. + + Attributes: + lookup_hash_prefix (bytes): + Optional. Exactly 26-bit prefix of the + SHA-256 hash of the canonicalized username. It + is used to look up password leaks associated + with that hash prefix. + encrypted_user_credentials_hash (bytes): + Optional. Encrypted Scrypt hash of the canonicalized + username+password. It is re-encrypted by the server and + returned through ``reencrypted_user_credentials_hash``. + encrypted_leak_match_prefixes (Sequence[bytes]): + Output only. List of prefixes of the encrypted potential + password leaks that matched the given parameters. They must + be compared with the client-side decryption prefix of + ``reencrypted_user_credentials_hash`` + reencrypted_user_credentials_hash (bytes): + Output only. Corresponds to the re-encryption of the + ``encrypted_user_credentials_hash`` field. It is used to + match potential password leaks within + ``encrypted_leak_match_prefixes``. + """ + + lookup_hash_prefix = proto.Field( + proto.BYTES, + number=1, + ) + encrypted_user_credentials_hash = proto.Field( + proto.BYTES, + number=2, + ) + encrypted_leak_match_prefixes = proto.RepeatedField( + proto.BYTES, + number=3, + ) + reencrypted_user_credentials_hash = proto.Field( + proto.BYTES, + number=4, + ) + + class Assessment(proto.Message): r"""A recaptcha assessment resource. @@ -172,10 +222,13 @@ class Assessment(proto.Message): Output only. Properties of the provided event token. account_defender_assessment (google.cloud.recaptchaenterprise_v1.types.AccountDefenderAssessment): - Assessment returned by Account Defender when a + Assessment returned by account defender when a hashed_account_id is provided. private_password_leak_verification (google.cloud.recaptchaenterprise_v1.types.PrivatePasswordLeakVerification): - Password leak verification info. + The private password leak verification field + contains the parameters that are used to to + check for leaks privately without sharing user + credentials. """ name = proto.Field( @@ -235,10 +288,9 @@ class Event(proto.Message): platforms already integrated with recaptcha enterprise. hashed_account_id (bytes): - Optional. Optional unique stable hashed user - identifier for the request. The identifier - should ideally be hashed using sha256 with - stable secret. + Optional. Unique stable hashed user + identifier for the request. The identifier must + be hashed using hmac-sha256 with stable secret. """ token = proto.Field( @@ -319,7 +371,7 @@ class TokenProperties(proto.Message): of the token. hostname (str): The hostname of the page on which the token - was generated. + was generated (Web keys only). action (str): Action name provided at token generation. """ @@ -359,7 +411,7 @@ class InvalidReason(proto.Enum): class AccountDefenderAssessment(proto.Message): - r"""Account Defender risk assessment. + r"""Account defender risk assessment. Attributes: labels (Sequence[google.cloud.recaptchaenterprise_v1.types.AccountDefenderAssessment.AccountDefenderLabel]): @@ -367,7 +419,7 @@ class AccountDefenderAssessment(proto.Message): """ class AccountDefenderLabel(proto.Enum): - r"""Labels returned by Account Defender for this request.""" + r"""Labels returned by account defender for this request.""" ACCOUNT_DEFENDER_LABEL_UNSPECIFIED = 0 PROFILE_MATCH = 1 SUSPICIOUS_LOGIN_ACTIVITY = 2 @@ -381,49 +433,6 @@ class AccountDefenderLabel(proto.Enum): ) -class PrivatePasswordLeakVerification(proto.Message): - r"""Private password leak verification info. - - Attributes: - lookup_hash_prefix (bytes): - Exactly 26-bit prefix of the SHA-256 hash of - the canonicalized username. It is used to look - up password leaks associated with that hash - prefix. - encrypted_user_credentials_hash (bytes): - Encrypted Scrypt hash of the canonicalized - username+password. It is re-encrypted by the server and - returned through ``reencrypted_user_credentials_hash``. - encrypted_leak_match_prefixes (Sequence[bytes]): - List of prefixes of the encrypted potential password leaks - that matched the given parameters. They should be compared - with the client-side decryption prefix of - ``reencrypted_user_credentials_hash`` - reencrypted_user_credentials_hash (bytes): - Corresponds to the re-encryption of the - ``encrypted_user_credentials_hash`` field. Used to match - potential password leaks within - ``encrypted_leak_match_prefixes``. - """ - - lookup_hash_prefix = proto.Field( - proto.BYTES, - number=1, - ) - encrypted_user_credentials_hash = proto.Field( - proto.BYTES, - number=2, - ) - encrypted_leak_match_prefixes = proto.RepeatedField( - proto.BYTES, - number=3, - ) - reencrypted_user_credentials_hash = proto.Field( - proto.BYTES, - number=4, - ) - - class CreateKeyRequest(proto.Message): r"""The create key request message. @@ -504,6 +513,22 @@ def raw_page(self): ) +class RetrieveLegacySecretKeyRequest(proto.Message): + r"""The retrieve legacy secret key request message. + + Attributes: + key (str): + Required. The public key name linked to the + requested secret key in the format + "projects/{project}/keys/{key}". + """ + + key = proto.Field( + proto.STRING, + number=1, + ) + + class GetKeyRequest(proto.Message): r"""The get key request message. @@ -630,6 +655,26 @@ class Metrics(proto.Message): ) +class RetrieveLegacySecretKeyResponse(proto.Message): + r"""Secret key is used only in legacy reCAPTCHA. It must be used + in a 3rd party integration with legacy reCAPTCHA. + + Attributes: + legacy_secret_key (str): + The secret key (also known as shared secret) + authorizes communication between your + application backend and the reCAPTCHA Enterprise + server to create an assessment. + The secret key needs to be kept safe for + security purposes. + """ + + legacy_secret_key = proto.Field( + proto.STRING, + number=1, + ) + + class Key(proto.Message): r"""A key used to identify and configure applications (web and/or mobile) that use reCAPTCHA Enterprise. @@ -964,10 +1009,10 @@ class ListRelatedAccountGroupMembershipsRequest(proto.Message): ``projects/{project}/relatedaccountgroups/{relatedaccountgroup}``. page_size (int): Optional. The maximum number of accounts to - return. The service may return fewer than this - value. If unspecified, at most 50 accounts will - be returned. The maximum value is 1000; values - above 1000 will be coerced to 1000. + return. The service might return fewer than this + value. If unspecified, at most 50 accounts are + returned. The maximum value is 1000; values + above 1000 are coerced to 1000. page_token (str): Optional. A page token, received from a previous ``ListRelatedAccountGroupMemberships`` call. @@ -1028,10 +1073,10 @@ class ListRelatedAccountGroupsRequest(proto.Message): "projects/{project}". page_size (int): Optional. The maximum number of groups to - return. The service may return fewer than this - value. If unspecified, at most 50 groups will be + return. The service might return fewer than this + value. If unspecified, at most 50 groups are returned. The maximum value is 1000; values - above 1000 will be coerced to 1000. + above 1000 are coerced to 1000. page_token (str): Optional. A page token, received from a previous ``ListRelatedAccountGroups`` call. Provide this to retrieve @@ -1091,19 +1136,20 @@ class SearchRelatedAccountGroupMembershipsRequest(proto.Message): Attributes: project (str): Required. The name of the project to search - related account group memberships from, in the - format "projects/{project}". + related account group memberships from. Specify + the project name in the following format: + "projects/{project}". hashed_account_id (bytes): 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. + ``CreateAssessment`` or ``AnnotateAssessment`` call. page_size (int): Optional. The maximum number of groups to - return. The service may return fewer than this - value. If unspecified, at most 50 groups will be + return. The service might return fewer than this + value. If unspecified, at most 50 groups are returned. The maximum value is 1000; values - above 1000 will be coerced to 1000. + above 1000 are coerced to 1000. page_token (str): Optional. A page token, received from a previous ``SearchRelatedAccountGroupMemberships`` call. Provide this @@ -1170,7 +1216,8 @@ class RelatedAccountGroupMembership(proto.Message): hashed_account_id (bytes): The unique stable hashed user identifier of the member. The identifier corresponds to a ``hashed_account_id`` provided - in a previous CreateAssessment or AnnotateAssessment call. + in a previous ``CreateAssessment`` or ``AnnotateAssessment`` + call. """ name = proto.Field( diff --git a/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_async.py b/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_async.py new file mode 100644 index 0000000..23e9e9a --- /dev/null +++ b/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_async.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RetrieveLegacySecretKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async] +# 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) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async] diff --git a/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_sync.py b/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_sync.py new file mode 100644 index 0000000..74fd8a1 --- /dev/null +++ b/samples/generated_samples/recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_sync.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RetrieveLegacySecretKey +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-recaptcha-enterprise + + +# [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_sync] +# 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) + +# [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_sync] diff --git a/samples/generated_samples/snippet_metadata_recaptchaenterprise_v1.json b/samples/generated_samples/snippet_metadata_recaptchaenterprise_v1.json index a2e75f6..ca2c5c7 100644 --- a/samples/generated_samples/snippet_metadata_recaptchaenterprise_v1.json +++ b/samples/generated_samples/snippet_metadata_recaptchaenterprise_v1.json @@ -1590,6 +1590,167 @@ ], "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_migrate_key_sync.py" }, + { + "canonical": true, + "clientMethod": { + "async": true, + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient", + "shortName": "RecaptchaEnterpriseServiceAsyncClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceAsyncClient.retrieve_legacy_secret_key", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.RetrieveLegacySecretKey", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "RetrieveLegacySecretKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyRequest" + }, + { + "name": "key", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse", + "shortName": "retrieve_legacy_secret_key" + }, + "description": "Sample for RetrieveLegacySecretKey", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_async", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_async.py" + }, + { + "canonical": true, + "clientMethod": { + "client": { + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient", + "shortName": "RecaptchaEnterpriseServiceClient" + }, + "fullName": "google.cloud.recaptchaenterprise_v1.RecaptchaEnterpriseServiceClient.retrieve_legacy_secret_key", + "method": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService.RetrieveLegacySecretKey", + "service": { + "fullName": "google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService", + "shortName": "RecaptchaEnterpriseService" + }, + "shortName": "RetrieveLegacySecretKey" + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyRequest" + }, + { + "name": "key", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.recaptchaenterprise_v1.types.RetrieveLegacySecretKeyResponse", + "shortName": "retrieve_legacy_secret_key" + }, + "description": "Sample for RetrieveLegacySecretKey", + "file": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", + "regionTag": "recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RetrieveLegacySecretKey_sync", + "segments": [ + { + "end": 51, + "start": 27, + "type": "FULL" + }, + { + "end": 51, + "start": 27, + "type": "SHORT" + }, + { + "end": 40, + "start": 38, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 45, + "start": 41, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 48, + "start": 46, + "type": "REQUEST_EXECUTION" + }, + { + "end": 52, + "start": 49, + "type": "RESPONSE_HANDLING" + } + ], + "title": "recaptchaenterprise_v1_generated_recaptcha_enterprise_service_retrieve_legacy_secret_key_sync.py" + }, { "canonical": true, "clientMethod": { diff --git a/scripts/fixup_recaptchaenterprise_v1_keywords.py b/scripts/fixup_recaptchaenterprise_v1_keywords.py index 5712f00..a13de26 100644 --- a/scripts/fixup_recaptchaenterprise_v1_keywords.py +++ b/scripts/fixup_recaptchaenterprise_v1_keywords.py @@ -49,6 +49,7 @@ class recaptchaenterpriseCallTransformer(cst.CSTTransformer): 'list_related_account_group_memberships': ('parent', 'page_size', 'page_token', ), 'list_related_account_groups': ('parent', 'page_size', 'page_token', ), 'migrate_key': ('name', ), + 'retrieve_legacy_secret_key': ('key', ), 'search_related_account_group_memberships': ('project', 'hashed_account_id', 'page_size', 'page_token', ), 'update_key': ('key', 'update_mask', ), } diff --git a/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py b/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py index 77040e0..2af2c91 100644 --- a/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py +++ b/tests/unit/gapic/recaptchaenterprise_v1/test_recaptcha_enterprise_service.py @@ -1715,6 +1715,253 @@ async def test_list_keys_async_pages(): assert page_.raw_page.next_page_token == token +@pytest.mark.parametrize( + "request_type", + [ + recaptchaenterprise.RetrieveLegacySecretKeyRequest, + dict, + ], +) +def test_retrieve_legacy_secret_key(request_type, transport: str = "grpc"): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_legacy_secret_key), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.RetrieveLegacySecretKeyResponse( + legacy_secret_key="legacy_secret_key_value", + ) + response = client.retrieve_legacy_secret_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.RetrieveLegacySecretKeyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.RetrieveLegacySecretKeyResponse) + assert response.legacy_secret_key == "legacy_secret_key_value" + + +def test_retrieve_legacy_secret_key_empty_call(): + # This test is a coverage failsafe to make sure that totally empty calls, + # i.e. request == None and no flattened fields passed, work. + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_legacy_secret_key), "__call__" + ) as call: + client.retrieve_legacy_secret_key() + call.assert_called() + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.RetrieveLegacySecretKeyRequest() + + +@pytest.mark.asyncio +async def test_retrieve_legacy_secret_key_async( + transport: str = "grpc_asyncio", + request_type=recaptchaenterprise.RetrieveLegacySecretKeyRequest, +): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, + ) + + # Everything is optional in proto3 as far as the runtime is concerned, + # and we are mocking out the actual API, so just send an empty request. + request = request_type() + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_legacy_secret_key), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.RetrieveLegacySecretKeyResponse( + legacy_secret_key="legacy_secret_key_value", + ) + ) + response = await client.retrieve_legacy_secret_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == recaptchaenterprise.RetrieveLegacySecretKeyRequest() + + # Establish that the response is the type that we expect. + assert isinstance(response, recaptchaenterprise.RetrieveLegacySecretKeyResponse) + assert response.legacy_secret_key == "legacy_secret_key_value" + + +@pytest.mark.asyncio +async def test_retrieve_legacy_secret_key_async_from_dict(): + await test_retrieve_legacy_secret_key_async(request_type=dict) + + +def test_retrieve_legacy_secret_key_field_headers(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.RetrieveLegacySecretKeyRequest() + + request.key = "key_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_legacy_secret_key), "__call__" + ) as call: + call.return_value = recaptchaenterprise.RetrieveLegacySecretKeyResponse() + client.retrieve_legacy_secret_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "key=key_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_retrieve_legacy_secret_key_field_headers_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = recaptchaenterprise.RetrieveLegacySecretKeyRequest() + + request.key = "key_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_legacy_secret_key), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.RetrieveLegacySecretKeyResponse() + ) + await client.retrieve_legacy_secret_key(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "key=key_value", + ) in kw["metadata"] + + +def test_retrieve_legacy_secret_key_flattened(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_legacy_secret_key), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.RetrieveLegacySecretKeyResponse() + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + client.retrieve_legacy_secret_key( + key="key_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + arg = args[0].key + mock_val = "key_value" + assert arg == mock_val + + +def test_retrieve_legacy_secret_key_flattened_error(): + client = RecaptchaEnterpriseServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + client.retrieve_legacy_secret_key( + recaptchaenterprise.RetrieveLegacySecretKeyRequest(), + key="key_value", + ) + + +@pytest.mark.asyncio +async def test_retrieve_legacy_secret_key_flattened_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_legacy_secret_key), "__call__" + ) as call: + # Designate an appropriate return value for the call. + call.return_value = recaptchaenterprise.RetrieveLegacySecretKeyResponse() + + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + recaptchaenterprise.RetrieveLegacySecretKeyResponse() + ) + # Call the method with a truthy value for each flattened field, + # using the keyword arguments to the method. + response = await client.retrieve_legacy_secret_key( + key="key_value", + ) + + # Establish that the underlying call was made with the expected + # request object values. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + arg = args[0].key + mock_val = "key_value" + assert arg == mock_val + + +@pytest.mark.asyncio +async def test_retrieve_legacy_secret_key_flattened_error_async(): + client = RecaptchaEnterpriseServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Attempting to call a method with both a request object and flattened + # fields is an error. + with pytest.raises(ValueError): + await client.retrieve_legacy_secret_key( + recaptchaenterprise.RetrieveLegacySecretKeyRequest(), + key="key_value", + ) + + @pytest.mark.parametrize( "request_type", [ @@ -4078,6 +4325,7 @@ def test_recaptcha_enterprise_service_base_transport(): "annotate_assessment", "create_key", "list_keys", + "retrieve_legacy_secret_key", "get_key", "update_key", "delete_key",