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

feat: add reCAPTCHA Enterprise Fraud Prevention API #350

Merged
merged 2 commits into from
Mar 20, 2023
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
6 changes: 6 additions & 0 deletions google/cloud/recaptchaenterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
DeleteKeyRequest,
EndpointVerificationInfo,
Event,
FraudPreventionAssessment,
GetKeyRequest,
GetMetricsRequest,
IOSKeySettings,
Expand All @@ -61,6 +62,8 @@
SearchRelatedAccountGroupMembershipsResponse,
TestingOptions,
TokenProperties,
TransactionData,
TransactionEvent,
UpdateKeyRequest,
WafSettings,
WebKeySettings,
Expand All @@ -81,6 +84,7 @@
"DeleteKeyRequest",
"EndpointVerificationInfo",
"Event",
"FraudPreventionAssessment",
"GetKeyRequest",
"GetMetricsRequest",
"IOSKeySettings",
Expand All @@ -105,6 +109,8 @@
"SearchRelatedAccountGroupMembershipsResponse",
"TestingOptions",
"TokenProperties",
"TransactionData",
"TransactionEvent",
"UpdateKeyRequest",
"WafSettings",
"WebKeySettings",
Expand Down
6 changes: 6 additions & 0 deletions google/cloud/recaptchaenterprise_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
DeleteKeyRequest,
EndpointVerificationInfo,
Event,
FraudPreventionAssessment,
GetKeyRequest,
GetMetricsRequest,
IOSKeySettings,
Expand All @@ -59,6 +60,8 @@
SearchRelatedAccountGroupMembershipsResponse,
TestingOptions,
TokenProperties,
TransactionData,
TransactionEvent,
UpdateKeyRequest,
WafSettings,
WebKeySettings,
Expand All @@ -78,6 +81,7 @@
"DeleteKeyRequest",
"EndpointVerificationInfo",
"Event",
"FraudPreventionAssessment",
"GetKeyRequest",
"GetMetricsRequest",
"IOSKeySettings",
Expand All @@ -103,6 +107,8 @@
"SearchRelatedAccountGroupMembershipsResponse",
"TestingOptions",
"TokenProperties",
"TransactionData",
"TransactionEvent",
"UpdateKeyRequest",
"WafSettings",
"WebKeySettings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
except AttributeError: # pragma: NO COVER
OptionalRetry = Union[retries.Retry, object] # type: ignore

from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore

from google.cloud.recaptchaenterprise_v1.services.recaptcha_enterprise_service import (
Expand Down Expand Up @@ -311,7 +312,9 @@ async def sample_create_assessment():

Returns:
google.cloud.recaptchaenterprise_v1.types.Assessment:
A recaptcha assessment resource.
A reCAPTCHA Enterprise assessment
resource.

"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
Expand Down Expand Up @@ -483,6 +486,8 @@ async def create_key(
self,
request: Optional[Union[recaptchaenterprise.CreateKeyRequest, dict]] = None,
*,
parent: Optional[str] = None,
key: Optional[recaptchaenterprise.Key] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
Expand Down Expand Up @@ -522,6 +527,21 @@ async def sample_create_key():
Args:
request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.CreateKeyRequest, dict]]):
The request object. The create key request message.
parent (:class:`str`):
Required. The name of the project in
which the key will be created, in the
format "projects/{project}".

This corresponds to the ``parent`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
key (:class:`google.cloud.recaptchaenterprise_v1.types.Key`):
Required. Information to create a
reCAPTCHA Enterprise 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.
Expand All @@ -536,8 +556,24 @@ async def sample_create_key():

"""
# 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([parent, 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.CreateKeyRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if parent is not None:
request.parent = parent
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(
Expand Down Expand Up @@ -567,6 +603,7 @@ async def list_keys(
self,
request: Optional[Union[recaptchaenterprise.ListKeysRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
Expand Down Expand Up @@ -604,6 +641,15 @@ async def sample_list_keys():
Args:
request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.ListKeysRequest, dict]]):
The request object. The list keys request message.
parent (:class:`str`):
Required. The name of the project
that contains the keys that will be
listed, in the format
"projects/{project}".

This corresponds to the ``parent`` 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.
Expand All @@ -620,8 +666,22 @@ async def sample_list_keys():

"""
# 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([parent])
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.ListKeysRequest(request)

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

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
Expand Down Expand Up @@ -768,6 +828,7 @@ async def get_key(
self,
request: Optional[Union[recaptchaenterprise.GetKeyRequest, 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]] = (),
Expand Down Expand Up @@ -803,6 +864,14 @@ async def sample_get_key():
Args:
request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.GetKeyRequest, dict]]):
The request object. The get key request message.
name (:class:`str`):
Required. The name of the requested
key, in the format
"projects/{project}/keys/{key}".

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.
Expand All @@ -817,8 +886,22 @@ async def sample_get_key():

"""
# 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 = recaptchaenterprise.GetKeyRequest(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(
Expand Down Expand Up @@ -848,6 +931,8 @@ async def update_key(
self,
request: Optional[Union[recaptchaenterprise.UpdateKeyRequest, dict]] = None,
*,
key: Optional[recaptchaenterprise.Key] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
Expand Down Expand Up @@ -886,6 +971,20 @@ async def sample_update_key():
Args:
request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.UpdateKeyRequest, dict]]):
The request object. The update key request message.
key (:class:`google.cloud.recaptchaenterprise_v1.types.Key`):
Required. The key to update.
This corresponds to the ``key`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Optional. The mask to control which
fields of the key get updated. If the
mask is not present, all fields will be
updated.

This corresponds to the ``update_mask`` 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.
Expand All @@ -900,8 +999,24 @@ async def sample_update_key():

"""
# 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, update_mask])
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.UpdateKeyRequest(request)

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

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
Expand Down Expand Up @@ -931,6 +1046,7 @@ async def delete_key(
self,
request: Optional[Union[recaptchaenterprise.DeleteKeyRequest, 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]] = (),
Expand Down Expand Up @@ -963,15 +1079,37 @@ async def sample_delete_key():
Args:
request (Optional[Union[google.cloud.recaptchaenterprise_v1.types.DeleteKeyRequest, dict]]):
The request object. The delete key request message.
name (:class:`str`):
Required. The name of the key to be
deleted, in the format
"projects/{project}/keys/{key}".

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.
"""
# 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 = recaptchaenterprise.DeleteKeyRequest(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(
Expand Down
Loading