Skip to content

Commit 7d6ce5b

Browse files
feat: [google-cloud-recaptcha-enterprise] added AnnotateAssessmentRequest.account_id (googleapis#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: googleapis/googleapis@3413c93 Source-Link: https://github.com/googleapis/googleapis-gen/commit/87d4cd102836d24ed2fbfb9ded537734cdc707a9 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXJlY2FwdGNoYS1lbnRlcnByaXNlLy5Pd2xCb3QueWFtbCIsImgiOiI4N2Q0Y2QxMDI4MzZkMjRlZDJmYmZiOWRlZDUzNzczNGNkYzcwN2E5In0= --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent a12d82f commit 7d6ce5b

5 files changed

Lines changed: 135 additions & 14 deletions

File tree

packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
TransactionEvent,
7777
UpdateFirewallPolicyRequest,
7878
UpdateKeyRequest,
79+
UserId,
80+
UserInfo,
7981
WafSettings,
8082
WebKeySettings,
8183
)
@@ -134,6 +136,8 @@
134136
"TransactionEvent",
135137
"UpdateFirewallPolicyRequest",
136138
"UpdateKeyRequest",
139+
"UserId",
140+
"UserInfo",
137141
"WafSettings",
138142
"WebKeySettings",
139143
)

packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
TransactionEvent,
7575
UpdateFirewallPolicyRequest,
7676
UpdateKeyRequest,
77+
UserId,
78+
UserInfo,
7779
WafSettings,
7880
WebKeySettings,
7981
)
@@ -132,6 +134,8 @@
132134
"TransactionEvent",
133135
"UpdateFirewallPolicyRequest",
134136
"UpdateKeyRequest",
137+
"UserId",
138+
"UserInfo",
135139
"WafSettings",
136140
"WebKeySettings",
137141
)

packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
TransactionEvent,
6666
UpdateFirewallPolicyRequest,
6767
UpdateKeyRequest,
68+
UserId,
69+
UserInfo,
6870
WafSettings,
6971
WebKeySettings,
7072
)
@@ -121,6 +123,8 @@
121123
"TransactionEvent",
122124
"UpdateFirewallPolicyRequest",
123125
"UpdateKeyRequest",
126+
"UserId",
127+
"UserInfo",
124128
"WafSettings",
125129
"WebKeySettings",
126130
)

packages/google-cloud-recaptcha-enterprise/google/cloud/recaptchaenterprise_v1/types/recaptchaenterprise.py

Lines changed: 122 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"Assessment",
3636
"Event",
3737
"TransactionData",
38+
"UserInfo",
39+
"UserId",
3840
"RiskAnalysis",
3941
"TokenProperties",
4042
"FraudPreventionAssessment",
@@ -277,15 +279,19 @@ class AnnotateAssessmentRequest(proto.Message):
277279
without concluding whether the event is
278280
legitimate or fraudulent.
279281
reasons (MutableSequence[google.cloud.recaptchaenterprise_v1.types.AnnotateAssessmentRequest.Reason]):
280-
Optional. Optional reasons for the annotation
281-
that will be assigned to the Event.
282+
Optional. Reasons for the annotation that are
283+
assigned to the event.
284+
account_id (str):
285+
Optional. A stable account identifier to apply to the
286+
assessment. This is an alternative to setting ``account_id``
287+
in ``CreateAssessment``, for example when a stable account
288+
identifier is not yet known in the initial request.
282289
hashed_account_id (bytes):
283-
Optional. Unique stable hashed user identifier to apply to
284-
the assessment. This is an alternative to setting the
285-
hashed_account_id in CreateAssessment, for example when the
286-
account identifier is not yet known in the initial request.
287-
It is recommended that the identifier is hashed using
288-
hmac-sha256 with stable secret.
290+
Optional. A stable hashed account identifier to apply to the
291+
assessment. This is an alternative to setting
292+
``hashed_account_id`` in ``CreateAssessment``, for example
293+
when a stable account identifier is not yet known in the
294+
initial request.
289295
transaction_event (google.cloud.recaptchaenterprise_v1.types.TransactionEvent):
290296
Optional. If the assessment is part of a
291297
payment transaction, provide details on payment
@@ -420,6 +426,10 @@ class Reason(proto.Enum):
420426
number=3,
421427
enum=Reason,
422428
)
429+
account_id: str = proto.Field(
430+
proto.STRING,
431+
number=7,
432+
)
423433
hashed_account_id: bytes = proto.Field(
424434
proto.BYTES,
425435
number=4,
@@ -644,8 +654,8 @@ class Assessment(proto.Message):
644654
must include a token and site key to use this
645655
feature.
646656
account_defender_assessment (google.cloud.recaptchaenterprise_v1.types.AccountDefenderAssessment):
647-
Output only. Assessment returned by account defender when a
648-
hashed_account_id is provided.
657+
Output only. Assessment returned by account
658+
defender when an account identifier is provided.
649659
private_password_leak_verification (google.cloud.recaptchaenterprise_v1.types.PrivatePasswordLeakVerification):
650660
Optional. The private password leak
651661
verification field contains the parameters that
@@ -740,9 +750,10 @@ class Event(proto.Message):
740750
platforms already integrated with recaptcha
741751
enterprise.
742752
hashed_account_id (bytes):
743-
Optional. Unique stable hashed user
744-
identifier for the request. The identifier must
745-
be hashed using hmac-sha256 with stable secret.
753+
Optional. Deprecated: use ``user_info.account_id`` instead.
754+
Unique stable hashed user identifier for the request. The
755+
identifier must be hashed using hmac-sha256 with stable
756+
secret.
746757
express (bool):
747758
Optional. Flag for a reCAPTCHA express request for an
748759
assessment without a token. If enabled, ``site_key`` must
@@ -772,6 +783,14 @@ class Event(proto.Message):
772783
enables reCAPTCHA Enterprise Fraud Prevention
773784
and the FraudPreventionAssessment component in
774785
the response.
786+
user_info (google.cloud.recaptchaenterprise_v1.types.UserInfo):
787+
Optional. Information about the user that
788+
generates this event, when they can be
789+
identified. They are often identified through
790+
the use of an account for logged-in requests or
791+
login/registration requests, or by providing
792+
user identifiers for guest actions like
793+
checkout.
775794
"""
776795

777796
token: str = proto.Field(
@@ -827,6 +846,11 @@ class Event(proto.Message):
827846
number=13,
828847
message="TransactionData",
829848
)
849+
user_info: "UserInfo" = proto.Field(
850+
proto.MESSAGE,
851+
number=15,
852+
message="UserInfo",
853+
)
830854

831855

832856
class TransactionData(proto.Message):
@@ -1126,6 +1150,91 @@ class GatewayInfo(proto.Message):
11261150
)
11271151

11281152

1153+
class UserInfo(proto.Message):
1154+
r"""User information associated with a request protected by
1155+
reCAPTCHA Enterprise.
1156+
1157+
Attributes:
1158+
create_account_time (google.protobuf.timestamp_pb2.Timestamp):
1159+
Optional. Creation time for this account
1160+
associated with this user. Leave blank for non
1161+
logged-in actions, guest checkout, or when there
1162+
is no account associated with the current user.
1163+
account_id (str):
1164+
Optional. For logged-in requests or
1165+
login/registration requests, the unique account
1166+
identifier associated with this user. You can
1167+
use the username if it is stable (meaning it is
1168+
the same for every request associated with the
1169+
same user), or any stable user ID of your
1170+
choice. Leave blank for non logged-in actions or
1171+
guest checkout.
1172+
user_ids (MutableSequence[google.cloud.recaptchaenterprise_v1.types.UserId]):
1173+
Optional. Identifiers associated with this
1174+
user or request.
1175+
"""
1176+
1177+
create_account_time: timestamp_pb2.Timestamp = proto.Field(
1178+
proto.MESSAGE,
1179+
number=1,
1180+
message=timestamp_pb2.Timestamp,
1181+
)
1182+
account_id: str = proto.Field(
1183+
proto.STRING,
1184+
number=2,
1185+
)
1186+
user_ids: MutableSequence["UserId"] = proto.RepeatedField(
1187+
proto.MESSAGE,
1188+
number=3,
1189+
message="UserId",
1190+
)
1191+
1192+
1193+
class UserId(proto.Message):
1194+
r"""An identifier associated with a user.
1195+
1196+
This message has `oneof`_ fields (mutually exclusive fields).
1197+
For each oneof, at most one member field can be set at the same time.
1198+
Setting any member of the oneof automatically clears all other
1199+
members.
1200+
1201+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
1202+
1203+
Attributes:
1204+
email (str):
1205+
Optional. An email address.
1206+
1207+
This field is a member of `oneof`_ ``id_oneof``.
1208+
phone_number (str):
1209+
Optional. A phone number. Should use the
1210+
E.164 format.
1211+
1212+
This field is a member of `oneof`_ ``id_oneof``.
1213+
username (str):
1214+
Optional. A unique username, if different from all the other
1215+
identifiers and ``account_id`` that are provided. Can be a
1216+
unique login handle or display name for a user.
1217+
1218+
This field is a member of `oneof`_ ``id_oneof``.
1219+
"""
1220+
1221+
email: str = proto.Field(
1222+
proto.STRING,
1223+
number=1,
1224+
oneof="id_oneof",
1225+
)
1226+
phone_number: str = proto.Field(
1227+
proto.STRING,
1228+
number=2,
1229+
oneof="id_oneof",
1230+
)
1231+
username: str = proto.Field(
1232+
proto.STRING,
1233+
number=3,
1234+
oneof="id_oneof",
1235+
)
1236+
1237+
11291238
class RiskAnalysis(proto.Message):
11301239
r"""Risk analysis result for an event.
11311240

packages/google-cloud-recaptcha-enterprise/scripts/fixup_recaptchaenterprise_v1_keywords.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def partition(
3939
class recaptchaenterpriseCallTransformer(cst.CSTTransformer):
4040
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
4141
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42-
'annotate_assessment': ('name', 'annotation', 'reasons', 'hashed_account_id', 'transaction_event', ),
42+
'annotate_assessment': ('name', 'annotation', 'reasons', 'account_id', 'hashed_account_id', 'transaction_event', ),
4343
'create_assessment': ('parent', 'assessment', ),
4444
'create_firewall_policy': ('parent', 'firewall_policy', ),
4545
'create_key': ('parent', 'key', ),

0 commit comments

Comments
 (0)