Skip to main content

gcp_client/google/cloud/recaptchaenterprise/
v1.rs

1/// The create assessment request message.
2#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct CreateAssessmentRequest {
4    /// Required. The name of the project in which the assessment will be created,
5    /// in the format "projects/{project}".
6    #[prost(string, tag="1")]
7    pub parent: std::string::String,
8    /// Required. The assessment details.
9    #[prost(message, optional, tag="2")]
10    pub assessment: ::std::option::Option<Assessment>,
11}
12/// The request message to annotate an Assessment.
13#[derive(Clone, PartialEq, ::prost::Message)]
14pub struct AnnotateAssessmentRequest {
15    /// Required. The resource name of the Assessment, in the format
16    /// "projects/{project}/assessments/{assessment}".
17    #[prost(string, tag="1")]
18    pub name: std::string::String,
19    /// Required. The annotation that will be assigned to the Event.
20    #[prost(enumeration="annotate_assessment_request::Annotation", tag="2")]
21    pub annotation: i32,
22}
23pub mod annotate_assessment_request {
24    /// Enum that reprensents the types of annotations.
25    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
26    #[repr(i32)]
27    pub enum Annotation {
28        /// Default unspecified type.
29        Unspecified = 0,
30        /// Provides information that the event turned out to be legitimate.
31        Legitimate = 1,
32        /// Provides information that the event turned out to be fraudulent.
33        Fraudulent = 2,
34        /// Provides information that the event was related to a login event in which
35        /// the user typed the correct password.
36        PasswordCorrect = 3,
37        /// Provides information that the event was related to a login event in which
38        /// the user typed the incorrect password.
39        PasswordIncorrect = 4,
40    }
41}
42/// Empty response for AnnotateAssessment.
43#[derive(Clone, PartialEq, ::prost::Message)]
44pub struct AnnotateAssessmentResponse {
45}
46/// A recaptcha assessment resource.
47#[derive(Clone, PartialEq, ::prost::Message)]
48pub struct Assessment {
49    /// Output only. The resource name for the Assessment in the format
50    /// "projects/{project}/assessments/{assessment}".
51    #[prost(string, tag="1")]
52    pub name: std::string::String,
53    /// The event being assessed.
54    #[prost(message, optional, tag="2")]
55    pub event: ::std::option::Option<Event>,
56    /// Output only. The risk analysis result for the event being assessed.
57    #[prost(message, optional, tag="3")]
58    pub risk_analysis: ::std::option::Option<RiskAnalysis>,
59    /// Output only. Properties of the provided event token.
60    #[prost(message, optional, tag="4")]
61    pub token_properties: ::std::option::Option<TokenProperties>,
62}
63#[derive(Clone, PartialEq, ::prost::Message)]
64pub struct Event {
65    /// Optional. The user response token provided by the reCAPTCHA client-side integration
66    /// on your site.
67    #[prost(string, tag="1")]
68    pub token: std::string::String,
69    /// Optional. The site key that was used to invoke reCAPTCHA on your site and generate
70    /// the token.
71    #[prost(string, tag="2")]
72    pub site_key: std::string::String,
73    /// Optional. The user agent present in the request from the user's device related to
74    /// this event.
75    #[prost(string, tag="3")]
76    pub user_agent: std::string::String,
77    /// Optional. The IP address in the request from the user's device related to this event.
78    #[prost(string, tag="4")]
79    pub user_ip_address: std::string::String,
80    /// Optional. The expected action for this type of event. This should be the same action
81    /// provided at token generation time on client-side platforms already
82    /// integrated with recaptcha enterprise.
83    #[prost(string, tag="5")]
84    pub expected_action: std::string::String,
85}
86/// Risk analysis result for an event.
87#[derive(Clone, PartialEq, ::prost::Message)]
88pub struct RiskAnalysis {
89    /// Legitimate event score from 0.0 to 1.0.
90    /// (1.0 means very likely legitimate traffic while 0.0 means very likely
91    /// non-legitimate traffic).
92    #[prost(float, tag="1")]
93    pub score: f32,
94    /// Reasons contributing to the risk analysis verdict.
95    #[prost(enumeration="risk_analysis::ClassificationReason", repeated, tag="2")]
96    pub reasons: ::std::vec::Vec<i32>,
97}
98pub mod risk_analysis {
99    /// LINT.IfChange(classification_reason)
100    /// Reasons contributing to the risk analysis verdict.
101    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
102    #[repr(i32)]
103    pub enum ClassificationReason {
104        /// Default unspecified type.
105        Unspecified = 0,
106        /// Interactions matched the behavior of an automated agent.
107        Automation = 1,
108        /// The event originated from an illegitimate environment.
109        UnexpectedEnvironment = 2,
110        /// Traffic volume from the event source is higher than normal.
111        TooMuchTraffic = 3,
112        /// Interactions with the site were significantly different than expected
113        /// patterns.
114        UnexpectedUsagePatterns = 4,
115        /// Too little traffic has been received from this site thus far to generate
116        /// quality risk analysis.
117        LowConfidenceScore = 5,
118    }
119}
120#[derive(Clone, PartialEq, ::prost::Message)]
121pub struct TokenProperties {
122    /// Whether the provided user response token is valid. When valid = false, the
123    /// reason could be specified in invalid_reason or it could also be due to
124    /// a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey
125    /// used to generate the token was different than the one specified in the
126    /// assessment).
127    #[prost(bool, tag="1")]
128    pub valid: bool,
129    /// Reason associated with the response when valid = false.
130    #[prost(enumeration="token_properties::InvalidReason", tag="2")]
131    pub invalid_reason: i32,
132    /// The timestamp corresponding to the generation of the token.
133    #[prost(message, optional, tag="3")]
134    pub create_time: ::std::option::Option<::prost_types::Timestamp>,
135    /// The hostname of the page on which the token was generated.
136    #[prost(string, tag="4")]
137    pub hostname: std::string::String,
138    /// Action name provided at token generation.
139    #[prost(string, tag="5")]
140    pub action: std::string::String,
141}
142pub mod token_properties {
143    /// LINT.IfChange
144    /// Enum that represents the types of invalid token reasons.
145    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
146    #[repr(i32)]
147    pub enum InvalidReason {
148        /// Default unspecified type.
149        Unspecified = 0,
150        /// If the failure reason was not accounted for.
151        UnknownInvalidReason = 1,
152        /// The provided user verification token was malformed.
153        Malformed = 2,
154        /// The user verification token had expired.
155        Expired = 3,
156        /// The user verification had already been seen.
157        Dupe = 4,
158        /// The user verification token was not present.
159        Missing = 5,
160    }
161}
162/// The create key request message.
163#[derive(Clone, PartialEq, ::prost::Message)]
164pub struct CreateKeyRequest {
165    /// Required. The name of the project in which the key will be created, in the
166    /// format "projects/{project}".
167    #[prost(string, tag="1")]
168    pub parent: std::string::String,
169    /// Required. Information to create a reCAPTCHA Enterprise key.
170    #[prost(message, optional, tag="2")]
171    pub key: ::std::option::Option<Key>,
172}
173/// The list keys request message.
174#[derive(Clone, PartialEq, ::prost::Message)]
175pub struct ListKeysRequest {
176    /// Required. The name of the project that contains the keys that will be
177    /// listed, in the format "projects/{project}".
178    #[prost(string, tag="1")]
179    pub parent: std::string::String,
180    /// Optional. The maximum number of keys to return. Default is 10. Max limit is
181    /// 1000.
182    #[prost(int32, tag="2")]
183    pub page_size: i32,
184    /// Optional. The next_page_token value returned from a previous.
185    /// ListKeysRequest, if any.
186    #[prost(string, tag="3")]
187    pub page_token: std::string::String,
188}
189/// Response to request to list keys in a project.
190#[derive(Clone, PartialEq, ::prost::Message)]
191pub struct ListKeysResponse {
192    /// Key details.
193    #[prost(message, repeated, tag="1")]
194    pub keys: ::std::vec::Vec<Key>,
195    /// Token to retrieve the next page of results. It is set to empty if no keys
196    /// remain in results.
197    #[prost(string, tag="2")]
198    pub next_page_token: std::string::String,
199}
200/// The get key request message.
201#[derive(Clone, PartialEq, ::prost::Message)]
202pub struct GetKeyRequest {
203    /// Required. The name of the requested key, in the format
204    /// "projects/{project}/keys/{key}".
205    #[prost(string, tag="1")]
206    pub name: std::string::String,
207}
208/// The update key request message.
209#[derive(Clone, PartialEq, ::prost::Message)]
210pub struct UpdateKeyRequest {
211    /// Required. The key to update.
212    #[prost(message, optional, tag="1")]
213    pub key: ::std::option::Option<Key>,
214    /// Optional. The mask to control which field of the key get updated. If the mask is not
215    /// present, all fields will be updated.
216    #[prost(message, optional, tag="2")]
217    pub update_mask: ::std::option::Option<::prost_types::FieldMask>,
218}
219/// The delete key request message.
220#[derive(Clone, PartialEq, ::prost::Message)]
221pub struct DeleteKeyRequest {
222    /// Required. The name of the key to be deleted, in the format
223    /// "projects/{project}/keys/{key}".
224    #[prost(string, tag="1")]
225    pub name: std::string::String,
226}
227/// A key used to identify and configure applications (web and/or mobile) that
228/// use reCAPTCHA Enterprise.
229#[derive(Clone, PartialEq, ::prost::Message)]
230pub struct Key {
231    /// The resource name for the Key in the format
232    /// "projects/{project}/keys/{key}".
233    #[prost(string, tag="1")]
234    pub name: std::string::String,
235    /// Human-readable display name of this key. Modifiable by user.
236    #[prost(string, tag="2")]
237    pub display_name: std::string::String,
238    /// Optional. See <a href="https://cloud.google.com/recaptcha-enterprise/docs/labels">
239    /// Creating and managing labels</a>.
240    #[prost(map="string, string", tag="6")]
241    pub labels: ::std::collections::HashMap<std::string::String, std::string::String>,
242    /// The timestamp corresponding to the creation of this Key.
243    #[prost(message, optional, tag="7")]
244    pub create_time: ::std::option::Option<::prost_types::Timestamp>,
245    /// Platform specific settings for this key. The key can only be used on one
246    /// platform, the one it has settings for.
247    #[prost(oneof="key::PlatformSettings", tags="3, 4, 5")]
248    pub platform_settings: ::std::option::Option<key::PlatformSettings>,
249}
250pub mod key {
251    /// Platform specific settings for this key. The key can only be used on one
252    /// platform, the one it has settings for.
253    #[derive(Clone, PartialEq, ::prost::Oneof)]
254    pub enum PlatformSettings {
255        /// Settings for keys that can be used by websites.
256        #[prost(message, tag="3")]
257        WebSettings(super::WebKeySettings),
258        /// Settings for keys that can be used by Android apps.
259        #[prost(message, tag="4")]
260        AndroidSettings(super::AndroidKeySettings),
261        /// Settings for keys that can be used by iOS apps.
262        #[prost(message, tag="5")]
263        IosSettings(super::IosKeySettings),
264    }
265}
266/// Settings specific to keys that can be used by websites.
267#[derive(Clone, PartialEq, ::prost::Message)]
268pub struct WebKeySettings {
269    /// If set to true, it means allowed_domains will not be enforced.
270    #[prost(bool, tag="3")]
271    pub allow_all_domains: bool,
272    /// Domains or subdomains of websites allowed to use the key. All subdomains
273    /// of an allowed domain are automatically allowed. A valid domain requires a
274    /// host and must not include any path, port, query or fragment.
275    /// Examples: 'example.com' or 'subdomain.example.com'
276    #[prost(string, repeated, tag="1")]
277    pub allowed_domains: ::std::vec::Vec<std::string::String>,
278    /// Required. Whether this key can be used on AMP (Accelerated Mobile Pages) websites.
279    #[prost(bool, tag="2")]
280    pub allow_amp_traffic: bool,
281    /// Required. Describes how this key is integrated with the website.
282    #[prost(enumeration="web_key_settings::IntegrationType", tag="4")]
283    pub integration_type: i32,
284    /// Settings for the frequency and difficulty at which this key triggers
285    /// captcha challenges. This should only be specified for IntegrationTypes
286    /// CHECKBOX and INVISIBLE.
287    #[prost(enumeration="web_key_settings::ChallengeSecurityPreference", tag="5")]
288    pub challenge_security_preference: i32,
289}
290pub mod web_key_settings {
291    /// Enum that represents the integration types for web keys.
292    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
293    #[repr(i32)]
294    pub enum IntegrationType {
295        /// Default type that indicates this enum hasn't been specified. This is not
296        /// a valid IntegrationType, one of the other types must be specified
297        /// instead.
298        Unspecified = 0,
299        /// Only used to produce scores. It doesn't display the "I'm not a robot"
300        /// checkbox and never shows captcha challenges.
301        Score = 1,
302        /// Displays the "I'm not a robot" checkbox and may show captcha challenges
303        /// after it is checked.
304        Checkbox = 2,
305        /// Doesn't display the "I'm not a robot" checkbox, but may show captcha
306        /// challenges after risk analysis.
307        Invisible = 3,
308    }
309    /// Enum that represents the possible challenge frequency and difficulty
310    /// configurations for a web key.
311    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
312    #[repr(i32)]
313    pub enum ChallengeSecurityPreference {
314        /// Default type that indicates this enum hasn't been specified.
315        Unspecified = 0,
316        /// Key tends to show fewer and easier challenges.
317        Usability = 1,
318        /// Key tends to show balanced (in amount and difficulty) challenges.
319        Balance = 2,
320        /// Key tends to show more and harder challenges.
321        Security = 3,
322    }
323}
324/// Settings specific to keys that can be used by Android apps.
325#[derive(Clone, PartialEq, ::prost::Message)]
326pub struct AndroidKeySettings {
327    /// Android package names of apps allowed to use the key.
328    /// Example: 'com.companyname.appname'
329    #[prost(string, repeated, tag="1")]
330    pub allowed_package_names: ::std::vec::Vec<std::string::String>,
331}
332/// Settings specific to keys that can be used by iOS apps.
333#[derive(Clone, PartialEq, ::prost::Message)]
334pub struct IosKeySettings {
335    /// iOS bundle ids of apps allowed to use the key.
336    /// Example: 'com.companyname.productname.appname'
337    #[prost(string, repeated, tag="1")]
338    pub allowed_bundle_ids: ::std::vec::Vec<std::string::String>,
339}
340# [ doc = r" Generated client implementations." ] pub mod recaptcha_enterprise_service_client { # ! [ allow ( unused_variables , dead_code , missing_docs ) ] use tonic :: codegen :: * ; # [ doc = " Service to determine the likelihood an event is legitimate." ] pub struct RecaptchaEnterpriseServiceClient < T > { inner : tonic :: client :: Grpc < T > , } impl < T > RecaptchaEnterpriseServiceClient < T > where T : tonic :: client :: GrpcService < tonic :: body :: BoxBody > , T :: ResponseBody : Body + HttpBody + Send + 'static , T :: Error : Into < StdError > , < T :: ResponseBody as HttpBody > :: Error : Into < StdError > + Send , { pub fn new ( inner : T ) -> Self { let inner = tonic :: client :: Grpc :: new ( inner ) ; Self { inner } } pub fn with_interceptor ( inner : T , interceptor : impl Into < tonic :: Interceptor > ) -> Self { let inner = tonic :: client :: Grpc :: with_interceptor ( inner , interceptor ) ; Self { inner } } # [ doc = " Creates an Assessment of the likelihood an event is legitimate." ] pub async fn create_assessment ( & mut self , request : impl tonic :: IntoRequest < super :: CreateAssessmentRequest > , ) -> Result < tonic :: Response < super :: Assessment > , tonic :: Status > { self . inner . ready ( ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Unknown , format ! ( "Service was not ready: {}" , e . into ( ) ) ) } ) ? ; let codec = tonic :: codec :: ProstCodec :: default ( ) ; let path = http :: uri :: PathAndQuery :: from_static ( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateAssessment" ) ; self . inner . unary ( request . into_request ( ) , path , codec ) . await } # [ doc = " Annotates a previously created Assessment to provide additional information" ] # [ doc = " on whether the event turned out to be authentic or fradulent." ] pub async fn annotate_assessment ( & mut self , request : impl tonic :: IntoRequest < super :: AnnotateAssessmentRequest > , ) -> Result < tonic :: Response < super :: AnnotateAssessmentResponse > , tonic :: Status > { self . inner . ready ( ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Unknown , format ! ( "Service was not ready: {}" , e . into ( ) ) ) } ) ? ; let codec = tonic :: codec :: ProstCodec :: default ( ) ; let path = http :: uri :: PathAndQuery :: from_static ( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/AnnotateAssessment" ) ; self . inner . unary ( request . into_request ( ) , path , codec ) . await } # [ doc = " Creates a new reCAPTCHA Enterprise key." ] pub async fn create_key ( & mut self , request : impl tonic :: IntoRequest < super :: CreateKeyRequest > , ) -> Result < tonic :: Response < super :: Key > , tonic :: Status > { self . inner . ready ( ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Unknown , format ! ( "Service was not ready: {}" , e . into ( ) ) ) } ) ? ; let codec = tonic :: codec :: ProstCodec :: default ( ) ; let path = http :: uri :: PathAndQuery :: from_static ( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/CreateKey" ) ; self . inner . unary ( request . into_request ( ) , path , codec ) . await } # [ doc = " Returns the list of all keys that belong to a project." ] pub async fn list_keys ( & mut self , request : impl tonic :: IntoRequest < super :: ListKeysRequest > , ) -> Result < tonic :: Response < super :: ListKeysResponse > , tonic :: Status > { self . inner . ready ( ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Unknown , format ! ( "Service was not ready: {}" , e . into ( ) ) ) } ) ? ; let codec = tonic :: codec :: ProstCodec :: default ( ) ; let path = http :: uri :: PathAndQuery :: from_static ( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListKeys" ) ; self . inner . unary ( request . into_request ( ) , path , codec ) . await } # [ doc = " Returns the specified key." ] pub async fn get_key ( & mut self , request : impl tonic :: IntoRequest < super :: GetKeyRequest > , ) -> Result < tonic :: Response < super :: Key > , tonic :: Status > { self . inner . ready ( ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Unknown , format ! ( "Service was not ready: {}" , e . into ( ) ) ) } ) ? ; let codec = tonic :: codec :: ProstCodec :: default ( ) ; let path = http :: uri :: PathAndQuery :: from_static ( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/GetKey" ) ; self . inner . unary ( request . into_request ( ) , path , codec ) . await } # [ doc = " Updates the specified key." ] pub async fn update_key ( & mut self , request : impl tonic :: IntoRequest < super :: UpdateKeyRequest > , ) -> Result < tonic :: Response < super :: Key > , tonic :: Status > { self . inner . ready ( ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Unknown , format ! ( "Service was not ready: {}" , e . into ( ) ) ) } ) ? ; let codec = tonic :: codec :: ProstCodec :: default ( ) ; let path = http :: uri :: PathAndQuery :: from_static ( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/UpdateKey" ) ; self . inner . unary ( request . into_request ( ) , path , codec ) . await } # [ doc = " Deletes the specified key." ] pub async fn delete_key ( & mut self , request : impl tonic :: IntoRequest < super :: DeleteKeyRequest > , ) -> Result < tonic :: Response < ( ) > , tonic :: Status > { self . inner . ready ( ) . await . map_err ( | e | { tonic :: Status :: new ( tonic :: Code :: Unknown , format ! ( "Service was not ready: {}" , e . into ( ) ) ) } ) ? ; let codec = tonic :: codec :: ProstCodec :: default ( ) ; let path = http :: uri :: PathAndQuery :: from_static ( "/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/DeleteKey" ) ; self . inner . unary ( request . into_request ( ) , path , codec ) . await } } impl < T : Clone > Clone for RecaptchaEnterpriseServiceClient < T > { fn clone ( & self ) -> Self { Self { inner : self . inner . clone ( ) , } } } impl < T > std :: fmt :: Debug for RecaptchaEnterpriseServiceClient < T > { fn fmt ( & self , f : & mut std :: fmt :: Formatter < '_ > ) -> std :: fmt :: Result { write ! ( f , "RecaptchaEnterpriseServiceClient {{ ... }}" ) } } }use serde :: { Serialize , Deserialize } ;