From 7d6ce5b49f9d1960cb3f4ffa8e7baf2e7ec126e2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 22 Nov 2023 06:10:57 -0500 Subject: [PATCH] feat: [google-cloud-recaptcha-enterprise] added AnnotateAssessmentRequest.account_id (#12045) - [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: Added AnnotateAssessmentRequest.account_id feat: Added Event.user_info END_COMMIT_OVERRIDE docs: updated comments PiperOrigin-RevId: 584376490 Source-Link: https://github.com/googleapis/googleapis/commit/3413c935f26db17787ea454bc686c488c42499ce Source-Link: https://github.com/googleapis/googleapis-gen/commit/87d4cd102836d24ed2fbfb9ded537734cdc707a9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY2FwdGNoYS1lbnRlcnByaXNlLy5Pd2xCb3QueWFtbCIsImgiOiI4N2Q0Y2QxMDI4MzZkMjRlZDJmYmZiOWRlZDUzNzczNGNkYzcwN2E5In0= --------- Co-authored-by: Owl Bot --- .../cloud/recaptchaenterprise/__init__.py | 4 + .../cloud/recaptchaenterprise_v1/__init__.py | 4 + .../recaptchaenterprise_v1/types/__init__.py | 4 + .../types/recaptchaenterprise.py | 135 ++++++++++++++++-- .../fixup_recaptchaenterprise_v1_keywords.py | 2 +- 5 files changed, 135 insertions(+), 14 deletions(-) diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py index 8ebb7b210598..f0fac363a68d 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py @@ -76,6 +76,8 @@ TransactionEvent, UpdateFirewallPolicyRequest, UpdateKeyRequest, + UserId, + UserInfo, WafSettings, WebKeySettings, ) @@ -134,6 +136,8 @@ "TransactionEvent", "UpdateFirewallPolicyRequest", "UpdateKeyRequest", + "UserId", + "UserInfo", "WafSettings", "WebKeySettings", ) diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py index 3fe58a774915..4a76da35c884 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py @@ -74,6 +74,8 @@ TransactionEvent, UpdateFirewallPolicyRequest, UpdateKeyRequest, + UserId, + UserInfo, WafSettings, WebKeySettings, ) @@ -132,6 +134,8 @@ "TransactionEvent", "UpdateFirewallPolicyRequest", "UpdateKeyRequest", + "UserId", + "UserInfo", "WafSettings", "WebKeySettings", ) diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py index a5376011d620..66e4318bcfa4 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py @@ -65,6 +65,8 @@ TransactionEvent, UpdateFirewallPolicyRequest, UpdateKeyRequest, + UserId, + UserInfo, WafSettings, WebKeySettings, ) @@ -121,6 +123,8 @@ "TransactionEvent", "UpdateFirewallPolicyRequest", "UpdateKeyRequest", + "UserId", + "UserInfo", "WafSettings", "WebKeySettings", ) diff --git a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py index 59bf1191e010..5c99894ddb52 100644 --- a/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py +++ b/packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py @@ -35,6 +35,8 @@ "Assessment", "Event", "TransactionData", + "UserInfo", + "UserId", "RiskAnalysis", "TokenProperties", "FraudPreventionAssessment", @@ -277,15 +279,19 @@ class AnnotateAssessmentRequest(proto.Message): without concluding whether the event is legitimate or fraudulent. reasons (MutableSequence[google.cloud.recaptchaenterprise_v1.types.AnnotateAssessmentRequest.Reason]): - Optional. Optional reasons for the annotation - that will be assigned to the Event. + Optional. Reasons for the annotation that are + assigned to the event. + account_id (str): + Optional. A stable account identifier to apply to the + assessment. This is an alternative to setting ``account_id`` + in ``CreateAssessment``, for example when a stable account + identifier is not yet known in the initial request. hashed_account_id (bytes): - 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. A stable hashed account identifier to apply to the + assessment. This is an alternative to setting + ``hashed_account_id`` in ``CreateAssessment``, for example + when a stable account identifier is not yet known in the + initial request. transaction_event (google.cloud.recaptchaenterprise_v1.types.TransactionEvent): Optional. If the assessment is part of a payment transaction, provide details on payment @@ -420,6 +426,10 @@ class Reason(proto.Enum): number=3, enum=Reason, ) + account_id: str = proto.Field( + proto.STRING, + number=7, + ) hashed_account_id: bytes = proto.Field( proto.BYTES, number=4, @@ -644,8 +654,8 @@ class Assessment(proto.Message): must include a token and site key to use this feature. account_defender_assessment (google.cloud.recaptchaenterprise_v1.types.AccountDefenderAssessment): - Output only. Assessment returned by account defender when a - hashed_account_id is provided. + Output only. Assessment returned by account + defender when an account identifier is provided. private_password_leak_verification (google.cloud.recaptchaenterprise_v1.types.PrivatePasswordLeakVerification): Optional. The private password leak verification field contains the parameters that @@ -740,9 +750,10 @@ class Event(proto.Message): platforms already integrated with recaptcha enterprise. hashed_account_id (bytes): - Optional. Unique stable hashed user - identifier for the request. The identifier must - be hashed using hmac-sha256 with stable secret. + Optional. Deprecated: use ``user_info.account_id`` instead. + Unique stable hashed user identifier for the request. The + identifier must be hashed using hmac-sha256 with stable + secret. express (bool): Optional. Flag for a reCAPTCHA express request for an assessment without a token. If enabled, ``site_key`` must @@ -772,6 +783,14 @@ class Event(proto.Message): enables reCAPTCHA Enterprise Fraud Prevention and the FraudPreventionAssessment component in the response. + user_info (google.cloud.recaptchaenterprise_v1.types.UserInfo): + Optional. Information about the user that + generates this event, when they can be + identified. They are often identified through + the use of an account for logged-in requests or + login/registration requests, or by providing + user identifiers for guest actions like + checkout. """ token: str = proto.Field( @@ -827,6 +846,11 @@ class Event(proto.Message): number=13, message="TransactionData", ) + user_info: "UserInfo" = proto.Field( + proto.MESSAGE, + number=15, + message="UserInfo", + ) class TransactionData(proto.Message): @@ -1126,6 +1150,91 @@ class GatewayInfo(proto.Message): ) +class UserInfo(proto.Message): + r"""User information associated with a request protected by + reCAPTCHA Enterprise. + + Attributes: + create_account_time (google.protobuf.timestamp_pb2.Timestamp): + Optional. Creation time for this account + associated with this user. Leave blank for non + logged-in actions, guest checkout, or when there + is no account associated with the current user. + account_id (str): + Optional. For logged-in requests or + login/registration requests, the unique account + identifier associated with this user. You can + use the username if it is stable (meaning it is + the same for every request associated with the + same user), or any stable user ID of your + choice. Leave blank for non logged-in actions or + guest checkout. + user_ids (MutableSequence[google.cloud.recaptchaenterprise_v1.types.UserId]): + Optional. Identifiers associated with this + user or request. + """ + + create_account_time: timestamp_pb2.Timestamp = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + account_id: str = proto.Field( + proto.STRING, + number=2, + ) + user_ids: MutableSequence["UserId"] = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="UserId", + ) + + +class UserId(proto.Message): + r"""An identifier associated with a user. + + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + + Attributes: + email (str): + Optional. An email address. + + This field is a member of `oneof`_ ``id_oneof``. + phone_number (str): + Optional. A phone number. Should use the + E.164 format. + + This field is a member of `oneof`_ ``id_oneof``. + username (str): + Optional. A unique username, if different from all the other + identifiers and ``account_id`` that are provided. Can be a + unique login handle or display name for a user. + + This field is a member of `oneof`_ ``id_oneof``. + """ + + email: str = proto.Field( + proto.STRING, + number=1, + oneof="id_oneof", + ) + phone_number: str = proto.Field( + proto.STRING, + number=2, + oneof="id_oneof", + ) + username: str = proto.Field( + proto.STRING, + number=3, + oneof="id_oneof", + ) + + class RiskAnalysis(proto.Message): r"""Risk analysis result for an event. diff --git a/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py b/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py index 23414045041e..39351e6a256e 100644 --- a/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py +++ b/packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py @@ -39,7 +39,7 @@ def partition( class recaptchaenterpriseCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'annotate_assessment': ('name', 'annotation', 'reasons', 'hashed_account_id', 'transaction_event', ), + 'annotate_assessment': ('name', 'annotation', 'reasons', 'account_id', 'hashed_account_id', 'transaction_event', ), 'create_assessment': ('parent', 'assessment', ), 'create_firewall_policy': ('parent', 'firewall_policy', ), 'create_key': ('parent', 'key', ),