Skip to content

Commit adfc3f9

Browse files
yoshi-automationcallmehiphop
authored andcommitted
feat: add crud support for keys (googleapis#84)
1 parent 0e96508 commit adfc3f9

File tree

11 files changed

+6274
-166
lines changed

11 files changed

+6274
-166
lines changed

protos/google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise.proto

+236-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import "google/api/annotations.proto";
2121
import "google/api/client.proto";
2222
import "google/api/field_behavior.proto";
2323
import "google/api/resource.proto";
24+
import "google/protobuf/empty.proto";
25+
import "google/protobuf/field_mask.proto";
2426
import "google/protobuf/timestamp.proto";
2527

2628
option csharp_namespace = "Google.Cloud.RecaptchaEnterprise.V1Beta1";
@@ -54,6 +56,43 @@ service RecaptchaEnterpriseServiceV1Beta1 {
5456
};
5557
option (google.api.method_signature) = "name,annotation";
5658
}
59+
60+
// Creates a new reCAPTCHA Enterprise key.
61+
rpc CreateKey(CreateKeyRequest) returns (Key) {
62+
option (google.api.http) = {
63+
post: "/v1beta1/{parent=projects/*}/keys"
64+
body: "key"
65+
};
66+
}
67+
68+
// Returns the list of all keys that belong to a project.
69+
rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) {
70+
option (google.api.http) = {
71+
get: "/v1beta1/{parent=projects/*}/keys"
72+
};
73+
}
74+
75+
// Returns the specified key.
76+
rpc GetKey(GetKeyRequest) returns (Key) {
77+
option (google.api.http) = {
78+
get: "/v1beta1/{name=projects/*/keys/*}"
79+
};
80+
}
81+
82+
// Updates the specified key.
83+
rpc UpdateKey(UpdateKeyRequest) returns (Key) {
84+
option (google.api.http) = {
85+
patch: "/v1beta1/{key.name=projects/*/keys/*}"
86+
body: "key"
87+
};
88+
}
89+
90+
// Deletes the specified key.
91+
rpc DeleteKey(DeleteKeyRequest) returns (google.protobuf.Empty) {
92+
option (google.api.http) = {
93+
delete: "/v1beta1/{name=projects/*/keys/*}"
94+
};
95+
}
5796
}
5897

5998
// The create assessment request message.
@@ -154,13 +193,25 @@ message Assessment {
154193
}
155194

156195
message Event {
157-
// Required. The user response token provided by the reCAPTCHA client-side integration
196+
// Optional. The user response token provided by the reCAPTCHA client-side integration
158197
// on your site.
159-
string token = 1 [(google.api.field_behavior) = REQUIRED];
198+
string token = 1 [(google.api.field_behavior) = OPTIONAL];
160199

161-
// Required. The site key that was used to invoke reCAPTCHA on your site and generate
200+
// Optional. The site key that was used to invoke reCAPTCHA on your site and generate
162201
// the token.
163-
string site_key = 2 [(google.api.field_behavior) = REQUIRED];
202+
string site_key = 2 [(google.api.field_behavior) = OPTIONAL];
203+
204+
// Optional. The user agent present in the request from the user's device related to
205+
// this event.
206+
string user_agent = 3 [(google.api.field_behavior) = OPTIONAL];
207+
208+
// Optional. The IP address in the request from the user's device related to this event.
209+
string user_ip_address = 4 [(google.api.field_behavior) = OPTIONAL];
210+
211+
// Optional. The expected action for this type of event. This should be the same action
212+
// provided at token generation time on client-side platforms already
213+
// integrated with recaptcha enterprise.
214+
string expected_action = 5 [(google.api.field_behavior) = OPTIONAL];
164215
}
165216

166217
message TokenProperties {
@@ -207,3 +258,184 @@ message TokenProperties {
207258
// Action name provided at token generation.
208259
string action = 5;
209260
}
261+
262+
// The create key request message.
263+
message CreateKeyRequest {
264+
// Required. The name of the project in which the key will be created, in the
265+
// format "projects/{project_number}".
266+
string parent = 1 [
267+
(google.api.field_behavior) = REQUIRED,
268+
(google.api.resource_reference) = {
269+
type: "cloudresourcemanager.googleapis.com/Project"
270+
}
271+
];
272+
273+
// Required. Information to create a reCAPTCHA Enterprise key.
274+
Key key = 2 [(google.api.field_behavior) = REQUIRED];
275+
}
276+
277+
// The list keys request message.
278+
message ListKeysRequest {
279+
// Required. The name of the project that contains the keys that will be
280+
// listed, in the format "projects/{project_number}".
281+
string parent = 1 [
282+
(google.api.field_behavior) = REQUIRED,
283+
(google.api.resource_reference) = {
284+
type: "cloudresourcemanager.googleapis.com/Project"
285+
}
286+
];
287+
288+
// Optional. The maximum number of keys to return. Default is 10. Max limit is
289+
// 1000.
290+
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
291+
292+
// Optional. The next_page_token value returned from a previous.
293+
// ListKeysRequest, if any.
294+
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
295+
}
296+
297+
// Response to request to list keys in a project.
298+
message ListKeysResponse {
299+
// Key details.
300+
repeated Key keys = 1;
301+
302+
// Token to retrieve the next page of results. It is set to empty if no keys
303+
// remain in results.
304+
string next_page_token = 2;
305+
}
306+
307+
// The get key request message.
308+
message GetKeyRequest {
309+
// Required. The name of the requested key, in the format
310+
// "projects/{project_number}/keys/{key_id}".
311+
string name = 1 [
312+
(google.api.field_behavior) = REQUIRED,
313+
(google.api.resource_reference) = {
314+
type: "recaptchaenterprise.googleapis.com/Key"
315+
}
316+
];
317+
}
318+
319+
// The update key request message.
320+
message UpdateKeyRequest {
321+
// Required. The key to update.
322+
Key key = 1 [(google.api.field_behavior) = REQUIRED];
323+
324+
// Optional. The mask to control which field of the key get updated. If the mask is not
325+
// present, all fields will be updated.
326+
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
327+
}
328+
329+
// The delete key request message.
330+
message DeleteKeyRequest {
331+
// Required. The name of the key to be deleted, in the format
332+
// "projects/{project_number}/keys/{key_id}".
333+
string name = 1 [
334+
(google.api.field_behavior) = REQUIRED,
335+
(google.api.resource_reference) = {
336+
type: "recaptchaenterprise.googleapis.com/Key"
337+
}
338+
];
339+
}
340+
341+
// A key used to identify and configure applications (web and/or mobile) that
342+
// use reCAPTCHA Enterprise.
343+
message Key {
344+
option (google.api.resource) = {
345+
type: "recaptchaenterprise.googleapis.com/Key"
346+
pattern: "projects/{project}/keys/{key}"
347+
};
348+
349+
// The resource name for the Key in the format
350+
// "projects/{project_number}/keys/{key_id}".
351+
string name = 1;
352+
353+
// Human-readable display name of this key. Modifiable by user.
354+
string display_name = 2;
355+
356+
// Platform specific settings for this key. The key can only be used on one
357+
// platform, the one it has settings for.
358+
oneof platform_settings {
359+
// Settings for keys that can be used by websites.
360+
WebKeySettings web_settings = 3;
361+
362+
// Settings for keys that can be used by Android apps.
363+
AndroidKeySettings android_settings = 4;
364+
365+
// Settings for keys that can be used by iOS apps.
366+
IOSKeySettings ios_settings = 5;
367+
}
368+
}
369+
370+
// Settings specific to keys that can be used by websites.
371+
message WebKeySettings {
372+
// Enum that represents the integration types for web keys.
373+
enum IntegrationType {
374+
// Default type that indicates this enum hasn't been specified. This is not
375+
// a valid IntegrationType, one of the other types must be specified
376+
// instead.
377+
INTEGRATION_TYPE_UNSPECIFIED = 0;
378+
379+
// Only used to produce scores. It doesn't display the "I'm not a robot"
380+
// checkbox and never shows captcha challenges.
381+
SCORE_ONLY = 1;
382+
383+
// Displays the "I'm not a robot" checkbox and may show captcha challenges
384+
// after it is checked.
385+
CHECKBOX_CHALLENGE = 2;
386+
387+
// Doesn't display the "I'm not a robot" checkbox, but may show captcha
388+
// challenges after risk analysis.
389+
INVISIBLE_CHALLENGE = 3;
390+
}
391+
392+
// Enum that represents the possible challenge frequency and difficulty
393+
// configurations for a web key.
394+
enum ChallengeSecurityPreference {
395+
// Default type that indicates this enum hasn't been specified.
396+
CHALLENGE_SECURITY_PREFERENCE_UNSPECIFIED = 0;
397+
398+
// Key tends to show fewer and easier challenges.
399+
USABILITY = 1;
400+
401+
// Key tends to show balanced (in amount and difficulty) challenges.
402+
BALANCED = 2;
403+
404+
// Key tends to show more and harder challenges.
405+
SECURITY = 3;
406+
}
407+
408+
// Whether allowed_domains is enforced or not.
409+
bool enforce_allowed_domains = 3;
410+
411+
// Domains or subdomains of websites allowed to use the key. All subdomains
412+
// of an allowed domain are automatically allowed. A valid domain requires a
413+
// host and must not include any path, port, query or fragment.
414+
// Examples: 'example.com' or 'subdomain.example.com'
415+
repeated string allowed_domains = 1;
416+
417+
// Whether this key can be used on AMP (Accelerated Mobile Pages) websites.
418+
bool allow_amp_traffic = 2;
419+
420+
// Required. Describes how this key is integrated with the website.
421+
IntegrationType integration_type = 4 [(google.api.field_behavior) = REQUIRED];
422+
423+
// Settings for the frequency and difficulty at which this key triggers
424+
// captcha challenges. This should only be specified for IntegrationTypes
425+
// CHECKBOX_CHALLENGE and INVISIBLE_CHALLENGE.
426+
ChallengeSecurityPreference challenge_security_preference = 5;
427+
}
428+
429+
// Settings specific to keys that can be used by Android apps.
430+
message AndroidKeySettings {
431+
// Android package names of apps allowed to use the key.
432+
// Example: 'com.companyname.appname'
433+
repeated string allowed_package_names = 1;
434+
}
435+
436+
// Settings specific to keys that can be used by iOS apps.
437+
message IOSKeySettings {
438+
// iOS bundle ids of apps allowed to use the key.
439+
// Example: 'com.companyname.productname.appname'
440+
repeated string allowed_bundle_ids = 1;
441+
}

0 commit comments

Comments
 (0)