google_recaptchaenterprise1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::CloudPlatform
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all RecaptchaEnterprise related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
49/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1Key;
50/// use recaptchaenterprise1::{Result, Error};
51/// # async fn dox() {
52/// use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = RecaptchaEnterprise::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GoogleCloudRecaptchaenterpriseV1Key::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().keys_patch(req, "name")
99/// .update_mask(FieldMask::new::<&str>(&[]))
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct RecaptchaEnterprise<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for RecaptchaEnterprise<C> {}
131
132impl<'a, C> RecaptchaEnterprise<C> {
133 pub fn new<A: 'static + common::GetToken>(
134 client: common::Client<C>,
135 auth: A,
136 ) -> RecaptchaEnterprise<C> {
137 RecaptchaEnterprise {
138 client,
139 auth: Box::new(auth),
140 _user_agent: "google-api-rust-client/7.0.0".to_string(),
141 _base_url: "https://recaptchaenterprise.googleapis.com/".to_string(),
142 _root_url: "https://recaptchaenterprise.googleapis.com/".to_string(),
143 }
144 }
145
146 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147 ProjectMethods { hub: self }
148 }
149
150 /// Set the user-agent header field to use in all requests to the server.
151 /// It defaults to `google-api-rust-client/7.0.0`.
152 ///
153 /// Returns the previously set user-agent.
154 pub fn user_agent(&mut self, agent_name: String) -> String {
155 std::mem::replace(&mut self._user_agent, agent_name)
156 }
157
158 /// Set the base url to use in all requests to the server.
159 /// It defaults to `https://recaptchaenterprise.googleapis.com/`.
160 ///
161 /// Returns the previously set base url.
162 pub fn base_url(&mut self, new_base_url: String) -> String {
163 std::mem::replace(&mut self._base_url, new_base_url)
164 }
165
166 /// Set the root url to use in all requests to the server.
167 /// It defaults to `https://recaptchaenterprise.googleapis.com/`.
168 ///
169 /// Returns the previously set root url.
170 pub fn root_url(&mut self, new_root_url: String) -> String {
171 std::mem::replace(&mut self._root_url, new_root_url)
172 }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Account defender risk assessment.
179///
180/// This type is not used in any activity, and only used as *part* of another schema.
181///
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct GoogleCloudRecaptchaenterpriseV1AccountDefenderAssessment {
186 /// Output only. Labels for this request.
187 pub labels: Option<Vec<String>>,
188}
189
190impl common::Part for GoogleCloudRecaptchaenterpriseV1AccountDefenderAssessment {}
191
192/// Information about account verification, used for identity verification.
193///
194/// This type is not used in any activity, and only used as *part* of another schema.
195///
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct GoogleCloudRecaptchaenterpriseV1AccountVerificationInfo {
200 /// Optional. Endpoints that can be used for identity verification.
201 pub endpoints: Option<Vec<GoogleCloudRecaptchaenterpriseV1EndpointVerificationInfo>>,
202 /// Optional. Language code preference for the verification message, set as a IETF BCP 47 language code.
203 #[serde(rename = "languageCode")]
204 pub language_code: Option<String>,
205 /// Output only. Result of the latest account verification challenge.
206 #[serde(rename = "latestVerificationResult")]
207 pub latest_verification_result: Option<String>,
208 /// Username of the account that is being verified. Deprecated. Customers should now provide the `account_id` field in `event.user_info`.
209 pub username: Option<String>,
210}
211
212impl common::Part for GoogleCloudRecaptchaenterpriseV1AccountVerificationInfo {}
213
214/// The AddIpOverride request message.
215///
216/// # Activities
217///
218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
220///
221/// * [keys add ip override projects](ProjectKeyAddIpOverrideCall) (request)
222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
223#[serde_with::serde_as]
224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
225pub struct GoogleCloudRecaptchaenterpriseV1AddIpOverrideRequest {
226 /// Required. IP override added to the key.
227 #[serde(rename = "ipOverrideData")]
228 pub ip_override_data: Option<GoogleCloudRecaptchaenterpriseV1IpOverrideData>,
229}
230
231impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1AddIpOverrideRequest {}
232
233/// Response for AddIpOverride.
234///
235/// # Activities
236///
237/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
238/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
239///
240/// * [keys add ip override projects](ProjectKeyAddIpOverrideCall) (response)
241#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
242#[serde_with::serde_as]
243#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
244pub struct GoogleCloudRecaptchaenterpriseV1AddIpOverrideResponse {
245 _never_set: Option<bool>,
246}
247
248impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1AddIpOverrideResponse {}
249
250/// Settings specific to keys that can be used by Android apps.
251///
252/// This type is not used in any activity, and only used as *part* of another schema.
253///
254#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
255#[serde_with::serde_as]
256#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
257pub struct GoogleCloudRecaptchaenterpriseV1AndroidKeySettings {
258 /// Optional. If set to true, allowed_package_names are not enforced.
259 #[serde(rename = "allowAllPackageNames")]
260 pub allow_all_package_names: Option<bool>,
261 /// Optional. Android package names of apps allowed to use the key. Example: 'com.companyname.appname' Each key supports a maximum of 250 package names. To use a key on more apps, set `allow_all_package_names` to true. When this is set, you are responsible for validating the package name by checking the `token_properties.android_package_name` field in each assessment response against your list of allowed package names.
262 #[serde(rename = "allowedPackageNames")]
263 pub allowed_package_names: Option<Vec<String>>,
264 /// Optional. Set to true for keys that are used in an Android application that is available for download in app stores in addition to the Google Play Store.
265 #[serde(rename = "supportNonGoogleAppStoreDistribution")]
266 pub support_non_google_app_store_distribution: Option<bool>,
267}
268
269impl common::Part for GoogleCloudRecaptchaenterpriseV1AndroidKeySettings {}
270
271/// The request message to annotate an Assessment.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [assessments annotate projects](ProjectAssessmentAnnotateCall) (request)
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentRequest {
283 /// 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.
284 #[serde(rename = "accountId")]
285 pub account_id: Option<String>,
286 /// Optional. The annotation that is assigned to the Event. This field can be left empty to provide reasons that apply to an event without concluding whether the event is legitimate or fraudulent.
287 pub annotation: Option<String>,
288 /// 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.
289 #[serde(rename = "hashedAccountId")]
290 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
291 pub hashed_account_id: Option<Vec<u8>>,
292 /// Optional. If using an external multi-factor authentication provider, provide phone authentication details for fraud detection purposes.
293 #[serde(rename = "phoneAuthenticationEvent")]
294 pub phone_authentication_event:
295 Option<GoogleCloudRecaptchaenterpriseV1PhoneAuthenticationEvent>,
296 /// Optional. Reasons for the annotation that are assigned to the event.
297 pub reasons: Option<Vec<String>>,
298 /// Optional. If the assessment is part of a payment transaction, provide details on payment lifecycle events that occur in the transaction.
299 #[serde(rename = "transactionEvent")]
300 pub transaction_event: Option<GoogleCloudRecaptchaenterpriseV1TransactionEvent>,
301}
302
303impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentRequest {}
304
305/// Empty response for AnnotateAssessment.
306///
307/// # Activities
308///
309/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
310/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
311///
312/// * [assessments annotate projects](ProjectAssessmentAnnotateCall) (response)
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentResponse {
317 _never_set: Option<bool>,
318}
319
320impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentResponse {}
321
322/// Contains fields that are required to perform Apple-specific integrity checks.
323///
324/// This type is not used in any activity, and only used as *part* of another schema.
325///
326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
327#[serde_with::serde_as]
328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
329pub struct GoogleCloudRecaptchaenterpriseV1AppleDeveloperId {
330 /// Required. The Apple developer key ID (10-character string).
331 #[serde(rename = "keyId")]
332 pub key_id: Option<String>,
333 /// Required. Input only. A private key (downloaded as a text file with a .p8 file extension) generated for your Apple Developer account. Ensure that Apple DeviceCheck is enabled for the private key.
334 #[serde(rename = "privateKey")]
335 pub private_key: Option<String>,
336 /// Required. The Apple team ID (10-character string) owning the provisioning profile used to build your application.
337 #[serde(rename = "teamId")]
338 pub team_id: Option<String>,
339}
340
341impl common::Part for GoogleCloudRecaptchaenterpriseV1AppleDeveloperId {}
342
343/// A reCAPTCHA Enterprise assessment resource.
344///
345/// # Activities
346///
347/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
348/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
349///
350/// * [assessments create projects](ProjectAssessmentCreateCall) (request|response)
351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
352#[serde_with::serde_as]
353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
354pub struct GoogleCloudRecaptchaenterpriseV1Assessment {
355 /// Output only. Assessment returned by account defender when an account identifier is provided.
356 #[serde(rename = "accountDefenderAssessment")]
357 pub account_defender_assessment:
358 Option<GoogleCloudRecaptchaenterpriseV1AccountDefenderAssessment>,
359 /// Optional. Account verification information for identity verification. The assessment event must include a token and site key to use this feature.
360 #[serde(rename = "accountVerification")]
361 pub account_verification: Option<GoogleCloudRecaptchaenterpriseV1AccountVerificationInfo>,
362 /// Optional. The environment creating the assessment. This describes your environment (the system invoking CreateAssessment), NOT the environment of your user.
363 #[serde(rename = "assessmentEnvironment")]
364 pub assessment_environment: Option<GoogleCloudRecaptchaenterpriseV1AssessmentEnvironment>,
365 /// Optional. The event being assessed.
366 pub event: Option<GoogleCloudRecaptchaenterpriseV1Event>,
367 /// Output only. Assessment returned when firewall policies belonging to the project are evaluated using the field firewall_policy_evaluation.
368 #[serde(rename = "firewallPolicyAssessment")]
369 pub firewall_policy_assessment:
370 Option<GoogleCloudRecaptchaenterpriseV1FirewallPolicyAssessment>,
371 /// Output only. Assessment returned by Fraud Prevention when TransactionData is provided.
372 #[serde(rename = "fraudPreventionAssessment")]
373 pub fraud_prevention_assessment:
374 Option<GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessment>,
375 /// Output only. Fraud Signals specific to the users involved in a payment transaction.
376 #[serde(rename = "fraudSignals")]
377 pub fraud_signals: Option<GoogleCloudRecaptchaenterpriseV1FraudSignals>,
378 /// Output only. Identifier. The resource name for the Assessment in the format `projects/{project}/assessments/{assessment}`.
379 pub name: Option<String>,
380 /// Output only. Assessment returned when a site key, a token, and a phone number as `user_id` are provided. Account defender and SMS toll fraud protection need to be enabled.
381 #[serde(rename = "phoneFraudAssessment")]
382 pub phone_fraud_assessment: Option<GoogleCloudRecaptchaenterpriseV1PhoneFraudAssessment>,
383 /// Optional. The private password leak verification field contains the parameters that are used to to check for leaks privately without sharing user credentials.
384 #[serde(rename = "privatePasswordLeakVerification")]
385 pub private_password_leak_verification:
386 Option<GoogleCloudRecaptchaenterpriseV1PrivatePasswordLeakVerification>,
387 /// Output only. The risk analysis result for the event being assessed.
388 #[serde(rename = "riskAnalysis")]
389 pub risk_analysis: Option<GoogleCloudRecaptchaenterpriseV1RiskAnalysis>,
390 /// Output only. Properties of the provided event token.
391 #[serde(rename = "tokenProperties")]
392 pub token_properties: Option<GoogleCloudRecaptchaenterpriseV1TokenProperties>,
393}
394
395impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1Assessment {}
396impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1Assessment {}
397
398/// The environment creating the assessment. This describes your environment (the system invoking CreateAssessment), NOT the environment of your user.
399///
400/// This type is not used in any activity, and only used as *part* of another schema.
401///
402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
403#[serde_with::serde_as]
404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
405pub struct GoogleCloudRecaptchaenterpriseV1AssessmentEnvironment {
406 /// Optional. Identifies the client module initiating the CreateAssessment request. This can be the link to the client module's project. Examples include: - "github.com/GoogleCloudPlatform/recaptcha-enterprise-google-tag-manager" - "wordpress.org/plugins/recaptcha-something"
407 pub client: Option<String>,
408 /// Optional. The version of the client module. For example, "1.0.0".
409 pub version: Option<String>,
410}
411
412impl common::Part for GoogleCloudRecaptchaenterpriseV1AssessmentEnvironment {}
413
414/// Bot information and metadata.
415///
416/// This type is not used in any activity, and only used as *part* of another schema.
417///
418#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
419#[serde_with::serde_as]
420#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
421pub struct GoogleCloudRecaptchaenterpriseV1Bot {
422 /// Optional. Enumerated field representing the type of bot.
423 #[serde(rename = "botType")]
424 pub bot_type: Option<String>,
425 /// Optional. Enumerated string value that indicates the identity of the bot, formatted in kebab-case.
426 pub name: Option<String>,
427}
428
429impl common::Part for GoogleCloudRecaptchaenterpriseV1Bot {}
430
431/// Metrics related to challenges.
432///
433/// This type is not used in any activity, and only used as *part* of another schema.
434///
435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
436#[serde_with::serde_as]
437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
438pub struct GoogleCloudRecaptchaenterpriseV1ChallengeMetrics {
439 /// Count of submitted challenge solutions that were incorrect or otherwise deemed suspicious such that a subsequent challenge was triggered.
440 #[serde(rename = "failedCount")]
441 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
442 pub failed_count: Option<i64>,
443 /// Count of nocaptchas (successful verification without a challenge) issued.
444 #[serde(rename = "nocaptchaCount")]
445 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
446 pub nocaptcha_count: Option<i64>,
447 /// Count of reCAPTCHA checkboxes or badges rendered. This is mostly equivalent to a count of pageloads for pages that include reCAPTCHA.
448 #[serde(rename = "pageloadCount")]
449 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
450 pub pageload_count: Option<i64>,
451 /// Count of nocaptchas (successful verification without a challenge) plus submitted challenge solutions that were correct and resulted in verification.
452 #[serde(rename = "passedCount")]
453 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
454 pub passed_count: Option<i64>,
455}
456
457impl common::Part for GoogleCloudRecaptchaenterpriseV1ChallengeMetrics {}
458
459/// Information about a verification endpoint that can be used for 2FA.
460///
461/// This type is not used in any activity, and only used as *part* of another schema.
462///
463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
464#[serde_with::serde_as]
465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
466pub struct GoogleCloudRecaptchaenterpriseV1EndpointVerificationInfo {
467 /// Email address for which to trigger a verification request.
468 #[serde(rename = "emailAddress")]
469 pub email_address: Option<String>,
470 /// Output only. Timestamp of the last successful verification for the endpoint, if any.
471 #[serde(rename = "lastVerificationTime")]
472 pub last_verification_time: Option<chrono::DateTime<chrono::offset::Utc>>,
473 /// Phone number for which to trigger a verification request. Should be given in E.164 format.
474 #[serde(rename = "phoneNumber")]
475 pub phone_number: Option<String>,
476 /// Output only. Token to provide to the client to trigger endpoint verification. It must be used within 15 minutes.
477 #[serde(rename = "requestToken")]
478 pub request_token: Option<String>,
479}
480
481impl common::Part for GoogleCloudRecaptchaenterpriseV1EndpointVerificationInfo {}
482
483/// The event being assessed.
484///
485/// This type is not used in any activity, and only used as *part* of another schema.
486///
487#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
488#[serde_with::serde_as]
489#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
490pub struct GoogleCloudRecaptchaenterpriseV1Event {
491 /// Optional. The expected action for this type of event. This should be the same action provided at token generation time on client-side platforms already integrated with recaptcha enterprise.
492 #[serde(rename = "expectedAction")]
493 pub expected_action: Option<String>,
494 /// Optional. Flag for a reCAPTCHA express request for an assessment without a token. If enabled, `site_key` must reference an Express site key.
495 pub express: Option<bool>,
496 /// Optional. Flag for enabling firewall policy config assessment. If this flag is enabled, the firewall policy is evaluated and a suggested firewall action is returned in the response.
497 #[serde(rename = "firewallPolicyEvaluation")]
498 pub firewall_policy_evaluation: Option<bool>,
499 /// Optional. The Fraud Prevention setting for this assessment.
500 #[serde(rename = "fraudPrevention")]
501 pub fraud_prevention: Option<String>,
502 /// 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.
503 #[serde(rename = "hashedAccountId")]
504 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
505 pub hashed_account_id: Option<Vec<u8>>,
506 /// Optional. HTTP header information about the request.
507 pub headers: Option<Vec<String>>,
508 /// Optional. JA3 fingerprint for SSL clients. To learn how to compute this fingerprint, please refer to https://github.com/salesforce/ja3.
509 pub ja3: Option<String>,
510 /// Optional. JA4 fingerprint for SSL clients. To learn how to compute this fingerprint, please refer to https://github.com/FoxIO-LLC/ja4.
511 pub ja4: Option<String>,
512 /// Optional. The URI resource the user requested that triggered an assessment.
513 #[serde(rename = "requestedUri")]
514 pub requested_uri: Option<String>,
515 /// Optional. The site key that was used to invoke reCAPTCHA Enterprise on your site and generate the token.
516 #[serde(rename = "siteKey")]
517 pub site_key: Option<String>,
518 /// Optional. The user response token provided by the reCAPTCHA Enterprise client-side integration on your site.
519 pub token: Option<String>,
520 /// Optional. Data describing a payment transaction to be assessed. Sending this data enables reCAPTCHA Enterprise Fraud Prevention and the FraudPreventionAssessment component in the response.
521 #[serde(rename = "transactionData")]
522 pub transaction_data: Option<GoogleCloudRecaptchaenterpriseV1TransactionData>,
523 /// Optional. The user agent present in the request from the user's device related to this event.
524 #[serde(rename = "userAgent")]
525 pub user_agent: Option<String>,
526 /// 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.
527 #[serde(rename = "userInfo")]
528 pub user_info: Option<GoogleCloudRecaptchaenterpriseV1UserInfo>,
529 /// Optional. The IP address in the request from the user's device related to this event.
530 #[serde(rename = "userIpAddress")]
531 pub user_ip_address: Option<String>,
532 /// Optional. Flag for running Web Application Firewall (WAF) token assessment. If enabled, the token must be specified, and have been created by a WAF-enabled key.
533 #[serde(rename = "wafTokenAssessment")]
534 pub waf_token_assessment: Option<bool>,
535}
536
537impl common::Part for GoogleCloudRecaptchaenterpriseV1Event {}
538
539/// Settings specific to keys that can be used for reCAPTCHA Express.
540///
541/// This type is not used in any activity, and only used as *part* of another schema.
542///
543#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
544#[serde_with::serde_as]
545#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
546pub struct GoogleCloudRecaptchaenterpriseV1ExpressKeySettings {
547 _never_set: Option<bool>,
548}
549
550impl common::Part for GoogleCloudRecaptchaenterpriseV1ExpressKeySettings {}
551
552/// An individual action. Each action represents what to do if a policy matches.
553///
554/// This type is not used in any activity, and only used as *part* of another schema.
555///
556#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
557#[serde_with::serde_as]
558#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
559pub struct GoogleCloudRecaptchaenterpriseV1FirewallAction {
560 /// The user request did not match any policy and should be allowed access to the requested resource.
561 pub allow: Option<GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction>,
562 /// This action denies access to a given page. The user gets an HTTP error code.
563 pub block: Option<GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction>,
564 /// This action injects reCAPTCHA JavaScript code into the HTML page returned by the site backend.
565 #[serde(rename = "includeRecaptchaScript")]
566 pub include_recaptcha_script:
567 Option<GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction>,
568 /// This action redirects the request to a reCAPTCHA interstitial to attach a token.
569 pub redirect: Option<GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction>,
570 /// This action sets a custom header but allow the request to continue to the customer backend.
571 #[serde(rename = "setHeader")]
572 pub set_header: Option<GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction>,
573 /// This action transparently serves a different page to an offending user.
574 pub substitute: Option<GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction>,
575}
576
577impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallAction {}
578
579/// An allow action continues processing a request unimpeded.
580///
581/// This type is not used in any activity, and only used as *part* of another schema.
582///
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as]
585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
586pub struct GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction {
587 _never_set: Option<bool>,
588}
589
590impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction {}
591
592/// A block action serves an HTTP error code a prevents the request from hitting the backend.
593///
594/// This type is not used in any activity, and only used as *part* of another schema.
595///
596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
597#[serde_with::serde_as]
598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
599pub struct GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction {
600 _never_set: Option<bool>,
601}
602
603impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction {}
604
605/// An include reCAPTCHA script action involves injecting reCAPTCHA JavaScript code into the HTML returned by the site backend. This reCAPTCHA script is tasked with collecting user signals on the requested web page, issuing tokens as a cookie within the site domain, and enabling their utilization in subsequent page requests.
606///
607/// This type is not used in any activity, and only used as *part* of another schema.
608///
609#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
610#[serde_with::serde_as]
611#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
612pub struct GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction {
613 _never_set: Option<bool>,
614}
615
616impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction {}
617
618/// A redirect action returns a 307 (temporary redirect) response, pointing the user to a reCAPTCHA interstitial page to attach a token.
619///
620/// This type is not used in any activity, and only used as *part* of another schema.
621///
622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
623#[serde_with::serde_as]
624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
625pub struct GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction {
626 _never_set: Option<bool>,
627}
628
629impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction {}
630
631/// A set header action sets a header and forwards the request to the backend. This can be used to trigger custom protection implemented on the backend.
632///
633/// This type is not used in any activity, and only used as *part* of another schema.
634///
635#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
636#[serde_with::serde_as]
637#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
638pub struct GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction {
639 /// Optional. The header key to set in the request to the backend server.
640 pub key: Option<String>,
641 /// Optional. The header value to set in the request to the backend server.
642 pub value: Option<String>,
643}
644
645impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction {}
646
647/// A substitute action transparently serves a different page than the one requested.
648///
649/// This type is not used in any activity, and only used as *part* of another schema.
650///
651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
652#[serde_with::serde_as]
653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
654pub struct GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction {
655 /// Optional. The address to redirect to. The target is a relative path in the current host. Example: "/blog/404.html".
656 pub path: Option<String>,
657}
658
659impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction {}
660
661/// A FirewallPolicy represents a single matching pattern and resulting actions to take.
662///
663/// # Activities
664///
665/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
666/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
667///
668/// * [firewallpolicies create projects](ProjectFirewallpolicyCreateCall) (request|response)
669/// * [firewallpolicies get projects](ProjectFirewallpolicyGetCall) (response)
670/// * [firewallpolicies patch projects](ProjectFirewallpolicyPatchCall) (request|response)
671#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
672#[serde_with::serde_as]
673#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
674pub struct GoogleCloudRecaptchaenterpriseV1FirewallPolicy {
675 /// Optional. The actions that the caller should take regarding user access. There should be at most one terminal action. A terminal action is any action that forces a response, such as `AllowAction`, `BlockAction` or `SubstituteAction`. Zero or more non-terminal actions such as `SetHeader` might be specified. A single policy can contain up to 16 actions.
676 pub actions: Option<Vec<GoogleCloudRecaptchaenterpriseV1FirewallAction>>,
677 /// Optional. A CEL (Common Expression Language) conditional expression that specifies if this policy applies to an incoming user request. If this condition evaluates to true and the requested path matched the path pattern, the associated actions should be executed by the caller. The condition string is checked for CEL syntax correctness on creation. For more information, see the [CEL spec](https://github.com/google/cel-spec) and its [language definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md). A condition has a max length of 500 characters.
678 pub condition: Option<String>,
679 /// Optional. A description of what this policy aims to achieve, for convenience purposes. The description can at most include 256 UTF-8 characters.
680 pub description: Option<String>,
681 /// Identifier. The resource name for the FirewallPolicy in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
682 pub name: Option<String>,
683 /// Optional. The path for which this policy applies, specified as a glob pattern. For more information on glob, see the [manual page](https://man7.org/linux/man-pages/man7/glob.7.html). A path has a max length of 200 characters.
684 pub path: Option<String>,
685}
686
687impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1FirewallPolicy {}
688impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1FirewallPolicy {}
689
690/// Policy config assessment.
691///
692/// This type is not used in any activity, and only used as *part* of another schema.
693///
694#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
695#[serde_with::serde_as]
696#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
697pub struct GoogleCloudRecaptchaenterpriseV1FirewallPolicyAssessment {
698 /// Output only. If the processing of a policy config fails, an error is populated and the firewall_policy is left empty.
699 pub error: Option<GoogleRpcStatus>,
700 /// Output only. The policy that matched the request. If more than one policy may match, this is the first match. If no policy matches the incoming request, the policy field is left empty.
701 #[serde(rename = "firewallPolicy")]
702 pub firewall_policy: Option<GoogleCloudRecaptchaenterpriseV1FirewallPolicy>,
703}
704
705impl common::Part for GoogleCloudRecaptchaenterpriseV1FirewallPolicyAssessment {}
706
707/// Assessment for Fraud Prevention.
708///
709/// This type is not used in any activity, and only used as *part* of another schema.
710///
711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
712#[serde_with::serde_as]
713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
714pub struct GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessment {
715 /// Output only. Assessment of this transaction for behavioral trust.
716 #[serde(rename = "behavioralTrustVerdict")]
717 pub behavioral_trust_verdict:
718 Option<GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentBehavioralTrustVerdict>,
719 /// Output only. Assessment of this transaction for risk of being part of a card testing attack.
720 #[serde(rename = "cardTestingVerdict")]
721 pub card_testing_verdict:
722 Option<GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentCardTestingVerdict>,
723 /// Output only. Reasons why the transaction is probably fraudulent and received a high transaction risk score.
724 #[serde(rename = "riskReasons")]
725 pub risk_reasons:
726 Option<Vec<GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentRiskReason>>,
727 /// Output only. Assessment of this transaction for risk of a stolen instrument.
728 #[serde(rename = "stolenInstrumentVerdict")]
729 pub stolen_instrument_verdict:
730 Option<GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentStolenInstrumentVerdict>,
731 /// Output only. Probability of this transaction being fraudulent. Summarizes the combined risk of attack vectors below. Values are from 0.0 (lowest) to 1.0 (highest).
732 #[serde(rename = "transactionRisk")]
733 pub transaction_risk: Option<f32>,
734}
735
736impl common::Part for GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessment {}
737
738/// Information about behavioral trust of the transaction.
739///
740/// This type is not used in any activity, and only used as *part* of another schema.
741///
742#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
743#[serde_with::serde_as]
744#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
745pub struct GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentBehavioralTrustVerdict {
746 /// Output only. Probability of this transaction attempt being executed in a behaviorally trustworthy way. Values are from 0.0 (lowest) to 1.0 (highest).
747 pub trust: Option<f32>,
748}
749
750impl common::Part
751 for GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentBehavioralTrustVerdict
752{
753}
754
755/// Information about card testing fraud, where an adversary is testing fraudulently obtained cards or brute forcing their details.
756///
757/// This type is not used in any activity, and only used as *part* of another schema.
758///
759#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
760#[serde_with::serde_as]
761#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
762pub struct GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentCardTestingVerdict {
763 /// Output only. Probability of this transaction attempt being part of a card testing attack. Values are from 0.0 (lowest) to 1.0 (highest).
764 pub risk: Option<f32>,
765}
766
767impl common::Part for GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentCardTestingVerdict {}
768
769/// Risk reasons applicable to the Fraud Prevention assessment.
770///
771/// This type is not used in any activity, and only used as *part* of another schema.
772///
773#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
774#[serde_with::serde_as]
775#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
776pub struct GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentRiskReason {
777 /// Output only. Risk reasons applicable to the Fraud Prevention assessment.
778 pub reason: Option<String>,
779}
780
781impl common::Part for GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentRiskReason {}
782
783/// Information about stolen instrument fraud, where the user is not the legitimate owner of the instrument being used for the purchase.
784///
785/// This type is not used in any activity, and only used as *part* of another schema.
786///
787#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
788#[serde_with::serde_as]
789#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
790pub struct GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentStolenInstrumentVerdict {
791 /// Output only. Probability of this transaction being executed with a stolen instrument. Values are from 0.0 (lowest) to 1.0 (highest).
792 pub risk: Option<f32>,
793}
794
795impl common::Part
796 for GoogleCloudRecaptchaenterpriseV1FraudPreventionAssessmentStolenInstrumentVerdict
797{
798}
799
800/// Fraud signals describing users and cards involved in the transaction.
801///
802/// This type is not used in any activity, and only used as *part* of another schema.
803///
804#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
805#[serde_with::serde_as]
806#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
807pub struct GoogleCloudRecaptchaenterpriseV1FraudSignals {
808 /// Output only. Signals describing the payment card or cards used in this transaction.
809 #[serde(rename = "cardSignals")]
810 pub card_signals: Option<GoogleCloudRecaptchaenterpriseV1FraudSignalsCardSignals>,
811 /// Output only. Signals describing the end user in this transaction.
812 #[serde(rename = "userSignals")]
813 pub user_signals: Option<GoogleCloudRecaptchaenterpriseV1FraudSignalsUserSignals>,
814}
815
816impl common::Part for GoogleCloudRecaptchaenterpriseV1FraudSignals {}
817
818/// Signals describing the payment card used in this transaction.
819///
820/// This type is not used in any activity, and only used as *part* of another schema.
821///
822#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
823#[serde_with::serde_as]
824#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
825pub struct GoogleCloudRecaptchaenterpriseV1FraudSignalsCardSignals {
826 /// Output only. The labels for the payment card in this transaction.
827 #[serde(rename = "cardLabels")]
828 pub card_labels: Option<Vec<String>>,
829}
830
831impl common::Part for GoogleCloudRecaptchaenterpriseV1FraudSignalsCardSignals {}
832
833/// Signals describing the user involved in this transaction.
834///
835/// This type is not used in any activity, and only used as *part* of another schema.
836///
837#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
838#[serde_with::serde_as]
839#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
840pub struct GoogleCloudRecaptchaenterpriseV1FraudSignalsUserSignals {
841 /// Output only. This user (based on email, phone, and other identifiers) has been seen on the internet for at least this number of days.
842 #[serde(rename = "activeDaysLowerBound")]
843 pub active_days_lower_bound: Option<i32>,
844 /// Output only. Likelihood (from 0.0 to 1.0) this user includes synthetic components in their identity, such as a randomly generated email address, temporary phone number, or fake shipping address.
845 #[serde(rename = "syntheticRisk")]
846 pub synthetic_risk: Option<f32>,
847}
848
849impl common::Part for GoogleCloudRecaptchaenterpriseV1FraudSignalsUserSignals {}
850
851/// Settings specific to keys that can be used by iOS apps.
852///
853/// This type is not used in any activity, and only used as *part* of another schema.
854///
855#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
856#[serde_with::serde_as]
857#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
858pub struct GoogleCloudRecaptchaenterpriseV1IOSKeySettings {
859 /// Optional. If set to true, allowed_bundle_ids are not enforced.
860 #[serde(rename = "allowAllBundleIds")]
861 pub allow_all_bundle_ids: Option<bool>,
862 /// Optional. iOS bundle IDs of apps allowed to use the key. Example: 'com.companyname.productname.appname' Each key supports a maximum of 250 bundle IDs. To use a key on more apps, set `allow_all_bundle_ids` to true. When this is set, you are responsible for validating the bundle id by checking the `token_properties.ios_bundle_id` field in each assessment response against your list of allowed bundle IDs.
863 #[serde(rename = "allowedBundleIds")]
864 pub allowed_bundle_ids: Option<Vec<String>>,
865 /// Optional. Apple Developer account details for the app that is protected by the reCAPTCHA Key. reCAPTCHA leverages platform-specific checks like Apple App Attest and Apple DeviceCheck to protect your app from abuse. Providing these fields allows reCAPTCHA to get a better assessment of the integrity of your app.
866 #[serde(rename = "appleDeveloperId")]
867 pub apple_developer_id: Option<GoogleCloudRecaptchaenterpriseV1AppleDeveloperId>,
868}
869
870impl common::Part for GoogleCloudRecaptchaenterpriseV1IOSKeySettings {}
871
872/// Information about the IP or IP range override.
873///
874/// This type is not used in any activity, and only used as *part* of another schema.
875///
876#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
877#[serde_with::serde_as]
878#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
879pub struct GoogleCloudRecaptchaenterpriseV1IpOverrideData {
880 /// Required. The IP address to override (can be IPv4, IPv6 or CIDR). The IP override must be a valid IPv4 or IPv6 address, or a CIDR range. The IP override must be a public IP address. Example of IPv4: 168.192.5.6 Example of IPv6: 2001:0000:130F:0000:0000:09C0:876A:130B Example of IPv4 with CIDR: 168.192.5.0/24 Example of IPv6 with CIDR: 2001:0DB8:1234::/48
881 pub ip: Option<String>,
882 /// Required. Describes the type of IP override.
883 #[serde(rename = "overrideType")]
884 pub override_type: Option<String>,
885}
886
887impl common::Part for GoogleCloudRecaptchaenterpriseV1IpOverrideData {}
888
889/// A key used to identify and configure applications (web and/or mobile) that use reCAPTCHA Enterprise.
890///
891/// # Activities
892///
893/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
894/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
895///
896/// * [keys create projects](ProjectKeyCreateCall) (request|response)
897/// * [keys get projects](ProjectKeyGetCall) (response)
898/// * [keys migrate projects](ProjectKeyMigrateCall) (response)
899/// * [keys patch projects](ProjectKeyPatchCall) (request|response)
900#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
901#[serde_with::serde_as]
902#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
903pub struct GoogleCloudRecaptchaenterpriseV1Key {
904 /// Settings for keys that can be used by Android apps.
905 #[serde(rename = "androidSettings")]
906 pub android_settings: Option<GoogleCloudRecaptchaenterpriseV1AndroidKeySettings>,
907 /// Output only. The timestamp corresponding to the creation of this key.
908 #[serde(rename = "createTime")]
909 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
910 /// Required. Human-readable display name of this key. Modifiable by user.
911 #[serde(rename = "displayName")]
912 pub display_name: Option<String>,
913 /// Settings for keys that can be used by reCAPTCHA Express.
914 #[serde(rename = "expressSettings")]
915 pub express_settings: Option<GoogleCloudRecaptchaenterpriseV1ExpressKeySettings>,
916 /// Settings for keys that can be used by iOS apps.
917 #[serde(rename = "iosSettings")]
918 pub ios_settings: Option<GoogleCloudRecaptchaenterpriseV1IOSKeySettings>,
919 /// Optional. See [Creating and managing labels] (https://cloud.google.com/recaptcha/docs/labels).
920 pub labels: Option<HashMap<String, String>>,
921 /// Identifier. The resource name for the Key in the format `projects/{project}/keys/{key}`.
922 pub name: Option<String>,
923 /// Optional. Options for user acceptance testing.
924 #[serde(rename = "testingOptions")]
925 pub testing_options: Option<GoogleCloudRecaptchaenterpriseV1TestingOptions>,
926 /// Optional. Settings for Web Application Firewall (WAF).
927 #[serde(rename = "wafSettings")]
928 pub waf_settings: Option<GoogleCloudRecaptchaenterpriseV1WafSettings>,
929 /// Settings for keys that can be used by websites.
930 #[serde(rename = "webSettings")]
931 pub web_settings: Option<GoogleCloudRecaptchaenterpriseV1WebKeySettings>,
932}
933
934impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1Key {}
935impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1Key {}
936
937/// Response to request to list firewall policies belonging to a project.
938///
939/// # Activities
940///
941/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
942/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
943///
944/// * [firewallpolicies list projects](ProjectFirewallpolicyListCall) (response)
945#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
946#[serde_with::serde_as]
947#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
948pub struct GoogleCloudRecaptchaenterpriseV1ListFirewallPoliciesResponse {
949 /// Policy details.
950 #[serde(rename = "firewallPolicies")]
951 pub firewall_policies: Option<Vec<GoogleCloudRecaptchaenterpriseV1FirewallPolicy>>,
952 /// Token to retrieve the next page of results. It is set to empty if no policies remain in results.
953 #[serde(rename = "nextPageToken")]
954 pub next_page_token: Option<String>,
955}
956
957impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1ListFirewallPoliciesResponse {}
958
959/// Response for ListIpOverrides.
960///
961/// # Activities
962///
963/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
964/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
965///
966/// * [keys list ip overrides projects](ProjectKeyListIpOverrideCall) (response)
967#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
968#[serde_with::serde_as]
969#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
970pub struct GoogleCloudRecaptchaenterpriseV1ListIpOverridesResponse {
971 /// IP Overrides details.
972 #[serde(rename = "ipOverrides")]
973 pub ip_overrides: Option<Vec<GoogleCloudRecaptchaenterpriseV1IpOverrideData>>,
974 /// Token to retrieve the next page of results. If this field is empty, no keys remain in the results.
975 #[serde(rename = "nextPageToken")]
976 pub next_page_token: Option<String>,
977}
978
979impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1ListIpOverridesResponse {}
980
981/// Response to request to list keys in a project.
982///
983/// # Activities
984///
985/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
986/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
987///
988/// * [keys list projects](ProjectKeyListCall) (response)
989#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
990#[serde_with::serde_as]
991#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
992pub struct GoogleCloudRecaptchaenterpriseV1ListKeysResponse {
993 /// Key details.
994 pub keys: Option<Vec<GoogleCloudRecaptchaenterpriseV1Key>>,
995 /// Token to retrieve the next page of results. It is set to empty if no keys remain in results.
996 #[serde(rename = "nextPageToken")]
997 pub next_page_token: Option<String>,
998}
999
1000impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1ListKeysResponse {}
1001
1002/// The response to a `ListRelatedAccountGroupMemberships` call.
1003///
1004/// # Activities
1005///
1006/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1007/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1008///
1009/// * [relatedaccountgroups memberships list projects](ProjectRelatedaccountgroupMembershipListCall) (response)
1010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1011#[serde_with::serde_as]
1012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1013pub struct GoogleCloudRecaptchaenterpriseV1ListRelatedAccountGroupMembershipsResponse {
1014 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1015 #[serde(rename = "nextPageToken")]
1016 pub next_page_token: Option<String>,
1017 /// The memberships listed by the query.
1018 #[serde(rename = "relatedAccountGroupMemberships")]
1019 pub related_account_group_memberships:
1020 Option<Vec<GoogleCloudRecaptchaenterpriseV1RelatedAccountGroupMembership>>,
1021}
1022
1023impl common::ResponseResult
1024 for GoogleCloudRecaptchaenterpriseV1ListRelatedAccountGroupMembershipsResponse
1025{
1026}
1027
1028/// The response to a `ListRelatedAccountGroups` call.
1029///
1030/// # Activities
1031///
1032/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1033/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1034///
1035/// * [relatedaccountgroups list projects](ProjectRelatedaccountgroupListCall) (response)
1036#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1037#[serde_with::serde_as]
1038#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1039pub struct GoogleCloudRecaptchaenterpriseV1ListRelatedAccountGroupsResponse {
1040 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1041 #[serde(rename = "nextPageToken")]
1042 pub next_page_token: Option<String>,
1043 /// The groups of related accounts listed by the query.
1044 #[serde(rename = "relatedAccountGroups")]
1045 pub related_account_groups: Option<Vec<GoogleCloudRecaptchaenterpriseV1RelatedAccountGroup>>,
1046}
1047
1048impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1ListRelatedAccountGroupsResponse {}
1049
1050/// Metrics for a single Key.
1051///
1052/// # Activities
1053///
1054/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1055/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1056///
1057/// * [keys get metrics projects](ProjectKeyGetMetricCall) (response)
1058#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1059#[serde_with::serde_as]
1060#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1061pub struct GoogleCloudRecaptchaenterpriseV1Metrics {
1062 /// Metrics are continuous and in order by dates, and in the granularity of day. Only challenge-based keys (CHECKBOX, INVISIBLE) have challenge-based data.
1063 #[serde(rename = "challengeMetrics")]
1064 pub challenge_metrics: Option<Vec<GoogleCloudRecaptchaenterpriseV1ChallengeMetrics>>,
1065 /// Output only. Identifier. The name of the metrics, in the format `projects/{project}/keys/{key}/metrics`.
1066 pub name: Option<String>,
1067 /// Metrics are continuous and in order by dates, and in the granularity of day. All Key types should have score-based data.
1068 #[serde(rename = "scoreMetrics")]
1069 pub score_metrics: Option<Vec<GoogleCloudRecaptchaenterpriseV1ScoreMetrics>>,
1070 /// Inclusive start time aligned to a day in the America/Los_Angeles (Pacific) timezone.
1071 #[serde(rename = "startTime")]
1072 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1073}
1074
1075impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1Metrics {}
1076
1077/// The migrate key request message.
1078///
1079/// # Activities
1080///
1081/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1082/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1083///
1084/// * [keys migrate projects](ProjectKeyMigrateCall) (request)
1085#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1086#[serde_with::serde_as]
1087#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1088pub struct GoogleCloudRecaptchaenterpriseV1MigrateKeyRequest {
1089 /// Optional. If true, skips the billing check. A reCAPTCHA Enterprise key or migrated key behaves differently than a reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see https://docs.cloud.google.com/recaptcha/quotas#quota_limit). To avoid any disruption of your usage, we check that a billing account is present. If your usage of reCAPTCHA is under the free quota, you can safely skip the billing check and proceed with the migration. See https://cloud.google.com/recaptcha/docs/billing-information.
1090 #[serde(rename = "skipBillingCheck")]
1091 pub skip_billing_check: Option<bool>,
1092}
1093
1094impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1MigrateKeyRequest {}
1095
1096/// Details on a phone authentication event
1097///
1098/// This type is not used in any activity, and only used as *part* of another schema.
1099///
1100#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1101#[serde_with::serde_as]
1102#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1103pub struct GoogleCloudRecaptchaenterpriseV1PhoneAuthenticationEvent {
1104 /// Optional. The time at which the multi-factor authentication event (challenge or verification) occurred.
1105 #[serde(rename = "eventTime")]
1106 pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1107 /// Required. Phone number in E.164 format for which a multi-factor authentication challenge was initiated, succeeded, or failed.
1108 #[serde(rename = "phoneNumber")]
1109 pub phone_number: Option<String>,
1110}
1111
1112impl common::Part for GoogleCloudRecaptchaenterpriseV1PhoneAuthenticationEvent {}
1113
1114/// Assessment for Phone Fraud
1115///
1116/// This type is not used in any activity, and only used as *part* of another schema.
1117///
1118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1119#[serde_with::serde_as]
1120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1121pub struct GoogleCloudRecaptchaenterpriseV1PhoneFraudAssessment {
1122 /// Output only. Assessment of this phone event for risk of SMS toll fraud.
1123 #[serde(rename = "smsTollFraudVerdict")]
1124 pub sms_toll_fraud_verdict: Option<GoogleCloudRecaptchaenterpriseV1SmsTollFraudVerdict>,
1125}
1126
1127impl common::Part for GoogleCloudRecaptchaenterpriseV1PhoneFraudAssessment {}
1128
1129/// Private password leak verification info.
1130///
1131/// This type is not used in any activity, and only used as *part* of another schema.
1132///
1133#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1134#[serde_with::serde_as]
1135#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1136pub struct GoogleCloudRecaptchaenterpriseV1PrivatePasswordLeakVerification {
1137 /// Output only. List of prefixes of the encrypted potential password leaks that matched the given parameters. They must be compared with the client-side decryption prefix of `reencrypted_user_credentials_hash`
1138 #[serde(rename = "encryptedLeakMatchPrefixes")]
1139 #[serde_as(as = "Option<Vec<common::serde::standard_base64::Wrapper>>")]
1140 pub encrypted_leak_match_prefixes: Option<Vec<Vec<u8>>>,
1141 /// Optional. Encrypted Scrypt hash of the canonicalized username+password. It is re-encrypted by the server and returned through `reencrypted_user_credentials_hash`.
1142 #[serde(rename = "encryptedUserCredentialsHash")]
1143 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1144 pub encrypted_user_credentials_hash: Option<Vec<u8>>,
1145 /// Required. Exactly 26-bit prefix of the SHA-256 hash of the canonicalized username. It is used to look up password leaks associated with that hash prefix.
1146 #[serde(rename = "lookupHashPrefix")]
1147 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1148 pub lookup_hash_prefix: Option<Vec<u8>>,
1149 /// Output only. Corresponds to the re-encryption of the `encrypted_user_credentials_hash` field. It is used to match potential password leaks within `encrypted_leak_match_prefixes`.
1150 #[serde(rename = "reencryptedUserCredentialsHash")]
1151 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1152 pub reencrypted_user_credentials_hash: Option<Vec<u8>>,
1153}
1154
1155impl common::Part for GoogleCloudRecaptchaenterpriseV1PrivatePasswordLeakVerification {}
1156
1157/// A group of related accounts.
1158///
1159/// This type is not used in any activity, and only used as *part* of another schema.
1160///
1161#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1162#[serde_with::serde_as]
1163#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1164pub struct GoogleCloudRecaptchaenterpriseV1RelatedAccountGroup {
1165 /// Required. Identifier. The resource name for the related account group in the format `projects/{project}/relatedaccountgroups/{related_account_group}`.
1166 pub name: Option<String>,
1167}
1168
1169impl common::Part for GoogleCloudRecaptchaenterpriseV1RelatedAccountGroup {}
1170
1171/// A membership in a group of related accounts.
1172///
1173/// This type is not used in any activity, and only used as *part* of another schema.
1174///
1175#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1176#[serde_with::serde_as]
1177#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1178pub struct GoogleCloudRecaptchaenterpriseV1RelatedAccountGroupMembership {
1179 /// The unique stable account identifier of the member. The identifier corresponds to an `account_id` provided in a previous `CreateAssessment` or `AnnotateAssessment` call.
1180 #[serde(rename = "accountId")]
1181 pub account_id: Option<String>,
1182 /// Deprecated: use `account_id` instead. The unique stable hashed account identifier of the member. The identifier corresponds to a `hashed_account_id` provided in a previous `CreateAssessment` or `AnnotateAssessment` call.
1183 #[serde(rename = "hashedAccountId")]
1184 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1185 pub hashed_account_id: Option<Vec<u8>>,
1186 /// Required. Identifier. The resource name for this membership in the format `projects/{project}/relatedaccountgroups/{relatedaccountgroup}/memberships/{membership}`.
1187 pub name: Option<String>,
1188}
1189
1190impl common::Part for GoogleCloudRecaptchaenterpriseV1RelatedAccountGroupMembership {}
1191
1192/// The RemoveIpOverride request message.
1193///
1194/// # Activities
1195///
1196/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1197/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1198///
1199/// * [keys remove ip override projects](ProjectKeyRemoveIpOverrideCall) (request)
1200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1201#[serde_with::serde_as]
1202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1203pub struct GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideRequest {
1204 /// Required. IP override to be removed from the key.
1205 #[serde(rename = "ipOverrideData")]
1206 pub ip_override_data: Option<GoogleCloudRecaptchaenterpriseV1IpOverrideData>,
1207}
1208
1209impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideRequest {}
1210
1211/// Response for RemoveIpOverride.
1212///
1213/// # Activities
1214///
1215/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1216/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1217///
1218/// * [keys remove ip override projects](ProjectKeyRemoveIpOverrideCall) (response)
1219#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1220#[serde_with::serde_as]
1221#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1222pub struct GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideResponse {
1223 _never_set: Option<bool>,
1224}
1225
1226impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideResponse {}
1227
1228/// The reorder firewall policies request message.
1229///
1230/// # Activities
1231///
1232/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1233/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1234///
1235/// * [firewallpolicies reorder projects](ProjectFirewallpolicyReorderCall) (request)
1236#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1237#[serde_with::serde_as]
1238#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1239pub struct GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesRequest {
1240 /// Required. A list containing all policy names, in the new order. Each name is in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
1241 pub names: Option<Vec<String>>,
1242}
1243
1244impl common::RequestValue for GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesRequest {}
1245
1246/// The reorder firewall policies response message.
1247///
1248/// # Activities
1249///
1250/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1251/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1252///
1253/// * [firewallpolicies reorder projects](ProjectFirewallpolicyReorderCall) (response)
1254#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1255#[serde_with::serde_as]
1256#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1257pub struct GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesResponse {
1258 _never_set: Option<bool>,
1259}
1260
1261impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesResponse {}
1262
1263/// Secret key is used only in legacy reCAPTCHA. It must be used in a 3rd party integration with legacy reCAPTCHA.
1264///
1265/// # Activities
1266///
1267/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1268/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1269///
1270/// * [keys retrieve legacy secret key projects](ProjectKeyRetrieveLegacySecretKeyCall) (response)
1271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1272#[serde_with::serde_as]
1273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1274pub struct GoogleCloudRecaptchaenterpriseV1RetrieveLegacySecretKeyResponse {
1275 /// The secret key (also known as shared secret) authorizes communication between your application backend and the reCAPTCHA Enterprise server to create an assessment. The secret key needs to be kept safe for security purposes.
1276 #[serde(rename = "legacySecretKey")]
1277 pub legacy_secret_key: Option<String>,
1278}
1279
1280impl common::ResponseResult for GoogleCloudRecaptchaenterpriseV1RetrieveLegacySecretKeyResponse {}
1281
1282/// Risk analysis result for an event.
1283///
1284/// This type is not used in any activity, and only used as *part* of another schema.
1285///
1286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1287#[serde_with::serde_as]
1288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1289pub struct GoogleCloudRecaptchaenterpriseV1RiskAnalysis {
1290 /// Output only. Challenge information for POLICY_BASED_CHALLENGE and INVISIBLE keys.
1291 pub challenge: Option<String>,
1292 /// Output only. Extended verdict reasons to be used for experimentation only. The set of possible reasons is subject to change.
1293 #[serde(rename = "extendedVerdictReasons")]
1294 pub extended_verdict_reasons: Option<Vec<String>>,
1295 /// Output only. Reasons contributing to the risk analysis verdict.
1296 pub reasons: Option<Vec<String>>,
1297 /// Output only. Legitimate event score from 0.0 to 1.0. (1.0 means very likely legitimate traffic while 0.0 means very likely non-legitimate traffic).
1298 pub score: Option<f32>,
1299 /// Output only. Bots with identities that have been verified by reCAPTCHA and detected in the event.
1300 #[serde(rename = "verifiedBots")]
1301 pub verified_bots: Option<Vec<GoogleCloudRecaptchaenterpriseV1Bot>>,
1302}
1303
1304impl common::Part for GoogleCloudRecaptchaenterpriseV1RiskAnalysis {}
1305
1306/// Score distribution.
1307///
1308/// This type is not used in any activity, and only used as *part* of another schema.
1309///
1310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1311#[serde_with::serde_as]
1312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1313pub struct GoogleCloudRecaptchaenterpriseV1ScoreDistribution {
1314 /// Map key is score value multiplied by 100. The scores are discrete values between [0, 1]. The maximum number of buckets is on order of a few dozen, but typically much lower (ie. 10).
1315 #[serde(rename = "scoreBuckets")]
1316 #[serde_as(as = "Option<HashMap<_, serde_with::DisplayFromStr>>")]
1317 pub score_buckets: Option<HashMap<String, i64>>,
1318}
1319
1320impl common::Part for GoogleCloudRecaptchaenterpriseV1ScoreDistribution {}
1321
1322/// Metrics related to scoring.
1323///
1324/// This type is not used in any activity, and only used as *part* of another schema.
1325///
1326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1327#[serde_with::serde_as]
1328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1329pub struct GoogleCloudRecaptchaenterpriseV1ScoreMetrics {
1330 /// Action-based metrics. The map key is the action name which specified by the site owners at time of the "execute" client-side call.
1331 #[serde(rename = "actionMetrics")]
1332 pub action_metrics: Option<HashMap<String, GoogleCloudRecaptchaenterpriseV1ScoreDistribution>>,
1333 /// Aggregated score metrics for all traffic.
1334 #[serde(rename = "overallMetrics")]
1335 pub overall_metrics: Option<GoogleCloudRecaptchaenterpriseV1ScoreDistribution>,
1336}
1337
1338impl common::Part for GoogleCloudRecaptchaenterpriseV1ScoreMetrics {}
1339
1340/// The request message to search related account group memberships.
1341///
1342/// # Activities
1343///
1344/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1345/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1346///
1347/// * [relatedaccountgroupmemberships search projects](ProjectRelatedaccountgroupmembershipSearchCall) (request)
1348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1349#[serde_with::serde_as]
1350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1351pub struct GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsRequest {
1352 /// Optional. The unique stable account identifier used to search connections. The identifier should correspond to an `account_id` provided in a previous `CreateAssessment` or `AnnotateAssessment` call. Either hashed_account_id or account_id must be set, but not both.
1353 #[serde(rename = "accountId")]
1354 pub account_id: Option<String>,
1355 /// Optional. Deprecated: use `account_id` instead. The unique stable hashed account identifier used to search connections. The identifier should correspond to a `hashed_account_id` provided in a previous `CreateAssessment` or `AnnotateAssessment` call. Either hashed_account_id or account_id must be set, but not both.
1356 #[serde(rename = "hashedAccountId")]
1357 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1358 pub hashed_account_id: Option<Vec<u8>>,
1359 /// Optional. The maximum number of groups to return. The service might return fewer than this value. If unspecified, at most 50 groups are returned. The maximum value is 1000; values above 1000 are coerced to 1000.
1360 #[serde(rename = "pageSize")]
1361 pub page_size: Option<i32>,
1362 /// Optional. A page token, received from a previous `SearchRelatedAccountGroupMemberships` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `SearchRelatedAccountGroupMemberships` must match the call that provided the page token.
1363 #[serde(rename = "pageToken")]
1364 pub page_token: Option<String>,
1365}
1366
1367impl common::RequestValue
1368 for GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsRequest
1369{
1370}
1371
1372/// The response to a `SearchRelatedAccountGroupMemberships` call.
1373///
1374/// # Activities
1375///
1376/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1377/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1378///
1379/// * [relatedaccountgroupmemberships search projects](ProjectRelatedaccountgroupmembershipSearchCall) (response)
1380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1381#[serde_with::serde_as]
1382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1383pub struct GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsResponse {
1384 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1385 #[serde(rename = "nextPageToken")]
1386 pub next_page_token: Option<String>,
1387 /// The queried memberships.
1388 #[serde(rename = "relatedAccountGroupMemberships")]
1389 pub related_account_group_memberships:
1390 Option<Vec<GoogleCloudRecaptchaenterpriseV1RelatedAccountGroupMembership>>,
1391}
1392
1393impl common::ResponseResult
1394 for GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsResponse
1395{
1396}
1397
1398/// Information about SMS toll fraud.
1399///
1400/// This type is not used in any activity, and only used as *part* of another schema.
1401///
1402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1403#[serde_with::serde_as]
1404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1405pub struct GoogleCloudRecaptchaenterpriseV1SmsTollFraudVerdict {
1406 /// Output only. Reasons contributing to the SMS toll fraud verdict.
1407 pub reasons: Option<Vec<String>>,
1408 /// Output only. Probability of an SMS event being fraudulent. Values are from 0.0 (lowest) to 1.0 (highest).
1409 pub risk: Option<f32>,
1410}
1411
1412impl common::Part for GoogleCloudRecaptchaenterpriseV1SmsTollFraudVerdict {}
1413
1414/// Options for user acceptance testing.
1415///
1416/// This type is not used in any activity, and only used as *part* of another schema.
1417///
1418#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1419#[serde_with::serde_as]
1420#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1421pub struct GoogleCloudRecaptchaenterpriseV1TestingOptions {
1422 /// Optional. For challenge-based keys only (CHECKBOX, INVISIBLE), all challenge requests for this site return nocaptcha if NOCAPTCHA, or an unsolvable challenge if CHALLENGE.
1423 #[serde(rename = "testingChallenge")]
1424 pub testing_challenge: Option<String>,
1425 /// Optional. All assessments for this Key return this score. Must be between 0 (likely not legitimate) and 1 (likely legitimate) inclusive.
1426 #[serde(rename = "testingScore")]
1427 pub testing_score: Option<f32>,
1428}
1429
1430impl common::Part for GoogleCloudRecaptchaenterpriseV1TestingOptions {}
1431
1432/// Properties of the provided event token.
1433///
1434/// This type is not used in any activity, and only used as *part* of another schema.
1435///
1436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1437#[serde_with::serde_as]
1438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1439pub struct GoogleCloudRecaptchaenterpriseV1TokenProperties {
1440 /// Output only. Action name provided at token generation.
1441 pub action: Option<String>,
1442 /// Output only. The name of the Android package with which the token was generated (Android keys only).
1443 #[serde(rename = "androidPackageName")]
1444 pub android_package_name: Option<String>,
1445 /// Output only. The timestamp corresponding to the generation of the token.
1446 #[serde(rename = "createTime")]
1447 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1448 /// Output only. The hostname of the page on which the token was generated (Web keys only).
1449 pub hostname: Option<String>,
1450 /// Output only. Reason associated with the response when valid = false.
1451 #[serde(rename = "invalidReason")]
1452 pub invalid_reason: Option<String>,
1453 /// Output only. The ID of the iOS bundle with which the token was generated (iOS keys only).
1454 #[serde(rename = "iosBundleId")]
1455 pub ios_bundle_id: Option<String>,
1456 /// Output only. Whether the provided user response token is valid. When valid = false, the reason could be specified in invalid_reason or it could also be due to a user failing to solve a challenge or a sitekey mismatch (i.e the sitekey used to generate the token was different than the one specified in the assessment).
1457 pub valid: Option<bool>,
1458}
1459
1460impl common::Part for GoogleCloudRecaptchaenterpriseV1TokenProperties {}
1461
1462/// Transaction data associated with a payment protected by reCAPTCHA Enterprise.
1463///
1464/// This type is not used in any activity, and only used as *part* of another schema.
1465///
1466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1467#[serde_with::serde_as]
1468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1469pub struct GoogleCloudRecaptchaenterpriseV1TransactionData {
1470 /// Optional. Address associated with the payment method when applicable.
1471 #[serde(rename = "billingAddress")]
1472 pub billing_address: Option<GoogleCloudRecaptchaenterpriseV1TransactionDataAddress>,
1473 /// Optional. The Bank Identification Number - generally the first 6 or 8 digits of the card.
1474 #[serde(rename = "cardBin")]
1475 pub card_bin: Option<String>,
1476 /// Optional. The last four digits of the card.
1477 #[serde(rename = "cardLastFour")]
1478 pub card_last_four: Option<String>,
1479 /// Optional. The currency code in ISO-4217 format.
1480 #[serde(rename = "currencyCode")]
1481 pub currency_code: Option<String>,
1482 /// Optional. Information about the payment gateway's response to the transaction.
1483 #[serde(rename = "gatewayInfo")]
1484 pub gateway_info: Option<GoogleCloudRecaptchaenterpriseV1TransactionDataGatewayInfo>,
1485 /// Optional. Items purchased in this transaction.
1486 pub items: Option<Vec<GoogleCloudRecaptchaenterpriseV1TransactionDataItem>>,
1487 /// Optional. Information about the user or users fulfilling the transaction.
1488 pub merchants: Option<Vec<GoogleCloudRecaptchaenterpriseV1TransactionDataUser>>,
1489 /// Optional. The payment method for the transaction. The allowed values are: * credit-card * debit-card * gift-card * processor-{name} (If a third-party is used, for example, processor-paypal) * custom-{name} (If an alternative method is used, for example, custom-crypto)
1490 #[serde(rename = "paymentMethod")]
1491 pub payment_method: Option<String>,
1492 /// Optional. Destination address if this transaction involves shipping a physical item.
1493 #[serde(rename = "shippingAddress")]
1494 pub shipping_address: Option<GoogleCloudRecaptchaenterpriseV1TransactionDataAddress>,
1495 /// Optional. The value of shipping in the specified currency. 0 for free or no shipping.
1496 #[serde(rename = "shippingValue")]
1497 pub shipping_value: Option<f64>,
1498 /// Unique identifier for the transaction. This custom identifier can be used to reference this transaction in the future, for example, labeling a refund or chargeback event. Two attempts at the same transaction should use the same transaction id.
1499 #[serde(rename = "transactionId")]
1500 pub transaction_id: Option<String>,
1501 /// Optional. Information about the user paying/initiating the transaction.
1502 pub user: Option<GoogleCloudRecaptchaenterpriseV1TransactionDataUser>,
1503 /// Optional. The decimal value of the transaction in the specified currency.
1504 pub value: Option<f64>,
1505}
1506
1507impl common::Part for GoogleCloudRecaptchaenterpriseV1TransactionData {}
1508
1509/// Structured address format for billing and shipping addresses.
1510///
1511/// This type is not used in any activity, and only used as *part* of another schema.
1512///
1513#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1514#[serde_with::serde_as]
1515#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1516pub struct GoogleCloudRecaptchaenterpriseV1TransactionDataAddress {
1517 /// Optional. The first lines of the address. The first line generally contains the street name and number, and further lines may include information such as an apartment number.
1518 pub address: Option<Vec<String>>,
1519 /// Optional. The state, province, or otherwise administrative area of the address.
1520 #[serde(rename = "administrativeArea")]
1521 pub administrative_area: Option<String>,
1522 /// Optional. The town/city of the address.
1523 pub locality: Option<String>,
1524 /// Optional. The postal or ZIP code of the address.
1525 #[serde(rename = "postalCode")]
1526 pub postal_code: Option<String>,
1527 /// Optional. The recipient name, potentially including information such as "care of".
1528 pub recipient: Option<String>,
1529 /// Optional. The CLDR country/region of the address.
1530 #[serde(rename = "regionCode")]
1531 pub region_code: Option<String>,
1532}
1533
1534impl common::Part for GoogleCloudRecaptchaenterpriseV1TransactionDataAddress {}
1535
1536/// Details about the transaction from the gateway.
1537///
1538/// This type is not used in any activity, and only used as *part* of another schema.
1539///
1540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1541#[serde_with::serde_as]
1542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1543pub struct GoogleCloudRecaptchaenterpriseV1TransactionDataGatewayInfo {
1544 /// Optional. AVS response code from the gateway (available only when reCAPTCHA Enterprise is called after authorization).
1545 #[serde(rename = "avsResponseCode")]
1546 pub avs_response_code: Option<String>,
1547 /// Optional. CVV response code from the gateway (available only when reCAPTCHA Enterprise is called after authorization).
1548 #[serde(rename = "cvvResponseCode")]
1549 pub cvv_response_code: Option<String>,
1550 /// Optional. Gateway response code describing the state of the transaction.
1551 #[serde(rename = "gatewayResponseCode")]
1552 pub gateway_response_code: Option<String>,
1553 /// Optional. Name of the gateway service (for example, stripe, square, paypal).
1554 pub name: Option<String>,
1555}
1556
1557impl common::Part for GoogleCloudRecaptchaenterpriseV1TransactionDataGatewayInfo {}
1558
1559/// Line items being purchased in this transaction.
1560///
1561/// This type is not used in any activity, and only used as *part* of another schema.
1562///
1563#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1564#[serde_with::serde_as]
1565#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1566pub struct GoogleCloudRecaptchaenterpriseV1TransactionDataItem {
1567 /// Optional. When a merchant is specified, its corresponding account_id. Necessary to populate marketplace-style transactions.
1568 #[serde(rename = "merchantAccountId")]
1569 pub merchant_account_id: Option<String>,
1570 /// Optional. The full name of the item.
1571 pub name: Option<String>,
1572 /// Optional. The quantity of this item that is being purchased.
1573 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1574 pub quantity: Option<i64>,
1575 /// Optional. The value per item that the user is paying, in the transaction currency, after discounts.
1576 pub value: Option<f64>,
1577}
1578
1579impl common::Part for GoogleCloudRecaptchaenterpriseV1TransactionDataItem {}
1580
1581/// Details about a user's account involved in the transaction.
1582///
1583/// This type is not used in any activity, and only used as *part* of another schema.
1584///
1585#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1586#[serde_with::serde_as]
1587#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1588pub struct GoogleCloudRecaptchaenterpriseV1TransactionDataUser {
1589 /// Optional. Unique account identifier for this user. If using account defender, this should match the hashed_account_id field. Otherwise, a unique and persistent identifier for this account.
1590 #[serde(rename = "accountId")]
1591 pub account_id: Option<String>,
1592 /// Optional. The epoch milliseconds of the user's account creation.
1593 #[serde(rename = "creationMs")]
1594 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1595 pub creation_ms: Option<i64>,
1596 /// Optional. The email address of the user.
1597 pub email: Option<String>,
1598 /// Optional. Whether the email has been verified to be accessible by the user (OTP or similar).
1599 #[serde(rename = "emailVerified")]
1600 pub email_verified: Option<bool>,
1601 /// Optional. The phone number of the user, with country code.
1602 #[serde(rename = "phoneNumber")]
1603 pub phone_number: Option<String>,
1604 /// Optional. Whether the phone number has been verified to be accessible by the user (OTP or similar).
1605 #[serde(rename = "phoneVerified")]
1606 pub phone_verified: Option<bool>,
1607}
1608
1609impl common::Part for GoogleCloudRecaptchaenterpriseV1TransactionDataUser {}
1610
1611/// Describes an event in the lifecycle of a payment transaction.
1612///
1613/// This type is not used in any activity, and only used as *part* of another schema.
1614///
1615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1616#[serde_with::serde_as]
1617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1618pub struct GoogleCloudRecaptchaenterpriseV1TransactionEvent {
1619 /// Optional. Timestamp when this transaction event occurred; otherwise assumed to be the time of the API call.
1620 #[serde(rename = "eventTime")]
1621 pub event_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1622 /// Optional. The type of this transaction event.
1623 #[serde(rename = "eventType")]
1624 pub event_type: Option<String>,
1625 /// Optional. The reason or standardized code that corresponds with this transaction event, if one exists. For example, a CHARGEBACK event with code 6005.
1626 pub reason: Option<String>,
1627 /// Optional. The value that corresponds with this transaction event, if one exists. For example, a refund event where $5.00 was refunded. Currency is obtained from the original transaction data.
1628 pub value: Option<f64>,
1629}
1630
1631impl common::Part for GoogleCloudRecaptchaenterpriseV1TransactionEvent {}
1632
1633/// An identifier associated with a user.
1634///
1635/// This type is not used in any activity, and only used as *part* of another schema.
1636///
1637#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1638#[serde_with::serde_as]
1639#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1640pub struct GoogleCloudRecaptchaenterpriseV1UserId {
1641 /// Optional. An email address.
1642 pub email: Option<String>,
1643 /// Optional. A phone number. Should use the E.164 format.
1644 #[serde(rename = "phoneNumber")]
1645 pub phone_number: Option<String>,
1646 /// 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.
1647 pub username: Option<String>,
1648}
1649
1650impl common::Part for GoogleCloudRecaptchaenterpriseV1UserId {}
1651
1652/// User information associated with a request protected by reCAPTCHA Enterprise.
1653///
1654/// This type is not used in any activity, and only used as *part* of another schema.
1655///
1656#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1657#[serde_with::serde_as]
1658#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1659pub struct GoogleCloudRecaptchaenterpriseV1UserInfo {
1660 /// 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.
1661 #[serde(rename = "accountId")]
1662 pub account_id: Option<String>,
1663 /// 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.
1664 #[serde(rename = "createAccountTime")]
1665 pub create_account_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1666 /// Optional. Identifiers associated with this user or request.
1667 #[serde(rename = "userIds")]
1668 pub user_ids: Option<Vec<GoogleCloudRecaptchaenterpriseV1UserId>>,
1669}
1670
1671impl common::Part for GoogleCloudRecaptchaenterpriseV1UserInfo {}
1672
1673/// Settings specific to keys that can be used for WAF (Web Application Firewall).
1674///
1675/// This type is not used in any activity, and only used as *part* of another schema.
1676///
1677#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1678#[serde_with::serde_as]
1679#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1680pub struct GoogleCloudRecaptchaenterpriseV1WafSettings {
1681 /// Required. The Web Application Firewall (WAF) feature for which this key is enabled.
1682 #[serde(rename = "wafFeature")]
1683 pub waf_feature: Option<String>,
1684 /// Required. The Web Application Firewall (WAF) service that uses this key.
1685 #[serde(rename = "wafService")]
1686 pub waf_service: Option<String>,
1687}
1688
1689impl common::Part for GoogleCloudRecaptchaenterpriseV1WafSettings {}
1690
1691/// Settings specific to keys that can be used by websites.
1692///
1693/// This type is not used in any activity, and only used as *part* of another schema.
1694///
1695#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1696#[serde_with::serde_as]
1697#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1698pub struct GoogleCloudRecaptchaenterpriseV1WebKeySettings {
1699 /// Optional. If set to true, it means allowed_domains are not enforced.
1700 #[serde(rename = "allowAllDomains")]
1701 pub allow_all_domains: Option<bool>,
1702 /// Optional. If set to true, the key can be used on AMP (Accelerated Mobile Pages) websites. This is supported only for the SCORE integration type.
1703 #[serde(rename = "allowAmpTraffic")]
1704 pub allow_amp_traffic: Option<bool>,
1705 /// Optional. Domains or subdomains of websites allowed to use the key. All subdomains of an allowed domain are automatically allowed. A valid domain requires a host and must not include any path, port, query or fragment. Examples: 'example.com' or 'subdomain.example.com' Each key supports a maximum of 250 domains. To use a key on more domains, set `allow_all_domains` to true. When this is set, you are responsible for validating the hostname by checking the `token_properties.hostname` field in each assessment response against your list of allowed domains.
1706 #[serde(rename = "allowedDomains")]
1707 pub allowed_domains: Option<Vec<String>>,
1708 /// Optional. Settings for the frequency and difficulty at which this key triggers captcha challenges. This should only be specified for `IntegrationType` CHECKBOX, INVISIBLE or POLICY_BASED_CHALLENGE.
1709 #[serde(rename = "challengeSecurityPreference")]
1710 pub challenge_security_preference: Option<String>,
1711 /// Optional. Challenge settings.
1712 #[serde(rename = "challengeSettings")]
1713 pub challenge_settings: Option<GoogleCloudRecaptchaenterpriseV1WebKeySettingsChallengeSettings>,
1714 /// Required. Describes how this key is integrated with the website.
1715 #[serde(rename = "integrationType")]
1716 pub integration_type: Option<String>,
1717}
1718
1719impl common::Part for GoogleCloudRecaptchaenterpriseV1WebKeySettings {}
1720
1721/// Per-action challenge settings.
1722///
1723/// This type is not used in any activity, and only used as *part* of another schema.
1724///
1725#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1726#[serde_with::serde_as]
1727#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1728pub struct GoogleCloudRecaptchaenterpriseV1WebKeySettingsActionSettings {
1729 /// Required. A challenge is triggered if the end-user score is below that threshold. Value must be between 0 and 1 (inclusive).
1730 #[serde(rename = "scoreThreshold")]
1731 pub score_threshold: Option<f32>,
1732}
1733
1734impl common::Part for GoogleCloudRecaptchaenterpriseV1WebKeySettingsActionSettings {}
1735
1736/// Settings for POLICY_BASED_CHALLENGE keys to control when a challenge is triggered.
1737///
1738/// This type is not used in any activity, and only used as *part* of another schema.
1739///
1740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1741#[serde_with::serde_as]
1742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1743pub struct GoogleCloudRecaptchaenterpriseV1WebKeySettingsChallengeSettings {
1744 /// Optional. The action to score threshold map. The action name should be the same as the action name passed in the `data-action` attribute (see https://cloud.google.com/recaptcha/docs/actions-website). Action names are case-insensitive. There is a maximum of 100 action settings. An action name has a maximum length of 100.
1745 #[serde(rename = "actionSettings")]
1746 pub action_settings:
1747 Option<HashMap<String, GoogleCloudRecaptchaenterpriseV1WebKeySettingsActionSettings>>,
1748 /// Required. Defines when a challenge is triggered (unless the default threshold is overridden for the given action, see `action_settings`).
1749 #[serde(rename = "defaultSettings")]
1750 pub default_settings: Option<GoogleCloudRecaptchaenterpriseV1WebKeySettingsActionSettings>,
1751}
1752
1753impl common::Part for GoogleCloudRecaptchaenterpriseV1WebKeySettingsChallengeSettings {}
1754
1755/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
1756///
1757/// # Activities
1758///
1759/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1760/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1761///
1762/// * [firewallpolicies delete projects](ProjectFirewallpolicyDeleteCall) (response)
1763/// * [keys delete projects](ProjectKeyDeleteCall) (response)
1764#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1765#[serde_with::serde_as]
1766#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1767pub struct GoogleProtobufEmpty {
1768 _never_set: Option<bool>,
1769}
1770
1771impl common::ResponseResult for GoogleProtobufEmpty {}
1772
1773/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1774///
1775/// This type is not used in any activity, and only used as *part* of another schema.
1776///
1777#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1778#[serde_with::serde_as]
1779#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1780pub struct GoogleRpcStatus {
1781 /// The status code, which should be an enum value of google.rpc.Code.
1782 pub code: Option<i32>,
1783 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1784 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1785 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1786 pub message: Option<String>,
1787}
1788
1789impl common::Part for GoogleRpcStatus {}
1790
1791// ###################
1792// MethodBuilders ###
1793// #################
1794
1795/// A builder providing access to all methods supported on *project* resources.
1796/// It is not used directly, but through the [`RecaptchaEnterprise`] hub.
1797///
1798/// # Example
1799///
1800/// Instantiate a resource builder
1801///
1802/// ```test_harness,no_run
1803/// extern crate hyper;
1804/// extern crate hyper_rustls;
1805/// extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
1806///
1807/// # async fn dox() {
1808/// use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1809///
1810/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1811/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1812/// .with_native_roots()
1813/// .unwrap()
1814/// .https_only()
1815/// .enable_http2()
1816/// .build();
1817///
1818/// let executor = hyper_util::rt::TokioExecutor::new();
1819/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1820/// secret,
1821/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1822/// yup_oauth2::client::CustomHyperClientBuilder::from(
1823/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1824/// ),
1825/// ).build().await.unwrap();
1826///
1827/// let client = hyper_util::client::legacy::Client::builder(
1828/// hyper_util::rt::TokioExecutor::new()
1829/// )
1830/// .build(
1831/// hyper_rustls::HttpsConnectorBuilder::new()
1832/// .with_native_roots()
1833/// .unwrap()
1834/// .https_or_http()
1835/// .enable_http2()
1836/// .build()
1837/// );
1838/// let mut hub = RecaptchaEnterprise::new(client, auth);
1839/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1840/// // like `assessments_annotate(...)`, `assessments_create(...)`, `firewallpolicies_create(...)`, `firewallpolicies_delete(...)`, `firewallpolicies_get(...)`, `firewallpolicies_list(...)`, `firewallpolicies_patch(...)`, `firewallpolicies_reorder(...)`, `keys_add_ip_override(...)`, `keys_create(...)`, `keys_delete(...)`, `keys_get(...)`, `keys_get_metrics(...)`, `keys_list(...)`, `keys_list_ip_overrides(...)`, `keys_migrate(...)`, `keys_patch(...)`, `keys_remove_ip_override(...)`, `keys_retrieve_legacy_secret_key(...)`, `relatedaccountgroupmemberships_search(...)`, `relatedaccountgroups_list(...)` and `relatedaccountgroups_memberships_list(...)`
1841/// // to build up your call.
1842/// let rb = hub.projects();
1843/// # }
1844/// ```
1845pub struct ProjectMethods<'a, C>
1846where
1847 C: 'a,
1848{
1849 hub: &'a RecaptchaEnterprise<C>,
1850}
1851
1852impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1853
1854impl<'a, C> ProjectMethods<'a, C> {
1855 /// Create a builder to help you perform the following task:
1856 ///
1857 /// Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fraudulent.
1858 ///
1859 /// # Arguments
1860 ///
1861 /// * `request` - No description provided.
1862 /// * `name` - Required. The resource name of the Assessment, in the format `projects/{project}/assessments/{assessment}`.
1863 pub fn assessments_annotate(
1864 &self,
1865 request: GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentRequest,
1866 name: &str,
1867 ) -> ProjectAssessmentAnnotateCall<'a, C> {
1868 ProjectAssessmentAnnotateCall {
1869 hub: self.hub,
1870 _request: request,
1871 _name: name.to_string(),
1872 _delegate: Default::default(),
1873 _additional_params: Default::default(),
1874 _scopes: Default::default(),
1875 }
1876 }
1877
1878 /// Create a builder to help you perform the following task:
1879 ///
1880 /// Creates an Assessment of the likelihood an event is legitimate.
1881 ///
1882 /// # Arguments
1883 ///
1884 /// * `request` - No description provided.
1885 /// * `parent` - Required. The name of the project in which the assessment is created, in the format `projects/{project}`.
1886 pub fn assessments_create(
1887 &self,
1888 request: GoogleCloudRecaptchaenterpriseV1Assessment,
1889 parent: &str,
1890 ) -> ProjectAssessmentCreateCall<'a, C> {
1891 ProjectAssessmentCreateCall {
1892 hub: self.hub,
1893 _request: request,
1894 _parent: parent.to_string(),
1895 _delegate: Default::default(),
1896 _additional_params: Default::default(),
1897 _scopes: Default::default(),
1898 }
1899 }
1900
1901 /// Create a builder to help you perform the following task:
1902 ///
1903 /// Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA Enterprise actions can be executed. A project may have a maximum of 1000 policies.
1904 ///
1905 /// # Arguments
1906 ///
1907 /// * `request` - No description provided.
1908 /// * `parent` - Required. The name of the project this policy applies to, in the format `projects/{project}`.
1909 pub fn firewallpolicies_create(
1910 &self,
1911 request: GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
1912 parent: &str,
1913 ) -> ProjectFirewallpolicyCreateCall<'a, C> {
1914 ProjectFirewallpolicyCreateCall {
1915 hub: self.hub,
1916 _request: request,
1917 _parent: parent.to_string(),
1918 _delegate: Default::default(),
1919 _additional_params: Default::default(),
1920 _scopes: Default::default(),
1921 }
1922 }
1923
1924 /// Create a builder to help you perform the following task:
1925 ///
1926 /// Deletes the specified firewall policy.
1927 ///
1928 /// # Arguments
1929 ///
1930 /// * `name` - Required. The name of the policy to be deleted, in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
1931 pub fn firewallpolicies_delete(&self, name: &str) -> ProjectFirewallpolicyDeleteCall<'a, C> {
1932 ProjectFirewallpolicyDeleteCall {
1933 hub: self.hub,
1934 _name: name.to_string(),
1935 _delegate: Default::default(),
1936 _additional_params: Default::default(),
1937 _scopes: Default::default(),
1938 }
1939 }
1940
1941 /// Create a builder to help you perform the following task:
1942 ///
1943 /// Returns the specified firewall policy.
1944 ///
1945 /// # Arguments
1946 ///
1947 /// * `name` - Required. The name of the requested policy, in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
1948 pub fn firewallpolicies_get(&self, name: &str) -> ProjectFirewallpolicyGetCall<'a, C> {
1949 ProjectFirewallpolicyGetCall {
1950 hub: self.hub,
1951 _name: name.to_string(),
1952 _delegate: Default::default(),
1953 _additional_params: Default::default(),
1954 _scopes: Default::default(),
1955 }
1956 }
1957
1958 /// Create a builder to help you perform the following task:
1959 ///
1960 /// Returns the list of all firewall policies that belong to a project.
1961 ///
1962 /// # Arguments
1963 ///
1964 /// * `parent` - Required. The name of the project to list the policies for, in the format `projects/{project}`.
1965 pub fn firewallpolicies_list(&self, parent: &str) -> ProjectFirewallpolicyListCall<'a, C> {
1966 ProjectFirewallpolicyListCall {
1967 hub: self.hub,
1968 _parent: parent.to_string(),
1969 _page_token: Default::default(),
1970 _page_size: Default::default(),
1971 _delegate: Default::default(),
1972 _additional_params: Default::default(),
1973 _scopes: Default::default(),
1974 }
1975 }
1976
1977 /// Create a builder to help you perform the following task:
1978 ///
1979 /// Updates the specified firewall policy.
1980 ///
1981 /// # Arguments
1982 ///
1983 /// * `request` - No description provided.
1984 /// * `name` - Identifier. The resource name for the FirewallPolicy in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
1985 pub fn firewallpolicies_patch(
1986 &self,
1987 request: GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
1988 name: &str,
1989 ) -> ProjectFirewallpolicyPatchCall<'a, C> {
1990 ProjectFirewallpolicyPatchCall {
1991 hub: self.hub,
1992 _request: request,
1993 _name: name.to_string(),
1994 _update_mask: Default::default(),
1995 _delegate: Default::default(),
1996 _additional_params: Default::default(),
1997 _scopes: Default::default(),
1998 }
1999 }
2000
2001 /// Create a builder to help you perform the following task:
2002 ///
2003 /// Reorders all firewall policies.
2004 ///
2005 /// # Arguments
2006 ///
2007 /// * `request` - No description provided.
2008 /// * `parent` - Required. The name of the project to list the policies for, in the format `projects/{project}`.
2009 pub fn firewallpolicies_reorder(
2010 &self,
2011 request: GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesRequest,
2012 parent: &str,
2013 ) -> ProjectFirewallpolicyReorderCall<'a, C> {
2014 ProjectFirewallpolicyReorderCall {
2015 hub: self.hub,
2016 _request: request,
2017 _parent: parent.to_string(),
2018 _delegate: Default::default(),
2019 _additional_params: Default::default(),
2020 _scopes: Default::default(),
2021 }
2022 }
2023
2024 /// Create a builder to help you perform the following task:
2025 ///
2026 /// Adds an IP override to a key. The following restrictions hold: * The maximum number of IP overrides per key is 1000. * For any conflict (such as IP already exists or IP part of an existing IP range), an error is returned.
2027 ///
2028 /// # Arguments
2029 ///
2030 /// * `request` - No description provided.
2031 /// * `name` - Required. The name of the key to which the IP override is added, in the format `projects/{project}/keys/{key}`.
2032 pub fn keys_add_ip_override(
2033 &self,
2034 request: GoogleCloudRecaptchaenterpriseV1AddIpOverrideRequest,
2035 name: &str,
2036 ) -> ProjectKeyAddIpOverrideCall<'a, C> {
2037 ProjectKeyAddIpOverrideCall {
2038 hub: self.hub,
2039 _request: request,
2040 _name: name.to_string(),
2041 _delegate: Default::default(),
2042 _additional_params: Default::default(),
2043 _scopes: Default::default(),
2044 }
2045 }
2046
2047 /// Create a builder to help you perform the following task:
2048 ///
2049 /// Creates a new reCAPTCHA Enterprise key.
2050 ///
2051 /// # Arguments
2052 ///
2053 /// * `request` - No description provided.
2054 /// * `parent` - Required. The name of the project in which the key is created, in the format `projects/{project}`.
2055 pub fn keys_create(
2056 &self,
2057 request: GoogleCloudRecaptchaenterpriseV1Key,
2058 parent: &str,
2059 ) -> ProjectKeyCreateCall<'a, C> {
2060 ProjectKeyCreateCall {
2061 hub: self.hub,
2062 _request: request,
2063 _parent: parent.to_string(),
2064 _delegate: Default::default(),
2065 _additional_params: Default::default(),
2066 _scopes: Default::default(),
2067 }
2068 }
2069
2070 /// Create a builder to help you perform the following task:
2071 ///
2072 /// Deletes the specified key.
2073 ///
2074 /// # Arguments
2075 ///
2076 /// * `name` - Required. The name of the key to be deleted, in the format `projects/{project}/keys/{key}`.
2077 pub fn keys_delete(&self, name: &str) -> ProjectKeyDeleteCall<'a, C> {
2078 ProjectKeyDeleteCall {
2079 hub: self.hub,
2080 _name: name.to_string(),
2081 _delegate: Default::default(),
2082 _additional_params: Default::default(),
2083 _scopes: Default::default(),
2084 }
2085 }
2086
2087 /// Create a builder to help you perform the following task:
2088 ///
2089 /// Returns the specified key.
2090 ///
2091 /// # Arguments
2092 ///
2093 /// * `name` - Required. The name of the requested key, in the format `projects/{project}/keys/{key}`.
2094 pub fn keys_get(&self, name: &str) -> ProjectKeyGetCall<'a, C> {
2095 ProjectKeyGetCall {
2096 hub: self.hub,
2097 _name: name.to_string(),
2098 _delegate: Default::default(),
2099 _additional_params: Default::default(),
2100 _scopes: Default::default(),
2101 }
2102 }
2103
2104 /// Create a builder to help you perform the following task:
2105 ///
2106 /// Get some aggregated metrics for a Key. This data can be used to build dashboards.
2107 ///
2108 /// # Arguments
2109 ///
2110 /// * `name` - Required. The name of the requested metrics, in the format `projects/{project}/keys/{key}/metrics`.
2111 pub fn keys_get_metrics(&self, name: &str) -> ProjectKeyGetMetricCall<'a, C> {
2112 ProjectKeyGetMetricCall {
2113 hub: self.hub,
2114 _name: name.to_string(),
2115 _delegate: Default::default(),
2116 _additional_params: Default::default(),
2117 _scopes: Default::default(),
2118 }
2119 }
2120
2121 /// Create a builder to help you perform the following task:
2122 ///
2123 /// Returns the list of all keys that belong to a project.
2124 ///
2125 /// # Arguments
2126 ///
2127 /// * `parent` - Required. The name of the project that contains the keys that is listed, in the format `projects/{project}`.
2128 pub fn keys_list(&self, parent: &str) -> ProjectKeyListCall<'a, C> {
2129 ProjectKeyListCall {
2130 hub: self.hub,
2131 _parent: parent.to_string(),
2132 _page_token: Default::default(),
2133 _page_size: Default::default(),
2134 _delegate: Default::default(),
2135 _additional_params: Default::default(),
2136 _scopes: Default::default(),
2137 }
2138 }
2139
2140 /// Create a builder to help you perform the following task:
2141 ///
2142 /// Lists all IP overrides for a key.
2143 ///
2144 /// # Arguments
2145 ///
2146 /// * `parent` - Required. The parent key for which the IP overrides are listed, in the format `projects/{project}/keys/{key}`.
2147 pub fn keys_list_ip_overrides(&self, parent: &str) -> ProjectKeyListIpOverrideCall<'a, C> {
2148 ProjectKeyListIpOverrideCall {
2149 hub: self.hub,
2150 _parent: parent.to_string(),
2151 _page_token: Default::default(),
2152 _page_size: Default::default(),
2153 _delegate: Default::default(),
2154 _additional_params: Default::default(),
2155 _scopes: Default::default(),
2156 }
2157 }
2158
2159 /// Create a builder to help you perform the following task:
2160 ///
2161 /// Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one of the current owners of the reCAPTCHA Key, and your user must have the reCAPTCHA Enterprise Admin IAM role in the destination project.
2162 ///
2163 /// # Arguments
2164 ///
2165 /// * `request` - No description provided.
2166 /// * `name` - Required. The name of the key to be migrated, in the format `projects/{project}/keys/{key}`.
2167 pub fn keys_migrate(
2168 &self,
2169 request: GoogleCloudRecaptchaenterpriseV1MigrateKeyRequest,
2170 name: &str,
2171 ) -> ProjectKeyMigrateCall<'a, C> {
2172 ProjectKeyMigrateCall {
2173 hub: self.hub,
2174 _request: request,
2175 _name: name.to_string(),
2176 _delegate: Default::default(),
2177 _additional_params: Default::default(),
2178 _scopes: Default::default(),
2179 }
2180 }
2181
2182 /// Create a builder to help you perform the following task:
2183 ///
2184 /// Updates the specified key.
2185 ///
2186 /// # Arguments
2187 ///
2188 /// * `request` - No description provided.
2189 /// * `name` - Identifier. The resource name for the Key in the format `projects/{project}/keys/{key}`.
2190 pub fn keys_patch(
2191 &self,
2192 request: GoogleCloudRecaptchaenterpriseV1Key,
2193 name: &str,
2194 ) -> ProjectKeyPatchCall<'a, C> {
2195 ProjectKeyPatchCall {
2196 hub: self.hub,
2197 _request: request,
2198 _name: name.to_string(),
2199 _update_mask: Default::default(),
2200 _delegate: Default::default(),
2201 _additional_params: Default::default(),
2202 _scopes: Default::default(),
2203 }
2204 }
2205
2206 /// Create a builder to help you perform the following task:
2207 ///
2208 /// Removes an IP override from a key. The following restrictions hold: * If the IP isn't found in an existing IP override, a `NOT_FOUND` error is returned. * If the IP is found in an existing IP override, but the override type does not match, a `NOT_FOUND` error is returned.
2209 ///
2210 /// # Arguments
2211 ///
2212 /// * `request` - No description provided.
2213 /// * `name` - Required. The name of the key from which the IP override is removed, in the format `projects/{project}/keys/{key}`.
2214 pub fn keys_remove_ip_override(
2215 &self,
2216 request: GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideRequest,
2217 name: &str,
2218 ) -> ProjectKeyRemoveIpOverrideCall<'a, C> {
2219 ProjectKeyRemoveIpOverrideCall {
2220 hub: self.hub,
2221 _request: request,
2222 _name: name.to_string(),
2223 _delegate: Default::default(),
2224 _additional_params: Default::default(),
2225 _scopes: Default::default(),
2226 }
2227 }
2228
2229 /// Create a builder to help you perform the following task:
2230 ///
2231 /// Returns the secret key related to the specified public key. You must use the legacy secret key only in a 3rd party integration with legacy reCAPTCHA.
2232 ///
2233 /// # Arguments
2234 ///
2235 /// * `key` - Required. The public key name linked to the requested secret key in the format `projects/{project}/keys/{key}`.
2236 pub fn keys_retrieve_legacy_secret_key(
2237 &self,
2238 key: &str,
2239 ) -> ProjectKeyRetrieveLegacySecretKeyCall<'a, C> {
2240 ProjectKeyRetrieveLegacySecretKeyCall {
2241 hub: self.hub,
2242 _key: key.to_string(),
2243 _delegate: Default::default(),
2244 _additional_params: Default::default(),
2245 _scopes: Default::default(),
2246 }
2247 }
2248
2249 /// Create a builder to help you perform the following task:
2250 ///
2251 /// Search group memberships related to a given account.
2252 ///
2253 /// # Arguments
2254 ///
2255 /// * `request` - No description provided.
2256 /// * `project` - Required. The name of the project to search related account group memberships from. Specify the project name in the following format: `projects/{project}`.
2257 pub fn relatedaccountgroupmemberships_search(
2258 &self,
2259 request: GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsRequest,
2260 project: &str,
2261 ) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C> {
2262 ProjectRelatedaccountgroupmembershipSearchCall {
2263 hub: self.hub,
2264 _request: request,
2265 _project: project.to_string(),
2266 _delegate: Default::default(),
2267 _additional_params: Default::default(),
2268 _scopes: Default::default(),
2269 }
2270 }
2271
2272 /// Create a builder to help you perform the following task:
2273 ///
2274 /// Get memberships in a group of related accounts.
2275 ///
2276 /// # Arguments
2277 ///
2278 /// * `parent` - Required. The resource name for the related account group in the format `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`.
2279 pub fn relatedaccountgroups_memberships_list(
2280 &self,
2281 parent: &str,
2282 ) -> ProjectRelatedaccountgroupMembershipListCall<'a, C> {
2283 ProjectRelatedaccountgroupMembershipListCall {
2284 hub: self.hub,
2285 _parent: parent.to_string(),
2286 _page_token: Default::default(),
2287 _page_size: Default::default(),
2288 _delegate: Default::default(),
2289 _additional_params: Default::default(),
2290 _scopes: Default::default(),
2291 }
2292 }
2293
2294 /// Create a builder to help you perform the following task:
2295 ///
2296 /// List groups of related accounts.
2297 ///
2298 /// # Arguments
2299 ///
2300 /// * `parent` - Required. The name of the project to list related account groups from, in the format `projects/{project}`.
2301 pub fn relatedaccountgroups_list(
2302 &self,
2303 parent: &str,
2304 ) -> ProjectRelatedaccountgroupListCall<'a, C> {
2305 ProjectRelatedaccountgroupListCall {
2306 hub: self.hub,
2307 _parent: parent.to_string(),
2308 _page_token: Default::default(),
2309 _page_size: Default::default(),
2310 _delegate: Default::default(),
2311 _additional_params: Default::default(),
2312 _scopes: Default::default(),
2313 }
2314 }
2315}
2316
2317// ###################
2318// CallBuilders ###
2319// #################
2320
2321/// Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fraudulent.
2322///
2323/// A builder for the *assessments.annotate* method supported by a *project* resource.
2324/// It is not used directly, but through a [`ProjectMethods`] instance.
2325///
2326/// # Example
2327///
2328/// Instantiate a resource method builder
2329///
2330/// ```test_harness,no_run
2331/// # extern crate hyper;
2332/// # extern crate hyper_rustls;
2333/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
2334/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentRequest;
2335/// # async fn dox() {
2336/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2337///
2338/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2339/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2340/// # .with_native_roots()
2341/// # .unwrap()
2342/// # .https_only()
2343/// # .enable_http2()
2344/// # .build();
2345///
2346/// # let executor = hyper_util::rt::TokioExecutor::new();
2347/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2348/// # secret,
2349/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2350/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2351/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2352/// # ),
2353/// # ).build().await.unwrap();
2354///
2355/// # let client = hyper_util::client::legacy::Client::builder(
2356/// # hyper_util::rt::TokioExecutor::new()
2357/// # )
2358/// # .build(
2359/// # hyper_rustls::HttpsConnectorBuilder::new()
2360/// # .with_native_roots()
2361/// # .unwrap()
2362/// # .https_or_http()
2363/// # .enable_http2()
2364/// # .build()
2365/// # );
2366/// # let mut hub = RecaptchaEnterprise::new(client, auth);
2367/// // As the method needs a request, you would usually fill it with the desired information
2368/// // into the respective structure. Some of the parts shown here might not be applicable !
2369/// // Values shown here are possibly random and not representative !
2370/// let mut req = GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentRequest::default();
2371///
2372/// // You can configure optional parameters by calling the respective setters at will, and
2373/// // execute the final call using `doit()`.
2374/// // Values shown here are possibly random and not representative !
2375/// let result = hub.projects().assessments_annotate(req, "name")
2376/// .doit().await;
2377/// # }
2378/// ```
2379pub struct ProjectAssessmentAnnotateCall<'a, C>
2380where
2381 C: 'a,
2382{
2383 hub: &'a RecaptchaEnterprise<C>,
2384 _request: GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentRequest,
2385 _name: String,
2386 _delegate: Option<&'a mut dyn common::Delegate>,
2387 _additional_params: HashMap<String, String>,
2388 _scopes: BTreeSet<String>,
2389}
2390
2391impl<'a, C> common::CallBuilder for ProjectAssessmentAnnotateCall<'a, C> {}
2392
2393impl<'a, C> ProjectAssessmentAnnotateCall<'a, C>
2394where
2395 C: common::Connector,
2396{
2397 /// Perform the operation you have build so far.
2398 pub async fn doit(
2399 mut self,
2400 ) -> common::Result<(
2401 common::Response,
2402 GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentResponse,
2403 )> {
2404 use std::borrow::Cow;
2405 use std::io::{Read, Seek};
2406
2407 use common::{url::Params, ToParts};
2408 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2409
2410 let mut dd = common::DefaultDelegate;
2411 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2412 dlg.begin(common::MethodInfo {
2413 id: "recaptchaenterprise.projects.assessments.annotate",
2414 http_method: hyper::Method::POST,
2415 });
2416
2417 for &field in ["alt", "name"].iter() {
2418 if self._additional_params.contains_key(field) {
2419 dlg.finished(false);
2420 return Err(common::Error::FieldClash(field));
2421 }
2422 }
2423
2424 let mut params = Params::with_capacity(4 + self._additional_params.len());
2425 params.push("name", self._name);
2426
2427 params.extend(self._additional_params.iter());
2428
2429 params.push("alt", "json");
2430 let mut url = self.hub._base_url.clone() + "v1/{+name}:annotate";
2431 if self._scopes.is_empty() {
2432 self._scopes
2433 .insert(Scope::CloudPlatform.as_ref().to_string());
2434 }
2435
2436 #[allow(clippy::single_element_loop)]
2437 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2438 url = params.uri_replacement(url, param_name, find_this, true);
2439 }
2440 {
2441 let to_remove = ["name"];
2442 params.remove_params(&to_remove);
2443 }
2444
2445 let url = params.parse_with_url(&url);
2446
2447 let mut json_mime_type = mime::APPLICATION_JSON;
2448 let mut request_value_reader = {
2449 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2450 common::remove_json_null_values(&mut value);
2451 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2452 serde_json::to_writer(&mut dst, &value).unwrap();
2453 dst
2454 };
2455 let request_size = request_value_reader
2456 .seek(std::io::SeekFrom::End(0))
2457 .unwrap();
2458 request_value_reader
2459 .seek(std::io::SeekFrom::Start(0))
2460 .unwrap();
2461
2462 loop {
2463 let token = match self
2464 .hub
2465 .auth
2466 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2467 .await
2468 {
2469 Ok(token) => token,
2470 Err(e) => match dlg.token(e) {
2471 Ok(token) => token,
2472 Err(e) => {
2473 dlg.finished(false);
2474 return Err(common::Error::MissingToken(e));
2475 }
2476 },
2477 };
2478 request_value_reader
2479 .seek(std::io::SeekFrom::Start(0))
2480 .unwrap();
2481 let mut req_result = {
2482 let client = &self.hub.client;
2483 dlg.pre_request();
2484 let mut req_builder = hyper::Request::builder()
2485 .method(hyper::Method::POST)
2486 .uri(url.as_str())
2487 .header(USER_AGENT, self.hub._user_agent.clone());
2488
2489 if let Some(token) = token.as_ref() {
2490 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2491 }
2492
2493 let request = req_builder
2494 .header(CONTENT_TYPE, json_mime_type.to_string())
2495 .header(CONTENT_LENGTH, request_size as u64)
2496 .body(common::to_body(
2497 request_value_reader.get_ref().clone().into(),
2498 ));
2499
2500 client.request(request.unwrap()).await
2501 };
2502
2503 match req_result {
2504 Err(err) => {
2505 if let common::Retry::After(d) = dlg.http_error(&err) {
2506 sleep(d).await;
2507 continue;
2508 }
2509 dlg.finished(false);
2510 return Err(common::Error::HttpError(err));
2511 }
2512 Ok(res) => {
2513 let (mut parts, body) = res.into_parts();
2514 let mut body = common::Body::new(body);
2515 if !parts.status.is_success() {
2516 let bytes = common::to_bytes(body).await.unwrap_or_default();
2517 let error = serde_json::from_str(&common::to_string(&bytes));
2518 let response = common::to_response(parts, bytes.into());
2519
2520 if let common::Retry::After(d) =
2521 dlg.http_failure(&response, error.as_ref().ok())
2522 {
2523 sleep(d).await;
2524 continue;
2525 }
2526
2527 dlg.finished(false);
2528
2529 return Err(match error {
2530 Ok(value) => common::Error::BadRequest(value),
2531 _ => common::Error::Failure(response),
2532 });
2533 }
2534 let response = {
2535 let bytes = common::to_bytes(body).await.unwrap_or_default();
2536 let encoded = common::to_string(&bytes);
2537 match serde_json::from_str(&encoded) {
2538 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2539 Err(error) => {
2540 dlg.response_json_decode_error(&encoded, &error);
2541 return Err(common::Error::JsonDecodeError(
2542 encoded.to_string(),
2543 error,
2544 ));
2545 }
2546 }
2547 };
2548
2549 dlg.finished(true);
2550 return Ok(response);
2551 }
2552 }
2553 }
2554 }
2555
2556 ///
2557 /// Sets the *request* property to the given value.
2558 ///
2559 /// Even though the property as already been set when instantiating this call,
2560 /// we provide this method for API completeness.
2561 pub fn request(
2562 mut self,
2563 new_value: GoogleCloudRecaptchaenterpriseV1AnnotateAssessmentRequest,
2564 ) -> ProjectAssessmentAnnotateCall<'a, C> {
2565 self._request = new_value;
2566 self
2567 }
2568 /// Required. The resource name of the Assessment, in the format `projects/{project}/assessments/{assessment}`.
2569 ///
2570 /// Sets the *name* path property to the given value.
2571 ///
2572 /// Even though the property as already been set when instantiating this call,
2573 /// we provide this method for API completeness.
2574 pub fn name(mut self, new_value: &str) -> ProjectAssessmentAnnotateCall<'a, C> {
2575 self._name = new_value.to_string();
2576 self
2577 }
2578 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2579 /// while executing the actual API request.
2580 ///
2581 /// ````text
2582 /// It should be used to handle progress information, and to implement a certain level of resilience.
2583 /// ````
2584 ///
2585 /// Sets the *delegate* property to the given value.
2586 pub fn delegate(
2587 mut self,
2588 new_value: &'a mut dyn common::Delegate,
2589 ) -> ProjectAssessmentAnnotateCall<'a, C> {
2590 self._delegate = Some(new_value);
2591 self
2592 }
2593
2594 /// Set any additional parameter of the query string used in the request.
2595 /// It should be used to set parameters which are not yet available through their own
2596 /// setters.
2597 ///
2598 /// Please note that this method must not be used to set any of the known parameters
2599 /// which have their own setter method. If done anyway, the request will fail.
2600 ///
2601 /// # Additional Parameters
2602 ///
2603 /// * *$.xgafv* (query-string) - V1 error format.
2604 /// * *access_token* (query-string) - OAuth access token.
2605 /// * *alt* (query-string) - Data format for response.
2606 /// * *callback* (query-string) - JSONP
2607 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2608 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2609 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2610 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2611 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2612 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2613 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2614 pub fn param<T>(mut self, name: T, value: T) -> ProjectAssessmentAnnotateCall<'a, C>
2615 where
2616 T: AsRef<str>,
2617 {
2618 self._additional_params
2619 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2620 self
2621 }
2622
2623 /// Identifies the authorization scope for the method you are building.
2624 ///
2625 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2626 /// [`Scope::CloudPlatform`].
2627 ///
2628 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2629 /// tokens for more than one scope.
2630 ///
2631 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2632 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2633 /// sufficient, a read-write scope will do as well.
2634 pub fn add_scope<St>(mut self, scope: St) -> ProjectAssessmentAnnotateCall<'a, C>
2635 where
2636 St: AsRef<str>,
2637 {
2638 self._scopes.insert(String::from(scope.as_ref()));
2639 self
2640 }
2641 /// Identifies the authorization scope(s) for the method you are building.
2642 ///
2643 /// See [`Self::add_scope()`] for details.
2644 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAssessmentAnnotateCall<'a, C>
2645 where
2646 I: IntoIterator<Item = St>,
2647 St: AsRef<str>,
2648 {
2649 self._scopes
2650 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2651 self
2652 }
2653
2654 /// Removes all scopes, and no default scope will be used either.
2655 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2656 /// for details).
2657 pub fn clear_scopes(mut self) -> ProjectAssessmentAnnotateCall<'a, C> {
2658 self._scopes.clear();
2659 self
2660 }
2661}
2662
2663/// Creates an Assessment of the likelihood an event is legitimate.
2664///
2665/// A builder for the *assessments.create* method supported by a *project* resource.
2666/// It is not used directly, but through a [`ProjectMethods`] instance.
2667///
2668/// # Example
2669///
2670/// Instantiate a resource method builder
2671///
2672/// ```test_harness,no_run
2673/// # extern crate hyper;
2674/// # extern crate hyper_rustls;
2675/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
2676/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1Assessment;
2677/// # async fn dox() {
2678/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2679///
2680/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2681/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2682/// # .with_native_roots()
2683/// # .unwrap()
2684/// # .https_only()
2685/// # .enable_http2()
2686/// # .build();
2687///
2688/// # let executor = hyper_util::rt::TokioExecutor::new();
2689/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2690/// # secret,
2691/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2692/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2693/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2694/// # ),
2695/// # ).build().await.unwrap();
2696///
2697/// # let client = hyper_util::client::legacy::Client::builder(
2698/// # hyper_util::rt::TokioExecutor::new()
2699/// # )
2700/// # .build(
2701/// # hyper_rustls::HttpsConnectorBuilder::new()
2702/// # .with_native_roots()
2703/// # .unwrap()
2704/// # .https_or_http()
2705/// # .enable_http2()
2706/// # .build()
2707/// # );
2708/// # let mut hub = RecaptchaEnterprise::new(client, auth);
2709/// // As the method needs a request, you would usually fill it with the desired information
2710/// // into the respective structure. Some of the parts shown here might not be applicable !
2711/// // Values shown here are possibly random and not representative !
2712/// let mut req = GoogleCloudRecaptchaenterpriseV1Assessment::default();
2713///
2714/// // You can configure optional parameters by calling the respective setters at will, and
2715/// // execute the final call using `doit()`.
2716/// // Values shown here are possibly random and not representative !
2717/// let result = hub.projects().assessments_create(req, "parent")
2718/// .doit().await;
2719/// # }
2720/// ```
2721pub struct ProjectAssessmentCreateCall<'a, C>
2722where
2723 C: 'a,
2724{
2725 hub: &'a RecaptchaEnterprise<C>,
2726 _request: GoogleCloudRecaptchaenterpriseV1Assessment,
2727 _parent: String,
2728 _delegate: Option<&'a mut dyn common::Delegate>,
2729 _additional_params: HashMap<String, String>,
2730 _scopes: BTreeSet<String>,
2731}
2732
2733impl<'a, C> common::CallBuilder for ProjectAssessmentCreateCall<'a, C> {}
2734
2735impl<'a, C> ProjectAssessmentCreateCall<'a, C>
2736where
2737 C: common::Connector,
2738{
2739 /// Perform the operation you have build so far.
2740 pub async fn doit(
2741 mut self,
2742 ) -> common::Result<(common::Response, GoogleCloudRecaptchaenterpriseV1Assessment)> {
2743 use std::borrow::Cow;
2744 use std::io::{Read, Seek};
2745
2746 use common::{url::Params, ToParts};
2747 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2748
2749 let mut dd = common::DefaultDelegate;
2750 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2751 dlg.begin(common::MethodInfo {
2752 id: "recaptchaenterprise.projects.assessments.create",
2753 http_method: hyper::Method::POST,
2754 });
2755
2756 for &field in ["alt", "parent"].iter() {
2757 if self._additional_params.contains_key(field) {
2758 dlg.finished(false);
2759 return Err(common::Error::FieldClash(field));
2760 }
2761 }
2762
2763 let mut params = Params::with_capacity(4 + self._additional_params.len());
2764 params.push("parent", self._parent);
2765
2766 params.extend(self._additional_params.iter());
2767
2768 params.push("alt", "json");
2769 let mut url = self.hub._base_url.clone() + "v1/{+parent}/assessments";
2770 if self._scopes.is_empty() {
2771 self._scopes
2772 .insert(Scope::CloudPlatform.as_ref().to_string());
2773 }
2774
2775 #[allow(clippy::single_element_loop)]
2776 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2777 url = params.uri_replacement(url, param_name, find_this, true);
2778 }
2779 {
2780 let to_remove = ["parent"];
2781 params.remove_params(&to_remove);
2782 }
2783
2784 let url = params.parse_with_url(&url);
2785
2786 let mut json_mime_type = mime::APPLICATION_JSON;
2787 let mut request_value_reader = {
2788 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2789 common::remove_json_null_values(&mut value);
2790 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2791 serde_json::to_writer(&mut dst, &value).unwrap();
2792 dst
2793 };
2794 let request_size = request_value_reader
2795 .seek(std::io::SeekFrom::End(0))
2796 .unwrap();
2797 request_value_reader
2798 .seek(std::io::SeekFrom::Start(0))
2799 .unwrap();
2800
2801 loop {
2802 let token = match self
2803 .hub
2804 .auth
2805 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2806 .await
2807 {
2808 Ok(token) => token,
2809 Err(e) => match dlg.token(e) {
2810 Ok(token) => token,
2811 Err(e) => {
2812 dlg.finished(false);
2813 return Err(common::Error::MissingToken(e));
2814 }
2815 },
2816 };
2817 request_value_reader
2818 .seek(std::io::SeekFrom::Start(0))
2819 .unwrap();
2820 let mut req_result = {
2821 let client = &self.hub.client;
2822 dlg.pre_request();
2823 let mut req_builder = hyper::Request::builder()
2824 .method(hyper::Method::POST)
2825 .uri(url.as_str())
2826 .header(USER_AGENT, self.hub._user_agent.clone());
2827
2828 if let Some(token) = token.as_ref() {
2829 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2830 }
2831
2832 let request = req_builder
2833 .header(CONTENT_TYPE, json_mime_type.to_string())
2834 .header(CONTENT_LENGTH, request_size as u64)
2835 .body(common::to_body(
2836 request_value_reader.get_ref().clone().into(),
2837 ));
2838
2839 client.request(request.unwrap()).await
2840 };
2841
2842 match req_result {
2843 Err(err) => {
2844 if let common::Retry::After(d) = dlg.http_error(&err) {
2845 sleep(d).await;
2846 continue;
2847 }
2848 dlg.finished(false);
2849 return Err(common::Error::HttpError(err));
2850 }
2851 Ok(res) => {
2852 let (mut parts, body) = res.into_parts();
2853 let mut body = common::Body::new(body);
2854 if !parts.status.is_success() {
2855 let bytes = common::to_bytes(body).await.unwrap_or_default();
2856 let error = serde_json::from_str(&common::to_string(&bytes));
2857 let response = common::to_response(parts, bytes.into());
2858
2859 if let common::Retry::After(d) =
2860 dlg.http_failure(&response, error.as_ref().ok())
2861 {
2862 sleep(d).await;
2863 continue;
2864 }
2865
2866 dlg.finished(false);
2867
2868 return Err(match error {
2869 Ok(value) => common::Error::BadRequest(value),
2870 _ => common::Error::Failure(response),
2871 });
2872 }
2873 let response = {
2874 let bytes = common::to_bytes(body).await.unwrap_or_default();
2875 let encoded = common::to_string(&bytes);
2876 match serde_json::from_str(&encoded) {
2877 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2878 Err(error) => {
2879 dlg.response_json_decode_error(&encoded, &error);
2880 return Err(common::Error::JsonDecodeError(
2881 encoded.to_string(),
2882 error,
2883 ));
2884 }
2885 }
2886 };
2887
2888 dlg.finished(true);
2889 return Ok(response);
2890 }
2891 }
2892 }
2893 }
2894
2895 ///
2896 /// Sets the *request* property to the given value.
2897 ///
2898 /// Even though the property as already been set when instantiating this call,
2899 /// we provide this method for API completeness.
2900 pub fn request(
2901 mut self,
2902 new_value: GoogleCloudRecaptchaenterpriseV1Assessment,
2903 ) -> ProjectAssessmentCreateCall<'a, C> {
2904 self._request = new_value;
2905 self
2906 }
2907 /// Required. The name of the project in which the assessment is created, in the format `projects/{project}`.
2908 ///
2909 /// Sets the *parent* path property to the given value.
2910 ///
2911 /// Even though the property as already been set when instantiating this call,
2912 /// we provide this method for API completeness.
2913 pub fn parent(mut self, new_value: &str) -> ProjectAssessmentCreateCall<'a, C> {
2914 self._parent = new_value.to_string();
2915 self
2916 }
2917 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2918 /// while executing the actual API request.
2919 ///
2920 /// ````text
2921 /// It should be used to handle progress information, and to implement a certain level of resilience.
2922 /// ````
2923 ///
2924 /// Sets the *delegate* property to the given value.
2925 pub fn delegate(
2926 mut self,
2927 new_value: &'a mut dyn common::Delegate,
2928 ) -> ProjectAssessmentCreateCall<'a, C> {
2929 self._delegate = Some(new_value);
2930 self
2931 }
2932
2933 /// Set any additional parameter of the query string used in the request.
2934 /// It should be used to set parameters which are not yet available through their own
2935 /// setters.
2936 ///
2937 /// Please note that this method must not be used to set any of the known parameters
2938 /// which have their own setter method. If done anyway, the request will fail.
2939 ///
2940 /// # Additional Parameters
2941 ///
2942 /// * *$.xgafv* (query-string) - V1 error format.
2943 /// * *access_token* (query-string) - OAuth access token.
2944 /// * *alt* (query-string) - Data format for response.
2945 /// * *callback* (query-string) - JSONP
2946 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2947 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2948 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2949 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2950 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2951 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2952 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2953 pub fn param<T>(mut self, name: T, value: T) -> ProjectAssessmentCreateCall<'a, C>
2954 where
2955 T: AsRef<str>,
2956 {
2957 self._additional_params
2958 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2959 self
2960 }
2961
2962 /// Identifies the authorization scope for the method you are building.
2963 ///
2964 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2965 /// [`Scope::CloudPlatform`].
2966 ///
2967 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2968 /// tokens for more than one scope.
2969 ///
2970 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2971 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2972 /// sufficient, a read-write scope will do as well.
2973 pub fn add_scope<St>(mut self, scope: St) -> ProjectAssessmentCreateCall<'a, C>
2974 where
2975 St: AsRef<str>,
2976 {
2977 self._scopes.insert(String::from(scope.as_ref()));
2978 self
2979 }
2980 /// Identifies the authorization scope(s) for the method you are building.
2981 ///
2982 /// See [`Self::add_scope()`] for details.
2983 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAssessmentCreateCall<'a, C>
2984 where
2985 I: IntoIterator<Item = St>,
2986 St: AsRef<str>,
2987 {
2988 self._scopes
2989 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2990 self
2991 }
2992
2993 /// Removes all scopes, and no default scope will be used either.
2994 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2995 /// for details).
2996 pub fn clear_scopes(mut self) -> ProjectAssessmentCreateCall<'a, C> {
2997 self._scopes.clear();
2998 self
2999 }
3000}
3001
3002/// Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA Enterprise actions can be executed. A project may have a maximum of 1000 policies.
3003///
3004/// A builder for the *firewallpolicies.create* method supported by a *project* resource.
3005/// It is not used directly, but through a [`ProjectMethods`] instance.
3006///
3007/// # Example
3008///
3009/// Instantiate a resource method builder
3010///
3011/// ```test_harness,no_run
3012/// # extern crate hyper;
3013/// # extern crate hyper_rustls;
3014/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
3015/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1FirewallPolicy;
3016/// # async fn dox() {
3017/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3018///
3019/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3020/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3021/// # .with_native_roots()
3022/// # .unwrap()
3023/// # .https_only()
3024/// # .enable_http2()
3025/// # .build();
3026///
3027/// # let executor = hyper_util::rt::TokioExecutor::new();
3028/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3029/// # secret,
3030/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3031/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3032/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3033/// # ),
3034/// # ).build().await.unwrap();
3035///
3036/// # let client = hyper_util::client::legacy::Client::builder(
3037/// # hyper_util::rt::TokioExecutor::new()
3038/// # )
3039/// # .build(
3040/// # hyper_rustls::HttpsConnectorBuilder::new()
3041/// # .with_native_roots()
3042/// # .unwrap()
3043/// # .https_or_http()
3044/// # .enable_http2()
3045/// # .build()
3046/// # );
3047/// # let mut hub = RecaptchaEnterprise::new(client, auth);
3048/// // As the method needs a request, you would usually fill it with the desired information
3049/// // into the respective structure. Some of the parts shown here might not be applicable !
3050/// // Values shown here are possibly random and not representative !
3051/// let mut req = GoogleCloudRecaptchaenterpriseV1FirewallPolicy::default();
3052///
3053/// // You can configure optional parameters by calling the respective setters at will, and
3054/// // execute the final call using `doit()`.
3055/// // Values shown here are possibly random and not representative !
3056/// let result = hub.projects().firewallpolicies_create(req, "parent")
3057/// .doit().await;
3058/// # }
3059/// ```
3060pub struct ProjectFirewallpolicyCreateCall<'a, C>
3061where
3062 C: 'a,
3063{
3064 hub: &'a RecaptchaEnterprise<C>,
3065 _request: GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
3066 _parent: String,
3067 _delegate: Option<&'a mut dyn common::Delegate>,
3068 _additional_params: HashMap<String, String>,
3069 _scopes: BTreeSet<String>,
3070}
3071
3072impl<'a, C> common::CallBuilder for ProjectFirewallpolicyCreateCall<'a, C> {}
3073
3074impl<'a, C> ProjectFirewallpolicyCreateCall<'a, C>
3075where
3076 C: common::Connector,
3077{
3078 /// Perform the operation you have build so far.
3079 pub async fn doit(
3080 mut self,
3081 ) -> common::Result<(
3082 common::Response,
3083 GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
3084 )> {
3085 use std::borrow::Cow;
3086 use std::io::{Read, Seek};
3087
3088 use common::{url::Params, ToParts};
3089 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3090
3091 let mut dd = common::DefaultDelegate;
3092 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3093 dlg.begin(common::MethodInfo {
3094 id: "recaptchaenterprise.projects.firewallpolicies.create",
3095 http_method: hyper::Method::POST,
3096 });
3097
3098 for &field in ["alt", "parent"].iter() {
3099 if self._additional_params.contains_key(field) {
3100 dlg.finished(false);
3101 return Err(common::Error::FieldClash(field));
3102 }
3103 }
3104
3105 let mut params = Params::with_capacity(4 + self._additional_params.len());
3106 params.push("parent", self._parent);
3107
3108 params.extend(self._additional_params.iter());
3109
3110 params.push("alt", "json");
3111 let mut url = self.hub._base_url.clone() + "v1/{+parent}/firewallpolicies";
3112 if self._scopes.is_empty() {
3113 self._scopes
3114 .insert(Scope::CloudPlatform.as_ref().to_string());
3115 }
3116
3117 #[allow(clippy::single_element_loop)]
3118 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3119 url = params.uri_replacement(url, param_name, find_this, true);
3120 }
3121 {
3122 let to_remove = ["parent"];
3123 params.remove_params(&to_remove);
3124 }
3125
3126 let url = params.parse_with_url(&url);
3127
3128 let mut json_mime_type = mime::APPLICATION_JSON;
3129 let mut request_value_reader = {
3130 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3131 common::remove_json_null_values(&mut value);
3132 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3133 serde_json::to_writer(&mut dst, &value).unwrap();
3134 dst
3135 };
3136 let request_size = request_value_reader
3137 .seek(std::io::SeekFrom::End(0))
3138 .unwrap();
3139 request_value_reader
3140 .seek(std::io::SeekFrom::Start(0))
3141 .unwrap();
3142
3143 loop {
3144 let token = match self
3145 .hub
3146 .auth
3147 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3148 .await
3149 {
3150 Ok(token) => token,
3151 Err(e) => match dlg.token(e) {
3152 Ok(token) => token,
3153 Err(e) => {
3154 dlg.finished(false);
3155 return Err(common::Error::MissingToken(e));
3156 }
3157 },
3158 };
3159 request_value_reader
3160 .seek(std::io::SeekFrom::Start(0))
3161 .unwrap();
3162 let mut req_result = {
3163 let client = &self.hub.client;
3164 dlg.pre_request();
3165 let mut req_builder = hyper::Request::builder()
3166 .method(hyper::Method::POST)
3167 .uri(url.as_str())
3168 .header(USER_AGENT, self.hub._user_agent.clone());
3169
3170 if let Some(token) = token.as_ref() {
3171 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3172 }
3173
3174 let request = req_builder
3175 .header(CONTENT_TYPE, json_mime_type.to_string())
3176 .header(CONTENT_LENGTH, request_size as u64)
3177 .body(common::to_body(
3178 request_value_reader.get_ref().clone().into(),
3179 ));
3180
3181 client.request(request.unwrap()).await
3182 };
3183
3184 match req_result {
3185 Err(err) => {
3186 if let common::Retry::After(d) = dlg.http_error(&err) {
3187 sleep(d).await;
3188 continue;
3189 }
3190 dlg.finished(false);
3191 return Err(common::Error::HttpError(err));
3192 }
3193 Ok(res) => {
3194 let (mut parts, body) = res.into_parts();
3195 let mut body = common::Body::new(body);
3196 if !parts.status.is_success() {
3197 let bytes = common::to_bytes(body).await.unwrap_or_default();
3198 let error = serde_json::from_str(&common::to_string(&bytes));
3199 let response = common::to_response(parts, bytes.into());
3200
3201 if let common::Retry::After(d) =
3202 dlg.http_failure(&response, error.as_ref().ok())
3203 {
3204 sleep(d).await;
3205 continue;
3206 }
3207
3208 dlg.finished(false);
3209
3210 return Err(match error {
3211 Ok(value) => common::Error::BadRequest(value),
3212 _ => common::Error::Failure(response),
3213 });
3214 }
3215 let response = {
3216 let bytes = common::to_bytes(body).await.unwrap_or_default();
3217 let encoded = common::to_string(&bytes);
3218 match serde_json::from_str(&encoded) {
3219 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3220 Err(error) => {
3221 dlg.response_json_decode_error(&encoded, &error);
3222 return Err(common::Error::JsonDecodeError(
3223 encoded.to_string(),
3224 error,
3225 ));
3226 }
3227 }
3228 };
3229
3230 dlg.finished(true);
3231 return Ok(response);
3232 }
3233 }
3234 }
3235 }
3236
3237 ///
3238 /// Sets the *request* property to the given value.
3239 ///
3240 /// Even though the property as already been set when instantiating this call,
3241 /// we provide this method for API completeness.
3242 pub fn request(
3243 mut self,
3244 new_value: GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
3245 ) -> ProjectFirewallpolicyCreateCall<'a, C> {
3246 self._request = new_value;
3247 self
3248 }
3249 /// Required. The name of the project this policy applies to, in the format `projects/{project}`.
3250 ///
3251 /// Sets the *parent* path property to the given value.
3252 ///
3253 /// Even though the property as already been set when instantiating this call,
3254 /// we provide this method for API completeness.
3255 pub fn parent(mut self, new_value: &str) -> ProjectFirewallpolicyCreateCall<'a, C> {
3256 self._parent = new_value.to_string();
3257 self
3258 }
3259 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3260 /// while executing the actual API request.
3261 ///
3262 /// ````text
3263 /// It should be used to handle progress information, and to implement a certain level of resilience.
3264 /// ````
3265 ///
3266 /// Sets the *delegate* property to the given value.
3267 pub fn delegate(
3268 mut self,
3269 new_value: &'a mut dyn common::Delegate,
3270 ) -> ProjectFirewallpolicyCreateCall<'a, C> {
3271 self._delegate = Some(new_value);
3272 self
3273 }
3274
3275 /// Set any additional parameter of the query string used in the request.
3276 /// It should be used to set parameters which are not yet available through their own
3277 /// setters.
3278 ///
3279 /// Please note that this method must not be used to set any of the known parameters
3280 /// which have their own setter method. If done anyway, the request will fail.
3281 ///
3282 /// # Additional Parameters
3283 ///
3284 /// * *$.xgafv* (query-string) - V1 error format.
3285 /// * *access_token* (query-string) - OAuth access token.
3286 /// * *alt* (query-string) - Data format for response.
3287 /// * *callback* (query-string) - JSONP
3288 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3289 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3290 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3291 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3292 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3293 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3294 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3295 pub fn param<T>(mut self, name: T, value: T) -> ProjectFirewallpolicyCreateCall<'a, C>
3296 where
3297 T: AsRef<str>,
3298 {
3299 self._additional_params
3300 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3301 self
3302 }
3303
3304 /// Identifies the authorization scope for the method you are building.
3305 ///
3306 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3307 /// [`Scope::CloudPlatform`].
3308 ///
3309 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3310 /// tokens for more than one scope.
3311 ///
3312 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3313 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3314 /// sufficient, a read-write scope will do as well.
3315 pub fn add_scope<St>(mut self, scope: St) -> ProjectFirewallpolicyCreateCall<'a, C>
3316 where
3317 St: AsRef<str>,
3318 {
3319 self._scopes.insert(String::from(scope.as_ref()));
3320 self
3321 }
3322 /// Identifies the authorization scope(s) for the method you are building.
3323 ///
3324 /// See [`Self::add_scope()`] for details.
3325 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFirewallpolicyCreateCall<'a, C>
3326 where
3327 I: IntoIterator<Item = St>,
3328 St: AsRef<str>,
3329 {
3330 self._scopes
3331 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3332 self
3333 }
3334
3335 /// Removes all scopes, and no default scope will be used either.
3336 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3337 /// for details).
3338 pub fn clear_scopes(mut self) -> ProjectFirewallpolicyCreateCall<'a, C> {
3339 self._scopes.clear();
3340 self
3341 }
3342}
3343
3344/// Deletes the specified firewall policy.
3345///
3346/// A builder for the *firewallpolicies.delete* method supported by a *project* resource.
3347/// It is not used directly, but through a [`ProjectMethods`] instance.
3348///
3349/// # Example
3350///
3351/// Instantiate a resource method builder
3352///
3353/// ```test_harness,no_run
3354/// # extern crate hyper;
3355/// # extern crate hyper_rustls;
3356/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
3357/// # async fn dox() {
3358/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3359///
3360/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3361/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3362/// # .with_native_roots()
3363/// # .unwrap()
3364/// # .https_only()
3365/// # .enable_http2()
3366/// # .build();
3367///
3368/// # let executor = hyper_util::rt::TokioExecutor::new();
3369/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3370/// # secret,
3371/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3372/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3373/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3374/// # ),
3375/// # ).build().await.unwrap();
3376///
3377/// # let client = hyper_util::client::legacy::Client::builder(
3378/// # hyper_util::rt::TokioExecutor::new()
3379/// # )
3380/// # .build(
3381/// # hyper_rustls::HttpsConnectorBuilder::new()
3382/// # .with_native_roots()
3383/// # .unwrap()
3384/// # .https_or_http()
3385/// # .enable_http2()
3386/// # .build()
3387/// # );
3388/// # let mut hub = RecaptchaEnterprise::new(client, auth);
3389/// // You can configure optional parameters by calling the respective setters at will, and
3390/// // execute the final call using `doit()`.
3391/// // Values shown here are possibly random and not representative !
3392/// let result = hub.projects().firewallpolicies_delete("name")
3393/// .doit().await;
3394/// # }
3395/// ```
3396pub struct ProjectFirewallpolicyDeleteCall<'a, C>
3397where
3398 C: 'a,
3399{
3400 hub: &'a RecaptchaEnterprise<C>,
3401 _name: String,
3402 _delegate: Option<&'a mut dyn common::Delegate>,
3403 _additional_params: HashMap<String, String>,
3404 _scopes: BTreeSet<String>,
3405}
3406
3407impl<'a, C> common::CallBuilder for ProjectFirewallpolicyDeleteCall<'a, C> {}
3408
3409impl<'a, C> ProjectFirewallpolicyDeleteCall<'a, C>
3410where
3411 C: common::Connector,
3412{
3413 /// Perform the operation you have build so far.
3414 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
3415 use std::borrow::Cow;
3416 use std::io::{Read, Seek};
3417
3418 use common::{url::Params, ToParts};
3419 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3420
3421 let mut dd = common::DefaultDelegate;
3422 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3423 dlg.begin(common::MethodInfo {
3424 id: "recaptchaenterprise.projects.firewallpolicies.delete",
3425 http_method: hyper::Method::DELETE,
3426 });
3427
3428 for &field in ["alt", "name"].iter() {
3429 if self._additional_params.contains_key(field) {
3430 dlg.finished(false);
3431 return Err(common::Error::FieldClash(field));
3432 }
3433 }
3434
3435 let mut params = Params::with_capacity(3 + self._additional_params.len());
3436 params.push("name", self._name);
3437
3438 params.extend(self._additional_params.iter());
3439
3440 params.push("alt", "json");
3441 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3442 if self._scopes.is_empty() {
3443 self._scopes
3444 .insert(Scope::CloudPlatform.as_ref().to_string());
3445 }
3446
3447 #[allow(clippy::single_element_loop)]
3448 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3449 url = params.uri_replacement(url, param_name, find_this, true);
3450 }
3451 {
3452 let to_remove = ["name"];
3453 params.remove_params(&to_remove);
3454 }
3455
3456 let url = params.parse_with_url(&url);
3457
3458 loop {
3459 let token = match self
3460 .hub
3461 .auth
3462 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3463 .await
3464 {
3465 Ok(token) => token,
3466 Err(e) => match dlg.token(e) {
3467 Ok(token) => token,
3468 Err(e) => {
3469 dlg.finished(false);
3470 return Err(common::Error::MissingToken(e));
3471 }
3472 },
3473 };
3474 let mut req_result = {
3475 let client = &self.hub.client;
3476 dlg.pre_request();
3477 let mut req_builder = hyper::Request::builder()
3478 .method(hyper::Method::DELETE)
3479 .uri(url.as_str())
3480 .header(USER_AGENT, self.hub._user_agent.clone());
3481
3482 if let Some(token) = token.as_ref() {
3483 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3484 }
3485
3486 let request = req_builder
3487 .header(CONTENT_LENGTH, 0_u64)
3488 .body(common::to_body::<String>(None));
3489
3490 client.request(request.unwrap()).await
3491 };
3492
3493 match req_result {
3494 Err(err) => {
3495 if let common::Retry::After(d) = dlg.http_error(&err) {
3496 sleep(d).await;
3497 continue;
3498 }
3499 dlg.finished(false);
3500 return Err(common::Error::HttpError(err));
3501 }
3502 Ok(res) => {
3503 let (mut parts, body) = res.into_parts();
3504 let mut body = common::Body::new(body);
3505 if !parts.status.is_success() {
3506 let bytes = common::to_bytes(body).await.unwrap_or_default();
3507 let error = serde_json::from_str(&common::to_string(&bytes));
3508 let response = common::to_response(parts, bytes.into());
3509
3510 if let common::Retry::After(d) =
3511 dlg.http_failure(&response, error.as_ref().ok())
3512 {
3513 sleep(d).await;
3514 continue;
3515 }
3516
3517 dlg.finished(false);
3518
3519 return Err(match error {
3520 Ok(value) => common::Error::BadRequest(value),
3521 _ => common::Error::Failure(response),
3522 });
3523 }
3524 let response = {
3525 let bytes = common::to_bytes(body).await.unwrap_or_default();
3526 let encoded = common::to_string(&bytes);
3527 match serde_json::from_str(&encoded) {
3528 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3529 Err(error) => {
3530 dlg.response_json_decode_error(&encoded, &error);
3531 return Err(common::Error::JsonDecodeError(
3532 encoded.to_string(),
3533 error,
3534 ));
3535 }
3536 }
3537 };
3538
3539 dlg.finished(true);
3540 return Ok(response);
3541 }
3542 }
3543 }
3544 }
3545
3546 /// Required. The name of the policy to be deleted, in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
3547 ///
3548 /// Sets the *name* path property to the given value.
3549 ///
3550 /// Even though the property as already been set when instantiating this call,
3551 /// we provide this method for API completeness.
3552 pub fn name(mut self, new_value: &str) -> ProjectFirewallpolicyDeleteCall<'a, C> {
3553 self._name = new_value.to_string();
3554 self
3555 }
3556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3557 /// while executing the actual API request.
3558 ///
3559 /// ````text
3560 /// It should be used to handle progress information, and to implement a certain level of resilience.
3561 /// ````
3562 ///
3563 /// Sets the *delegate* property to the given value.
3564 pub fn delegate(
3565 mut self,
3566 new_value: &'a mut dyn common::Delegate,
3567 ) -> ProjectFirewallpolicyDeleteCall<'a, C> {
3568 self._delegate = Some(new_value);
3569 self
3570 }
3571
3572 /// Set any additional parameter of the query string used in the request.
3573 /// It should be used to set parameters which are not yet available through their own
3574 /// setters.
3575 ///
3576 /// Please note that this method must not be used to set any of the known parameters
3577 /// which have their own setter method. If done anyway, the request will fail.
3578 ///
3579 /// # Additional Parameters
3580 ///
3581 /// * *$.xgafv* (query-string) - V1 error format.
3582 /// * *access_token* (query-string) - OAuth access token.
3583 /// * *alt* (query-string) - Data format for response.
3584 /// * *callback* (query-string) - JSONP
3585 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3586 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3587 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3588 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3589 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3590 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3591 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3592 pub fn param<T>(mut self, name: T, value: T) -> ProjectFirewallpolicyDeleteCall<'a, C>
3593 where
3594 T: AsRef<str>,
3595 {
3596 self._additional_params
3597 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3598 self
3599 }
3600
3601 /// Identifies the authorization scope for the method you are building.
3602 ///
3603 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3604 /// [`Scope::CloudPlatform`].
3605 ///
3606 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3607 /// tokens for more than one scope.
3608 ///
3609 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3610 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3611 /// sufficient, a read-write scope will do as well.
3612 pub fn add_scope<St>(mut self, scope: St) -> ProjectFirewallpolicyDeleteCall<'a, C>
3613 where
3614 St: AsRef<str>,
3615 {
3616 self._scopes.insert(String::from(scope.as_ref()));
3617 self
3618 }
3619 /// Identifies the authorization scope(s) for the method you are building.
3620 ///
3621 /// See [`Self::add_scope()`] for details.
3622 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFirewallpolicyDeleteCall<'a, C>
3623 where
3624 I: IntoIterator<Item = St>,
3625 St: AsRef<str>,
3626 {
3627 self._scopes
3628 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3629 self
3630 }
3631
3632 /// Removes all scopes, and no default scope will be used either.
3633 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3634 /// for details).
3635 pub fn clear_scopes(mut self) -> ProjectFirewallpolicyDeleteCall<'a, C> {
3636 self._scopes.clear();
3637 self
3638 }
3639}
3640
3641/// Returns the specified firewall policy.
3642///
3643/// A builder for the *firewallpolicies.get* method supported by a *project* resource.
3644/// It is not used directly, but through a [`ProjectMethods`] instance.
3645///
3646/// # Example
3647///
3648/// Instantiate a resource method builder
3649///
3650/// ```test_harness,no_run
3651/// # extern crate hyper;
3652/// # extern crate hyper_rustls;
3653/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
3654/// # async fn dox() {
3655/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3656///
3657/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3658/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3659/// # .with_native_roots()
3660/// # .unwrap()
3661/// # .https_only()
3662/// # .enable_http2()
3663/// # .build();
3664///
3665/// # let executor = hyper_util::rt::TokioExecutor::new();
3666/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3667/// # secret,
3668/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3669/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3670/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3671/// # ),
3672/// # ).build().await.unwrap();
3673///
3674/// # let client = hyper_util::client::legacy::Client::builder(
3675/// # hyper_util::rt::TokioExecutor::new()
3676/// # )
3677/// # .build(
3678/// # hyper_rustls::HttpsConnectorBuilder::new()
3679/// # .with_native_roots()
3680/// # .unwrap()
3681/// # .https_or_http()
3682/// # .enable_http2()
3683/// # .build()
3684/// # );
3685/// # let mut hub = RecaptchaEnterprise::new(client, auth);
3686/// // You can configure optional parameters by calling the respective setters at will, and
3687/// // execute the final call using `doit()`.
3688/// // Values shown here are possibly random and not representative !
3689/// let result = hub.projects().firewallpolicies_get("name")
3690/// .doit().await;
3691/// # }
3692/// ```
3693pub struct ProjectFirewallpolicyGetCall<'a, C>
3694where
3695 C: 'a,
3696{
3697 hub: &'a RecaptchaEnterprise<C>,
3698 _name: String,
3699 _delegate: Option<&'a mut dyn common::Delegate>,
3700 _additional_params: HashMap<String, String>,
3701 _scopes: BTreeSet<String>,
3702}
3703
3704impl<'a, C> common::CallBuilder for ProjectFirewallpolicyGetCall<'a, C> {}
3705
3706impl<'a, C> ProjectFirewallpolicyGetCall<'a, C>
3707where
3708 C: common::Connector,
3709{
3710 /// Perform the operation you have build so far.
3711 pub async fn doit(
3712 mut self,
3713 ) -> common::Result<(
3714 common::Response,
3715 GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
3716 )> {
3717 use std::borrow::Cow;
3718 use std::io::{Read, Seek};
3719
3720 use common::{url::Params, ToParts};
3721 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3722
3723 let mut dd = common::DefaultDelegate;
3724 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3725 dlg.begin(common::MethodInfo {
3726 id: "recaptchaenterprise.projects.firewallpolicies.get",
3727 http_method: hyper::Method::GET,
3728 });
3729
3730 for &field in ["alt", "name"].iter() {
3731 if self._additional_params.contains_key(field) {
3732 dlg.finished(false);
3733 return Err(common::Error::FieldClash(field));
3734 }
3735 }
3736
3737 let mut params = Params::with_capacity(3 + self._additional_params.len());
3738 params.push("name", self._name);
3739
3740 params.extend(self._additional_params.iter());
3741
3742 params.push("alt", "json");
3743 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3744 if self._scopes.is_empty() {
3745 self._scopes
3746 .insert(Scope::CloudPlatform.as_ref().to_string());
3747 }
3748
3749 #[allow(clippy::single_element_loop)]
3750 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3751 url = params.uri_replacement(url, param_name, find_this, true);
3752 }
3753 {
3754 let to_remove = ["name"];
3755 params.remove_params(&to_remove);
3756 }
3757
3758 let url = params.parse_with_url(&url);
3759
3760 loop {
3761 let token = match self
3762 .hub
3763 .auth
3764 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3765 .await
3766 {
3767 Ok(token) => token,
3768 Err(e) => match dlg.token(e) {
3769 Ok(token) => token,
3770 Err(e) => {
3771 dlg.finished(false);
3772 return Err(common::Error::MissingToken(e));
3773 }
3774 },
3775 };
3776 let mut req_result = {
3777 let client = &self.hub.client;
3778 dlg.pre_request();
3779 let mut req_builder = hyper::Request::builder()
3780 .method(hyper::Method::GET)
3781 .uri(url.as_str())
3782 .header(USER_AGENT, self.hub._user_agent.clone());
3783
3784 if let Some(token) = token.as_ref() {
3785 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3786 }
3787
3788 let request = req_builder
3789 .header(CONTENT_LENGTH, 0_u64)
3790 .body(common::to_body::<String>(None));
3791
3792 client.request(request.unwrap()).await
3793 };
3794
3795 match req_result {
3796 Err(err) => {
3797 if let common::Retry::After(d) = dlg.http_error(&err) {
3798 sleep(d).await;
3799 continue;
3800 }
3801 dlg.finished(false);
3802 return Err(common::Error::HttpError(err));
3803 }
3804 Ok(res) => {
3805 let (mut parts, body) = res.into_parts();
3806 let mut body = common::Body::new(body);
3807 if !parts.status.is_success() {
3808 let bytes = common::to_bytes(body).await.unwrap_or_default();
3809 let error = serde_json::from_str(&common::to_string(&bytes));
3810 let response = common::to_response(parts, bytes.into());
3811
3812 if let common::Retry::After(d) =
3813 dlg.http_failure(&response, error.as_ref().ok())
3814 {
3815 sleep(d).await;
3816 continue;
3817 }
3818
3819 dlg.finished(false);
3820
3821 return Err(match error {
3822 Ok(value) => common::Error::BadRequest(value),
3823 _ => common::Error::Failure(response),
3824 });
3825 }
3826 let response = {
3827 let bytes = common::to_bytes(body).await.unwrap_or_default();
3828 let encoded = common::to_string(&bytes);
3829 match serde_json::from_str(&encoded) {
3830 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3831 Err(error) => {
3832 dlg.response_json_decode_error(&encoded, &error);
3833 return Err(common::Error::JsonDecodeError(
3834 encoded.to_string(),
3835 error,
3836 ));
3837 }
3838 }
3839 };
3840
3841 dlg.finished(true);
3842 return Ok(response);
3843 }
3844 }
3845 }
3846 }
3847
3848 /// Required. The name of the requested policy, in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
3849 ///
3850 /// Sets the *name* path property to the given value.
3851 ///
3852 /// Even though the property as already been set when instantiating this call,
3853 /// we provide this method for API completeness.
3854 pub fn name(mut self, new_value: &str) -> ProjectFirewallpolicyGetCall<'a, C> {
3855 self._name = new_value.to_string();
3856 self
3857 }
3858 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3859 /// while executing the actual API request.
3860 ///
3861 /// ````text
3862 /// It should be used to handle progress information, and to implement a certain level of resilience.
3863 /// ````
3864 ///
3865 /// Sets the *delegate* property to the given value.
3866 pub fn delegate(
3867 mut self,
3868 new_value: &'a mut dyn common::Delegate,
3869 ) -> ProjectFirewallpolicyGetCall<'a, C> {
3870 self._delegate = Some(new_value);
3871 self
3872 }
3873
3874 /// Set any additional parameter of the query string used in the request.
3875 /// It should be used to set parameters which are not yet available through their own
3876 /// setters.
3877 ///
3878 /// Please note that this method must not be used to set any of the known parameters
3879 /// which have their own setter method. If done anyway, the request will fail.
3880 ///
3881 /// # Additional Parameters
3882 ///
3883 /// * *$.xgafv* (query-string) - V1 error format.
3884 /// * *access_token* (query-string) - OAuth access token.
3885 /// * *alt* (query-string) - Data format for response.
3886 /// * *callback* (query-string) - JSONP
3887 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3888 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3889 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3890 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3891 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
3892 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3893 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3894 pub fn param<T>(mut self, name: T, value: T) -> ProjectFirewallpolicyGetCall<'a, C>
3895 where
3896 T: AsRef<str>,
3897 {
3898 self._additional_params
3899 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3900 self
3901 }
3902
3903 /// Identifies the authorization scope for the method you are building.
3904 ///
3905 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3906 /// [`Scope::CloudPlatform`].
3907 ///
3908 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3909 /// tokens for more than one scope.
3910 ///
3911 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3912 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3913 /// sufficient, a read-write scope will do as well.
3914 pub fn add_scope<St>(mut self, scope: St) -> ProjectFirewallpolicyGetCall<'a, C>
3915 where
3916 St: AsRef<str>,
3917 {
3918 self._scopes.insert(String::from(scope.as_ref()));
3919 self
3920 }
3921 /// Identifies the authorization scope(s) for the method you are building.
3922 ///
3923 /// See [`Self::add_scope()`] for details.
3924 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFirewallpolicyGetCall<'a, C>
3925 where
3926 I: IntoIterator<Item = St>,
3927 St: AsRef<str>,
3928 {
3929 self._scopes
3930 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3931 self
3932 }
3933
3934 /// Removes all scopes, and no default scope will be used either.
3935 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3936 /// for details).
3937 pub fn clear_scopes(mut self) -> ProjectFirewallpolicyGetCall<'a, C> {
3938 self._scopes.clear();
3939 self
3940 }
3941}
3942
3943/// Returns the list of all firewall policies that belong to a project.
3944///
3945/// A builder for the *firewallpolicies.list* method supported by a *project* resource.
3946/// It is not used directly, but through a [`ProjectMethods`] instance.
3947///
3948/// # Example
3949///
3950/// Instantiate a resource method builder
3951///
3952/// ```test_harness,no_run
3953/// # extern crate hyper;
3954/// # extern crate hyper_rustls;
3955/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
3956/// # async fn dox() {
3957/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3958///
3959/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3960/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3961/// # .with_native_roots()
3962/// # .unwrap()
3963/// # .https_only()
3964/// # .enable_http2()
3965/// # .build();
3966///
3967/// # let executor = hyper_util::rt::TokioExecutor::new();
3968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3969/// # secret,
3970/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3971/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3972/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3973/// # ),
3974/// # ).build().await.unwrap();
3975///
3976/// # let client = hyper_util::client::legacy::Client::builder(
3977/// # hyper_util::rt::TokioExecutor::new()
3978/// # )
3979/// # .build(
3980/// # hyper_rustls::HttpsConnectorBuilder::new()
3981/// # .with_native_roots()
3982/// # .unwrap()
3983/// # .https_or_http()
3984/// # .enable_http2()
3985/// # .build()
3986/// # );
3987/// # let mut hub = RecaptchaEnterprise::new(client, auth);
3988/// // You can configure optional parameters by calling the respective setters at will, and
3989/// // execute the final call using `doit()`.
3990/// // Values shown here are possibly random and not representative !
3991/// let result = hub.projects().firewallpolicies_list("parent")
3992/// .page_token("takimata")
3993/// .page_size(-52)
3994/// .doit().await;
3995/// # }
3996/// ```
3997pub struct ProjectFirewallpolicyListCall<'a, C>
3998where
3999 C: 'a,
4000{
4001 hub: &'a RecaptchaEnterprise<C>,
4002 _parent: String,
4003 _page_token: Option<String>,
4004 _page_size: Option<i32>,
4005 _delegate: Option<&'a mut dyn common::Delegate>,
4006 _additional_params: HashMap<String, String>,
4007 _scopes: BTreeSet<String>,
4008}
4009
4010impl<'a, C> common::CallBuilder for ProjectFirewallpolicyListCall<'a, C> {}
4011
4012impl<'a, C> ProjectFirewallpolicyListCall<'a, C>
4013where
4014 C: common::Connector,
4015{
4016 /// Perform the operation you have build so far.
4017 pub async fn doit(
4018 mut self,
4019 ) -> common::Result<(
4020 common::Response,
4021 GoogleCloudRecaptchaenterpriseV1ListFirewallPoliciesResponse,
4022 )> {
4023 use std::borrow::Cow;
4024 use std::io::{Read, Seek};
4025
4026 use common::{url::Params, ToParts};
4027 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4028
4029 let mut dd = common::DefaultDelegate;
4030 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4031 dlg.begin(common::MethodInfo {
4032 id: "recaptchaenterprise.projects.firewallpolicies.list",
4033 http_method: hyper::Method::GET,
4034 });
4035
4036 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4037 if self._additional_params.contains_key(field) {
4038 dlg.finished(false);
4039 return Err(common::Error::FieldClash(field));
4040 }
4041 }
4042
4043 let mut params = Params::with_capacity(5 + self._additional_params.len());
4044 params.push("parent", self._parent);
4045 if let Some(value) = self._page_token.as_ref() {
4046 params.push("pageToken", value);
4047 }
4048 if let Some(value) = self._page_size.as_ref() {
4049 params.push("pageSize", value.to_string());
4050 }
4051
4052 params.extend(self._additional_params.iter());
4053
4054 params.push("alt", "json");
4055 let mut url = self.hub._base_url.clone() + "v1/{+parent}/firewallpolicies";
4056 if self._scopes.is_empty() {
4057 self._scopes
4058 .insert(Scope::CloudPlatform.as_ref().to_string());
4059 }
4060
4061 #[allow(clippy::single_element_loop)]
4062 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4063 url = params.uri_replacement(url, param_name, find_this, true);
4064 }
4065 {
4066 let to_remove = ["parent"];
4067 params.remove_params(&to_remove);
4068 }
4069
4070 let url = params.parse_with_url(&url);
4071
4072 loop {
4073 let token = match self
4074 .hub
4075 .auth
4076 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4077 .await
4078 {
4079 Ok(token) => token,
4080 Err(e) => match dlg.token(e) {
4081 Ok(token) => token,
4082 Err(e) => {
4083 dlg.finished(false);
4084 return Err(common::Error::MissingToken(e));
4085 }
4086 },
4087 };
4088 let mut req_result = {
4089 let client = &self.hub.client;
4090 dlg.pre_request();
4091 let mut req_builder = hyper::Request::builder()
4092 .method(hyper::Method::GET)
4093 .uri(url.as_str())
4094 .header(USER_AGENT, self.hub._user_agent.clone());
4095
4096 if let Some(token) = token.as_ref() {
4097 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4098 }
4099
4100 let request = req_builder
4101 .header(CONTENT_LENGTH, 0_u64)
4102 .body(common::to_body::<String>(None));
4103
4104 client.request(request.unwrap()).await
4105 };
4106
4107 match req_result {
4108 Err(err) => {
4109 if let common::Retry::After(d) = dlg.http_error(&err) {
4110 sleep(d).await;
4111 continue;
4112 }
4113 dlg.finished(false);
4114 return Err(common::Error::HttpError(err));
4115 }
4116 Ok(res) => {
4117 let (mut parts, body) = res.into_parts();
4118 let mut body = common::Body::new(body);
4119 if !parts.status.is_success() {
4120 let bytes = common::to_bytes(body).await.unwrap_or_default();
4121 let error = serde_json::from_str(&common::to_string(&bytes));
4122 let response = common::to_response(parts, bytes.into());
4123
4124 if let common::Retry::After(d) =
4125 dlg.http_failure(&response, error.as_ref().ok())
4126 {
4127 sleep(d).await;
4128 continue;
4129 }
4130
4131 dlg.finished(false);
4132
4133 return Err(match error {
4134 Ok(value) => common::Error::BadRequest(value),
4135 _ => common::Error::Failure(response),
4136 });
4137 }
4138 let response = {
4139 let bytes = common::to_bytes(body).await.unwrap_or_default();
4140 let encoded = common::to_string(&bytes);
4141 match serde_json::from_str(&encoded) {
4142 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4143 Err(error) => {
4144 dlg.response_json_decode_error(&encoded, &error);
4145 return Err(common::Error::JsonDecodeError(
4146 encoded.to_string(),
4147 error,
4148 ));
4149 }
4150 }
4151 };
4152
4153 dlg.finished(true);
4154 return Ok(response);
4155 }
4156 }
4157 }
4158 }
4159
4160 /// Required. The name of the project to list the policies for, in the format `projects/{project}`.
4161 ///
4162 /// Sets the *parent* path property to the given value.
4163 ///
4164 /// Even though the property as already been set when instantiating this call,
4165 /// we provide this method for API completeness.
4166 pub fn parent(mut self, new_value: &str) -> ProjectFirewallpolicyListCall<'a, C> {
4167 self._parent = new_value.to_string();
4168 self
4169 }
4170 /// Optional. The next_page_token value returned from a previous. ListFirewallPoliciesRequest, if any.
4171 ///
4172 /// Sets the *page token* query property to the given value.
4173 pub fn page_token(mut self, new_value: &str) -> ProjectFirewallpolicyListCall<'a, C> {
4174 self._page_token = Some(new_value.to_string());
4175 self
4176 }
4177 /// Optional. The maximum number of policies to return. Default is 10. Max limit is 1000.
4178 ///
4179 /// Sets the *page size* query property to the given value.
4180 pub fn page_size(mut self, new_value: i32) -> ProjectFirewallpolicyListCall<'a, C> {
4181 self._page_size = Some(new_value);
4182 self
4183 }
4184 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4185 /// while executing the actual API request.
4186 ///
4187 /// ````text
4188 /// It should be used to handle progress information, and to implement a certain level of resilience.
4189 /// ````
4190 ///
4191 /// Sets the *delegate* property to the given value.
4192 pub fn delegate(
4193 mut self,
4194 new_value: &'a mut dyn common::Delegate,
4195 ) -> ProjectFirewallpolicyListCall<'a, C> {
4196 self._delegate = Some(new_value);
4197 self
4198 }
4199
4200 /// Set any additional parameter of the query string used in the request.
4201 /// It should be used to set parameters which are not yet available through their own
4202 /// setters.
4203 ///
4204 /// Please note that this method must not be used to set any of the known parameters
4205 /// which have their own setter method. If done anyway, the request will fail.
4206 ///
4207 /// # Additional Parameters
4208 ///
4209 /// * *$.xgafv* (query-string) - V1 error format.
4210 /// * *access_token* (query-string) - OAuth access token.
4211 /// * *alt* (query-string) - Data format for response.
4212 /// * *callback* (query-string) - JSONP
4213 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4214 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4215 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4216 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4217 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4218 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4219 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4220 pub fn param<T>(mut self, name: T, value: T) -> ProjectFirewallpolicyListCall<'a, C>
4221 where
4222 T: AsRef<str>,
4223 {
4224 self._additional_params
4225 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4226 self
4227 }
4228
4229 /// Identifies the authorization scope for the method you are building.
4230 ///
4231 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4232 /// [`Scope::CloudPlatform`].
4233 ///
4234 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4235 /// tokens for more than one scope.
4236 ///
4237 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4238 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4239 /// sufficient, a read-write scope will do as well.
4240 pub fn add_scope<St>(mut self, scope: St) -> ProjectFirewallpolicyListCall<'a, C>
4241 where
4242 St: AsRef<str>,
4243 {
4244 self._scopes.insert(String::from(scope.as_ref()));
4245 self
4246 }
4247 /// Identifies the authorization scope(s) for the method you are building.
4248 ///
4249 /// See [`Self::add_scope()`] for details.
4250 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFirewallpolicyListCall<'a, C>
4251 where
4252 I: IntoIterator<Item = St>,
4253 St: AsRef<str>,
4254 {
4255 self._scopes
4256 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4257 self
4258 }
4259
4260 /// Removes all scopes, and no default scope will be used either.
4261 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4262 /// for details).
4263 pub fn clear_scopes(mut self) -> ProjectFirewallpolicyListCall<'a, C> {
4264 self._scopes.clear();
4265 self
4266 }
4267}
4268
4269/// Updates the specified firewall policy.
4270///
4271/// A builder for the *firewallpolicies.patch* method supported by a *project* resource.
4272/// It is not used directly, but through a [`ProjectMethods`] instance.
4273///
4274/// # Example
4275///
4276/// Instantiate a resource method builder
4277///
4278/// ```test_harness,no_run
4279/// # extern crate hyper;
4280/// # extern crate hyper_rustls;
4281/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
4282/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1FirewallPolicy;
4283/// # async fn dox() {
4284/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4285///
4286/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4287/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4288/// # .with_native_roots()
4289/// # .unwrap()
4290/// # .https_only()
4291/// # .enable_http2()
4292/// # .build();
4293///
4294/// # let executor = hyper_util::rt::TokioExecutor::new();
4295/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4296/// # secret,
4297/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4298/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4299/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4300/// # ),
4301/// # ).build().await.unwrap();
4302///
4303/// # let client = hyper_util::client::legacy::Client::builder(
4304/// # hyper_util::rt::TokioExecutor::new()
4305/// # )
4306/// # .build(
4307/// # hyper_rustls::HttpsConnectorBuilder::new()
4308/// # .with_native_roots()
4309/// # .unwrap()
4310/// # .https_or_http()
4311/// # .enable_http2()
4312/// # .build()
4313/// # );
4314/// # let mut hub = RecaptchaEnterprise::new(client, auth);
4315/// // As the method needs a request, you would usually fill it with the desired information
4316/// // into the respective structure. Some of the parts shown here might not be applicable !
4317/// // Values shown here are possibly random and not representative !
4318/// let mut req = GoogleCloudRecaptchaenterpriseV1FirewallPolicy::default();
4319///
4320/// // You can configure optional parameters by calling the respective setters at will, and
4321/// // execute the final call using `doit()`.
4322/// // Values shown here are possibly random and not representative !
4323/// let result = hub.projects().firewallpolicies_patch(req, "name")
4324/// .update_mask(FieldMask::new::<&str>(&[]))
4325/// .doit().await;
4326/// # }
4327/// ```
4328pub struct ProjectFirewallpolicyPatchCall<'a, C>
4329where
4330 C: 'a,
4331{
4332 hub: &'a RecaptchaEnterprise<C>,
4333 _request: GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
4334 _name: String,
4335 _update_mask: Option<common::FieldMask>,
4336 _delegate: Option<&'a mut dyn common::Delegate>,
4337 _additional_params: HashMap<String, String>,
4338 _scopes: BTreeSet<String>,
4339}
4340
4341impl<'a, C> common::CallBuilder for ProjectFirewallpolicyPatchCall<'a, C> {}
4342
4343impl<'a, C> ProjectFirewallpolicyPatchCall<'a, C>
4344where
4345 C: common::Connector,
4346{
4347 /// Perform the operation you have build so far.
4348 pub async fn doit(
4349 mut self,
4350 ) -> common::Result<(
4351 common::Response,
4352 GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
4353 )> {
4354 use std::borrow::Cow;
4355 use std::io::{Read, Seek};
4356
4357 use common::{url::Params, ToParts};
4358 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4359
4360 let mut dd = common::DefaultDelegate;
4361 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4362 dlg.begin(common::MethodInfo {
4363 id: "recaptchaenterprise.projects.firewallpolicies.patch",
4364 http_method: hyper::Method::PATCH,
4365 });
4366
4367 for &field in ["alt", "name", "updateMask"].iter() {
4368 if self._additional_params.contains_key(field) {
4369 dlg.finished(false);
4370 return Err(common::Error::FieldClash(field));
4371 }
4372 }
4373
4374 let mut params = Params::with_capacity(5 + self._additional_params.len());
4375 params.push("name", self._name);
4376 if let Some(value) = self._update_mask.as_ref() {
4377 params.push("updateMask", value.to_string());
4378 }
4379
4380 params.extend(self._additional_params.iter());
4381
4382 params.push("alt", "json");
4383 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4384 if self._scopes.is_empty() {
4385 self._scopes
4386 .insert(Scope::CloudPlatform.as_ref().to_string());
4387 }
4388
4389 #[allow(clippy::single_element_loop)]
4390 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4391 url = params.uri_replacement(url, param_name, find_this, true);
4392 }
4393 {
4394 let to_remove = ["name"];
4395 params.remove_params(&to_remove);
4396 }
4397
4398 let url = params.parse_with_url(&url);
4399
4400 let mut json_mime_type = mime::APPLICATION_JSON;
4401 let mut request_value_reader = {
4402 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4403 common::remove_json_null_values(&mut value);
4404 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4405 serde_json::to_writer(&mut dst, &value).unwrap();
4406 dst
4407 };
4408 let request_size = request_value_reader
4409 .seek(std::io::SeekFrom::End(0))
4410 .unwrap();
4411 request_value_reader
4412 .seek(std::io::SeekFrom::Start(0))
4413 .unwrap();
4414
4415 loop {
4416 let token = match self
4417 .hub
4418 .auth
4419 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4420 .await
4421 {
4422 Ok(token) => token,
4423 Err(e) => match dlg.token(e) {
4424 Ok(token) => token,
4425 Err(e) => {
4426 dlg.finished(false);
4427 return Err(common::Error::MissingToken(e));
4428 }
4429 },
4430 };
4431 request_value_reader
4432 .seek(std::io::SeekFrom::Start(0))
4433 .unwrap();
4434 let mut req_result = {
4435 let client = &self.hub.client;
4436 dlg.pre_request();
4437 let mut req_builder = hyper::Request::builder()
4438 .method(hyper::Method::PATCH)
4439 .uri(url.as_str())
4440 .header(USER_AGENT, self.hub._user_agent.clone());
4441
4442 if let Some(token) = token.as_ref() {
4443 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4444 }
4445
4446 let request = req_builder
4447 .header(CONTENT_TYPE, json_mime_type.to_string())
4448 .header(CONTENT_LENGTH, request_size as u64)
4449 .body(common::to_body(
4450 request_value_reader.get_ref().clone().into(),
4451 ));
4452
4453 client.request(request.unwrap()).await
4454 };
4455
4456 match req_result {
4457 Err(err) => {
4458 if let common::Retry::After(d) = dlg.http_error(&err) {
4459 sleep(d).await;
4460 continue;
4461 }
4462 dlg.finished(false);
4463 return Err(common::Error::HttpError(err));
4464 }
4465 Ok(res) => {
4466 let (mut parts, body) = res.into_parts();
4467 let mut body = common::Body::new(body);
4468 if !parts.status.is_success() {
4469 let bytes = common::to_bytes(body).await.unwrap_or_default();
4470 let error = serde_json::from_str(&common::to_string(&bytes));
4471 let response = common::to_response(parts, bytes.into());
4472
4473 if let common::Retry::After(d) =
4474 dlg.http_failure(&response, error.as_ref().ok())
4475 {
4476 sleep(d).await;
4477 continue;
4478 }
4479
4480 dlg.finished(false);
4481
4482 return Err(match error {
4483 Ok(value) => common::Error::BadRequest(value),
4484 _ => common::Error::Failure(response),
4485 });
4486 }
4487 let response = {
4488 let bytes = common::to_bytes(body).await.unwrap_or_default();
4489 let encoded = common::to_string(&bytes);
4490 match serde_json::from_str(&encoded) {
4491 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4492 Err(error) => {
4493 dlg.response_json_decode_error(&encoded, &error);
4494 return Err(common::Error::JsonDecodeError(
4495 encoded.to_string(),
4496 error,
4497 ));
4498 }
4499 }
4500 };
4501
4502 dlg.finished(true);
4503 return Ok(response);
4504 }
4505 }
4506 }
4507 }
4508
4509 ///
4510 /// Sets the *request* property to the given value.
4511 ///
4512 /// Even though the property as already been set when instantiating this call,
4513 /// we provide this method for API completeness.
4514 pub fn request(
4515 mut self,
4516 new_value: GoogleCloudRecaptchaenterpriseV1FirewallPolicy,
4517 ) -> ProjectFirewallpolicyPatchCall<'a, C> {
4518 self._request = new_value;
4519 self
4520 }
4521 /// Identifier. The resource name for the FirewallPolicy in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
4522 ///
4523 /// Sets the *name* path property to the given value.
4524 ///
4525 /// Even though the property as already been set when instantiating this call,
4526 /// we provide this method for API completeness.
4527 pub fn name(mut self, new_value: &str) -> ProjectFirewallpolicyPatchCall<'a, C> {
4528 self._name = new_value.to_string();
4529 self
4530 }
4531 /// Optional. The mask to control which fields of the policy get updated. If the mask is not present, all fields are updated.
4532 ///
4533 /// Sets the *update mask* query property to the given value.
4534 pub fn update_mask(
4535 mut self,
4536 new_value: common::FieldMask,
4537 ) -> ProjectFirewallpolicyPatchCall<'a, C> {
4538 self._update_mask = Some(new_value);
4539 self
4540 }
4541 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4542 /// while executing the actual API request.
4543 ///
4544 /// ````text
4545 /// It should be used to handle progress information, and to implement a certain level of resilience.
4546 /// ````
4547 ///
4548 /// Sets the *delegate* property to the given value.
4549 pub fn delegate(
4550 mut self,
4551 new_value: &'a mut dyn common::Delegate,
4552 ) -> ProjectFirewallpolicyPatchCall<'a, C> {
4553 self._delegate = Some(new_value);
4554 self
4555 }
4556
4557 /// Set any additional parameter of the query string used in the request.
4558 /// It should be used to set parameters which are not yet available through their own
4559 /// setters.
4560 ///
4561 /// Please note that this method must not be used to set any of the known parameters
4562 /// which have their own setter method. If done anyway, the request will fail.
4563 ///
4564 /// # Additional Parameters
4565 ///
4566 /// * *$.xgafv* (query-string) - V1 error format.
4567 /// * *access_token* (query-string) - OAuth access token.
4568 /// * *alt* (query-string) - Data format for response.
4569 /// * *callback* (query-string) - JSONP
4570 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4571 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4572 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4573 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4574 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4575 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4576 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4577 pub fn param<T>(mut self, name: T, value: T) -> ProjectFirewallpolicyPatchCall<'a, C>
4578 where
4579 T: AsRef<str>,
4580 {
4581 self._additional_params
4582 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4583 self
4584 }
4585
4586 /// Identifies the authorization scope for the method you are building.
4587 ///
4588 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4589 /// [`Scope::CloudPlatform`].
4590 ///
4591 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4592 /// tokens for more than one scope.
4593 ///
4594 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4595 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4596 /// sufficient, a read-write scope will do as well.
4597 pub fn add_scope<St>(mut self, scope: St) -> ProjectFirewallpolicyPatchCall<'a, C>
4598 where
4599 St: AsRef<str>,
4600 {
4601 self._scopes.insert(String::from(scope.as_ref()));
4602 self
4603 }
4604 /// Identifies the authorization scope(s) for the method you are building.
4605 ///
4606 /// See [`Self::add_scope()`] for details.
4607 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFirewallpolicyPatchCall<'a, C>
4608 where
4609 I: IntoIterator<Item = St>,
4610 St: AsRef<str>,
4611 {
4612 self._scopes
4613 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4614 self
4615 }
4616
4617 /// Removes all scopes, and no default scope will be used either.
4618 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4619 /// for details).
4620 pub fn clear_scopes(mut self) -> ProjectFirewallpolicyPatchCall<'a, C> {
4621 self._scopes.clear();
4622 self
4623 }
4624}
4625
4626/// Reorders all firewall policies.
4627///
4628/// A builder for the *firewallpolicies.reorder* method supported by a *project* resource.
4629/// It is not used directly, but through a [`ProjectMethods`] instance.
4630///
4631/// # Example
4632///
4633/// Instantiate a resource method builder
4634///
4635/// ```test_harness,no_run
4636/// # extern crate hyper;
4637/// # extern crate hyper_rustls;
4638/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
4639/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesRequest;
4640/// # async fn dox() {
4641/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4642///
4643/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4644/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4645/// # .with_native_roots()
4646/// # .unwrap()
4647/// # .https_only()
4648/// # .enable_http2()
4649/// # .build();
4650///
4651/// # let executor = hyper_util::rt::TokioExecutor::new();
4652/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4653/// # secret,
4654/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4655/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4656/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4657/// # ),
4658/// # ).build().await.unwrap();
4659///
4660/// # let client = hyper_util::client::legacy::Client::builder(
4661/// # hyper_util::rt::TokioExecutor::new()
4662/// # )
4663/// # .build(
4664/// # hyper_rustls::HttpsConnectorBuilder::new()
4665/// # .with_native_roots()
4666/// # .unwrap()
4667/// # .https_or_http()
4668/// # .enable_http2()
4669/// # .build()
4670/// # );
4671/// # let mut hub = RecaptchaEnterprise::new(client, auth);
4672/// // As the method needs a request, you would usually fill it with the desired information
4673/// // into the respective structure. Some of the parts shown here might not be applicable !
4674/// // Values shown here are possibly random and not representative !
4675/// let mut req = GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesRequest::default();
4676///
4677/// // You can configure optional parameters by calling the respective setters at will, and
4678/// // execute the final call using `doit()`.
4679/// // Values shown here are possibly random and not representative !
4680/// let result = hub.projects().firewallpolicies_reorder(req, "parent")
4681/// .doit().await;
4682/// # }
4683/// ```
4684pub struct ProjectFirewallpolicyReorderCall<'a, C>
4685where
4686 C: 'a,
4687{
4688 hub: &'a RecaptchaEnterprise<C>,
4689 _request: GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesRequest,
4690 _parent: String,
4691 _delegate: Option<&'a mut dyn common::Delegate>,
4692 _additional_params: HashMap<String, String>,
4693 _scopes: BTreeSet<String>,
4694}
4695
4696impl<'a, C> common::CallBuilder for ProjectFirewallpolicyReorderCall<'a, C> {}
4697
4698impl<'a, C> ProjectFirewallpolicyReorderCall<'a, C>
4699where
4700 C: common::Connector,
4701{
4702 /// Perform the operation you have build so far.
4703 pub async fn doit(
4704 mut self,
4705 ) -> common::Result<(
4706 common::Response,
4707 GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesResponse,
4708 )> {
4709 use std::borrow::Cow;
4710 use std::io::{Read, Seek};
4711
4712 use common::{url::Params, ToParts};
4713 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4714
4715 let mut dd = common::DefaultDelegate;
4716 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4717 dlg.begin(common::MethodInfo {
4718 id: "recaptchaenterprise.projects.firewallpolicies.reorder",
4719 http_method: hyper::Method::POST,
4720 });
4721
4722 for &field in ["alt", "parent"].iter() {
4723 if self._additional_params.contains_key(field) {
4724 dlg.finished(false);
4725 return Err(common::Error::FieldClash(field));
4726 }
4727 }
4728
4729 let mut params = Params::with_capacity(4 + self._additional_params.len());
4730 params.push("parent", self._parent);
4731
4732 params.extend(self._additional_params.iter());
4733
4734 params.push("alt", "json");
4735 let mut url = self.hub._base_url.clone() + "v1/{+parent}/firewallpolicies:reorder";
4736 if self._scopes.is_empty() {
4737 self._scopes
4738 .insert(Scope::CloudPlatform.as_ref().to_string());
4739 }
4740
4741 #[allow(clippy::single_element_loop)]
4742 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4743 url = params.uri_replacement(url, param_name, find_this, true);
4744 }
4745 {
4746 let to_remove = ["parent"];
4747 params.remove_params(&to_remove);
4748 }
4749
4750 let url = params.parse_with_url(&url);
4751
4752 let mut json_mime_type = mime::APPLICATION_JSON;
4753 let mut request_value_reader = {
4754 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4755 common::remove_json_null_values(&mut value);
4756 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4757 serde_json::to_writer(&mut dst, &value).unwrap();
4758 dst
4759 };
4760 let request_size = request_value_reader
4761 .seek(std::io::SeekFrom::End(0))
4762 .unwrap();
4763 request_value_reader
4764 .seek(std::io::SeekFrom::Start(0))
4765 .unwrap();
4766
4767 loop {
4768 let token = match self
4769 .hub
4770 .auth
4771 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4772 .await
4773 {
4774 Ok(token) => token,
4775 Err(e) => match dlg.token(e) {
4776 Ok(token) => token,
4777 Err(e) => {
4778 dlg.finished(false);
4779 return Err(common::Error::MissingToken(e));
4780 }
4781 },
4782 };
4783 request_value_reader
4784 .seek(std::io::SeekFrom::Start(0))
4785 .unwrap();
4786 let mut req_result = {
4787 let client = &self.hub.client;
4788 dlg.pre_request();
4789 let mut req_builder = hyper::Request::builder()
4790 .method(hyper::Method::POST)
4791 .uri(url.as_str())
4792 .header(USER_AGENT, self.hub._user_agent.clone());
4793
4794 if let Some(token) = token.as_ref() {
4795 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4796 }
4797
4798 let request = req_builder
4799 .header(CONTENT_TYPE, json_mime_type.to_string())
4800 .header(CONTENT_LENGTH, request_size as u64)
4801 .body(common::to_body(
4802 request_value_reader.get_ref().clone().into(),
4803 ));
4804
4805 client.request(request.unwrap()).await
4806 };
4807
4808 match req_result {
4809 Err(err) => {
4810 if let common::Retry::After(d) = dlg.http_error(&err) {
4811 sleep(d).await;
4812 continue;
4813 }
4814 dlg.finished(false);
4815 return Err(common::Error::HttpError(err));
4816 }
4817 Ok(res) => {
4818 let (mut parts, body) = res.into_parts();
4819 let mut body = common::Body::new(body);
4820 if !parts.status.is_success() {
4821 let bytes = common::to_bytes(body).await.unwrap_or_default();
4822 let error = serde_json::from_str(&common::to_string(&bytes));
4823 let response = common::to_response(parts, bytes.into());
4824
4825 if let common::Retry::After(d) =
4826 dlg.http_failure(&response, error.as_ref().ok())
4827 {
4828 sleep(d).await;
4829 continue;
4830 }
4831
4832 dlg.finished(false);
4833
4834 return Err(match error {
4835 Ok(value) => common::Error::BadRequest(value),
4836 _ => common::Error::Failure(response),
4837 });
4838 }
4839 let response = {
4840 let bytes = common::to_bytes(body).await.unwrap_or_default();
4841 let encoded = common::to_string(&bytes);
4842 match serde_json::from_str(&encoded) {
4843 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4844 Err(error) => {
4845 dlg.response_json_decode_error(&encoded, &error);
4846 return Err(common::Error::JsonDecodeError(
4847 encoded.to_string(),
4848 error,
4849 ));
4850 }
4851 }
4852 };
4853
4854 dlg.finished(true);
4855 return Ok(response);
4856 }
4857 }
4858 }
4859 }
4860
4861 ///
4862 /// Sets the *request* property to the given value.
4863 ///
4864 /// Even though the property as already been set when instantiating this call,
4865 /// we provide this method for API completeness.
4866 pub fn request(
4867 mut self,
4868 new_value: GoogleCloudRecaptchaenterpriseV1ReorderFirewallPoliciesRequest,
4869 ) -> ProjectFirewallpolicyReorderCall<'a, C> {
4870 self._request = new_value;
4871 self
4872 }
4873 /// Required. The name of the project to list the policies for, in the format `projects/{project}`.
4874 ///
4875 /// Sets the *parent* path property to the given value.
4876 ///
4877 /// Even though the property as already been set when instantiating this call,
4878 /// we provide this method for API completeness.
4879 pub fn parent(mut self, new_value: &str) -> ProjectFirewallpolicyReorderCall<'a, C> {
4880 self._parent = new_value.to_string();
4881 self
4882 }
4883 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4884 /// while executing the actual API request.
4885 ///
4886 /// ````text
4887 /// It should be used to handle progress information, and to implement a certain level of resilience.
4888 /// ````
4889 ///
4890 /// Sets the *delegate* property to the given value.
4891 pub fn delegate(
4892 mut self,
4893 new_value: &'a mut dyn common::Delegate,
4894 ) -> ProjectFirewallpolicyReorderCall<'a, C> {
4895 self._delegate = Some(new_value);
4896 self
4897 }
4898
4899 /// Set any additional parameter of the query string used in the request.
4900 /// It should be used to set parameters which are not yet available through their own
4901 /// setters.
4902 ///
4903 /// Please note that this method must not be used to set any of the known parameters
4904 /// which have their own setter method. If done anyway, the request will fail.
4905 ///
4906 /// # Additional Parameters
4907 ///
4908 /// * *$.xgafv* (query-string) - V1 error format.
4909 /// * *access_token* (query-string) - OAuth access token.
4910 /// * *alt* (query-string) - Data format for response.
4911 /// * *callback* (query-string) - JSONP
4912 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4913 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4914 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4915 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4916 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
4917 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4918 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4919 pub fn param<T>(mut self, name: T, value: T) -> ProjectFirewallpolicyReorderCall<'a, C>
4920 where
4921 T: AsRef<str>,
4922 {
4923 self._additional_params
4924 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4925 self
4926 }
4927
4928 /// Identifies the authorization scope for the method you are building.
4929 ///
4930 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4931 /// [`Scope::CloudPlatform`].
4932 ///
4933 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4934 /// tokens for more than one scope.
4935 ///
4936 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4937 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4938 /// sufficient, a read-write scope will do as well.
4939 pub fn add_scope<St>(mut self, scope: St) -> ProjectFirewallpolicyReorderCall<'a, C>
4940 where
4941 St: AsRef<str>,
4942 {
4943 self._scopes.insert(String::from(scope.as_ref()));
4944 self
4945 }
4946 /// Identifies the authorization scope(s) for the method you are building.
4947 ///
4948 /// See [`Self::add_scope()`] for details.
4949 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectFirewallpolicyReorderCall<'a, C>
4950 where
4951 I: IntoIterator<Item = St>,
4952 St: AsRef<str>,
4953 {
4954 self._scopes
4955 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4956 self
4957 }
4958
4959 /// Removes all scopes, and no default scope will be used either.
4960 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4961 /// for details).
4962 pub fn clear_scopes(mut self) -> ProjectFirewallpolicyReorderCall<'a, C> {
4963 self._scopes.clear();
4964 self
4965 }
4966}
4967
4968/// Adds an IP override to a key. The following restrictions hold: * The maximum number of IP overrides per key is 1000. * For any conflict (such as IP already exists or IP part of an existing IP range), an error is returned.
4969///
4970/// A builder for the *keys.addIpOverride* method supported by a *project* resource.
4971/// It is not used directly, but through a [`ProjectMethods`] instance.
4972///
4973/// # Example
4974///
4975/// Instantiate a resource method builder
4976///
4977/// ```test_harness,no_run
4978/// # extern crate hyper;
4979/// # extern crate hyper_rustls;
4980/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
4981/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1AddIpOverrideRequest;
4982/// # async fn dox() {
4983/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4984///
4985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4986/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4987/// # .with_native_roots()
4988/// # .unwrap()
4989/// # .https_only()
4990/// # .enable_http2()
4991/// # .build();
4992///
4993/// # let executor = hyper_util::rt::TokioExecutor::new();
4994/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4995/// # secret,
4996/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4997/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4998/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4999/// # ),
5000/// # ).build().await.unwrap();
5001///
5002/// # let client = hyper_util::client::legacy::Client::builder(
5003/// # hyper_util::rt::TokioExecutor::new()
5004/// # )
5005/// # .build(
5006/// # hyper_rustls::HttpsConnectorBuilder::new()
5007/// # .with_native_roots()
5008/// # .unwrap()
5009/// # .https_or_http()
5010/// # .enable_http2()
5011/// # .build()
5012/// # );
5013/// # let mut hub = RecaptchaEnterprise::new(client, auth);
5014/// // As the method needs a request, you would usually fill it with the desired information
5015/// // into the respective structure. Some of the parts shown here might not be applicable !
5016/// // Values shown here are possibly random and not representative !
5017/// let mut req = GoogleCloudRecaptchaenterpriseV1AddIpOverrideRequest::default();
5018///
5019/// // You can configure optional parameters by calling the respective setters at will, and
5020/// // execute the final call using `doit()`.
5021/// // Values shown here are possibly random and not representative !
5022/// let result = hub.projects().keys_add_ip_override(req, "name")
5023/// .doit().await;
5024/// # }
5025/// ```
5026pub struct ProjectKeyAddIpOverrideCall<'a, C>
5027where
5028 C: 'a,
5029{
5030 hub: &'a RecaptchaEnterprise<C>,
5031 _request: GoogleCloudRecaptchaenterpriseV1AddIpOverrideRequest,
5032 _name: String,
5033 _delegate: Option<&'a mut dyn common::Delegate>,
5034 _additional_params: HashMap<String, String>,
5035 _scopes: BTreeSet<String>,
5036}
5037
5038impl<'a, C> common::CallBuilder for ProjectKeyAddIpOverrideCall<'a, C> {}
5039
5040impl<'a, C> ProjectKeyAddIpOverrideCall<'a, C>
5041where
5042 C: common::Connector,
5043{
5044 /// Perform the operation you have build so far.
5045 pub async fn doit(
5046 mut self,
5047 ) -> common::Result<(
5048 common::Response,
5049 GoogleCloudRecaptchaenterpriseV1AddIpOverrideResponse,
5050 )> {
5051 use std::borrow::Cow;
5052 use std::io::{Read, Seek};
5053
5054 use common::{url::Params, ToParts};
5055 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5056
5057 let mut dd = common::DefaultDelegate;
5058 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5059 dlg.begin(common::MethodInfo {
5060 id: "recaptchaenterprise.projects.keys.addIpOverride",
5061 http_method: hyper::Method::POST,
5062 });
5063
5064 for &field in ["alt", "name"].iter() {
5065 if self._additional_params.contains_key(field) {
5066 dlg.finished(false);
5067 return Err(common::Error::FieldClash(field));
5068 }
5069 }
5070
5071 let mut params = Params::with_capacity(4 + self._additional_params.len());
5072 params.push("name", self._name);
5073
5074 params.extend(self._additional_params.iter());
5075
5076 params.push("alt", "json");
5077 let mut url = self.hub._base_url.clone() + "v1/{+name}:addIpOverride";
5078 if self._scopes.is_empty() {
5079 self._scopes
5080 .insert(Scope::CloudPlatform.as_ref().to_string());
5081 }
5082
5083 #[allow(clippy::single_element_loop)]
5084 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5085 url = params.uri_replacement(url, param_name, find_this, true);
5086 }
5087 {
5088 let to_remove = ["name"];
5089 params.remove_params(&to_remove);
5090 }
5091
5092 let url = params.parse_with_url(&url);
5093
5094 let mut json_mime_type = mime::APPLICATION_JSON;
5095 let mut request_value_reader = {
5096 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5097 common::remove_json_null_values(&mut value);
5098 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5099 serde_json::to_writer(&mut dst, &value).unwrap();
5100 dst
5101 };
5102 let request_size = request_value_reader
5103 .seek(std::io::SeekFrom::End(0))
5104 .unwrap();
5105 request_value_reader
5106 .seek(std::io::SeekFrom::Start(0))
5107 .unwrap();
5108
5109 loop {
5110 let token = match self
5111 .hub
5112 .auth
5113 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5114 .await
5115 {
5116 Ok(token) => token,
5117 Err(e) => match dlg.token(e) {
5118 Ok(token) => token,
5119 Err(e) => {
5120 dlg.finished(false);
5121 return Err(common::Error::MissingToken(e));
5122 }
5123 },
5124 };
5125 request_value_reader
5126 .seek(std::io::SeekFrom::Start(0))
5127 .unwrap();
5128 let mut req_result = {
5129 let client = &self.hub.client;
5130 dlg.pre_request();
5131 let mut req_builder = hyper::Request::builder()
5132 .method(hyper::Method::POST)
5133 .uri(url.as_str())
5134 .header(USER_AGENT, self.hub._user_agent.clone());
5135
5136 if let Some(token) = token.as_ref() {
5137 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5138 }
5139
5140 let request = req_builder
5141 .header(CONTENT_TYPE, json_mime_type.to_string())
5142 .header(CONTENT_LENGTH, request_size as u64)
5143 .body(common::to_body(
5144 request_value_reader.get_ref().clone().into(),
5145 ));
5146
5147 client.request(request.unwrap()).await
5148 };
5149
5150 match req_result {
5151 Err(err) => {
5152 if let common::Retry::After(d) = dlg.http_error(&err) {
5153 sleep(d).await;
5154 continue;
5155 }
5156 dlg.finished(false);
5157 return Err(common::Error::HttpError(err));
5158 }
5159 Ok(res) => {
5160 let (mut parts, body) = res.into_parts();
5161 let mut body = common::Body::new(body);
5162 if !parts.status.is_success() {
5163 let bytes = common::to_bytes(body).await.unwrap_or_default();
5164 let error = serde_json::from_str(&common::to_string(&bytes));
5165 let response = common::to_response(parts, bytes.into());
5166
5167 if let common::Retry::After(d) =
5168 dlg.http_failure(&response, error.as_ref().ok())
5169 {
5170 sleep(d).await;
5171 continue;
5172 }
5173
5174 dlg.finished(false);
5175
5176 return Err(match error {
5177 Ok(value) => common::Error::BadRequest(value),
5178 _ => common::Error::Failure(response),
5179 });
5180 }
5181 let response = {
5182 let bytes = common::to_bytes(body).await.unwrap_or_default();
5183 let encoded = common::to_string(&bytes);
5184 match serde_json::from_str(&encoded) {
5185 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5186 Err(error) => {
5187 dlg.response_json_decode_error(&encoded, &error);
5188 return Err(common::Error::JsonDecodeError(
5189 encoded.to_string(),
5190 error,
5191 ));
5192 }
5193 }
5194 };
5195
5196 dlg.finished(true);
5197 return Ok(response);
5198 }
5199 }
5200 }
5201 }
5202
5203 ///
5204 /// Sets the *request* property to the given value.
5205 ///
5206 /// Even though the property as already been set when instantiating this call,
5207 /// we provide this method for API completeness.
5208 pub fn request(
5209 mut self,
5210 new_value: GoogleCloudRecaptchaenterpriseV1AddIpOverrideRequest,
5211 ) -> ProjectKeyAddIpOverrideCall<'a, C> {
5212 self._request = new_value;
5213 self
5214 }
5215 /// Required. The name of the key to which the IP override is added, in the format `projects/{project}/keys/{key}`.
5216 ///
5217 /// Sets the *name* path property to the given value.
5218 ///
5219 /// Even though the property as already been set when instantiating this call,
5220 /// we provide this method for API completeness.
5221 pub fn name(mut self, new_value: &str) -> ProjectKeyAddIpOverrideCall<'a, C> {
5222 self._name = new_value.to_string();
5223 self
5224 }
5225 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5226 /// while executing the actual API request.
5227 ///
5228 /// ````text
5229 /// It should be used to handle progress information, and to implement a certain level of resilience.
5230 /// ````
5231 ///
5232 /// Sets the *delegate* property to the given value.
5233 pub fn delegate(
5234 mut self,
5235 new_value: &'a mut dyn common::Delegate,
5236 ) -> ProjectKeyAddIpOverrideCall<'a, C> {
5237 self._delegate = Some(new_value);
5238 self
5239 }
5240
5241 /// Set any additional parameter of the query string used in the request.
5242 /// It should be used to set parameters which are not yet available through their own
5243 /// setters.
5244 ///
5245 /// Please note that this method must not be used to set any of the known parameters
5246 /// which have their own setter method. If done anyway, the request will fail.
5247 ///
5248 /// # Additional Parameters
5249 ///
5250 /// * *$.xgafv* (query-string) - V1 error format.
5251 /// * *access_token* (query-string) - OAuth access token.
5252 /// * *alt* (query-string) - Data format for response.
5253 /// * *callback* (query-string) - JSONP
5254 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5255 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5256 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5257 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5258 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5259 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5260 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5261 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyAddIpOverrideCall<'a, C>
5262 where
5263 T: AsRef<str>,
5264 {
5265 self._additional_params
5266 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5267 self
5268 }
5269
5270 /// Identifies the authorization scope for the method you are building.
5271 ///
5272 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5273 /// [`Scope::CloudPlatform`].
5274 ///
5275 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5276 /// tokens for more than one scope.
5277 ///
5278 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5279 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5280 /// sufficient, a read-write scope will do as well.
5281 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyAddIpOverrideCall<'a, C>
5282 where
5283 St: AsRef<str>,
5284 {
5285 self._scopes.insert(String::from(scope.as_ref()));
5286 self
5287 }
5288 /// Identifies the authorization scope(s) for the method you are building.
5289 ///
5290 /// See [`Self::add_scope()`] for details.
5291 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyAddIpOverrideCall<'a, C>
5292 where
5293 I: IntoIterator<Item = St>,
5294 St: AsRef<str>,
5295 {
5296 self._scopes
5297 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5298 self
5299 }
5300
5301 /// Removes all scopes, and no default scope will be used either.
5302 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5303 /// for details).
5304 pub fn clear_scopes(mut self) -> ProjectKeyAddIpOverrideCall<'a, C> {
5305 self._scopes.clear();
5306 self
5307 }
5308}
5309
5310/// Creates a new reCAPTCHA Enterprise key.
5311///
5312/// A builder for the *keys.create* method supported by a *project* resource.
5313/// It is not used directly, but through a [`ProjectMethods`] instance.
5314///
5315/// # Example
5316///
5317/// Instantiate a resource method builder
5318///
5319/// ```test_harness,no_run
5320/// # extern crate hyper;
5321/// # extern crate hyper_rustls;
5322/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
5323/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1Key;
5324/// # async fn dox() {
5325/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5326///
5327/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5328/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5329/// # .with_native_roots()
5330/// # .unwrap()
5331/// # .https_only()
5332/// # .enable_http2()
5333/// # .build();
5334///
5335/// # let executor = hyper_util::rt::TokioExecutor::new();
5336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5337/// # secret,
5338/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5339/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5340/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5341/// # ),
5342/// # ).build().await.unwrap();
5343///
5344/// # let client = hyper_util::client::legacy::Client::builder(
5345/// # hyper_util::rt::TokioExecutor::new()
5346/// # )
5347/// # .build(
5348/// # hyper_rustls::HttpsConnectorBuilder::new()
5349/// # .with_native_roots()
5350/// # .unwrap()
5351/// # .https_or_http()
5352/// # .enable_http2()
5353/// # .build()
5354/// # );
5355/// # let mut hub = RecaptchaEnterprise::new(client, auth);
5356/// // As the method needs a request, you would usually fill it with the desired information
5357/// // into the respective structure. Some of the parts shown here might not be applicable !
5358/// // Values shown here are possibly random and not representative !
5359/// let mut req = GoogleCloudRecaptchaenterpriseV1Key::default();
5360///
5361/// // You can configure optional parameters by calling the respective setters at will, and
5362/// // execute the final call using `doit()`.
5363/// // Values shown here are possibly random and not representative !
5364/// let result = hub.projects().keys_create(req, "parent")
5365/// .doit().await;
5366/// # }
5367/// ```
5368pub struct ProjectKeyCreateCall<'a, C>
5369where
5370 C: 'a,
5371{
5372 hub: &'a RecaptchaEnterprise<C>,
5373 _request: GoogleCloudRecaptchaenterpriseV1Key,
5374 _parent: String,
5375 _delegate: Option<&'a mut dyn common::Delegate>,
5376 _additional_params: HashMap<String, String>,
5377 _scopes: BTreeSet<String>,
5378}
5379
5380impl<'a, C> common::CallBuilder for ProjectKeyCreateCall<'a, C> {}
5381
5382impl<'a, C> ProjectKeyCreateCall<'a, C>
5383where
5384 C: common::Connector,
5385{
5386 /// Perform the operation you have build so far.
5387 pub async fn doit(
5388 mut self,
5389 ) -> common::Result<(common::Response, GoogleCloudRecaptchaenterpriseV1Key)> {
5390 use std::borrow::Cow;
5391 use std::io::{Read, Seek};
5392
5393 use common::{url::Params, ToParts};
5394 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5395
5396 let mut dd = common::DefaultDelegate;
5397 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5398 dlg.begin(common::MethodInfo {
5399 id: "recaptchaenterprise.projects.keys.create",
5400 http_method: hyper::Method::POST,
5401 });
5402
5403 for &field in ["alt", "parent"].iter() {
5404 if self._additional_params.contains_key(field) {
5405 dlg.finished(false);
5406 return Err(common::Error::FieldClash(field));
5407 }
5408 }
5409
5410 let mut params = Params::with_capacity(4 + self._additional_params.len());
5411 params.push("parent", self._parent);
5412
5413 params.extend(self._additional_params.iter());
5414
5415 params.push("alt", "json");
5416 let mut url = self.hub._base_url.clone() + "v1/{+parent}/keys";
5417 if self._scopes.is_empty() {
5418 self._scopes
5419 .insert(Scope::CloudPlatform.as_ref().to_string());
5420 }
5421
5422 #[allow(clippy::single_element_loop)]
5423 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5424 url = params.uri_replacement(url, param_name, find_this, true);
5425 }
5426 {
5427 let to_remove = ["parent"];
5428 params.remove_params(&to_remove);
5429 }
5430
5431 let url = params.parse_with_url(&url);
5432
5433 let mut json_mime_type = mime::APPLICATION_JSON;
5434 let mut request_value_reader = {
5435 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5436 common::remove_json_null_values(&mut value);
5437 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5438 serde_json::to_writer(&mut dst, &value).unwrap();
5439 dst
5440 };
5441 let request_size = request_value_reader
5442 .seek(std::io::SeekFrom::End(0))
5443 .unwrap();
5444 request_value_reader
5445 .seek(std::io::SeekFrom::Start(0))
5446 .unwrap();
5447
5448 loop {
5449 let token = match self
5450 .hub
5451 .auth
5452 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5453 .await
5454 {
5455 Ok(token) => token,
5456 Err(e) => match dlg.token(e) {
5457 Ok(token) => token,
5458 Err(e) => {
5459 dlg.finished(false);
5460 return Err(common::Error::MissingToken(e));
5461 }
5462 },
5463 };
5464 request_value_reader
5465 .seek(std::io::SeekFrom::Start(0))
5466 .unwrap();
5467 let mut req_result = {
5468 let client = &self.hub.client;
5469 dlg.pre_request();
5470 let mut req_builder = hyper::Request::builder()
5471 .method(hyper::Method::POST)
5472 .uri(url.as_str())
5473 .header(USER_AGENT, self.hub._user_agent.clone());
5474
5475 if let Some(token) = token.as_ref() {
5476 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5477 }
5478
5479 let request = req_builder
5480 .header(CONTENT_TYPE, json_mime_type.to_string())
5481 .header(CONTENT_LENGTH, request_size as u64)
5482 .body(common::to_body(
5483 request_value_reader.get_ref().clone().into(),
5484 ));
5485
5486 client.request(request.unwrap()).await
5487 };
5488
5489 match req_result {
5490 Err(err) => {
5491 if let common::Retry::After(d) = dlg.http_error(&err) {
5492 sleep(d).await;
5493 continue;
5494 }
5495 dlg.finished(false);
5496 return Err(common::Error::HttpError(err));
5497 }
5498 Ok(res) => {
5499 let (mut parts, body) = res.into_parts();
5500 let mut body = common::Body::new(body);
5501 if !parts.status.is_success() {
5502 let bytes = common::to_bytes(body).await.unwrap_or_default();
5503 let error = serde_json::from_str(&common::to_string(&bytes));
5504 let response = common::to_response(parts, bytes.into());
5505
5506 if let common::Retry::After(d) =
5507 dlg.http_failure(&response, error.as_ref().ok())
5508 {
5509 sleep(d).await;
5510 continue;
5511 }
5512
5513 dlg.finished(false);
5514
5515 return Err(match error {
5516 Ok(value) => common::Error::BadRequest(value),
5517 _ => common::Error::Failure(response),
5518 });
5519 }
5520 let response = {
5521 let bytes = common::to_bytes(body).await.unwrap_or_default();
5522 let encoded = common::to_string(&bytes);
5523 match serde_json::from_str(&encoded) {
5524 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5525 Err(error) => {
5526 dlg.response_json_decode_error(&encoded, &error);
5527 return Err(common::Error::JsonDecodeError(
5528 encoded.to_string(),
5529 error,
5530 ));
5531 }
5532 }
5533 };
5534
5535 dlg.finished(true);
5536 return Ok(response);
5537 }
5538 }
5539 }
5540 }
5541
5542 ///
5543 /// Sets the *request* property to the given value.
5544 ///
5545 /// Even though the property as already been set when instantiating this call,
5546 /// we provide this method for API completeness.
5547 pub fn request(
5548 mut self,
5549 new_value: GoogleCloudRecaptchaenterpriseV1Key,
5550 ) -> ProjectKeyCreateCall<'a, C> {
5551 self._request = new_value;
5552 self
5553 }
5554 /// Required. The name of the project in which the key is created, in the format `projects/{project}`.
5555 ///
5556 /// Sets the *parent* path property to the given value.
5557 ///
5558 /// Even though the property as already been set when instantiating this call,
5559 /// we provide this method for API completeness.
5560 pub fn parent(mut self, new_value: &str) -> ProjectKeyCreateCall<'a, C> {
5561 self._parent = new_value.to_string();
5562 self
5563 }
5564 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5565 /// while executing the actual API request.
5566 ///
5567 /// ````text
5568 /// It should be used to handle progress information, and to implement a certain level of resilience.
5569 /// ````
5570 ///
5571 /// Sets the *delegate* property to the given value.
5572 pub fn delegate(
5573 mut self,
5574 new_value: &'a mut dyn common::Delegate,
5575 ) -> ProjectKeyCreateCall<'a, C> {
5576 self._delegate = Some(new_value);
5577 self
5578 }
5579
5580 /// Set any additional parameter of the query string used in the request.
5581 /// It should be used to set parameters which are not yet available through their own
5582 /// setters.
5583 ///
5584 /// Please note that this method must not be used to set any of the known parameters
5585 /// which have their own setter method. If done anyway, the request will fail.
5586 ///
5587 /// # Additional Parameters
5588 ///
5589 /// * *$.xgafv* (query-string) - V1 error format.
5590 /// * *access_token* (query-string) - OAuth access token.
5591 /// * *alt* (query-string) - Data format for response.
5592 /// * *callback* (query-string) - JSONP
5593 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5594 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5595 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5596 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5597 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5598 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5599 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5600 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyCreateCall<'a, C>
5601 where
5602 T: AsRef<str>,
5603 {
5604 self._additional_params
5605 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5606 self
5607 }
5608
5609 /// Identifies the authorization scope for the method you are building.
5610 ///
5611 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5612 /// [`Scope::CloudPlatform`].
5613 ///
5614 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5615 /// tokens for more than one scope.
5616 ///
5617 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5618 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5619 /// sufficient, a read-write scope will do as well.
5620 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyCreateCall<'a, C>
5621 where
5622 St: AsRef<str>,
5623 {
5624 self._scopes.insert(String::from(scope.as_ref()));
5625 self
5626 }
5627 /// Identifies the authorization scope(s) for the method you are building.
5628 ///
5629 /// See [`Self::add_scope()`] for details.
5630 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyCreateCall<'a, C>
5631 where
5632 I: IntoIterator<Item = St>,
5633 St: AsRef<str>,
5634 {
5635 self._scopes
5636 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5637 self
5638 }
5639
5640 /// Removes all scopes, and no default scope will be used either.
5641 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5642 /// for details).
5643 pub fn clear_scopes(mut self) -> ProjectKeyCreateCall<'a, C> {
5644 self._scopes.clear();
5645 self
5646 }
5647}
5648
5649/// Deletes the specified key.
5650///
5651/// A builder for the *keys.delete* method supported by a *project* resource.
5652/// It is not used directly, but through a [`ProjectMethods`] instance.
5653///
5654/// # Example
5655///
5656/// Instantiate a resource method builder
5657///
5658/// ```test_harness,no_run
5659/// # extern crate hyper;
5660/// # extern crate hyper_rustls;
5661/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
5662/// # async fn dox() {
5663/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5664///
5665/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5666/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5667/// # .with_native_roots()
5668/// # .unwrap()
5669/// # .https_only()
5670/// # .enable_http2()
5671/// # .build();
5672///
5673/// # let executor = hyper_util::rt::TokioExecutor::new();
5674/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5675/// # secret,
5676/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5677/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5678/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5679/// # ),
5680/// # ).build().await.unwrap();
5681///
5682/// # let client = hyper_util::client::legacy::Client::builder(
5683/// # hyper_util::rt::TokioExecutor::new()
5684/// # )
5685/// # .build(
5686/// # hyper_rustls::HttpsConnectorBuilder::new()
5687/// # .with_native_roots()
5688/// # .unwrap()
5689/// # .https_or_http()
5690/// # .enable_http2()
5691/// # .build()
5692/// # );
5693/// # let mut hub = RecaptchaEnterprise::new(client, auth);
5694/// // You can configure optional parameters by calling the respective setters at will, and
5695/// // execute the final call using `doit()`.
5696/// // Values shown here are possibly random and not representative !
5697/// let result = hub.projects().keys_delete("name")
5698/// .doit().await;
5699/// # }
5700/// ```
5701pub struct ProjectKeyDeleteCall<'a, C>
5702where
5703 C: 'a,
5704{
5705 hub: &'a RecaptchaEnterprise<C>,
5706 _name: String,
5707 _delegate: Option<&'a mut dyn common::Delegate>,
5708 _additional_params: HashMap<String, String>,
5709 _scopes: BTreeSet<String>,
5710}
5711
5712impl<'a, C> common::CallBuilder for ProjectKeyDeleteCall<'a, C> {}
5713
5714impl<'a, C> ProjectKeyDeleteCall<'a, C>
5715where
5716 C: common::Connector,
5717{
5718 /// Perform the operation you have build so far.
5719 pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
5720 use std::borrow::Cow;
5721 use std::io::{Read, Seek};
5722
5723 use common::{url::Params, ToParts};
5724 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5725
5726 let mut dd = common::DefaultDelegate;
5727 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5728 dlg.begin(common::MethodInfo {
5729 id: "recaptchaenterprise.projects.keys.delete",
5730 http_method: hyper::Method::DELETE,
5731 });
5732
5733 for &field in ["alt", "name"].iter() {
5734 if self._additional_params.contains_key(field) {
5735 dlg.finished(false);
5736 return Err(common::Error::FieldClash(field));
5737 }
5738 }
5739
5740 let mut params = Params::with_capacity(3 + self._additional_params.len());
5741 params.push("name", self._name);
5742
5743 params.extend(self._additional_params.iter());
5744
5745 params.push("alt", "json");
5746 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5747 if self._scopes.is_empty() {
5748 self._scopes
5749 .insert(Scope::CloudPlatform.as_ref().to_string());
5750 }
5751
5752 #[allow(clippy::single_element_loop)]
5753 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5754 url = params.uri_replacement(url, param_name, find_this, true);
5755 }
5756 {
5757 let to_remove = ["name"];
5758 params.remove_params(&to_remove);
5759 }
5760
5761 let url = params.parse_with_url(&url);
5762
5763 loop {
5764 let token = match self
5765 .hub
5766 .auth
5767 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5768 .await
5769 {
5770 Ok(token) => token,
5771 Err(e) => match dlg.token(e) {
5772 Ok(token) => token,
5773 Err(e) => {
5774 dlg.finished(false);
5775 return Err(common::Error::MissingToken(e));
5776 }
5777 },
5778 };
5779 let mut req_result = {
5780 let client = &self.hub.client;
5781 dlg.pre_request();
5782 let mut req_builder = hyper::Request::builder()
5783 .method(hyper::Method::DELETE)
5784 .uri(url.as_str())
5785 .header(USER_AGENT, self.hub._user_agent.clone());
5786
5787 if let Some(token) = token.as_ref() {
5788 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5789 }
5790
5791 let request = req_builder
5792 .header(CONTENT_LENGTH, 0_u64)
5793 .body(common::to_body::<String>(None));
5794
5795 client.request(request.unwrap()).await
5796 };
5797
5798 match req_result {
5799 Err(err) => {
5800 if let common::Retry::After(d) = dlg.http_error(&err) {
5801 sleep(d).await;
5802 continue;
5803 }
5804 dlg.finished(false);
5805 return Err(common::Error::HttpError(err));
5806 }
5807 Ok(res) => {
5808 let (mut parts, body) = res.into_parts();
5809 let mut body = common::Body::new(body);
5810 if !parts.status.is_success() {
5811 let bytes = common::to_bytes(body).await.unwrap_or_default();
5812 let error = serde_json::from_str(&common::to_string(&bytes));
5813 let response = common::to_response(parts, bytes.into());
5814
5815 if let common::Retry::After(d) =
5816 dlg.http_failure(&response, error.as_ref().ok())
5817 {
5818 sleep(d).await;
5819 continue;
5820 }
5821
5822 dlg.finished(false);
5823
5824 return Err(match error {
5825 Ok(value) => common::Error::BadRequest(value),
5826 _ => common::Error::Failure(response),
5827 });
5828 }
5829 let response = {
5830 let bytes = common::to_bytes(body).await.unwrap_or_default();
5831 let encoded = common::to_string(&bytes);
5832 match serde_json::from_str(&encoded) {
5833 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5834 Err(error) => {
5835 dlg.response_json_decode_error(&encoded, &error);
5836 return Err(common::Error::JsonDecodeError(
5837 encoded.to_string(),
5838 error,
5839 ));
5840 }
5841 }
5842 };
5843
5844 dlg.finished(true);
5845 return Ok(response);
5846 }
5847 }
5848 }
5849 }
5850
5851 /// Required. The name of the key to be deleted, in the format `projects/{project}/keys/{key}`.
5852 ///
5853 /// Sets the *name* path property to the given value.
5854 ///
5855 /// Even though the property as already been set when instantiating this call,
5856 /// we provide this method for API completeness.
5857 pub fn name(mut self, new_value: &str) -> ProjectKeyDeleteCall<'a, C> {
5858 self._name = new_value.to_string();
5859 self
5860 }
5861 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5862 /// while executing the actual API request.
5863 ///
5864 /// ````text
5865 /// It should be used to handle progress information, and to implement a certain level of resilience.
5866 /// ````
5867 ///
5868 /// Sets the *delegate* property to the given value.
5869 pub fn delegate(
5870 mut self,
5871 new_value: &'a mut dyn common::Delegate,
5872 ) -> ProjectKeyDeleteCall<'a, C> {
5873 self._delegate = Some(new_value);
5874 self
5875 }
5876
5877 /// Set any additional parameter of the query string used in the request.
5878 /// It should be used to set parameters which are not yet available through their own
5879 /// setters.
5880 ///
5881 /// Please note that this method must not be used to set any of the known parameters
5882 /// which have their own setter method. If done anyway, the request will fail.
5883 ///
5884 /// # Additional Parameters
5885 ///
5886 /// * *$.xgafv* (query-string) - V1 error format.
5887 /// * *access_token* (query-string) - OAuth access token.
5888 /// * *alt* (query-string) - Data format for response.
5889 /// * *callback* (query-string) - JSONP
5890 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5891 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5892 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5893 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5894 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
5895 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5896 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5897 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyDeleteCall<'a, C>
5898 where
5899 T: AsRef<str>,
5900 {
5901 self._additional_params
5902 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5903 self
5904 }
5905
5906 /// Identifies the authorization scope for the method you are building.
5907 ///
5908 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5909 /// [`Scope::CloudPlatform`].
5910 ///
5911 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5912 /// tokens for more than one scope.
5913 ///
5914 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5915 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5916 /// sufficient, a read-write scope will do as well.
5917 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyDeleteCall<'a, C>
5918 where
5919 St: AsRef<str>,
5920 {
5921 self._scopes.insert(String::from(scope.as_ref()));
5922 self
5923 }
5924 /// Identifies the authorization scope(s) for the method you are building.
5925 ///
5926 /// See [`Self::add_scope()`] for details.
5927 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyDeleteCall<'a, C>
5928 where
5929 I: IntoIterator<Item = St>,
5930 St: AsRef<str>,
5931 {
5932 self._scopes
5933 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5934 self
5935 }
5936
5937 /// Removes all scopes, and no default scope will be used either.
5938 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5939 /// for details).
5940 pub fn clear_scopes(mut self) -> ProjectKeyDeleteCall<'a, C> {
5941 self._scopes.clear();
5942 self
5943 }
5944}
5945
5946/// Returns the specified key.
5947///
5948/// A builder for the *keys.get* method supported by a *project* resource.
5949/// It is not used directly, but through a [`ProjectMethods`] instance.
5950///
5951/// # Example
5952///
5953/// Instantiate a resource method builder
5954///
5955/// ```test_harness,no_run
5956/// # extern crate hyper;
5957/// # extern crate hyper_rustls;
5958/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
5959/// # async fn dox() {
5960/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5961///
5962/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5963/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5964/// # .with_native_roots()
5965/// # .unwrap()
5966/// # .https_only()
5967/// # .enable_http2()
5968/// # .build();
5969///
5970/// # let executor = hyper_util::rt::TokioExecutor::new();
5971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5972/// # secret,
5973/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5974/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5975/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5976/// # ),
5977/// # ).build().await.unwrap();
5978///
5979/// # let client = hyper_util::client::legacy::Client::builder(
5980/// # hyper_util::rt::TokioExecutor::new()
5981/// # )
5982/// # .build(
5983/// # hyper_rustls::HttpsConnectorBuilder::new()
5984/// # .with_native_roots()
5985/// # .unwrap()
5986/// # .https_or_http()
5987/// # .enable_http2()
5988/// # .build()
5989/// # );
5990/// # let mut hub = RecaptchaEnterprise::new(client, auth);
5991/// // You can configure optional parameters by calling the respective setters at will, and
5992/// // execute the final call using `doit()`.
5993/// // Values shown here are possibly random and not representative !
5994/// let result = hub.projects().keys_get("name")
5995/// .doit().await;
5996/// # }
5997/// ```
5998pub struct ProjectKeyGetCall<'a, C>
5999where
6000 C: 'a,
6001{
6002 hub: &'a RecaptchaEnterprise<C>,
6003 _name: String,
6004 _delegate: Option<&'a mut dyn common::Delegate>,
6005 _additional_params: HashMap<String, String>,
6006 _scopes: BTreeSet<String>,
6007}
6008
6009impl<'a, C> common::CallBuilder for ProjectKeyGetCall<'a, C> {}
6010
6011impl<'a, C> ProjectKeyGetCall<'a, C>
6012where
6013 C: common::Connector,
6014{
6015 /// Perform the operation you have build so far.
6016 pub async fn doit(
6017 mut self,
6018 ) -> common::Result<(common::Response, GoogleCloudRecaptchaenterpriseV1Key)> {
6019 use std::borrow::Cow;
6020 use std::io::{Read, Seek};
6021
6022 use common::{url::Params, ToParts};
6023 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6024
6025 let mut dd = common::DefaultDelegate;
6026 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6027 dlg.begin(common::MethodInfo {
6028 id: "recaptchaenterprise.projects.keys.get",
6029 http_method: hyper::Method::GET,
6030 });
6031
6032 for &field in ["alt", "name"].iter() {
6033 if self._additional_params.contains_key(field) {
6034 dlg.finished(false);
6035 return Err(common::Error::FieldClash(field));
6036 }
6037 }
6038
6039 let mut params = Params::with_capacity(3 + self._additional_params.len());
6040 params.push("name", self._name);
6041
6042 params.extend(self._additional_params.iter());
6043
6044 params.push("alt", "json");
6045 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6046 if self._scopes.is_empty() {
6047 self._scopes
6048 .insert(Scope::CloudPlatform.as_ref().to_string());
6049 }
6050
6051 #[allow(clippy::single_element_loop)]
6052 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6053 url = params.uri_replacement(url, param_name, find_this, true);
6054 }
6055 {
6056 let to_remove = ["name"];
6057 params.remove_params(&to_remove);
6058 }
6059
6060 let url = params.parse_with_url(&url);
6061
6062 loop {
6063 let token = match self
6064 .hub
6065 .auth
6066 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6067 .await
6068 {
6069 Ok(token) => token,
6070 Err(e) => match dlg.token(e) {
6071 Ok(token) => token,
6072 Err(e) => {
6073 dlg.finished(false);
6074 return Err(common::Error::MissingToken(e));
6075 }
6076 },
6077 };
6078 let mut req_result = {
6079 let client = &self.hub.client;
6080 dlg.pre_request();
6081 let mut req_builder = hyper::Request::builder()
6082 .method(hyper::Method::GET)
6083 .uri(url.as_str())
6084 .header(USER_AGENT, self.hub._user_agent.clone());
6085
6086 if let Some(token) = token.as_ref() {
6087 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6088 }
6089
6090 let request = req_builder
6091 .header(CONTENT_LENGTH, 0_u64)
6092 .body(common::to_body::<String>(None));
6093
6094 client.request(request.unwrap()).await
6095 };
6096
6097 match req_result {
6098 Err(err) => {
6099 if let common::Retry::After(d) = dlg.http_error(&err) {
6100 sleep(d).await;
6101 continue;
6102 }
6103 dlg.finished(false);
6104 return Err(common::Error::HttpError(err));
6105 }
6106 Ok(res) => {
6107 let (mut parts, body) = res.into_parts();
6108 let mut body = common::Body::new(body);
6109 if !parts.status.is_success() {
6110 let bytes = common::to_bytes(body).await.unwrap_or_default();
6111 let error = serde_json::from_str(&common::to_string(&bytes));
6112 let response = common::to_response(parts, bytes.into());
6113
6114 if let common::Retry::After(d) =
6115 dlg.http_failure(&response, error.as_ref().ok())
6116 {
6117 sleep(d).await;
6118 continue;
6119 }
6120
6121 dlg.finished(false);
6122
6123 return Err(match error {
6124 Ok(value) => common::Error::BadRequest(value),
6125 _ => common::Error::Failure(response),
6126 });
6127 }
6128 let response = {
6129 let bytes = common::to_bytes(body).await.unwrap_or_default();
6130 let encoded = common::to_string(&bytes);
6131 match serde_json::from_str(&encoded) {
6132 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6133 Err(error) => {
6134 dlg.response_json_decode_error(&encoded, &error);
6135 return Err(common::Error::JsonDecodeError(
6136 encoded.to_string(),
6137 error,
6138 ));
6139 }
6140 }
6141 };
6142
6143 dlg.finished(true);
6144 return Ok(response);
6145 }
6146 }
6147 }
6148 }
6149
6150 /// Required. The name of the requested key, in the format `projects/{project}/keys/{key}`.
6151 ///
6152 /// Sets the *name* path property to the given value.
6153 ///
6154 /// Even though the property as already been set when instantiating this call,
6155 /// we provide this method for API completeness.
6156 pub fn name(mut self, new_value: &str) -> ProjectKeyGetCall<'a, C> {
6157 self._name = new_value.to_string();
6158 self
6159 }
6160 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6161 /// while executing the actual API request.
6162 ///
6163 /// ````text
6164 /// It should be used to handle progress information, and to implement a certain level of resilience.
6165 /// ````
6166 ///
6167 /// Sets the *delegate* property to the given value.
6168 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectKeyGetCall<'a, C> {
6169 self._delegate = Some(new_value);
6170 self
6171 }
6172
6173 /// Set any additional parameter of the query string used in the request.
6174 /// It should be used to set parameters which are not yet available through their own
6175 /// setters.
6176 ///
6177 /// Please note that this method must not be used to set any of the known parameters
6178 /// which have their own setter method. If done anyway, the request will fail.
6179 ///
6180 /// # Additional Parameters
6181 ///
6182 /// * *$.xgafv* (query-string) - V1 error format.
6183 /// * *access_token* (query-string) - OAuth access token.
6184 /// * *alt* (query-string) - Data format for response.
6185 /// * *callback* (query-string) - JSONP
6186 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6187 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6188 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6189 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6190 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6191 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6192 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6193 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyGetCall<'a, C>
6194 where
6195 T: AsRef<str>,
6196 {
6197 self._additional_params
6198 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6199 self
6200 }
6201
6202 /// Identifies the authorization scope for the method you are building.
6203 ///
6204 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6205 /// [`Scope::CloudPlatform`].
6206 ///
6207 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6208 /// tokens for more than one scope.
6209 ///
6210 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6211 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6212 /// sufficient, a read-write scope will do as well.
6213 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyGetCall<'a, C>
6214 where
6215 St: AsRef<str>,
6216 {
6217 self._scopes.insert(String::from(scope.as_ref()));
6218 self
6219 }
6220 /// Identifies the authorization scope(s) for the method you are building.
6221 ///
6222 /// See [`Self::add_scope()`] for details.
6223 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyGetCall<'a, C>
6224 where
6225 I: IntoIterator<Item = St>,
6226 St: AsRef<str>,
6227 {
6228 self._scopes
6229 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6230 self
6231 }
6232
6233 /// Removes all scopes, and no default scope will be used either.
6234 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6235 /// for details).
6236 pub fn clear_scopes(mut self) -> ProjectKeyGetCall<'a, C> {
6237 self._scopes.clear();
6238 self
6239 }
6240}
6241
6242/// Get some aggregated metrics for a Key. This data can be used to build dashboards.
6243///
6244/// A builder for the *keys.getMetrics* method supported by a *project* resource.
6245/// It is not used directly, but through a [`ProjectMethods`] instance.
6246///
6247/// # Example
6248///
6249/// Instantiate a resource method builder
6250///
6251/// ```test_harness,no_run
6252/// # extern crate hyper;
6253/// # extern crate hyper_rustls;
6254/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
6255/// # async fn dox() {
6256/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6257///
6258/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6259/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6260/// # .with_native_roots()
6261/// # .unwrap()
6262/// # .https_only()
6263/// # .enable_http2()
6264/// # .build();
6265///
6266/// # let executor = hyper_util::rt::TokioExecutor::new();
6267/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6268/// # secret,
6269/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6270/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6271/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6272/// # ),
6273/// # ).build().await.unwrap();
6274///
6275/// # let client = hyper_util::client::legacy::Client::builder(
6276/// # hyper_util::rt::TokioExecutor::new()
6277/// # )
6278/// # .build(
6279/// # hyper_rustls::HttpsConnectorBuilder::new()
6280/// # .with_native_roots()
6281/// # .unwrap()
6282/// # .https_or_http()
6283/// # .enable_http2()
6284/// # .build()
6285/// # );
6286/// # let mut hub = RecaptchaEnterprise::new(client, auth);
6287/// // You can configure optional parameters by calling the respective setters at will, and
6288/// // execute the final call using `doit()`.
6289/// // Values shown here are possibly random and not representative !
6290/// let result = hub.projects().keys_get_metrics("name")
6291/// .doit().await;
6292/// # }
6293/// ```
6294pub struct ProjectKeyGetMetricCall<'a, C>
6295where
6296 C: 'a,
6297{
6298 hub: &'a RecaptchaEnterprise<C>,
6299 _name: String,
6300 _delegate: Option<&'a mut dyn common::Delegate>,
6301 _additional_params: HashMap<String, String>,
6302 _scopes: BTreeSet<String>,
6303}
6304
6305impl<'a, C> common::CallBuilder for ProjectKeyGetMetricCall<'a, C> {}
6306
6307impl<'a, C> ProjectKeyGetMetricCall<'a, C>
6308where
6309 C: common::Connector,
6310{
6311 /// Perform the operation you have build so far.
6312 pub async fn doit(
6313 mut self,
6314 ) -> common::Result<(common::Response, GoogleCloudRecaptchaenterpriseV1Metrics)> {
6315 use std::borrow::Cow;
6316 use std::io::{Read, Seek};
6317
6318 use common::{url::Params, ToParts};
6319 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6320
6321 let mut dd = common::DefaultDelegate;
6322 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6323 dlg.begin(common::MethodInfo {
6324 id: "recaptchaenterprise.projects.keys.getMetrics",
6325 http_method: hyper::Method::GET,
6326 });
6327
6328 for &field in ["alt", "name"].iter() {
6329 if self._additional_params.contains_key(field) {
6330 dlg.finished(false);
6331 return Err(common::Error::FieldClash(field));
6332 }
6333 }
6334
6335 let mut params = Params::with_capacity(3 + self._additional_params.len());
6336 params.push("name", self._name);
6337
6338 params.extend(self._additional_params.iter());
6339
6340 params.push("alt", "json");
6341 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6342 if self._scopes.is_empty() {
6343 self._scopes
6344 .insert(Scope::CloudPlatform.as_ref().to_string());
6345 }
6346
6347 #[allow(clippy::single_element_loop)]
6348 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6349 url = params.uri_replacement(url, param_name, find_this, true);
6350 }
6351 {
6352 let to_remove = ["name"];
6353 params.remove_params(&to_remove);
6354 }
6355
6356 let url = params.parse_with_url(&url);
6357
6358 loop {
6359 let token = match self
6360 .hub
6361 .auth
6362 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6363 .await
6364 {
6365 Ok(token) => token,
6366 Err(e) => match dlg.token(e) {
6367 Ok(token) => token,
6368 Err(e) => {
6369 dlg.finished(false);
6370 return Err(common::Error::MissingToken(e));
6371 }
6372 },
6373 };
6374 let mut req_result = {
6375 let client = &self.hub.client;
6376 dlg.pre_request();
6377 let mut req_builder = hyper::Request::builder()
6378 .method(hyper::Method::GET)
6379 .uri(url.as_str())
6380 .header(USER_AGENT, self.hub._user_agent.clone());
6381
6382 if let Some(token) = token.as_ref() {
6383 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6384 }
6385
6386 let request = req_builder
6387 .header(CONTENT_LENGTH, 0_u64)
6388 .body(common::to_body::<String>(None));
6389
6390 client.request(request.unwrap()).await
6391 };
6392
6393 match req_result {
6394 Err(err) => {
6395 if let common::Retry::After(d) = dlg.http_error(&err) {
6396 sleep(d).await;
6397 continue;
6398 }
6399 dlg.finished(false);
6400 return Err(common::Error::HttpError(err));
6401 }
6402 Ok(res) => {
6403 let (mut parts, body) = res.into_parts();
6404 let mut body = common::Body::new(body);
6405 if !parts.status.is_success() {
6406 let bytes = common::to_bytes(body).await.unwrap_or_default();
6407 let error = serde_json::from_str(&common::to_string(&bytes));
6408 let response = common::to_response(parts, bytes.into());
6409
6410 if let common::Retry::After(d) =
6411 dlg.http_failure(&response, error.as_ref().ok())
6412 {
6413 sleep(d).await;
6414 continue;
6415 }
6416
6417 dlg.finished(false);
6418
6419 return Err(match error {
6420 Ok(value) => common::Error::BadRequest(value),
6421 _ => common::Error::Failure(response),
6422 });
6423 }
6424 let response = {
6425 let bytes = common::to_bytes(body).await.unwrap_or_default();
6426 let encoded = common::to_string(&bytes);
6427 match serde_json::from_str(&encoded) {
6428 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6429 Err(error) => {
6430 dlg.response_json_decode_error(&encoded, &error);
6431 return Err(common::Error::JsonDecodeError(
6432 encoded.to_string(),
6433 error,
6434 ));
6435 }
6436 }
6437 };
6438
6439 dlg.finished(true);
6440 return Ok(response);
6441 }
6442 }
6443 }
6444 }
6445
6446 /// Required. The name of the requested metrics, in the format `projects/{project}/keys/{key}/metrics`.
6447 ///
6448 /// Sets the *name* path property to the given value.
6449 ///
6450 /// Even though the property as already been set when instantiating this call,
6451 /// we provide this method for API completeness.
6452 pub fn name(mut self, new_value: &str) -> ProjectKeyGetMetricCall<'a, C> {
6453 self._name = new_value.to_string();
6454 self
6455 }
6456 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6457 /// while executing the actual API request.
6458 ///
6459 /// ````text
6460 /// It should be used to handle progress information, and to implement a certain level of resilience.
6461 /// ````
6462 ///
6463 /// Sets the *delegate* property to the given value.
6464 pub fn delegate(
6465 mut self,
6466 new_value: &'a mut dyn common::Delegate,
6467 ) -> ProjectKeyGetMetricCall<'a, C> {
6468 self._delegate = Some(new_value);
6469 self
6470 }
6471
6472 /// Set any additional parameter of the query string used in the request.
6473 /// It should be used to set parameters which are not yet available through their own
6474 /// setters.
6475 ///
6476 /// Please note that this method must not be used to set any of the known parameters
6477 /// which have their own setter method. If done anyway, the request will fail.
6478 ///
6479 /// # Additional Parameters
6480 ///
6481 /// * *$.xgafv* (query-string) - V1 error format.
6482 /// * *access_token* (query-string) - OAuth access token.
6483 /// * *alt* (query-string) - Data format for response.
6484 /// * *callback* (query-string) - JSONP
6485 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6486 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6487 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6488 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6489 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6490 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6491 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6492 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyGetMetricCall<'a, C>
6493 where
6494 T: AsRef<str>,
6495 {
6496 self._additional_params
6497 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6498 self
6499 }
6500
6501 /// Identifies the authorization scope for the method you are building.
6502 ///
6503 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6504 /// [`Scope::CloudPlatform`].
6505 ///
6506 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6507 /// tokens for more than one scope.
6508 ///
6509 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6510 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6511 /// sufficient, a read-write scope will do as well.
6512 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyGetMetricCall<'a, C>
6513 where
6514 St: AsRef<str>,
6515 {
6516 self._scopes.insert(String::from(scope.as_ref()));
6517 self
6518 }
6519 /// Identifies the authorization scope(s) for the method you are building.
6520 ///
6521 /// See [`Self::add_scope()`] for details.
6522 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyGetMetricCall<'a, C>
6523 where
6524 I: IntoIterator<Item = St>,
6525 St: AsRef<str>,
6526 {
6527 self._scopes
6528 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6529 self
6530 }
6531
6532 /// Removes all scopes, and no default scope will be used either.
6533 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6534 /// for details).
6535 pub fn clear_scopes(mut self) -> ProjectKeyGetMetricCall<'a, C> {
6536 self._scopes.clear();
6537 self
6538 }
6539}
6540
6541/// Returns the list of all keys that belong to a project.
6542///
6543/// A builder for the *keys.list* method supported by a *project* resource.
6544/// It is not used directly, but through a [`ProjectMethods`] instance.
6545///
6546/// # Example
6547///
6548/// Instantiate a resource method builder
6549///
6550/// ```test_harness,no_run
6551/// # extern crate hyper;
6552/// # extern crate hyper_rustls;
6553/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
6554/// # async fn dox() {
6555/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6556///
6557/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6558/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6559/// # .with_native_roots()
6560/// # .unwrap()
6561/// # .https_only()
6562/// # .enable_http2()
6563/// # .build();
6564///
6565/// # let executor = hyper_util::rt::TokioExecutor::new();
6566/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6567/// # secret,
6568/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6569/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6570/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6571/// # ),
6572/// # ).build().await.unwrap();
6573///
6574/// # let client = hyper_util::client::legacy::Client::builder(
6575/// # hyper_util::rt::TokioExecutor::new()
6576/// # )
6577/// # .build(
6578/// # hyper_rustls::HttpsConnectorBuilder::new()
6579/// # .with_native_roots()
6580/// # .unwrap()
6581/// # .https_or_http()
6582/// # .enable_http2()
6583/// # .build()
6584/// # );
6585/// # let mut hub = RecaptchaEnterprise::new(client, auth);
6586/// // You can configure optional parameters by calling the respective setters at will, and
6587/// // execute the final call using `doit()`.
6588/// // Values shown here are possibly random and not representative !
6589/// let result = hub.projects().keys_list("parent")
6590/// .page_token("ipsum")
6591/// .page_size(-88)
6592/// .doit().await;
6593/// # }
6594/// ```
6595pub struct ProjectKeyListCall<'a, C>
6596where
6597 C: 'a,
6598{
6599 hub: &'a RecaptchaEnterprise<C>,
6600 _parent: String,
6601 _page_token: Option<String>,
6602 _page_size: Option<i32>,
6603 _delegate: Option<&'a mut dyn common::Delegate>,
6604 _additional_params: HashMap<String, String>,
6605 _scopes: BTreeSet<String>,
6606}
6607
6608impl<'a, C> common::CallBuilder for ProjectKeyListCall<'a, C> {}
6609
6610impl<'a, C> ProjectKeyListCall<'a, C>
6611where
6612 C: common::Connector,
6613{
6614 /// Perform the operation you have build so far.
6615 pub async fn doit(
6616 mut self,
6617 ) -> common::Result<(
6618 common::Response,
6619 GoogleCloudRecaptchaenterpriseV1ListKeysResponse,
6620 )> {
6621 use std::borrow::Cow;
6622 use std::io::{Read, Seek};
6623
6624 use common::{url::Params, ToParts};
6625 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6626
6627 let mut dd = common::DefaultDelegate;
6628 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6629 dlg.begin(common::MethodInfo {
6630 id: "recaptchaenterprise.projects.keys.list",
6631 http_method: hyper::Method::GET,
6632 });
6633
6634 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6635 if self._additional_params.contains_key(field) {
6636 dlg.finished(false);
6637 return Err(common::Error::FieldClash(field));
6638 }
6639 }
6640
6641 let mut params = Params::with_capacity(5 + self._additional_params.len());
6642 params.push("parent", self._parent);
6643 if let Some(value) = self._page_token.as_ref() {
6644 params.push("pageToken", value);
6645 }
6646 if let Some(value) = self._page_size.as_ref() {
6647 params.push("pageSize", value.to_string());
6648 }
6649
6650 params.extend(self._additional_params.iter());
6651
6652 params.push("alt", "json");
6653 let mut url = self.hub._base_url.clone() + "v1/{+parent}/keys";
6654 if self._scopes.is_empty() {
6655 self._scopes
6656 .insert(Scope::CloudPlatform.as_ref().to_string());
6657 }
6658
6659 #[allow(clippy::single_element_loop)]
6660 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6661 url = params.uri_replacement(url, param_name, find_this, true);
6662 }
6663 {
6664 let to_remove = ["parent"];
6665 params.remove_params(&to_remove);
6666 }
6667
6668 let url = params.parse_with_url(&url);
6669
6670 loop {
6671 let token = match self
6672 .hub
6673 .auth
6674 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6675 .await
6676 {
6677 Ok(token) => token,
6678 Err(e) => match dlg.token(e) {
6679 Ok(token) => token,
6680 Err(e) => {
6681 dlg.finished(false);
6682 return Err(common::Error::MissingToken(e));
6683 }
6684 },
6685 };
6686 let mut req_result = {
6687 let client = &self.hub.client;
6688 dlg.pre_request();
6689 let mut req_builder = hyper::Request::builder()
6690 .method(hyper::Method::GET)
6691 .uri(url.as_str())
6692 .header(USER_AGENT, self.hub._user_agent.clone());
6693
6694 if let Some(token) = token.as_ref() {
6695 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6696 }
6697
6698 let request = req_builder
6699 .header(CONTENT_LENGTH, 0_u64)
6700 .body(common::to_body::<String>(None));
6701
6702 client.request(request.unwrap()).await
6703 };
6704
6705 match req_result {
6706 Err(err) => {
6707 if let common::Retry::After(d) = dlg.http_error(&err) {
6708 sleep(d).await;
6709 continue;
6710 }
6711 dlg.finished(false);
6712 return Err(common::Error::HttpError(err));
6713 }
6714 Ok(res) => {
6715 let (mut parts, body) = res.into_parts();
6716 let mut body = common::Body::new(body);
6717 if !parts.status.is_success() {
6718 let bytes = common::to_bytes(body).await.unwrap_or_default();
6719 let error = serde_json::from_str(&common::to_string(&bytes));
6720 let response = common::to_response(parts, bytes.into());
6721
6722 if let common::Retry::After(d) =
6723 dlg.http_failure(&response, error.as_ref().ok())
6724 {
6725 sleep(d).await;
6726 continue;
6727 }
6728
6729 dlg.finished(false);
6730
6731 return Err(match error {
6732 Ok(value) => common::Error::BadRequest(value),
6733 _ => common::Error::Failure(response),
6734 });
6735 }
6736 let response = {
6737 let bytes = common::to_bytes(body).await.unwrap_or_default();
6738 let encoded = common::to_string(&bytes);
6739 match serde_json::from_str(&encoded) {
6740 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6741 Err(error) => {
6742 dlg.response_json_decode_error(&encoded, &error);
6743 return Err(common::Error::JsonDecodeError(
6744 encoded.to_string(),
6745 error,
6746 ));
6747 }
6748 }
6749 };
6750
6751 dlg.finished(true);
6752 return Ok(response);
6753 }
6754 }
6755 }
6756 }
6757
6758 /// Required. The name of the project that contains the keys that is listed, in the format `projects/{project}`.
6759 ///
6760 /// Sets the *parent* path property to the given value.
6761 ///
6762 /// Even though the property as already been set when instantiating this call,
6763 /// we provide this method for API completeness.
6764 pub fn parent(mut self, new_value: &str) -> ProjectKeyListCall<'a, C> {
6765 self._parent = new_value.to_string();
6766 self
6767 }
6768 /// Optional. The next_page_token value returned from a previous. ListKeysRequest, if any.
6769 ///
6770 /// Sets the *page token* query property to the given value.
6771 pub fn page_token(mut self, new_value: &str) -> ProjectKeyListCall<'a, C> {
6772 self._page_token = Some(new_value.to_string());
6773 self
6774 }
6775 /// Optional. The maximum number of keys to return. Default is 10. Max limit is 1000.
6776 ///
6777 /// Sets the *page size* query property to the given value.
6778 pub fn page_size(mut self, new_value: i32) -> ProjectKeyListCall<'a, C> {
6779 self._page_size = Some(new_value);
6780 self
6781 }
6782 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6783 /// while executing the actual API request.
6784 ///
6785 /// ````text
6786 /// It should be used to handle progress information, and to implement a certain level of resilience.
6787 /// ````
6788 ///
6789 /// Sets the *delegate* property to the given value.
6790 pub fn delegate(
6791 mut self,
6792 new_value: &'a mut dyn common::Delegate,
6793 ) -> ProjectKeyListCall<'a, C> {
6794 self._delegate = Some(new_value);
6795 self
6796 }
6797
6798 /// Set any additional parameter of the query string used in the request.
6799 /// It should be used to set parameters which are not yet available through their own
6800 /// setters.
6801 ///
6802 /// Please note that this method must not be used to set any of the known parameters
6803 /// which have their own setter method. If done anyway, the request will fail.
6804 ///
6805 /// # Additional Parameters
6806 ///
6807 /// * *$.xgafv* (query-string) - V1 error format.
6808 /// * *access_token* (query-string) - OAuth access token.
6809 /// * *alt* (query-string) - Data format for response.
6810 /// * *callback* (query-string) - JSONP
6811 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6812 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6813 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6814 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6815 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
6816 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6817 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6818 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyListCall<'a, C>
6819 where
6820 T: AsRef<str>,
6821 {
6822 self._additional_params
6823 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6824 self
6825 }
6826
6827 /// Identifies the authorization scope for the method you are building.
6828 ///
6829 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6830 /// [`Scope::CloudPlatform`].
6831 ///
6832 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6833 /// tokens for more than one scope.
6834 ///
6835 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6836 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6837 /// sufficient, a read-write scope will do as well.
6838 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyListCall<'a, C>
6839 where
6840 St: AsRef<str>,
6841 {
6842 self._scopes.insert(String::from(scope.as_ref()));
6843 self
6844 }
6845 /// Identifies the authorization scope(s) for the method you are building.
6846 ///
6847 /// See [`Self::add_scope()`] for details.
6848 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyListCall<'a, C>
6849 where
6850 I: IntoIterator<Item = St>,
6851 St: AsRef<str>,
6852 {
6853 self._scopes
6854 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6855 self
6856 }
6857
6858 /// Removes all scopes, and no default scope will be used either.
6859 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6860 /// for details).
6861 pub fn clear_scopes(mut self) -> ProjectKeyListCall<'a, C> {
6862 self._scopes.clear();
6863 self
6864 }
6865}
6866
6867/// Lists all IP overrides for a key.
6868///
6869/// A builder for the *keys.listIpOverrides* method supported by a *project* resource.
6870/// It is not used directly, but through a [`ProjectMethods`] instance.
6871///
6872/// # Example
6873///
6874/// Instantiate a resource method builder
6875///
6876/// ```test_harness,no_run
6877/// # extern crate hyper;
6878/// # extern crate hyper_rustls;
6879/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
6880/// # async fn dox() {
6881/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6882///
6883/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6884/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6885/// # .with_native_roots()
6886/// # .unwrap()
6887/// # .https_only()
6888/// # .enable_http2()
6889/// # .build();
6890///
6891/// # let executor = hyper_util::rt::TokioExecutor::new();
6892/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6893/// # secret,
6894/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6895/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6896/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6897/// # ),
6898/// # ).build().await.unwrap();
6899///
6900/// # let client = hyper_util::client::legacy::Client::builder(
6901/// # hyper_util::rt::TokioExecutor::new()
6902/// # )
6903/// # .build(
6904/// # hyper_rustls::HttpsConnectorBuilder::new()
6905/// # .with_native_roots()
6906/// # .unwrap()
6907/// # .https_or_http()
6908/// # .enable_http2()
6909/// # .build()
6910/// # );
6911/// # let mut hub = RecaptchaEnterprise::new(client, auth);
6912/// // You can configure optional parameters by calling the respective setters at will, and
6913/// // execute the final call using `doit()`.
6914/// // Values shown here are possibly random and not representative !
6915/// let result = hub.projects().keys_list_ip_overrides("parent")
6916/// .page_token("duo")
6917/// .page_size(-50)
6918/// .doit().await;
6919/// # }
6920/// ```
6921pub struct ProjectKeyListIpOverrideCall<'a, C>
6922where
6923 C: 'a,
6924{
6925 hub: &'a RecaptchaEnterprise<C>,
6926 _parent: String,
6927 _page_token: Option<String>,
6928 _page_size: Option<i32>,
6929 _delegate: Option<&'a mut dyn common::Delegate>,
6930 _additional_params: HashMap<String, String>,
6931 _scopes: BTreeSet<String>,
6932}
6933
6934impl<'a, C> common::CallBuilder for ProjectKeyListIpOverrideCall<'a, C> {}
6935
6936impl<'a, C> ProjectKeyListIpOverrideCall<'a, C>
6937where
6938 C: common::Connector,
6939{
6940 /// Perform the operation you have build so far.
6941 pub async fn doit(
6942 mut self,
6943 ) -> common::Result<(
6944 common::Response,
6945 GoogleCloudRecaptchaenterpriseV1ListIpOverridesResponse,
6946 )> {
6947 use std::borrow::Cow;
6948 use std::io::{Read, Seek};
6949
6950 use common::{url::Params, ToParts};
6951 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6952
6953 let mut dd = common::DefaultDelegate;
6954 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6955 dlg.begin(common::MethodInfo {
6956 id: "recaptchaenterprise.projects.keys.listIpOverrides",
6957 http_method: hyper::Method::GET,
6958 });
6959
6960 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6961 if self._additional_params.contains_key(field) {
6962 dlg.finished(false);
6963 return Err(common::Error::FieldClash(field));
6964 }
6965 }
6966
6967 let mut params = Params::with_capacity(5 + self._additional_params.len());
6968 params.push("parent", self._parent);
6969 if let Some(value) = self._page_token.as_ref() {
6970 params.push("pageToken", value);
6971 }
6972 if let Some(value) = self._page_size.as_ref() {
6973 params.push("pageSize", value.to_string());
6974 }
6975
6976 params.extend(self._additional_params.iter());
6977
6978 params.push("alt", "json");
6979 let mut url = self.hub._base_url.clone() + "v1/{+parent}:listIpOverrides";
6980 if self._scopes.is_empty() {
6981 self._scopes
6982 .insert(Scope::CloudPlatform.as_ref().to_string());
6983 }
6984
6985 #[allow(clippy::single_element_loop)]
6986 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6987 url = params.uri_replacement(url, param_name, find_this, true);
6988 }
6989 {
6990 let to_remove = ["parent"];
6991 params.remove_params(&to_remove);
6992 }
6993
6994 let url = params.parse_with_url(&url);
6995
6996 loop {
6997 let token = match self
6998 .hub
6999 .auth
7000 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7001 .await
7002 {
7003 Ok(token) => token,
7004 Err(e) => match dlg.token(e) {
7005 Ok(token) => token,
7006 Err(e) => {
7007 dlg.finished(false);
7008 return Err(common::Error::MissingToken(e));
7009 }
7010 },
7011 };
7012 let mut req_result = {
7013 let client = &self.hub.client;
7014 dlg.pre_request();
7015 let mut req_builder = hyper::Request::builder()
7016 .method(hyper::Method::GET)
7017 .uri(url.as_str())
7018 .header(USER_AGENT, self.hub._user_agent.clone());
7019
7020 if let Some(token) = token.as_ref() {
7021 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7022 }
7023
7024 let request = req_builder
7025 .header(CONTENT_LENGTH, 0_u64)
7026 .body(common::to_body::<String>(None));
7027
7028 client.request(request.unwrap()).await
7029 };
7030
7031 match req_result {
7032 Err(err) => {
7033 if let common::Retry::After(d) = dlg.http_error(&err) {
7034 sleep(d).await;
7035 continue;
7036 }
7037 dlg.finished(false);
7038 return Err(common::Error::HttpError(err));
7039 }
7040 Ok(res) => {
7041 let (mut parts, body) = res.into_parts();
7042 let mut body = common::Body::new(body);
7043 if !parts.status.is_success() {
7044 let bytes = common::to_bytes(body).await.unwrap_or_default();
7045 let error = serde_json::from_str(&common::to_string(&bytes));
7046 let response = common::to_response(parts, bytes.into());
7047
7048 if let common::Retry::After(d) =
7049 dlg.http_failure(&response, error.as_ref().ok())
7050 {
7051 sleep(d).await;
7052 continue;
7053 }
7054
7055 dlg.finished(false);
7056
7057 return Err(match error {
7058 Ok(value) => common::Error::BadRequest(value),
7059 _ => common::Error::Failure(response),
7060 });
7061 }
7062 let response = {
7063 let bytes = common::to_bytes(body).await.unwrap_or_default();
7064 let encoded = common::to_string(&bytes);
7065 match serde_json::from_str(&encoded) {
7066 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7067 Err(error) => {
7068 dlg.response_json_decode_error(&encoded, &error);
7069 return Err(common::Error::JsonDecodeError(
7070 encoded.to_string(),
7071 error,
7072 ));
7073 }
7074 }
7075 };
7076
7077 dlg.finished(true);
7078 return Ok(response);
7079 }
7080 }
7081 }
7082 }
7083
7084 /// Required. The parent key for which the IP overrides are listed, in the format `projects/{project}/keys/{key}`.
7085 ///
7086 /// Sets the *parent* path property to the given value.
7087 ///
7088 /// Even though the property as already been set when instantiating this call,
7089 /// we provide this method for API completeness.
7090 pub fn parent(mut self, new_value: &str) -> ProjectKeyListIpOverrideCall<'a, C> {
7091 self._parent = new_value.to_string();
7092 self
7093 }
7094 /// Optional. The next_page_token value returned from a previous ListIpOverridesRequest, if any.
7095 ///
7096 /// Sets the *page token* query property to the given value.
7097 pub fn page_token(mut self, new_value: &str) -> ProjectKeyListIpOverrideCall<'a, C> {
7098 self._page_token = Some(new_value.to_string());
7099 self
7100 }
7101 /// Optional. The maximum number of overrides to return. Default is 10. Max limit is 100. If the number of overrides is less than the page_size, all overrides are returned. If the page size is more than 100, it is coerced to 100.
7102 ///
7103 /// Sets the *page size* query property to the given value.
7104 pub fn page_size(mut self, new_value: i32) -> ProjectKeyListIpOverrideCall<'a, C> {
7105 self._page_size = Some(new_value);
7106 self
7107 }
7108 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7109 /// while executing the actual API request.
7110 ///
7111 /// ````text
7112 /// It should be used to handle progress information, and to implement a certain level of resilience.
7113 /// ````
7114 ///
7115 /// Sets the *delegate* property to the given value.
7116 pub fn delegate(
7117 mut self,
7118 new_value: &'a mut dyn common::Delegate,
7119 ) -> ProjectKeyListIpOverrideCall<'a, C> {
7120 self._delegate = Some(new_value);
7121 self
7122 }
7123
7124 /// Set any additional parameter of the query string used in the request.
7125 /// It should be used to set parameters which are not yet available through their own
7126 /// setters.
7127 ///
7128 /// Please note that this method must not be used to set any of the known parameters
7129 /// which have their own setter method. If done anyway, the request will fail.
7130 ///
7131 /// # Additional Parameters
7132 ///
7133 /// * *$.xgafv* (query-string) - V1 error format.
7134 /// * *access_token* (query-string) - OAuth access token.
7135 /// * *alt* (query-string) - Data format for response.
7136 /// * *callback* (query-string) - JSONP
7137 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7138 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7139 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7140 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7141 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7142 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7143 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7144 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyListIpOverrideCall<'a, C>
7145 where
7146 T: AsRef<str>,
7147 {
7148 self._additional_params
7149 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7150 self
7151 }
7152
7153 /// Identifies the authorization scope for the method you are building.
7154 ///
7155 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7156 /// [`Scope::CloudPlatform`].
7157 ///
7158 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7159 /// tokens for more than one scope.
7160 ///
7161 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7162 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7163 /// sufficient, a read-write scope will do as well.
7164 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyListIpOverrideCall<'a, C>
7165 where
7166 St: AsRef<str>,
7167 {
7168 self._scopes.insert(String::from(scope.as_ref()));
7169 self
7170 }
7171 /// Identifies the authorization scope(s) for the method you are building.
7172 ///
7173 /// See [`Self::add_scope()`] for details.
7174 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyListIpOverrideCall<'a, C>
7175 where
7176 I: IntoIterator<Item = St>,
7177 St: AsRef<str>,
7178 {
7179 self._scopes
7180 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7181 self
7182 }
7183
7184 /// Removes all scopes, and no default scope will be used either.
7185 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7186 /// for details).
7187 pub fn clear_scopes(mut self) -> ProjectKeyListIpOverrideCall<'a, C> {
7188 self._scopes.clear();
7189 self
7190 }
7191}
7192
7193/// Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one of the current owners of the reCAPTCHA Key, and your user must have the reCAPTCHA Enterprise Admin IAM role in the destination project.
7194///
7195/// A builder for the *keys.migrate* method supported by a *project* resource.
7196/// It is not used directly, but through a [`ProjectMethods`] instance.
7197///
7198/// # Example
7199///
7200/// Instantiate a resource method builder
7201///
7202/// ```test_harness,no_run
7203/// # extern crate hyper;
7204/// # extern crate hyper_rustls;
7205/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
7206/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1MigrateKeyRequest;
7207/// # async fn dox() {
7208/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7209///
7210/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7211/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7212/// # .with_native_roots()
7213/// # .unwrap()
7214/// # .https_only()
7215/// # .enable_http2()
7216/// # .build();
7217///
7218/// # let executor = hyper_util::rt::TokioExecutor::new();
7219/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7220/// # secret,
7221/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7222/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7223/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7224/// # ),
7225/// # ).build().await.unwrap();
7226///
7227/// # let client = hyper_util::client::legacy::Client::builder(
7228/// # hyper_util::rt::TokioExecutor::new()
7229/// # )
7230/// # .build(
7231/// # hyper_rustls::HttpsConnectorBuilder::new()
7232/// # .with_native_roots()
7233/// # .unwrap()
7234/// # .https_or_http()
7235/// # .enable_http2()
7236/// # .build()
7237/// # );
7238/// # let mut hub = RecaptchaEnterprise::new(client, auth);
7239/// // As the method needs a request, you would usually fill it with the desired information
7240/// // into the respective structure. Some of the parts shown here might not be applicable !
7241/// // Values shown here are possibly random and not representative !
7242/// let mut req = GoogleCloudRecaptchaenterpriseV1MigrateKeyRequest::default();
7243///
7244/// // You can configure optional parameters by calling the respective setters at will, and
7245/// // execute the final call using `doit()`.
7246/// // Values shown here are possibly random and not representative !
7247/// let result = hub.projects().keys_migrate(req, "name")
7248/// .doit().await;
7249/// # }
7250/// ```
7251pub struct ProjectKeyMigrateCall<'a, C>
7252where
7253 C: 'a,
7254{
7255 hub: &'a RecaptchaEnterprise<C>,
7256 _request: GoogleCloudRecaptchaenterpriseV1MigrateKeyRequest,
7257 _name: String,
7258 _delegate: Option<&'a mut dyn common::Delegate>,
7259 _additional_params: HashMap<String, String>,
7260 _scopes: BTreeSet<String>,
7261}
7262
7263impl<'a, C> common::CallBuilder for ProjectKeyMigrateCall<'a, C> {}
7264
7265impl<'a, C> ProjectKeyMigrateCall<'a, C>
7266where
7267 C: common::Connector,
7268{
7269 /// Perform the operation you have build so far.
7270 pub async fn doit(
7271 mut self,
7272 ) -> common::Result<(common::Response, GoogleCloudRecaptchaenterpriseV1Key)> {
7273 use std::borrow::Cow;
7274 use std::io::{Read, Seek};
7275
7276 use common::{url::Params, ToParts};
7277 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7278
7279 let mut dd = common::DefaultDelegate;
7280 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7281 dlg.begin(common::MethodInfo {
7282 id: "recaptchaenterprise.projects.keys.migrate",
7283 http_method: hyper::Method::POST,
7284 });
7285
7286 for &field in ["alt", "name"].iter() {
7287 if self._additional_params.contains_key(field) {
7288 dlg.finished(false);
7289 return Err(common::Error::FieldClash(field));
7290 }
7291 }
7292
7293 let mut params = Params::with_capacity(4 + self._additional_params.len());
7294 params.push("name", self._name);
7295
7296 params.extend(self._additional_params.iter());
7297
7298 params.push("alt", "json");
7299 let mut url = self.hub._base_url.clone() + "v1/{+name}:migrate";
7300 if self._scopes.is_empty() {
7301 self._scopes
7302 .insert(Scope::CloudPlatform.as_ref().to_string());
7303 }
7304
7305 #[allow(clippy::single_element_loop)]
7306 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7307 url = params.uri_replacement(url, param_name, find_this, true);
7308 }
7309 {
7310 let to_remove = ["name"];
7311 params.remove_params(&to_remove);
7312 }
7313
7314 let url = params.parse_with_url(&url);
7315
7316 let mut json_mime_type = mime::APPLICATION_JSON;
7317 let mut request_value_reader = {
7318 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7319 common::remove_json_null_values(&mut value);
7320 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7321 serde_json::to_writer(&mut dst, &value).unwrap();
7322 dst
7323 };
7324 let request_size = request_value_reader
7325 .seek(std::io::SeekFrom::End(0))
7326 .unwrap();
7327 request_value_reader
7328 .seek(std::io::SeekFrom::Start(0))
7329 .unwrap();
7330
7331 loop {
7332 let token = match self
7333 .hub
7334 .auth
7335 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7336 .await
7337 {
7338 Ok(token) => token,
7339 Err(e) => match dlg.token(e) {
7340 Ok(token) => token,
7341 Err(e) => {
7342 dlg.finished(false);
7343 return Err(common::Error::MissingToken(e));
7344 }
7345 },
7346 };
7347 request_value_reader
7348 .seek(std::io::SeekFrom::Start(0))
7349 .unwrap();
7350 let mut req_result = {
7351 let client = &self.hub.client;
7352 dlg.pre_request();
7353 let mut req_builder = hyper::Request::builder()
7354 .method(hyper::Method::POST)
7355 .uri(url.as_str())
7356 .header(USER_AGENT, self.hub._user_agent.clone());
7357
7358 if let Some(token) = token.as_ref() {
7359 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7360 }
7361
7362 let request = req_builder
7363 .header(CONTENT_TYPE, json_mime_type.to_string())
7364 .header(CONTENT_LENGTH, request_size as u64)
7365 .body(common::to_body(
7366 request_value_reader.get_ref().clone().into(),
7367 ));
7368
7369 client.request(request.unwrap()).await
7370 };
7371
7372 match req_result {
7373 Err(err) => {
7374 if let common::Retry::After(d) = dlg.http_error(&err) {
7375 sleep(d).await;
7376 continue;
7377 }
7378 dlg.finished(false);
7379 return Err(common::Error::HttpError(err));
7380 }
7381 Ok(res) => {
7382 let (mut parts, body) = res.into_parts();
7383 let mut body = common::Body::new(body);
7384 if !parts.status.is_success() {
7385 let bytes = common::to_bytes(body).await.unwrap_or_default();
7386 let error = serde_json::from_str(&common::to_string(&bytes));
7387 let response = common::to_response(parts, bytes.into());
7388
7389 if let common::Retry::After(d) =
7390 dlg.http_failure(&response, error.as_ref().ok())
7391 {
7392 sleep(d).await;
7393 continue;
7394 }
7395
7396 dlg.finished(false);
7397
7398 return Err(match error {
7399 Ok(value) => common::Error::BadRequest(value),
7400 _ => common::Error::Failure(response),
7401 });
7402 }
7403 let response = {
7404 let bytes = common::to_bytes(body).await.unwrap_or_default();
7405 let encoded = common::to_string(&bytes);
7406 match serde_json::from_str(&encoded) {
7407 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7408 Err(error) => {
7409 dlg.response_json_decode_error(&encoded, &error);
7410 return Err(common::Error::JsonDecodeError(
7411 encoded.to_string(),
7412 error,
7413 ));
7414 }
7415 }
7416 };
7417
7418 dlg.finished(true);
7419 return Ok(response);
7420 }
7421 }
7422 }
7423 }
7424
7425 ///
7426 /// Sets the *request* property to the given value.
7427 ///
7428 /// Even though the property as already been set when instantiating this call,
7429 /// we provide this method for API completeness.
7430 pub fn request(
7431 mut self,
7432 new_value: GoogleCloudRecaptchaenterpriseV1MigrateKeyRequest,
7433 ) -> ProjectKeyMigrateCall<'a, C> {
7434 self._request = new_value;
7435 self
7436 }
7437 /// Required. The name of the key to be migrated, in the format `projects/{project}/keys/{key}`.
7438 ///
7439 /// Sets the *name* path property to the given value.
7440 ///
7441 /// Even though the property as already been set when instantiating this call,
7442 /// we provide this method for API completeness.
7443 pub fn name(mut self, new_value: &str) -> ProjectKeyMigrateCall<'a, C> {
7444 self._name = new_value.to_string();
7445 self
7446 }
7447 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7448 /// while executing the actual API request.
7449 ///
7450 /// ````text
7451 /// It should be used to handle progress information, and to implement a certain level of resilience.
7452 /// ````
7453 ///
7454 /// Sets the *delegate* property to the given value.
7455 pub fn delegate(
7456 mut self,
7457 new_value: &'a mut dyn common::Delegate,
7458 ) -> ProjectKeyMigrateCall<'a, C> {
7459 self._delegate = Some(new_value);
7460 self
7461 }
7462
7463 /// Set any additional parameter of the query string used in the request.
7464 /// It should be used to set parameters which are not yet available through their own
7465 /// setters.
7466 ///
7467 /// Please note that this method must not be used to set any of the known parameters
7468 /// which have their own setter method. If done anyway, the request will fail.
7469 ///
7470 /// # Additional Parameters
7471 ///
7472 /// * *$.xgafv* (query-string) - V1 error format.
7473 /// * *access_token* (query-string) - OAuth access token.
7474 /// * *alt* (query-string) - Data format for response.
7475 /// * *callback* (query-string) - JSONP
7476 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7477 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7478 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7479 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7480 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7481 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7482 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7483 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyMigrateCall<'a, C>
7484 where
7485 T: AsRef<str>,
7486 {
7487 self._additional_params
7488 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7489 self
7490 }
7491
7492 /// Identifies the authorization scope for the method you are building.
7493 ///
7494 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7495 /// [`Scope::CloudPlatform`].
7496 ///
7497 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7498 /// tokens for more than one scope.
7499 ///
7500 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7501 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7502 /// sufficient, a read-write scope will do as well.
7503 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyMigrateCall<'a, C>
7504 where
7505 St: AsRef<str>,
7506 {
7507 self._scopes.insert(String::from(scope.as_ref()));
7508 self
7509 }
7510 /// Identifies the authorization scope(s) for the method you are building.
7511 ///
7512 /// See [`Self::add_scope()`] for details.
7513 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyMigrateCall<'a, C>
7514 where
7515 I: IntoIterator<Item = St>,
7516 St: AsRef<str>,
7517 {
7518 self._scopes
7519 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7520 self
7521 }
7522
7523 /// Removes all scopes, and no default scope will be used either.
7524 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7525 /// for details).
7526 pub fn clear_scopes(mut self) -> ProjectKeyMigrateCall<'a, C> {
7527 self._scopes.clear();
7528 self
7529 }
7530}
7531
7532/// Updates the specified key.
7533///
7534/// A builder for the *keys.patch* method supported by a *project* resource.
7535/// It is not used directly, but through a [`ProjectMethods`] instance.
7536///
7537/// # Example
7538///
7539/// Instantiate a resource method builder
7540///
7541/// ```test_harness,no_run
7542/// # extern crate hyper;
7543/// # extern crate hyper_rustls;
7544/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
7545/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1Key;
7546/// # async fn dox() {
7547/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7548///
7549/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7550/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7551/// # .with_native_roots()
7552/// # .unwrap()
7553/// # .https_only()
7554/// # .enable_http2()
7555/// # .build();
7556///
7557/// # let executor = hyper_util::rt::TokioExecutor::new();
7558/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7559/// # secret,
7560/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7561/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7562/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7563/// # ),
7564/// # ).build().await.unwrap();
7565///
7566/// # let client = hyper_util::client::legacy::Client::builder(
7567/// # hyper_util::rt::TokioExecutor::new()
7568/// # )
7569/// # .build(
7570/// # hyper_rustls::HttpsConnectorBuilder::new()
7571/// # .with_native_roots()
7572/// # .unwrap()
7573/// # .https_or_http()
7574/// # .enable_http2()
7575/// # .build()
7576/// # );
7577/// # let mut hub = RecaptchaEnterprise::new(client, auth);
7578/// // As the method needs a request, you would usually fill it with the desired information
7579/// // into the respective structure. Some of the parts shown here might not be applicable !
7580/// // Values shown here are possibly random and not representative !
7581/// let mut req = GoogleCloudRecaptchaenterpriseV1Key::default();
7582///
7583/// // You can configure optional parameters by calling the respective setters at will, and
7584/// // execute the final call using `doit()`.
7585/// // Values shown here are possibly random and not representative !
7586/// let result = hub.projects().keys_patch(req, "name")
7587/// .update_mask(FieldMask::new::<&str>(&[]))
7588/// .doit().await;
7589/// # }
7590/// ```
7591pub struct ProjectKeyPatchCall<'a, C>
7592where
7593 C: 'a,
7594{
7595 hub: &'a RecaptchaEnterprise<C>,
7596 _request: GoogleCloudRecaptchaenterpriseV1Key,
7597 _name: String,
7598 _update_mask: Option<common::FieldMask>,
7599 _delegate: Option<&'a mut dyn common::Delegate>,
7600 _additional_params: HashMap<String, String>,
7601 _scopes: BTreeSet<String>,
7602}
7603
7604impl<'a, C> common::CallBuilder for ProjectKeyPatchCall<'a, C> {}
7605
7606impl<'a, C> ProjectKeyPatchCall<'a, C>
7607where
7608 C: common::Connector,
7609{
7610 /// Perform the operation you have build so far.
7611 pub async fn doit(
7612 mut self,
7613 ) -> common::Result<(common::Response, GoogleCloudRecaptchaenterpriseV1Key)> {
7614 use std::borrow::Cow;
7615 use std::io::{Read, Seek};
7616
7617 use common::{url::Params, ToParts};
7618 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7619
7620 let mut dd = common::DefaultDelegate;
7621 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7622 dlg.begin(common::MethodInfo {
7623 id: "recaptchaenterprise.projects.keys.patch",
7624 http_method: hyper::Method::PATCH,
7625 });
7626
7627 for &field in ["alt", "name", "updateMask"].iter() {
7628 if self._additional_params.contains_key(field) {
7629 dlg.finished(false);
7630 return Err(common::Error::FieldClash(field));
7631 }
7632 }
7633
7634 let mut params = Params::with_capacity(5 + self._additional_params.len());
7635 params.push("name", self._name);
7636 if let Some(value) = self._update_mask.as_ref() {
7637 params.push("updateMask", value.to_string());
7638 }
7639
7640 params.extend(self._additional_params.iter());
7641
7642 params.push("alt", "json");
7643 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7644 if self._scopes.is_empty() {
7645 self._scopes
7646 .insert(Scope::CloudPlatform.as_ref().to_string());
7647 }
7648
7649 #[allow(clippy::single_element_loop)]
7650 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7651 url = params.uri_replacement(url, param_name, find_this, true);
7652 }
7653 {
7654 let to_remove = ["name"];
7655 params.remove_params(&to_remove);
7656 }
7657
7658 let url = params.parse_with_url(&url);
7659
7660 let mut json_mime_type = mime::APPLICATION_JSON;
7661 let mut request_value_reader = {
7662 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7663 common::remove_json_null_values(&mut value);
7664 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7665 serde_json::to_writer(&mut dst, &value).unwrap();
7666 dst
7667 };
7668 let request_size = request_value_reader
7669 .seek(std::io::SeekFrom::End(0))
7670 .unwrap();
7671 request_value_reader
7672 .seek(std::io::SeekFrom::Start(0))
7673 .unwrap();
7674
7675 loop {
7676 let token = match self
7677 .hub
7678 .auth
7679 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7680 .await
7681 {
7682 Ok(token) => token,
7683 Err(e) => match dlg.token(e) {
7684 Ok(token) => token,
7685 Err(e) => {
7686 dlg.finished(false);
7687 return Err(common::Error::MissingToken(e));
7688 }
7689 },
7690 };
7691 request_value_reader
7692 .seek(std::io::SeekFrom::Start(0))
7693 .unwrap();
7694 let mut req_result = {
7695 let client = &self.hub.client;
7696 dlg.pre_request();
7697 let mut req_builder = hyper::Request::builder()
7698 .method(hyper::Method::PATCH)
7699 .uri(url.as_str())
7700 .header(USER_AGENT, self.hub._user_agent.clone());
7701
7702 if let Some(token) = token.as_ref() {
7703 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7704 }
7705
7706 let request = req_builder
7707 .header(CONTENT_TYPE, json_mime_type.to_string())
7708 .header(CONTENT_LENGTH, request_size as u64)
7709 .body(common::to_body(
7710 request_value_reader.get_ref().clone().into(),
7711 ));
7712
7713 client.request(request.unwrap()).await
7714 };
7715
7716 match req_result {
7717 Err(err) => {
7718 if let common::Retry::After(d) = dlg.http_error(&err) {
7719 sleep(d).await;
7720 continue;
7721 }
7722 dlg.finished(false);
7723 return Err(common::Error::HttpError(err));
7724 }
7725 Ok(res) => {
7726 let (mut parts, body) = res.into_parts();
7727 let mut body = common::Body::new(body);
7728 if !parts.status.is_success() {
7729 let bytes = common::to_bytes(body).await.unwrap_or_default();
7730 let error = serde_json::from_str(&common::to_string(&bytes));
7731 let response = common::to_response(parts, bytes.into());
7732
7733 if let common::Retry::After(d) =
7734 dlg.http_failure(&response, error.as_ref().ok())
7735 {
7736 sleep(d).await;
7737 continue;
7738 }
7739
7740 dlg.finished(false);
7741
7742 return Err(match error {
7743 Ok(value) => common::Error::BadRequest(value),
7744 _ => common::Error::Failure(response),
7745 });
7746 }
7747 let response = {
7748 let bytes = common::to_bytes(body).await.unwrap_or_default();
7749 let encoded = common::to_string(&bytes);
7750 match serde_json::from_str(&encoded) {
7751 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7752 Err(error) => {
7753 dlg.response_json_decode_error(&encoded, &error);
7754 return Err(common::Error::JsonDecodeError(
7755 encoded.to_string(),
7756 error,
7757 ));
7758 }
7759 }
7760 };
7761
7762 dlg.finished(true);
7763 return Ok(response);
7764 }
7765 }
7766 }
7767 }
7768
7769 ///
7770 /// Sets the *request* property to the given value.
7771 ///
7772 /// Even though the property as already been set when instantiating this call,
7773 /// we provide this method for API completeness.
7774 pub fn request(
7775 mut self,
7776 new_value: GoogleCloudRecaptchaenterpriseV1Key,
7777 ) -> ProjectKeyPatchCall<'a, C> {
7778 self._request = new_value;
7779 self
7780 }
7781 /// Identifier. The resource name for the Key in the format `projects/{project}/keys/{key}`.
7782 ///
7783 /// Sets the *name* path property to the given value.
7784 ///
7785 /// Even though the property as already been set when instantiating this call,
7786 /// we provide this method for API completeness.
7787 pub fn name(mut self, new_value: &str) -> ProjectKeyPatchCall<'a, C> {
7788 self._name = new_value.to_string();
7789 self
7790 }
7791 /// Optional. The mask to control which fields of the key get updated. If the mask is not present, all fields are updated.
7792 ///
7793 /// Sets the *update mask* query property to the given value.
7794 pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectKeyPatchCall<'a, C> {
7795 self._update_mask = Some(new_value);
7796 self
7797 }
7798 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7799 /// while executing the actual API request.
7800 ///
7801 /// ````text
7802 /// It should be used to handle progress information, and to implement a certain level of resilience.
7803 /// ````
7804 ///
7805 /// Sets the *delegate* property to the given value.
7806 pub fn delegate(
7807 mut self,
7808 new_value: &'a mut dyn common::Delegate,
7809 ) -> ProjectKeyPatchCall<'a, C> {
7810 self._delegate = Some(new_value);
7811 self
7812 }
7813
7814 /// Set any additional parameter of the query string used in the request.
7815 /// It should be used to set parameters which are not yet available through their own
7816 /// setters.
7817 ///
7818 /// Please note that this method must not be used to set any of the known parameters
7819 /// which have their own setter method. If done anyway, the request will fail.
7820 ///
7821 /// # Additional Parameters
7822 ///
7823 /// * *$.xgafv* (query-string) - V1 error format.
7824 /// * *access_token* (query-string) - OAuth access token.
7825 /// * *alt* (query-string) - Data format for response.
7826 /// * *callback* (query-string) - JSONP
7827 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7828 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7829 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7830 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7831 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
7832 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7833 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7834 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyPatchCall<'a, C>
7835 where
7836 T: AsRef<str>,
7837 {
7838 self._additional_params
7839 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7840 self
7841 }
7842
7843 /// Identifies the authorization scope for the method you are building.
7844 ///
7845 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7846 /// [`Scope::CloudPlatform`].
7847 ///
7848 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7849 /// tokens for more than one scope.
7850 ///
7851 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7852 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7853 /// sufficient, a read-write scope will do as well.
7854 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyPatchCall<'a, C>
7855 where
7856 St: AsRef<str>,
7857 {
7858 self._scopes.insert(String::from(scope.as_ref()));
7859 self
7860 }
7861 /// Identifies the authorization scope(s) for the method you are building.
7862 ///
7863 /// See [`Self::add_scope()`] for details.
7864 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyPatchCall<'a, C>
7865 where
7866 I: IntoIterator<Item = St>,
7867 St: AsRef<str>,
7868 {
7869 self._scopes
7870 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7871 self
7872 }
7873
7874 /// Removes all scopes, and no default scope will be used either.
7875 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7876 /// for details).
7877 pub fn clear_scopes(mut self) -> ProjectKeyPatchCall<'a, C> {
7878 self._scopes.clear();
7879 self
7880 }
7881}
7882
7883/// Removes an IP override from a key. The following restrictions hold: * If the IP isn't found in an existing IP override, a `NOT_FOUND` error is returned. * If the IP is found in an existing IP override, but the override type does not match, a `NOT_FOUND` error is returned.
7884///
7885/// A builder for the *keys.removeIpOverride* method supported by a *project* resource.
7886/// It is not used directly, but through a [`ProjectMethods`] instance.
7887///
7888/// # Example
7889///
7890/// Instantiate a resource method builder
7891///
7892/// ```test_harness,no_run
7893/// # extern crate hyper;
7894/// # extern crate hyper_rustls;
7895/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
7896/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideRequest;
7897/// # async fn dox() {
7898/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7899///
7900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7901/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7902/// # .with_native_roots()
7903/// # .unwrap()
7904/// # .https_only()
7905/// # .enable_http2()
7906/// # .build();
7907///
7908/// # let executor = hyper_util::rt::TokioExecutor::new();
7909/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7910/// # secret,
7911/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7912/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7913/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7914/// # ),
7915/// # ).build().await.unwrap();
7916///
7917/// # let client = hyper_util::client::legacy::Client::builder(
7918/// # hyper_util::rt::TokioExecutor::new()
7919/// # )
7920/// # .build(
7921/// # hyper_rustls::HttpsConnectorBuilder::new()
7922/// # .with_native_roots()
7923/// # .unwrap()
7924/// # .https_or_http()
7925/// # .enable_http2()
7926/// # .build()
7927/// # );
7928/// # let mut hub = RecaptchaEnterprise::new(client, auth);
7929/// // As the method needs a request, you would usually fill it with the desired information
7930/// // into the respective structure. Some of the parts shown here might not be applicable !
7931/// // Values shown here are possibly random and not representative !
7932/// let mut req = GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideRequest::default();
7933///
7934/// // You can configure optional parameters by calling the respective setters at will, and
7935/// // execute the final call using `doit()`.
7936/// // Values shown here are possibly random and not representative !
7937/// let result = hub.projects().keys_remove_ip_override(req, "name")
7938/// .doit().await;
7939/// # }
7940/// ```
7941pub struct ProjectKeyRemoveIpOverrideCall<'a, C>
7942where
7943 C: 'a,
7944{
7945 hub: &'a RecaptchaEnterprise<C>,
7946 _request: GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideRequest,
7947 _name: String,
7948 _delegate: Option<&'a mut dyn common::Delegate>,
7949 _additional_params: HashMap<String, String>,
7950 _scopes: BTreeSet<String>,
7951}
7952
7953impl<'a, C> common::CallBuilder for ProjectKeyRemoveIpOverrideCall<'a, C> {}
7954
7955impl<'a, C> ProjectKeyRemoveIpOverrideCall<'a, C>
7956where
7957 C: common::Connector,
7958{
7959 /// Perform the operation you have build so far.
7960 pub async fn doit(
7961 mut self,
7962 ) -> common::Result<(
7963 common::Response,
7964 GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideResponse,
7965 )> {
7966 use std::borrow::Cow;
7967 use std::io::{Read, Seek};
7968
7969 use common::{url::Params, ToParts};
7970 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7971
7972 let mut dd = common::DefaultDelegate;
7973 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7974 dlg.begin(common::MethodInfo {
7975 id: "recaptchaenterprise.projects.keys.removeIpOverride",
7976 http_method: hyper::Method::POST,
7977 });
7978
7979 for &field in ["alt", "name"].iter() {
7980 if self._additional_params.contains_key(field) {
7981 dlg.finished(false);
7982 return Err(common::Error::FieldClash(field));
7983 }
7984 }
7985
7986 let mut params = Params::with_capacity(4 + self._additional_params.len());
7987 params.push("name", self._name);
7988
7989 params.extend(self._additional_params.iter());
7990
7991 params.push("alt", "json");
7992 let mut url = self.hub._base_url.clone() + "v1/{+name}:removeIpOverride";
7993 if self._scopes.is_empty() {
7994 self._scopes
7995 .insert(Scope::CloudPlatform.as_ref().to_string());
7996 }
7997
7998 #[allow(clippy::single_element_loop)]
7999 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8000 url = params.uri_replacement(url, param_name, find_this, true);
8001 }
8002 {
8003 let to_remove = ["name"];
8004 params.remove_params(&to_remove);
8005 }
8006
8007 let url = params.parse_with_url(&url);
8008
8009 let mut json_mime_type = mime::APPLICATION_JSON;
8010 let mut request_value_reader = {
8011 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8012 common::remove_json_null_values(&mut value);
8013 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8014 serde_json::to_writer(&mut dst, &value).unwrap();
8015 dst
8016 };
8017 let request_size = request_value_reader
8018 .seek(std::io::SeekFrom::End(0))
8019 .unwrap();
8020 request_value_reader
8021 .seek(std::io::SeekFrom::Start(0))
8022 .unwrap();
8023
8024 loop {
8025 let token = match self
8026 .hub
8027 .auth
8028 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8029 .await
8030 {
8031 Ok(token) => token,
8032 Err(e) => match dlg.token(e) {
8033 Ok(token) => token,
8034 Err(e) => {
8035 dlg.finished(false);
8036 return Err(common::Error::MissingToken(e));
8037 }
8038 },
8039 };
8040 request_value_reader
8041 .seek(std::io::SeekFrom::Start(0))
8042 .unwrap();
8043 let mut req_result = {
8044 let client = &self.hub.client;
8045 dlg.pre_request();
8046 let mut req_builder = hyper::Request::builder()
8047 .method(hyper::Method::POST)
8048 .uri(url.as_str())
8049 .header(USER_AGENT, self.hub._user_agent.clone());
8050
8051 if let Some(token) = token.as_ref() {
8052 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8053 }
8054
8055 let request = req_builder
8056 .header(CONTENT_TYPE, json_mime_type.to_string())
8057 .header(CONTENT_LENGTH, request_size as u64)
8058 .body(common::to_body(
8059 request_value_reader.get_ref().clone().into(),
8060 ));
8061
8062 client.request(request.unwrap()).await
8063 };
8064
8065 match req_result {
8066 Err(err) => {
8067 if let common::Retry::After(d) = dlg.http_error(&err) {
8068 sleep(d).await;
8069 continue;
8070 }
8071 dlg.finished(false);
8072 return Err(common::Error::HttpError(err));
8073 }
8074 Ok(res) => {
8075 let (mut parts, body) = res.into_parts();
8076 let mut body = common::Body::new(body);
8077 if !parts.status.is_success() {
8078 let bytes = common::to_bytes(body).await.unwrap_or_default();
8079 let error = serde_json::from_str(&common::to_string(&bytes));
8080 let response = common::to_response(parts, bytes.into());
8081
8082 if let common::Retry::After(d) =
8083 dlg.http_failure(&response, error.as_ref().ok())
8084 {
8085 sleep(d).await;
8086 continue;
8087 }
8088
8089 dlg.finished(false);
8090
8091 return Err(match error {
8092 Ok(value) => common::Error::BadRequest(value),
8093 _ => common::Error::Failure(response),
8094 });
8095 }
8096 let response = {
8097 let bytes = common::to_bytes(body).await.unwrap_or_default();
8098 let encoded = common::to_string(&bytes);
8099 match serde_json::from_str(&encoded) {
8100 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8101 Err(error) => {
8102 dlg.response_json_decode_error(&encoded, &error);
8103 return Err(common::Error::JsonDecodeError(
8104 encoded.to_string(),
8105 error,
8106 ));
8107 }
8108 }
8109 };
8110
8111 dlg.finished(true);
8112 return Ok(response);
8113 }
8114 }
8115 }
8116 }
8117
8118 ///
8119 /// Sets the *request* property to the given value.
8120 ///
8121 /// Even though the property as already been set when instantiating this call,
8122 /// we provide this method for API completeness.
8123 pub fn request(
8124 mut self,
8125 new_value: GoogleCloudRecaptchaenterpriseV1RemoveIpOverrideRequest,
8126 ) -> ProjectKeyRemoveIpOverrideCall<'a, C> {
8127 self._request = new_value;
8128 self
8129 }
8130 /// Required. The name of the key from which the IP override is removed, in the format `projects/{project}/keys/{key}`.
8131 ///
8132 /// Sets the *name* path property to the given value.
8133 ///
8134 /// Even though the property as already been set when instantiating this call,
8135 /// we provide this method for API completeness.
8136 pub fn name(mut self, new_value: &str) -> ProjectKeyRemoveIpOverrideCall<'a, C> {
8137 self._name = new_value.to_string();
8138 self
8139 }
8140 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8141 /// while executing the actual API request.
8142 ///
8143 /// ````text
8144 /// It should be used to handle progress information, and to implement a certain level of resilience.
8145 /// ````
8146 ///
8147 /// Sets the *delegate* property to the given value.
8148 pub fn delegate(
8149 mut self,
8150 new_value: &'a mut dyn common::Delegate,
8151 ) -> ProjectKeyRemoveIpOverrideCall<'a, C> {
8152 self._delegate = Some(new_value);
8153 self
8154 }
8155
8156 /// Set any additional parameter of the query string used in the request.
8157 /// It should be used to set parameters which are not yet available through their own
8158 /// setters.
8159 ///
8160 /// Please note that this method must not be used to set any of the known parameters
8161 /// which have their own setter method. If done anyway, the request will fail.
8162 ///
8163 /// # Additional Parameters
8164 ///
8165 /// * *$.xgafv* (query-string) - V1 error format.
8166 /// * *access_token* (query-string) - OAuth access token.
8167 /// * *alt* (query-string) - Data format for response.
8168 /// * *callback* (query-string) - JSONP
8169 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8170 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8171 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8172 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8173 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8174 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8175 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8176 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyRemoveIpOverrideCall<'a, C>
8177 where
8178 T: AsRef<str>,
8179 {
8180 self._additional_params
8181 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8182 self
8183 }
8184
8185 /// Identifies the authorization scope for the method you are building.
8186 ///
8187 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8188 /// [`Scope::CloudPlatform`].
8189 ///
8190 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8191 /// tokens for more than one scope.
8192 ///
8193 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8194 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8195 /// sufficient, a read-write scope will do as well.
8196 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyRemoveIpOverrideCall<'a, C>
8197 where
8198 St: AsRef<str>,
8199 {
8200 self._scopes.insert(String::from(scope.as_ref()));
8201 self
8202 }
8203 /// Identifies the authorization scope(s) for the method you are building.
8204 ///
8205 /// See [`Self::add_scope()`] for details.
8206 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyRemoveIpOverrideCall<'a, C>
8207 where
8208 I: IntoIterator<Item = St>,
8209 St: AsRef<str>,
8210 {
8211 self._scopes
8212 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8213 self
8214 }
8215
8216 /// Removes all scopes, and no default scope will be used either.
8217 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8218 /// for details).
8219 pub fn clear_scopes(mut self) -> ProjectKeyRemoveIpOverrideCall<'a, C> {
8220 self._scopes.clear();
8221 self
8222 }
8223}
8224
8225/// Returns the secret key related to the specified public key. You must use the legacy secret key only in a 3rd party integration with legacy reCAPTCHA.
8226///
8227/// A builder for the *keys.retrieveLegacySecretKey* method supported by a *project* resource.
8228/// It is not used directly, but through a [`ProjectMethods`] instance.
8229///
8230/// # Example
8231///
8232/// Instantiate a resource method builder
8233///
8234/// ```test_harness,no_run
8235/// # extern crate hyper;
8236/// # extern crate hyper_rustls;
8237/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
8238/// # async fn dox() {
8239/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8240///
8241/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8242/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8243/// # .with_native_roots()
8244/// # .unwrap()
8245/// # .https_only()
8246/// # .enable_http2()
8247/// # .build();
8248///
8249/// # let executor = hyper_util::rt::TokioExecutor::new();
8250/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8251/// # secret,
8252/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8253/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8254/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8255/// # ),
8256/// # ).build().await.unwrap();
8257///
8258/// # let client = hyper_util::client::legacy::Client::builder(
8259/// # hyper_util::rt::TokioExecutor::new()
8260/// # )
8261/// # .build(
8262/// # hyper_rustls::HttpsConnectorBuilder::new()
8263/// # .with_native_roots()
8264/// # .unwrap()
8265/// # .https_or_http()
8266/// # .enable_http2()
8267/// # .build()
8268/// # );
8269/// # let mut hub = RecaptchaEnterprise::new(client, auth);
8270/// // You can configure optional parameters by calling the respective setters at will, and
8271/// // execute the final call using `doit()`.
8272/// // Values shown here are possibly random and not representative !
8273/// let result = hub.projects().keys_retrieve_legacy_secret_key("key")
8274/// .doit().await;
8275/// # }
8276/// ```
8277pub struct ProjectKeyRetrieveLegacySecretKeyCall<'a, C>
8278where
8279 C: 'a,
8280{
8281 hub: &'a RecaptchaEnterprise<C>,
8282 _key: String,
8283 _delegate: Option<&'a mut dyn common::Delegate>,
8284 _additional_params: HashMap<String, String>,
8285 _scopes: BTreeSet<String>,
8286}
8287
8288impl<'a, C> common::CallBuilder for ProjectKeyRetrieveLegacySecretKeyCall<'a, C> {}
8289
8290impl<'a, C> ProjectKeyRetrieveLegacySecretKeyCall<'a, C>
8291where
8292 C: common::Connector,
8293{
8294 /// Perform the operation you have build so far.
8295 pub async fn doit(
8296 mut self,
8297 ) -> common::Result<(
8298 common::Response,
8299 GoogleCloudRecaptchaenterpriseV1RetrieveLegacySecretKeyResponse,
8300 )> {
8301 use std::borrow::Cow;
8302 use std::io::{Read, Seek};
8303
8304 use common::{url::Params, ToParts};
8305 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8306
8307 let mut dd = common::DefaultDelegate;
8308 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8309 dlg.begin(common::MethodInfo {
8310 id: "recaptchaenterprise.projects.keys.retrieveLegacySecretKey",
8311 http_method: hyper::Method::GET,
8312 });
8313
8314 for &field in ["alt", "key"].iter() {
8315 if self._additional_params.contains_key(field) {
8316 dlg.finished(false);
8317 return Err(common::Error::FieldClash(field));
8318 }
8319 }
8320
8321 let mut params = Params::with_capacity(3 + self._additional_params.len());
8322 params.push("key", self._key);
8323
8324 params.extend(self._additional_params.iter());
8325
8326 params.push("alt", "json");
8327 let mut url = self.hub._base_url.clone() + "v1/{+key}:retrieveLegacySecretKey";
8328 if self._scopes.is_empty() {
8329 self._scopes
8330 .insert(Scope::CloudPlatform.as_ref().to_string());
8331 }
8332
8333 #[allow(clippy::single_element_loop)]
8334 for &(find_this, param_name) in [("{+key}", "key")].iter() {
8335 url = params.uri_replacement(url, param_name, find_this, true);
8336 }
8337 {
8338 let to_remove = ["key"];
8339 params.remove_params(&to_remove);
8340 }
8341
8342 let url = params.parse_with_url(&url);
8343
8344 loop {
8345 let token = match self
8346 .hub
8347 .auth
8348 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8349 .await
8350 {
8351 Ok(token) => token,
8352 Err(e) => match dlg.token(e) {
8353 Ok(token) => token,
8354 Err(e) => {
8355 dlg.finished(false);
8356 return Err(common::Error::MissingToken(e));
8357 }
8358 },
8359 };
8360 let mut req_result = {
8361 let client = &self.hub.client;
8362 dlg.pre_request();
8363 let mut req_builder = hyper::Request::builder()
8364 .method(hyper::Method::GET)
8365 .uri(url.as_str())
8366 .header(USER_AGENT, self.hub._user_agent.clone());
8367
8368 if let Some(token) = token.as_ref() {
8369 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8370 }
8371
8372 let request = req_builder
8373 .header(CONTENT_LENGTH, 0_u64)
8374 .body(common::to_body::<String>(None));
8375
8376 client.request(request.unwrap()).await
8377 };
8378
8379 match req_result {
8380 Err(err) => {
8381 if let common::Retry::After(d) = dlg.http_error(&err) {
8382 sleep(d).await;
8383 continue;
8384 }
8385 dlg.finished(false);
8386 return Err(common::Error::HttpError(err));
8387 }
8388 Ok(res) => {
8389 let (mut parts, body) = res.into_parts();
8390 let mut body = common::Body::new(body);
8391 if !parts.status.is_success() {
8392 let bytes = common::to_bytes(body).await.unwrap_or_default();
8393 let error = serde_json::from_str(&common::to_string(&bytes));
8394 let response = common::to_response(parts, bytes.into());
8395
8396 if let common::Retry::After(d) =
8397 dlg.http_failure(&response, error.as_ref().ok())
8398 {
8399 sleep(d).await;
8400 continue;
8401 }
8402
8403 dlg.finished(false);
8404
8405 return Err(match error {
8406 Ok(value) => common::Error::BadRequest(value),
8407 _ => common::Error::Failure(response),
8408 });
8409 }
8410 let response = {
8411 let bytes = common::to_bytes(body).await.unwrap_or_default();
8412 let encoded = common::to_string(&bytes);
8413 match serde_json::from_str(&encoded) {
8414 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8415 Err(error) => {
8416 dlg.response_json_decode_error(&encoded, &error);
8417 return Err(common::Error::JsonDecodeError(
8418 encoded.to_string(),
8419 error,
8420 ));
8421 }
8422 }
8423 };
8424
8425 dlg.finished(true);
8426 return Ok(response);
8427 }
8428 }
8429 }
8430 }
8431
8432 /// Required. The public key name linked to the requested secret key in the format `projects/{project}/keys/{key}`.
8433 ///
8434 /// Sets the *key* path property to the given value.
8435 ///
8436 /// Even though the property as already been set when instantiating this call,
8437 /// we provide this method for API completeness.
8438 pub fn key(mut self, new_value: &str) -> ProjectKeyRetrieveLegacySecretKeyCall<'a, C> {
8439 self._key = new_value.to_string();
8440 self
8441 }
8442 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8443 /// while executing the actual API request.
8444 ///
8445 /// ````text
8446 /// It should be used to handle progress information, and to implement a certain level of resilience.
8447 /// ````
8448 ///
8449 /// Sets the *delegate* property to the given value.
8450 pub fn delegate(
8451 mut self,
8452 new_value: &'a mut dyn common::Delegate,
8453 ) -> ProjectKeyRetrieveLegacySecretKeyCall<'a, C> {
8454 self._delegate = Some(new_value);
8455 self
8456 }
8457
8458 /// Set any additional parameter of the query string used in the request.
8459 /// It should be used to set parameters which are not yet available through their own
8460 /// setters.
8461 ///
8462 /// Please note that this method must not be used to set any of the known parameters
8463 /// which have their own setter method. If done anyway, the request will fail.
8464 ///
8465 /// # Additional Parameters
8466 ///
8467 /// * *$.xgafv* (query-string) - V1 error format.
8468 /// * *access_token* (query-string) - OAuth access token.
8469 /// * *alt* (query-string) - Data format for response.
8470 /// * *callback* (query-string) - JSONP
8471 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8472 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8473 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8474 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8475 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8476 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8477 pub fn param<T>(mut self, name: T, value: T) -> ProjectKeyRetrieveLegacySecretKeyCall<'a, C>
8478 where
8479 T: AsRef<str>,
8480 {
8481 self._additional_params
8482 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8483 self
8484 }
8485
8486 /// Identifies the authorization scope for the method you are building.
8487 ///
8488 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8489 /// [`Scope::CloudPlatform`].
8490 ///
8491 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8492 /// tokens for more than one scope.
8493 ///
8494 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8495 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8496 /// sufficient, a read-write scope will do as well.
8497 pub fn add_scope<St>(mut self, scope: St) -> ProjectKeyRetrieveLegacySecretKeyCall<'a, C>
8498 where
8499 St: AsRef<str>,
8500 {
8501 self._scopes.insert(String::from(scope.as_ref()));
8502 self
8503 }
8504 /// Identifies the authorization scope(s) for the method you are building.
8505 ///
8506 /// See [`Self::add_scope()`] for details.
8507 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectKeyRetrieveLegacySecretKeyCall<'a, C>
8508 where
8509 I: IntoIterator<Item = St>,
8510 St: AsRef<str>,
8511 {
8512 self._scopes
8513 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8514 self
8515 }
8516
8517 /// Removes all scopes, and no default scope will be used either.
8518 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8519 /// for details).
8520 pub fn clear_scopes(mut self) -> ProjectKeyRetrieveLegacySecretKeyCall<'a, C> {
8521 self._scopes.clear();
8522 self
8523 }
8524}
8525
8526/// Search group memberships related to a given account.
8527///
8528/// A builder for the *relatedaccountgroupmemberships.search* method supported by a *project* resource.
8529/// It is not used directly, but through a [`ProjectMethods`] instance.
8530///
8531/// # Example
8532///
8533/// Instantiate a resource method builder
8534///
8535/// ```test_harness,no_run
8536/// # extern crate hyper;
8537/// # extern crate hyper_rustls;
8538/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
8539/// use recaptchaenterprise1::api::GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsRequest;
8540/// # async fn dox() {
8541/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8542///
8543/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8544/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8545/// # .with_native_roots()
8546/// # .unwrap()
8547/// # .https_only()
8548/// # .enable_http2()
8549/// # .build();
8550///
8551/// # let executor = hyper_util::rt::TokioExecutor::new();
8552/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8553/// # secret,
8554/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8555/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8556/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8557/// # ),
8558/// # ).build().await.unwrap();
8559///
8560/// # let client = hyper_util::client::legacy::Client::builder(
8561/// # hyper_util::rt::TokioExecutor::new()
8562/// # )
8563/// # .build(
8564/// # hyper_rustls::HttpsConnectorBuilder::new()
8565/// # .with_native_roots()
8566/// # .unwrap()
8567/// # .https_or_http()
8568/// # .enable_http2()
8569/// # .build()
8570/// # );
8571/// # let mut hub = RecaptchaEnterprise::new(client, auth);
8572/// // As the method needs a request, you would usually fill it with the desired information
8573/// // into the respective structure. Some of the parts shown here might not be applicable !
8574/// // Values shown here are possibly random and not representative !
8575/// let mut req = GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsRequest::default();
8576///
8577/// // You can configure optional parameters by calling the respective setters at will, and
8578/// // execute the final call using `doit()`.
8579/// // Values shown here are possibly random and not representative !
8580/// let result = hub.projects().relatedaccountgroupmemberships_search(req, "project")
8581/// .doit().await;
8582/// # }
8583/// ```
8584pub struct ProjectRelatedaccountgroupmembershipSearchCall<'a, C>
8585where
8586 C: 'a,
8587{
8588 hub: &'a RecaptchaEnterprise<C>,
8589 _request: GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsRequest,
8590 _project: String,
8591 _delegate: Option<&'a mut dyn common::Delegate>,
8592 _additional_params: HashMap<String, String>,
8593 _scopes: BTreeSet<String>,
8594}
8595
8596impl<'a, C> common::CallBuilder for ProjectRelatedaccountgroupmembershipSearchCall<'a, C> {}
8597
8598impl<'a, C> ProjectRelatedaccountgroupmembershipSearchCall<'a, C>
8599where
8600 C: common::Connector,
8601{
8602 /// Perform the operation you have build so far.
8603 pub async fn doit(
8604 mut self,
8605 ) -> common::Result<(
8606 common::Response,
8607 GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsResponse,
8608 )> {
8609 use std::borrow::Cow;
8610 use std::io::{Read, Seek};
8611
8612 use common::{url::Params, ToParts};
8613 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8614
8615 let mut dd = common::DefaultDelegate;
8616 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8617 dlg.begin(common::MethodInfo {
8618 id: "recaptchaenterprise.projects.relatedaccountgroupmemberships.search",
8619 http_method: hyper::Method::POST,
8620 });
8621
8622 for &field in ["alt", "project"].iter() {
8623 if self._additional_params.contains_key(field) {
8624 dlg.finished(false);
8625 return Err(common::Error::FieldClash(field));
8626 }
8627 }
8628
8629 let mut params = Params::with_capacity(4 + self._additional_params.len());
8630 params.push("project", self._project);
8631
8632 params.extend(self._additional_params.iter());
8633
8634 params.push("alt", "json");
8635 let mut url =
8636 self.hub._base_url.clone() + "v1/{+project}/relatedaccountgroupmemberships:search";
8637 if self._scopes.is_empty() {
8638 self._scopes
8639 .insert(Scope::CloudPlatform.as_ref().to_string());
8640 }
8641
8642 #[allow(clippy::single_element_loop)]
8643 for &(find_this, param_name) in [("{+project}", "project")].iter() {
8644 url = params.uri_replacement(url, param_name, find_this, true);
8645 }
8646 {
8647 let to_remove = ["project"];
8648 params.remove_params(&to_remove);
8649 }
8650
8651 let url = params.parse_with_url(&url);
8652
8653 let mut json_mime_type = mime::APPLICATION_JSON;
8654 let mut request_value_reader = {
8655 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8656 common::remove_json_null_values(&mut value);
8657 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8658 serde_json::to_writer(&mut dst, &value).unwrap();
8659 dst
8660 };
8661 let request_size = request_value_reader
8662 .seek(std::io::SeekFrom::End(0))
8663 .unwrap();
8664 request_value_reader
8665 .seek(std::io::SeekFrom::Start(0))
8666 .unwrap();
8667
8668 loop {
8669 let token = match self
8670 .hub
8671 .auth
8672 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8673 .await
8674 {
8675 Ok(token) => token,
8676 Err(e) => match dlg.token(e) {
8677 Ok(token) => token,
8678 Err(e) => {
8679 dlg.finished(false);
8680 return Err(common::Error::MissingToken(e));
8681 }
8682 },
8683 };
8684 request_value_reader
8685 .seek(std::io::SeekFrom::Start(0))
8686 .unwrap();
8687 let mut req_result = {
8688 let client = &self.hub.client;
8689 dlg.pre_request();
8690 let mut req_builder = hyper::Request::builder()
8691 .method(hyper::Method::POST)
8692 .uri(url.as_str())
8693 .header(USER_AGENT, self.hub._user_agent.clone());
8694
8695 if let Some(token) = token.as_ref() {
8696 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8697 }
8698
8699 let request = req_builder
8700 .header(CONTENT_TYPE, json_mime_type.to_string())
8701 .header(CONTENT_LENGTH, request_size as u64)
8702 .body(common::to_body(
8703 request_value_reader.get_ref().clone().into(),
8704 ));
8705
8706 client.request(request.unwrap()).await
8707 };
8708
8709 match req_result {
8710 Err(err) => {
8711 if let common::Retry::After(d) = dlg.http_error(&err) {
8712 sleep(d).await;
8713 continue;
8714 }
8715 dlg.finished(false);
8716 return Err(common::Error::HttpError(err));
8717 }
8718 Ok(res) => {
8719 let (mut parts, body) = res.into_parts();
8720 let mut body = common::Body::new(body);
8721 if !parts.status.is_success() {
8722 let bytes = common::to_bytes(body).await.unwrap_or_default();
8723 let error = serde_json::from_str(&common::to_string(&bytes));
8724 let response = common::to_response(parts, bytes.into());
8725
8726 if let common::Retry::After(d) =
8727 dlg.http_failure(&response, error.as_ref().ok())
8728 {
8729 sleep(d).await;
8730 continue;
8731 }
8732
8733 dlg.finished(false);
8734
8735 return Err(match error {
8736 Ok(value) => common::Error::BadRequest(value),
8737 _ => common::Error::Failure(response),
8738 });
8739 }
8740 let response = {
8741 let bytes = common::to_bytes(body).await.unwrap_or_default();
8742 let encoded = common::to_string(&bytes);
8743 match serde_json::from_str(&encoded) {
8744 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8745 Err(error) => {
8746 dlg.response_json_decode_error(&encoded, &error);
8747 return Err(common::Error::JsonDecodeError(
8748 encoded.to_string(),
8749 error,
8750 ));
8751 }
8752 }
8753 };
8754
8755 dlg.finished(true);
8756 return Ok(response);
8757 }
8758 }
8759 }
8760 }
8761
8762 ///
8763 /// Sets the *request* property to the given value.
8764 ///
8765 /// Even though the property as already been set when instantiating this call,
8766 /// we provide this method for API completeness.
8767 pub fn request(
8768 mut self,
8769 new_value: GoogleCloudRecaptchaenterpriseV1SearchRelatedAccountGroupMembershipsRequest,
8770 ) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C> {
8771 self._request = new_value;
8772 self
8773 }
8774 /// Required. The name of the project to search related account group memberships from. Specify the project name in the following format: `projects/{project}`.
8775 ///
8776 /// Sets the *project* path property to the given value.
8777 ///
8778 /// Even though the property as already been set when instantiating this call,
8779 /// we provide this method for API completeness.
8780 pub fn project(
8781 mut self,
8782 new_value: &str,
8783 ) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C> {
8784 self._project = new_value.to_string();
8785 self
8786 }
8787 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8788 /// while executing the actual API request.
8789 ///
8790 /// ````text
8791 /// It should be used to handle progress information, and to implement a certain level of resilience.
8792 /// ````
8793 ///
8794 /// Sets the *delegate* property to the given value.
8795 pub fn delegate(
8796 mut self,
8797 new_value: &'a mut dyn common::Delegate,
8798 ) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C> {
8799 self._delegate = Some(new_value);
8800 self
8801 }
8802
8803 /// Set any additional parameter of the query string used in the request.
8804 /// It should be used to set parameters which are not yet available through their own
8805 /// setters.
8806 ///
8807 /// Please note that this method must not be used to set any of the known parameters
8808 /// which have their own setter method. If done anyway, the request will fail.
8809 ///
8810 /// # Additional Parameters
8811 ///
8812 /// * *$.xgafv* (query-string) - V1 error format.
8813 /// * *access_token* (query-string) - OAuth access token.
8814 /// * *alt* (query-string) - Data format for response.
8815 /// * *callback* (query-string) - JSONP
8816 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8817 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8818 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8819 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8820 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
8821 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8822 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8823 pub fn param<T>(
8824 mut self,
8825 name: T,
8826 value: T,
8827 ) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C>
8828 where
8829 T: AsRef<str>,
8830 {
8831 self._additional_params
8832 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8833 self
8834 }
8835
8836 /// Identifies the authorization scope for the method you are building.
8837 ///
8838 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8839 /// [`Scope::CloudPlatform`].
8840 ///
8841 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8842 /// tokens for more than one scope.
8843 ///
8844 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8845 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8846 /// sufficient, a read-write scope will do as well.
8847 pub fn add_scope<St>(
8848 mut self,
8849 scope: St,
8850 ) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C>
8851 where
8852 St: AsRef<str>,
8853 {
8854 self._scopes.insert(String::from(scope.as_ref()));
8855 self
8856 }
8857 /// Identifies the authorization scope(s) for the method you are building.
8858 ///
8859 /// See [`Self::add_scope()`] for details.
8860 pub fn add_scopes<I, St>(
8861 mut self,
8862 scopes: I,
8863 ) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C>
8864 where
8865 I: IntoIterator<Item = St>,
8866 St: AsRef<str>,
8867 {
8868 self._scopes
8869 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8870 self
8871 }
8872
8873 /// Removes all scopes, and no default scope will be used either.
8874 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8875 /// for details).
8876 pub fn clear_scopes(mut self) -> ProjectRelatedaccountgroupmembershipSearchCall<'a, C> {
8877 self._scopes.clear();
8878 self
8879 }
8880}
8881
8882/// Get memberships in a group of related accounts.
8883///
8884/// A builder for the *relatedaccountgroups.memberships.list* method supported by a *project* resource.
8885/// It is not used directly, but through a [`ProjectMethods`] instance.
8886///
8887/// # Example
8888///
8889/// Instantiate a resource method builder
8890///
8891/// ```test_harness,no_run
8892/// # extern crate hyper;
8893/// # extern crate hyper_rustls;
8894/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
8895/// # async fn dox() {
8896/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8897///
8898/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8899/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8900/// # .with_native_roots()
8901/// # .unwrap()
8902/// # .https_only()
8903/// # .enable_http2()
8904/// # .build();
8905///
8906/// # let executor = hyper_util::rt::TokioExecutor::new();
8907/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8908/// # secret,
8909/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8910/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8911/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8912/// # ),
8913/// # ).build().await.unwrap();
8914///
8915/// # let client = hyper_util::client::legacy::Client::builder(
8916/// # hyper_util::rt::TokioExecutor::new()
8917/// # )
8918/// # .build(
8919/// # hyper_rustls::HttpsConnectorBuilder::new()
8920/// # .with_native_roots()
8921/// # .unwrap()
8922/// # .https_or_http()
8923/// # .enable_http2()
8924/// # .build()
8925/// # );
8926/// # let mut hub = RecaptchaEnterprise::new(client, auth);
8927/// // You can configure optional parameters by calling the respective setters at will, and
8928/// // execute the final call using `doit()`.
8929/// // Values shown here are possibly random and not representative !
8930/// let result = hub.projects().relatedaccountgroups_memberships_list("parent")
8931/// .page_token("ipsum")
8932/// .page_size(-7)
8933/// .doit().await;
8934/// # }
8935/// ```
8936pub struct ProjectRelatedaccountgroupMembershipListCall<'a, C>
8937where
8938 C: 'a,
8939{
8940 hub: &'a RecaptchaEnterprise<C>,
8941 _parent: String,
8942 _page_token: Option<String>,
8943 _page_size: Option<i32>,
8944 _delegate: Option<&'a mut dyn common::Delegate>,
8945 _additional_params: HashMap<String, String>,
8946 _scopes: BTreeSet<String>,
8947}
8948
8949impl<'a, C> common::CallBuilder for ProjectRelatedaccountgroupMembershipListCall<'a, C> {}
8950
8951impl<'a, C> ProjectRelatedaccountgroupMembershipListCall<'a, C>
8952where
8953 C: common::Connector,
8954{
8955 /// Perform the operation you have build so far.
8956 pub async fn doit(
8957 mut self,
8958 ) -> common::Result<(
8959 common::Response,
8960 GoogleCloudRecaptchaenterpriseV1ListRelatedAccountGroupMembershipsResponse,
8961 )> {
8962 use std::borrow::Cow;
8963 use std::io::{Read, Seek};
8964
8965 use common::{url::Params, ToParts};
8966 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8967
8968 let mut dd = common::DefaultDelegate;
8969 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8970 dlg.begin(common::MethodInfo {
8971 id: "recaptchaenterprise.projects.relatedaccountgroups.memberships.list",
8972 http_method: hyper::Method::GET,
8973 });
8974
8975 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
8976 if self._additional_params.contains_key(field) {
8977 dlg.finished(false);
8978 return Err(common::Error::FieldClash(field));
8979 }
8980 }
8981
8982 let mut params = Params::with_capacity(5 + self._additional_params.len());
8983 params.push("parent", self._parent);
8984 if let Some(value) = self._page_token.as_ref() {
8985 params.push("pageToken", value);
8986 }
8987 if let Some(value) = self._page_size.as_ref() {
8988 params.push("pageSize", value.to_string());
8989 }
8990
8991 params.extend(self._additional_params.iter());
8992
8993 params.push("alt", "json");
8994 let mut url = self.hub._base_url.clone() + "v1/{+parent}/memberships";
8995 if self._scopes.is_empty() {
8996 self._scopes
8997 .insert(Scope::CloudPlatform.as_ref().to_string());
8998 }
8999
9000 #[allow(clippy::single_element_loop)]
9001 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9002 url = params.uri_replacement(url, param_name, find_this, true);
9003 }
9004 {
9005 let to_remove = ["parent"];
9006 params.remove_params(&to_remove);
9007 }
9008
9009 let url = params.parse_with_url(&url);
9010
9011 loop {
9012 let token = match self
9013 .hub
9014 .auth
9015 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9016 .await
9017 {
9018 Ok(token) => token,
9019 Err(e) => match dlg.token(e) {
9020 Ok(token) => token,
9021 Err(e) => {
9022 dlg.finished(false);
9023 return Err(common::Error::MissingToken(e));
9024 }
9025 },
9026 };
9027 let mut req_result = {
9028 let client = &self.hub.client;
9029 dlg.pre_request();
9030 let mut req_builder = hyper::Request::builder()
9031 .method(hyper::Method::GET)
9032 .uri(url.as_str())
9033 .header(USER_AGENT, self.hub._user_agent.clone());
9034
9035 if let Some(token) = token.as_ref() {
9036 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9037 }
9038
9039 let request = req_builder
9040 .header(CONTENT_LENGTH, 0_u64)
9041 .body(common::to_body::<String>(None));
9042
9043 client.request(request.unwrap()).await
9044 };
9045
9046 match req_result {
9047 Err(err) => {
9048 if let common::Retry::After(d) = dlg.http_error(&err) {
9049 sleep(d).await;
9050 continue;
9051 }
9052 dlg.finished(false);
9053 return Err(common::Error::HttpError(err));
9054 }
9055 Ok(res) => {
9056 let (mut parts, body) = res.into_parts();
9057 let mut body = common::Body::new(body);
9058 if !parts.status.is_success() {
9059 let bytes = common::to_bytes(body).await.unwrap_or_default();
9060 let error = serde_json::from_str(&common::to_string(&bytes));
9061 let response = common::to_response(parts, bytes.into());
9062
9063 if let common::Retry::After(d) =
9064 dlg.http_failure(&response, error.as_ref().ok())
9065 {
9066 sleep(d).await;
9067 continue;
9068 }
9069
9070 dlg.finished(false);
9071
9072 return Err(match error {
9073 Ok(value) => common::Error::BadRequest(value),
9074 _ => common::Error::Failure(response),
9075 });
9076 }
9077 let response = {
9078 let bytes = common::to_bytes(body).await.unwrap_or_default();
9079 let encoded = common::to_string(&bytes);
9080 match serde_json::from_str(&encoded) {
9081 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9082 Err(error) => {
9083 dlg.response_json_decode_error(&encoded, &error);
9084 return Err(common::Error::JsonDecodeError(
9085 encoded.to_string(),
9086 error,
9087 ));
9088 }
9089 }
9090 };
9091
9092 dlg.finished(true);
9093 return Ok(response);
9094 }
9095 }
9096 }
9097 }
9098
9099 /// Required. The resource name for the related account group in the format `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`.
9100 ///
9101 /// Sets the *parent* path property to the given value.
9102 ///
9103 /// Even though the property as already been set when instantiating this call,
9104 /// we provide this method for API completeness.
9105 pub fn parent(
9106 mut self,
9107 new_value: &str,
9108 ) -> ProjectRelatedaccountgroupMembershipListCall<'a, C> {
9109 self._parent = new_value.to_string();
9110 self
9111 }
9112 /// Optional. A page token, received from a previous `ListRelatedAccountGroupMemberships` call. When paginating, all other parameters provided to `ListRelatedAccountGroupMemberships` must match the call that provided the page token.
9113 ///
9114 /// Sets the *page token* query property to the given value.
9115 pub fn page_token(
9116 mut self,
9117 new_value: &str,
9118 ) -> ProjectRelatedaccountgroupMembershipListCall<'a, C> {
9119 self._page_token = Some(new_value.to_string());
9120 self
9121 }
9122 /// Optional. The maximum number of accounts to return. The service might return fewer than this value. If unspecified, at most 50 accounts are returned. The maximum value is 1000; values above 1000 are coerced to 1000.
9123 ///
9124 /// Sets the *page size* query property to the given value.
9125 pub fn page_size(
9126 mut self,
9127 new_value: i32,
9128 ) -> ProjectRelatedaccountgroupMembershipListCall<'a, C> {
9129 self._page_size = Some(new_value);
9130 self
9131 }
9132 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9133 /// while executing the actual API request.
9134 ///
9135 /// ````text
9136 /// It should be used to handle progress information, and to implement a certain level of resilience.
9137 /// ````
9138 ///
9139 /// Sets the *delegate* property to the given value.
9140 pub fn delegate(
9141 mut self,
9142 new_value: &'a mut dyn common::Delegate,
9143 ) -> ProjectRelatedaccountgroupMembershipListCall<'a, C> {
9144 self._delegate = Some(new_value);
9145 self
9146 }
9147
9148 /// Set any additional parameter of the query string used in the request.
9149 /// It should be used to set parameters which are not yet available through their own
9150 /// setters.
9151 ///
9152 /// Please note that this method must not be used to set any of the known parameters
9153 /// which have their own setter method. If done anyway, the request will fail.
9154 ///
9155 /// # Additional Parameters
9156 ///
9157 /// * *$.xgafv* (query-string) - V1 error format.
9158 /// * *access_token* (query-string) - OAuth access token.
9159 /// * *alt* (query-string) - Data format for response.
9160 /// * *callback* (query-string) - JSONP
9161 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9162 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9163 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9164 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9165 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9166 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9167 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9168 pub fn param<T>(
9169 mut self,
9170 name: T,
9171 value: T,
9172 ) -> ProjectRelatedaccountgroupMembershipListCall<'a, C>
9173 where
9174 T: AsRef<str>,
9175 {
9176 self._additional_params
9177 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9178 self
9179 }
9180
9181 /// Identifies the authorization scope for the method you are building.
9182 ///
9183 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9184 /// [`Scope::CloudPlatform`].
9185 ///
9186 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9187 /// tokens for more than one scope.
9188 ///
9189 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9190 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9191 /// sufficient, a read-write scope will do as well.
9192 pub fn add_scope<St>(mut self, scope: St) -> ProjectRelatedaccountgroupMembershipListCall<'a, C>
9193 where
9194 St: AsRef<str>,
9195 {
9196 self._scopes.insert(String::from(scope.as_ref()));
9197 self
9198 }
9199 /// Identifies the authorization scope(s) for the method you are building.
9200 ///
9201 /// See [`Self::add_scope()`] for details.
9202 pub fn add_scopes<I, St>(
9203 mut self,
9204 scopes: I,
9205 ) -> ProjectRelatedaccountgroupMembershipListCall<'a, C>
9206 where
9207 I: IntoIterator<Item = St>,
9208 St: AsRef<str>,
9209 {
9210 self._scopes
9211 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9212 self
9213 }
9214
9215 /// Removes all scopes, and no default scope will be used either.
9216 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9217 /// for details).
9218 pub fn clear_scopes(mut self) -> ProjectRelatedaccountgroupMembershipListCall<'a, C> {
9219 self._scopes.clear();
9220 self
9221 }
9222}
9223
9224/// List groups of related accounts.
9225///
9226/// A builder for the *relatedaccountgroups.list* method supported by a *project* resource.
9227/// It is not used directly, but through a [`ProjectMethods`] instance.
9228///
9229/// # Example
9230///
9231/// Instantiate a resource method builder
9232///
9233/// ```test_harness,no_run
9234/// # extern crate hyper;
9235/// # extern crate hyper_rustls;
9236/// # extern crate google_recaptchaenterprise1 as recaptchaenterprise1;
9237/// # async fn dox() {
9238/// # use recaptchaenterprise1::{RecaptchaEnterprise, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9239///
9240/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9241/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9242/// # .with_native_roots()
9243/// # .unwrap()
9244/// # .https_only()
9245/// # .enable_http2()
9246/// # .build();
9247///
9248/// # let executor = hyper_util::rt::TokioExecutor::new();
9249/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9250/// # secret,
9251/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9252/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9253/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9254/// # ),
9255/// # ).build().await.unwrap();
9256///
9257/// # let client = hyper_util::client::legacy::Client::builder(
9258/// # hyper_util::rt::TokioExecutor::new()
9259/// # )
9260/// # .build(
9261/// # hyper_rustls::HttpsConnectorBuilder::new()
9262/// # .with_native_roots()
9263/// # .unwrap()
9264/// # .https_or_http()
9265/// # .enable_http2()
9266/// # .build()
9267/// # );
9268/// # let mut hub = RecaptchaEnterprise::new(client, auth);
9269/// // You can configure optional parameters by calling the respective setters at will, and
9270/// // execute the final call using `doit()`.
9271/// // Values shown here are possibly random and not representative !
9272/// let result = hub.projects().relatedaccountgroups_list("parent")
9273/// .page_token("ea")
9274/// .page_size(-99)
9275/// .doit().await;
9276/// # }
9277/// ```
9278pub struct ProjectRelatedaccountgroupListCall<'a, C>
9279where
9280 C: 'a,
9281{
9282 hub: &'a RecaptchaEnterprise<C>,
9283 _parent: String,
9284 _page_token: Option<String>,
9285 _page_size: Option<i32>,
9286 _delegate: Option<&'a mut dyn common::Delegate>,
9287 _additional_params: HashMap<String, String>,
9288 _scopes: BTreeSet<String>,
9289}
9290
9291impl<'a, C> common::CallBuilder for ProjectRelatedaccountgroupListCall<'a, C> {}
9292
9293impl<'a, C> ProjectRelatedaccountgroupListCall<'a, C>
9294where
9295 C: common::Connector,
9296{
9297 /// Perform the operation you have build so far.
9298 pub async fn doit(
9299 mut self,
9300 ) -> common::Result<(
9301 common::Response,
9302 GoogleCloudRecaptchaenterpriseV1ListRelatedAccountGroupsResponse,
9303 )> {
9304 use std::borrow::Cow;
9305 use std::io::{Read, Seek};
9306
9307 use common::{url::Params, ToParts};
9308 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9309
9310 let mut dd = common::DefaultDelegate;
9311 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9312 dlg.begin(common::MethodInfo {
9313 id: "recaptchaenterprise.projects.relatedaccountgroups.list",
9314 http_method: hyper::Method::GET,
9315 });
9316
9317 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9318 if self._additional_params.contains_key(field) {
9319 dlg.finished(false);
9320 return Err(common::Error::FieldClash(field));
9321 }
9322 }
9323
9324 let mut params = Params::with_capacity(5 + self._additional_params.len());
9325 params.push("parent", self._parent);
9326 if let Some(value) = self._page_token.as_ref() {
9327 params.push("pageToken", value);
9328 }
9329 if let Some(value) = self._page_size.as_ref() {
9330 params.push("pageSize", value.to_string());
9331 }
9332
9333 params.extend(self._additional_params.iter());
9334
9335 params.push("alt", "json");
9336 let mut url = self.hub._base_url.clone() + "v1/{+parent}/relatedaccountgroups";
9337 if self._scopes.is_empty() {
9338 self._scopes
9339 .insert(Scope::CloudPlatform.as_ref().to_string());
9340 }
9341
9342 #[allow(clippy::single_element_loop)]
9343 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9344 url = params.uri_replacement(url, param_name, find_this, true);
9345 }
9346 {
9347 let to_remove = ["parent"];
9348 params.remove_params(&to_remove);
9349 }
9350
9351 let url = params.parse_with_url(&url);
9352
9353 loop {
9354 let token = match self
9355 .hub
9356 .auth
9357 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9358 .await
9359 {
9360 Ok(token) => token,
9361 Err(e) => match dlg.token(e) {
9362 Ok(token) => token,
9363 Err(e) => {
9364 dlg.finished(false);
9365 return Err(common::Error::MissingToken(e));
9366 }
9367 },
9368 };
9369 let mut req_result = {
9370 let client = &self.hub.client;
9371 dlg.pre_request();
9372 let mut req_builder = hyper::Request::builder()
9373 .method(hyper::Method::GET)
9374 .uri(url.as_str())
9375 .header(USER_AGENT, self.hub._user_agent.clone());
9376
9377 if let Some(token) = token.as_ref() {
9378 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9379 }
9380
9381 let request = req_builder
9382 .header(CONTENT_LENGTH, 0_u64)
9383 .body(common::to_body::<String>(None));
9384
9385 client.request(request.unwrap()).await
9386 };
9387
9388 match req_result {
9389 Err(err) => {
9390 if let common::Retry::After(d) = dlg.http_error(&err) {
9391 sleep(d).await;
9392 continue;
9393 }
9394 dlg.finished(false);
9395 return Err(common::Error::HttpError(err));
9396 }
9397 Ok(res) => {
9398 let (mut parts, body) = res.into_parts();
9399 let mut body = common::Body::new(body);
9400 if !parts.status.is_success() {
9401 let bytes = common::to_bytes(body).await.unwrap_or_default();
9402 let error = serde_json::from_str(&common::to_string(&bytes));
9403 let response = common::to_response(parts, bytes.into());
9404
9405 if let common::Retry::After(d) =
9406 dlg.http_failure(&response, error.as_ref().ok())
9407 {
9408 sleep(d).await;
9409 continue;
9410 }
9411
9412 dlg.finished(false);
9413
9414 return Err(match error {
9415 Ok(value) => common::Error::BadRequest(value),
9416 _ => common::Error::Failure(response),
9417 });
9418 }
9419 let response = {
9420 let bytes = common::to_bytes(body).await.unwrap_or_default();
9421 let encoded = common::to_string(&bytes);
9422 match serde_json::from_str(&encoded) {
9423 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9424 Err(error) => {
9425 dlg.response_json_decode_error(&encoded, &error);
9426 return Err(common::Error::JsonDecodeError(
9427 encoded.to_string(),
9428 error,
9429 ));
9430 }
9431 }
9432 };
9433
9434 dlg.finished(true);
9435 return Ok(response);
9436 }
9437 }
9438 }
9439 }
9440
9441 /// Required. The name of the project to list related account groups from, in the format `projects/{project}`.
9442 ///
9443 /// Sets the *parent* path property to the given value.
9444 ///
9445 /// Even though the property as already been set when instantiating this call,
9446 /// we provide this method for API completeness.
9447 pub fn parent(mut self, new_value: &str) -> ProjectRelatedaccountgroupListCall<'a, C> {
9448 self._parent = new_value.to_string();
9449 self
9450 }
9451 /// Optional. A page token, received from a previous `ListRelatedAccountGroups` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListRelatedAccountGroups` must match the call that provided the page token.
9452 ///
9453 /// Sets the *page token* query property to the given value.
9454 pub fn page_token(mut self, new_value: &str) -> ProjectRelatedaccountgroupListCall<'a, C> {
9455 self._page_token = Some(new_value.to_string());
9456 self
9457 }
9458 /// Optional. The maximum number of groups to return. The service might return fewer than this value. If unspecified, at most 50 groups are returned. The maximum value is 1000; values above 1000 are coerced to 1000.
9459 ///
9460 /// Sets the *page size* query property to the given value.
9461 pub fn page_size(mut self, new_value: i32) -> ProjectRelatedaccountgroupListCall<'a, C> {
9462 self._page_size = Some(new_value);
9463 self
9464 }
9465 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9466 /// while executing the actual API request.
9467 ///
9468 /// ````text
9469 /// It should be used to handle progress information, and to implement a certain level of resilience.
9470 /// ````
9471 ///
9472 /// Sets the *delegate* property to the given value.
9473 pub fn delegate(
9474 mut self,
9475 new_value: &'a mut dyn common::Delegate,
9476 ) -> ProjectRelatedaccountgroupListCall<'a, C> {
9477 self._delegate = Some(new_value);
9478 self
9479 }
9480
9481 /// Set any additional parameter of the query string used in the request.
9482 /// It should be used to set parameters which are not yet available through their own
9483 /// setters.
9484 ///
9485 /// Please note that this method must not be used to set any of the known parameters
9486 /// which have their own setter method. If done anyway, the request will fail.
9487 ///
9488 /// # Additional Parameters
9489 ///
9490 /// * *$.xgafv* (query-string) - V1 error format.
9491 /// * *access_token* (query-string) - OAuth access token.
9492 /// * *alt* (query-string) - Data format for response.
9493 /// * *callback* (query-string) - JSONP
9494 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9495 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9496 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9497 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9498 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
9499 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9500 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9501 pub fn param<T>(mut self, name: T, value: T) -> ProjectRelatedaccountgroupListCall<'a, C>
9502 where
9503 T: AsRef<str>,
9504 {
9505 self._additional_params
9506 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9507 self
9508 }
9509
9510 /// Identifies the authorization scope for the method you are building.
9511 ///
9512 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9513 /// [`Scope::CloudPlatform`].
9514 ///
9515 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9516 /// tokens for more than one scope.
9517 ///
9518 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9519 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9520 /// sufficient, a read-write scope will do as well.
9521 pub fn add_scope<St>(mut self, scope: St) -> ProjectRelatedaccountgroupListCall<'a, C>
9522 where
9523 St: AsRef<str>,
9524 {
9525 self._scopes.insert(String::from(scope.as_ref()));
9526 self
9527 }
9528 /// Identifies the authorization scope(s) for the method you are building.
9529 ///
9530 /// See [`Self::add_scope()`] for details.
9531 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectRelatedaccountgroupListCall<'a, C>
9532 where
9533 I: IntoIterator<Item = St>,
9534 St: AsRef<str>,
9535 {
9536 self._scopes
9537 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9538 self
9539 }
9540
9541 /// Removes all scopes, and no default scope will be used either.
9542 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9543 /// for details).
9544 pub fn clear_scopes(mut self) -> ProjectRelatedaccountgroupListCall<'a, C> {
9545 self._scopes.clear();
9546 self
9547 }
9548}