google_accessapproval1/
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 AccessApproval 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_accessapproval1 as accessapproval1;
49/// use accessapproval1::api::ApproveApprovalRequestMessage;
50/// use accessapproval1::{Result, Error};
51/// # async fn dox() {
52/// use accessapproval1::{AccessApproval, 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 = AccessApproval::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 = ApproveApprovalRequestMessage::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.folders().approval_requests_approve(req, "name")
99///              .doit().await;
100///
101/// match result {
102///     Err(e) => match e {
103///         // The Error enum provides details about what exactly happened.
104///         // You can also just use its `Debug`, `Display` or `Error` traits
105///          Error::HttpError(_)
106///         |Error::Io(_)
107///         |Error::MissingAPIKey
108///         |Error::MissingToken(_)
109///         |Error::Cancelled
110///         |Error::UploadSizeLimitExceeded(_, _)
111///         |Error::Failure(_)
112///         |Error::BadRequest(_)
113///         |Error::FieldClash(_)
114///         |Error::JsonDecodeError(_, _) => println!("{}", e),
115///     },
116///     Ok(res) => println!("Success: {:?}", res),
117/// }
118/// # }
119/// ```
120#[derive(Clone)]
121pub struct AccessApproval<C> {
122    pub client: common::Client<C>,
123    pub auth: Box<dyn common::GetToken>,
124    _user_agent: String,
125    _base_url: String,
126    _root_url: String,
127}
128
129impl<C> common::Hub for AccessApproval<C> {}
130
131impl<'a, C> AccessApproval<C> {
132    pub fn new<A: 'static + common::GetToken>(
133        client: common::Client<C>,
134        auth: A,
135    ) -> AccessApproval<C> {
136        AccessApproval {
137            client,
138            auth: Box::new(auth),
139            _user_agent: "google-api-rust-client/7.0.0".to_string(),
140            _base_url: "https://accessapproval.googleapis.com/".to_string(),
141            _root_url: "https://accessapproval.googleapis.com/".to_string(),
142        }
143    }
144
145    pub fn folders(&'a self) -> FolderMethods<'a, C> {
146        FolderMethods { hub: self }
147    }
148    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
149        OrganizationMethods { hub: self }
150    }
151    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
152        ProjectMethods { hub: self }
153    }
154
155    /// Set the user-agent header field to use in all requests to the server.
156    /// It defaults to `google-api-rust-client/7.0.0`.
157    ///
158    /// Returns the previously set user-agent.
159    pub fn user_agent(&mut self, agent_name: String) -> String {
160        std::mem::replace(&mut self._user_agent, agent_name)
161    }
162
163    /// Set the base url to use in all requests to the server.
164    /// It defaults to `https://accessapproval.googleapis.com/`.
165    ///
166    /// Returns the previously set base url.
167    pub fn base_url(&mut self, new_base_url: String) -> String {
168        std::mem::replace(&mut self._base_url, new_base_url)
169    }
170
171    /// Set the root url to use in all requests to the server.
172    /// It defaults to `https://accessapproval.googleapis.com/`.
173    ///
174    /// Returns the previously set root url.
175    pub fn root_url(&mut self, new_root_url: String) -> String {
176        std::mem::replace(&mut self._root_url, new_root_url)
177    }
178}
179
180// ############
181// SCHEMAS ###
182// ##########
183/// Access Approval service account related to a project/folder/organization.
184///
185/// # Activities
186///
187/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
188/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
189///
190/// * [get service account folders](FolderGetServiceAccountCall) (response)
191/// * [get service account organizations](OrganizationGetServiceAccountCall) (response)
192/// * [get service account projects](ProjectGetServiceAccountCall) (response)
193#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
194#[serde_with::serde_as]
195#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
196pub struct AccessApprovalServiceAccount {
197    /// Email address of the service account.
198    #[serde(rename = "accountEmail")]
199    pub account_email: Option<String>,
200    /// The resource name of the Access Approval service account. Format is one of: * "projects/{project}/serviceAccount" * "folders/{folder}/serviceAccount" * "organizations/{organization}/serviceAccount"
201    pub name: Option<String>,
202}
203
204impl common::ResponseResult for AccessApprovalServiceAccount {}
205
206/// Settings on a Project/Folder/Organization related to Access Approval.
207///
208/// # Activities
209///
210/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
211/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
212///
213/// * [get access approval settings folders](FolderGetAccessApprovalSettingCall) (response)
214/// * [update access approval settings folders](FolderUpdateAccessApprovalSettingCall) (request|response)
215/// * [get access approval settings organizations](OrganizationGetAccessApprovalSettingCall) (response)
216/// * [update access approval settings organizations](OrganizationUpdateAccessApprovalSettingCall) (request|response)
217/// * [get access approval settings projects](ProjectGetAccessApprovalSettingCall) (response)
218/// * [update access approval settings projects](ProjectUpdateAccessApprovalSettingCall) (request|response)
219#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
220#[serde_with::serde_as]
221#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
222pub struct AccessApprovalSettings {
223    /// The asymmetric crypto key version to use for signing approval requests. Empty active_key_version indicates that a Google-managed key should be used for signing. This property will be ignored if set by an ancestor of this resource, and new non-empty values may not be set.
224    #[serde(rename = "activeKeyVersion")]
225    pub active_key_version: Option<String>,
226    /// Output only. This field is read only (not settable via UpdateAccessApprovalSettings method). If the field is true, that indicates that an ancestor of this Project or Folder has set active_key_version (this field will always be unset for the organization since organizations do not have ancestors).
227    #[serde(rename = "ancestorHasActiveKeyVersion")]
228    pub ancestor_has_active_key_version: Option<bool>,
229    /// Optional. Policy configuration for Access Approval that sets the operating mode. The available policies are Transparency, Streamlined Support, and Approval Required.
230    #[serde(rename = "approvalPolicy")]
231    pub approval_policy: Option<CustomerApprovalApprovalPolicy>,
232    /// Output only. Effective policy applied for Access Approval, inclusive of inheritance.
233    #[serde(rename = "effectiveApprovalPolicy")]
234    pub effective_approval_policy: Option<CustomerApprovalApprovalPolicy>,
235    /// Output only. This field is read only (not settable via UpdateAccessApprovalSettings method). If the field is true, that indicates that at least one service is enrolled for Access Approval in one or more ancestors of the Project or Folder (this field will always be unset for the organization since organizations do not have ancestors).
236    #[serde(rename = "enrolledAncestor")]
237    pub enrolled_ancestor: Option<bool>,
238    /// A list of Google Cloud Services for which the given resource has Access Approval enrolled. Access requests for the resource given by name against any of these services contained here will be required to have explicit approval. If name refers to an organization, enrollment can be done for individual services. If name refers to a folder or project, enrollment can only be done on an all or nothing basis. If a cloud_product is repeated in this list, the first entry will be honored and all following entries will be discarded.
239    #[serde(rename = "enrolledServices")]
240    pub enrolled_services: Option<Vec<EnrolledService>>,
241    /// Output only. This field is read only (not settable via UpdateAccessApprovalSettings method). If the field is true, that indicates that there is some configuration issue with the active_key_version configured at this level in the resource hierarchy (e.g. it doesn't exist or the Access Approval service account doesn't have the correct permissions on it, etc.) This key version is not necessarily the effective key version at this level, as key versions are inherited top-down.
242    #[serde(rename = "invalidKeyVersion")]
243    pub invalid_key_version: Option<bool>,
244    /// The resource name of the settings. Format is one of: * "projects/{project}/accessApprovalSettings" * "folders/{folder}/accessApprovalSettings" * "organizations/{organization}/accessApprovalSettings"
245    pub name: Option<String>,
246    /// A list of email addresses to which notifications relating to approval requests should be sent. Notifications relating to a resource will be sent to all emails in the settings of ancestor resources of that resource. A maximum of 50 email addresses are allowed.
247    #[serde(rename = "notificationEmails")]
248    pub notification_emails: Option<Vec<String>>,
249    /// Optional. A pubsub topic that notifications relating to access approval are published to. Notifications include pre-approved accesses.
250    #[serde(rename = "notificationPubsubTopic")]
251    pub notification_pubsub_topic: Option<String>,
252    /// This field is used to set a preference for granularity of an access approval request. If true, Google personnel will be asked to send resource-level requests when possible. If false, Google personnel will be asked to send requests at the project level.
253    #[serde(rename = "preferNoBroadApprovalRequests")]
254    pub prefer_no_broad_approval_requests: Option<bool>,
255    /// Set the default access approval request expiration time. This value is able to be set directly by the customer at the time of approval, overriding this suggested value. We recommend setting this value to 30 days.
256    #[serde(rename = "preferredRequestExpirationDays")]
257    pub preferred_request_expiration_days: Option<i32>,
258    /// Optional. A setting that indicates the maximum scope of an Access Approval request: either organization, folder, or project. Google administrators will be asked to send requests no broader than the configured scope.
259    #[serde(rename = "requestScopeMaxWidthPreference")]
260    pub request_scope_max_width_preference: Option<String>,
261    /// Optional. When enabled, Google will only be able to send approval requests for access reasons with a customer accessible case ID in the reason detail. Also known as "Require customer initiated support case justification"
262    #[serde(rename = "requireCustomerVisibleJustification")]
263    pub require_customer_visible_justification: Option<bool>,
264}
265
266impl common::RequestValue for AccessApprovalSettings {}
267impl common::ResponseResult for AccessApprovalSettings {}
268
269/// Physical assigned office and physical location of the Google administrator performing the access.
270///
271/// This type is not used in any activity, and only used as *part* of another schema.
272///
273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
274#[serde_with::serde_as]
275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
276pub struct AccessLocations {
277    /// The "home office" location of the Google administrator. A two-letter country code (ISO 3166-1 alpha-2), such as "US", "DE" or "GB" or a region code. In some limited situations Google systems may refer refer to a region code instead of a country code. Possible Region Codes: * ASI: Asia * EUR: Europe * OCE: Oceania * AFR: Africa * NAM: North America * SAM: South America * ANT: Antarctica * ANY: Any location
278    #[serde(rename = "principalOfficeCountry")]
279    pub principal_office_country: Option<String>,
280    /// Physical location of the Google administrator at the time of the access. A two-letter country code (ISO 3166-1 alpha-2), such as "US", "DE" or "GB" or a region code. In some limited situations Google systems may refer refer to a region code instead of a country code. Possible Region Codes: * ASI: Asia * EUR: Europe * OCE: Oceania * AFR: Africa * NAM: North America * SAM: South America * ANT: Antarctica * ANY: Any location
281    #[serde(rename = "principalPhysicalLocationCountry")]
282    pub principal_physical_location_country: Option<String>,
283}
284
285impl common::Part for AccessLocations {}
286
287/// There is no detailed description.
288///
289/// This type is not used in any activity, and only used as *part* of another schema.
290///
291#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
292#[serde_with::serde_as]
293#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
294pub struct AccessReason {
295    /// More detail about certain reason types. See comments for each type above.
296    pub detail: Option<String>,
297    /// Type of access reason.
298    #[serde(rename = "type")]
299    pub type_: Option<String>,
300}
301
302impl common::Part for AccessReason {}
303
304/// A request for the customer to approve access to a resource.
305///
306/// # Activities
307///
308/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
309/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
310///
311/// * [approval requests approve folders](FolderApprovalRequestApproveCall) (response)
312/// * [approval requests dismiss folders](FolderApprovalRequestDismisCall) (response)
313/// * [approval requests get folders](FolderApprovalRequestGetCall) (response)
314/// * [approval requests invalidate folders](FolderApprovalRequestInvalidateCall) (response)
315/// * [approval requests approve organizations](OrganizationApprovalRequestApproveCall) (response)
316/// * [approval requests dismiss organizations](OrganizationApprovalRequestDismisCall) (response)
317/// * [approval requests get organizations](OrganizationApprovalRequestGetCall) (response)
318/// * [approval requests invalidate organizations](OrganizationApprovalRequestInvalidateCall) (response)
319/// * [approval requests approve projects](ProjectApprovalRequestApproveCall) (response)
320/// * [approval requests dismiss projects](ProjectApprovalRequestDismisCall) (response)
321/// * [approval requests get projects](ProjectApprovalRequestGetCall) (response)
322/// * [approval requests invalidate projects](ProjectApprovalRequestInvalidateCall) (response)
323#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
324#[serde_with::serde_as]
325#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
326pub struct ApprovalRequest {
327    /// Access was approved.
328    pub approve: Option<ApproveDecision>,
329    /// The request was dismissed.
330    pub dismiss: Option<DismissDecision>,
331    /// The resource name of the request. Format is "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}".
332    pub name: Option<String>,
333    /// The time at which approval was requested.
334    #[serde(rename = "requestTime")]
335    pub request_time: Option<chrono::DateTime<chrono::offset::Utc>>,
336    /// This field contains the augmented information of the request.
337    #[serde(rename = "requestedAugmentedInfo")]
338    pub requested_augmented_info: Option<AugmentedInfo>,
339    /// The requested access duration.
340    #[serde(rename = "requestedDuration")]
341    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
342    pub requested_duration: Option<chrono::Duration>,
343    /// The original requested expiration for the approval. Calculated by adding the requested_duration to the request_time.
344    #[serde(rename = "requestedExpiration")]
345    pub requested_expiration: Option<chrono::DateTime<chrono::offset::Utc>>,
346    /// The locations for which approval is being requested.
347    #[serde(rename = "requestedLocations")]
348    pub requested_locations: Option<AccessLocations>,
349    /// The access reason for which approval is being requested.
350    #[serde(rename = "requestedReason")]
351    pub requested_reason: Option<AccessReason>,
352    /// The resource for which approval is being requested. The format of the resource name is defined at https://cloud.google.com/apis/design/resource_names. The resource name here may either be a "full" resource name (e.g. "//library.googleapis.com/shelves/shelf1/books/book2") or a "relative" resource name (e.g. "shelves/shelf1/books/book2") as described in the resource name specification.
353    #[serde(rename = "requestedResourceName")]
354    pub requested_resource_name: Option<String>,
355    /// Properties related to the resource represented by requested_resource_name.
356    #[serde(rename = "requestedResourceProperties")]
357    pub requested_resource_properties: Option<ResourceProperties>,
358}
359
360impl common::ResponseResult for ApprovalRequest {}
361
362/// Request to approve an ApprovalRequest.
363///
364/// # Activities
365///
366/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
367/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
368///
369/// * [approval requests approve folders](FolderApprovalRequestApproveCall) (request)
370/// * [approval requests approve organizations](OrganizationApprovalRequestApproveCall) (request)
371/// * [approval requests approve projects](ProjectApprovalRequestApproveCall) (request)
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct ApproveApprovalRequestMessage {
376    /// The expiration time of this approval.
377    #[serde(rename = "expireTime")]
378    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
379}
380
381impl common::RequestValue for ApproveApprovalRequestMessage {}
382
383/// A decision that has been made to approve access to a resource.
384///
385/// This type is not used in any activity, and only used as *part* of another schema.
386///
387#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
388#[serde_with::serde_as]
389#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
390pub struct ApproveDecision {
391    /// The time at which approval was granted.
392    #[serde(rename = "approveTime")]
393    pub approve_time: Option<chrono::DateTime<chrono::offset::Utc>>,
394    /// True when the request has been auto-approved.
395    #[serde(rename = "autoApproved")]
396    pub auto_approved: Option<bool>,
397    /// The time at which the approval expires.
398    #[serde(rename = "expireTime")]
399    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
400    /// If set, denotes the timestamp at which the approval is invalidated.
401    #[serde(rename = "invalidateTime")]
402    pub invalidate_time: Option<chrono::DateTime<chrono::offset::Utc>>,
403    /// True when the request has been approved by the customer's defined policy.
404    #[serde(rename = "policyApproved")]
405    pub policy_approved: Option<bool>,
406    /// The signature for the ApprovalRequest and details on how it was signed.
407    #[serde(rename = "signatureInfo")]
408    pub signature_info: Option<SignatureInfo>,
409}
410
411impl common::Part for ApproveDecision {}
412
413/// This field contains the augmented information of the request. Requires augmented administrative access to be enabled.
414///
415/// This type is not used in any activity, and only used as *part* of another schema.
416///
417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
418#[serde_with::serde_as]
419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
420pub struct AugmentedInfo {
421    /// For command-line tools, the full command-line exactly as entered by the actor without adding any additional characters (such as quotation marks).
422    pub command: Option<String>,
423}
424
425impl common::Part for AugmentedInfo {}
426
427/// Represents all the policies that can be set for Customer Approval.
428///
429/// This type is not used in any activity, and only used as *part* of another schema.
430///
431#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
432#[serde_with::serde_as]
433#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
434pub struct CustomerApprovalApprovalPolicy {
435    /// Optional. Policy for approval based on the justification given.
436    #[serde(rename = "justificationBasedApprovalPolicy")]
437    pub justification_based_approval_policy: Option<String>,
438}
439
440impl common::Part for CustomerApprovalApprovalPolicy {}
441
442/// Request to dismiss an approval request.
443///
444/// # Activities
445///
446/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
447/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
448///
449/// * [approval requests dismiss folders](FolderApprovalRequestDismisCall) (request)
450/// * [approval requests dismiss organizations](OrganizationApprovalRequestDismisCall) (request)
451/// * [approval requests dismiss projects](ProjectApprovalRequestDismisCall) (request)
452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
453#[serde_with::serde_as]
454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
455pub struct DismissApprovalRequestMessage {
456    _never_set: Option<bool>,
457}
458
459impl common::RequestValue for DismissApprovalRequestMessage {}
460
461/// A decision that has been made to dismiss an approval request.
462///
463/// This type is not used in any activity, and only used as *part* of another schema.
464///
465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
466#[serde_with::serde_as]
467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
468pub struct DismissDecision {
469    /// The time at which the approval request was dismissed.
470    #[serde(rename = "dismissTime")]
471    pub dismiss_time: Option<chrono::DateTime<chrono::offset::Utc>>,
472    /// This field will be true if the ApprovalRequest was implicitly dismissed due to inaction by the access approval approvers (the request is not acted on by the approvers before the exiration time).
473    pub implicit: Option<bool>,
474}
475
476impl common::Part for DismissDecision {}
477
478/// 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); }
479///
480/// # Activities
481///
482/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
483/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
484///
485/// * [delete access approval settings folders](FolderDeleteAccessApprovalSettingCall) (response)
486/// * [delete access approval settings organizations](OrganizationDeleteAccessApprovalSettingCall) (response)
487/// * [delete access approval settings projects](ProjectDeleteAccessApprovalSettingCall) (response)
488#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
489#[serde_with::serde_as]
490#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
491pub struct Empty {
492    _never_set: Option<bool>,
493}
494
495impl common::ResponseResult for Empty {}
496
497/// Represents the enrollment of a cloud resource into a specific service.
498///
499/// This type is not used in any activity, and only used as *part* of another schema.
500///
501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
502#[serde_with::serde_as]
503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
504pub struct EnrolledService {
505    /// The product for which Access Approval will be enrolled. Allowed values are listed below (case-sensitive): * all * GA * Access Context Manager * Anthos Identity Service * AlloyDB for PostgreSQL * Apigee * Application Integration * App Hub * Artifact Registry * Anthos Service Mesh * Access Transparency * BigQuery * Certificate Authority Service * Cloud Bigtable * CCAI Assist and Knowledge * Cloud Dataflow * Cloud Dataproc * CEP Security Gateway * Compliance Evaluation Service * Cloud Firestore * Cloud Healthcare API * Chronicle * Cloud AI Companion Gateway - Titan * Google Cloud Armor * Cloud Asset Inventory * Cloud Asset Search * Cloud Deploy * Cloud DNS * Cloud Latency * Cloud Memorystore for Redis * CloudNet Control * Cloud Riptide * Cloud Tasks * Cloud Trace * Cloud Data Transfer * Cloud Composer * Integration Connectors * Contact Center AI Insights * Cloud Pub/Sub * Cloud Run * Resource Manager * Cloud Spanner * Database Center * Cloud Dataform * Cloud Data Fusion * Dataplex * Dialogflow Customer Experience Edition * Cloud DLP * Document AI * Edge Container * Edge Network * Cloud EKM * Eventarc * Firebase Data Connect * Firebase Rules * App Engine * Cloud Build * Compute Engine * Cloud Functions (2nd Gen) * Cloud Filestore * Cloud Interconnect * Cloud NetApp Volumes * Cloud Storage * Generative AI App Builder * Google Kubernetes Engine * Backup for GKE API * GKE Connect * GKE Hub * Hoverboard * Cloud HSM * Cloud Identity and Access Management * Cloud Identity-Aware Proxy * Infrastructure Manager * Identity Storage Service * Key Access Justifications * Cloud Key Management Service * Cloud Logging * Looker (Google Cloud core) * Looker Studio * Management Hub * Model Armor * Cloud Monitoring * Cloud NAT * Connectivity Hub * External passthrough Network Load Balancer * OIDC One * Organization Policy Service * Org Lifecycle * Persistent Disk * Parameter Manager * Private Services Access * Regional Internal Application Load Balancer * Storage Batch Operations * Cloud Security Command Center * Secure Source Manager * Seeker * Service Provisioning * Speaker ID * Secret Manager * Cloud SQL * Cloud Speech-to-Text * Traffic Director * Cloud Text-to-Speech * USPS Andromeda * Vertex AI * Virtual Private Cloud (VPC) * VPC Access * VPC Service Controls Troubleshooter * VPC virtnet * Cloud Workstations * Web Risk Note: These values are supported as input for legacy purposes, but will not be returned from the API. * all * ga-only * appengine.googleapis.com * artifactregistry.googleapis.com * bigquery.googleapis.com * bigtable.googleapis.com * container.googleapis.com * cloudkms.googleapis.com * cloudresourcemanager.googleapis.com * cloudsql.googleapis.com * compute.googleapis.com * dataflow.googleapis.com * dataproc.googleapis.com * dlp.googleapis.com * iam.googleapis.com * logging.googleapis.com * orgpolicy.googleapis.com * pubsub.googleapis.com * spanner.googleapis.com * secretmanager.googleapis.com * speakerid.googleapis.com * storage.googleapis.com Calls to UpdateAccessApprovalSettings using 'all' or any of the XXX.googleapis.com will be translated to the associated product name ('all', 'App Engine', etc.). Note: 'all' will enroll the resource in all products supported at both 'GA' and 'Preview' levels. More information about levels of support is available at https://cloud.google.com/access-approval/docs/supported-services
506    #[serde(rename = "cloudProduct")]
507    pub cloud_product: Option<String>,
508    /// The enrollment level of the service.
509    #[serde(rename = "enrollmentLevel")]
510    pub enrollment_level: Option<String>,
511}
512
513impl common::Part for EnrolledService {}
514
515/// Request to invalidate an existing approval.
516///
517/// # Activities
518///
519/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
520/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
521///
522/// * [approval requests invalidate folders](FolderApprovalRequestInvalidateCall) (request)
523/// * [approval requests invalidate organizations](OrganizationApprovalRequestInvalidateCall) (request)
524/// * [approval requests invalidate projects](ProjectApprovalRequestInvalidateCall) (request)
525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
526#[serde_with::serde_as]
527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
528pub struct InvalidateApprovalRequestMessage {
529    _never_set: Option<bool>,
530}
531
532impl common::RequestValue for InvalidateApprovalRequestMessage {}
533
534/// Response to listing of ApprovalRequest objects.
535///
536/// # Activities
537///
538/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
539/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
540///
541/// * [approval requests list folders](FolderApprovalRequestListCall) (response)
542/// * [approval requests list organizations](OrganizationApprovalRequestListCall) (response)
543/// * [approval requests list projects](ProjectApprovalRequestListCall) (response)
544#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
545#[serde_with::serde_as]
546#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
547pub struct ListApprovalRequestsResponse {
548    /// Approval request details.
549    #[serde(rename = "approvalRequests")]
550    pub approval_requests: Option<Vec<ApprovalRequest>>,
551    /// Token to retrieve the next page of results, or empty if there are no more.
552    #[serde(rename = "nextPageToken")]
553    pub next_page_token: Option<String>,
554}
555
556impl common::ResponseResult for ListApprovalRequestsResponse {}
557
558/// The properties associated with the resource of the request.
559///
560/// This type is not used in any activity, and only used as *part* of another schema.
561///
562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
563#[serde_with::serde_as]
564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
565pub struct ResourceProperties {
566    /// Whether an approval will exclude the descendants of the resource being requested.
567    #[serde(rename = "excludesDescendants")]
568    pub excludes_descendants: Option<bool>,
569}
570
571impl common::Part for ResourceProperties {}
572
573/// Information about the digital signature of the resource.
574///
575/// This type is not used in any activity, and only used as *part* of another schema.
576///
577#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
578#[serde_with::serde_as]
579#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
580pub struct SignatureInfo {
581    /// The resource name of the customer CryptoKeyVersion used for signing.
582    #[serde(rename = "customerKmsKeyVersion")]
583    pub customer_kms_key_version: Option<String>,
584    /// The hashing algorithm used for signature verification. It will only be present in the case of Google managed keys.
585    #[serde(rename = "googleKeyAlgorithm")]
586    pub google_key_algorithm: Option<String>,
587    /// The public key for the Google default signing, encoded in PEM format. The signature was created using a private key which may be verified using this public key.
588    #[serde(rename = "googlePublicKeyPem")]
589    pub google_public_key_pem: Option<String>,
590    /// The ApprovalRequest that is serialized without the SignatureInfo message field. This data is used with the hashing algorithm to generate the digital signature, and it can be used for signature verification.
591    #[serde(rename = "serializedApprovalRequest")]
592    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
593    pub serialized_approval_request: Option<Vec<u8>>,
594    /// The digital signature.
595    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
596    pub signature: Option<Vec<u8>>,
597}
598
599impl common::Part for SignatureInfo {}
600
601// ###################
602// MethodBuilders ###
603// #################
604
605/// A builder providing access to all methods supported on *folder* resources.
606/// It is not used directly, but through the [`AccessApproval`] hub.
607///
608/// # Example
609///
610/// Instantiate a resource builder
611///
612/// ```test_harness,no_run
613/// extern crate hyper;
614/// extern crate hyper_rustls;
615/// extern crate google_accessapproval1 as accessapproval1;
616///
617/// # async fn dox() {
618/// use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
619///
620/// let secret: yup_oauth2::ApplicationSecret = Default::default();
621/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
622///     .with_native_roots()
623///     .unwrap()
624///     .https_only()
625///     .enable_http2()
626///     .build();
627///
628/// let executor = hyper_util::rt::TokioExecutor::new();
629/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
630///     secret,
631///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
632///     yup_oauth2::client::CustomHyperClientBuilder::from(
633///         hyper_util::client::legacy::Client::builder(executor).build(connector),
634///     ),
635/// ).build().await.unwrap();
636///
637/// let client = hyper_util::client::legacy::Client::builder(
638///     hyper_util::rt::TokioExecutor::new()
639/// )
640/// .build(
641///     hyper_rustls::HttpsConnectorBuilder::new()
642///         .with_native_roots()
643///         .unwrap()
644///         .https_or_http()
645///         .enable_http2()
646///         .build()
647/// );
648/// let mut hub = AccessApproval::new(client, auth);
649/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
650/// // like `approval_requests_approve(...)`, `approval_requests_dismiss(...)`, `approval_requests_get(...)`, `approval_requests_invalidate(...)`, `approval_requests_list(...)`, `delete_access_approval_settings(...)`, `get_access_approval_settings(...)`, `get_service_account(...)` and `update_access_approval_settings(...)`
651/// // to build up your call.
652/// let rb = hub.folders();
653/// # }
654/// ```
655pub struct FolderMethods<'a, C>
656where
657    C: 'a,
658{
659    hub: &'a AccessApproval<C>,
660}
661
662impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
663
664impl<'a, C> FolderMethods<'a, C> {
665    /// Create a builder to help you perform the following task:
666    ///
667    /// Approves a request and returns the updated ApprovalRequest. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
668    ///
669    /// # Arguments
670    ///
671    /// * `request` - No description provided.
672    /// * `name` - Name of the approval request to approve.
673    pub fn approval_requests_approve(
674        &self,
675        request: ApproveApprovalRequestMessage,
676        name: &str,
677    ) -> FolderApprovalRequestApproveCall<'a, C> {
678        FolderApprovalRequestApproveCall {
679            hub: self.hub,
680            _request: request,
681            _name: name.to_string(),
682            _delegate: Default::default(),
683            _additional_params: Default::default(),
684            _scopes: Default::default(),
685        }
686    }
687
688    /// Create a builder to help you perform the following task:
689    ///
690    /// Dismisses a request. Returns the updated ApprovalRequest. NOTE: When a request is dismissed, it is considered ignored. Dismissing a request does not prevent access granted by other Access Approval requests. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
691    ///
692    /// # Arguments
693    ///
694    /// * `request` - No description provided.
695    /// * `name` - Name of the ApprovalRequest to dismiss.
696    pub fn approval_requests_dismiss(
697        &self,
698        request: DismissApprovalRequestMessage,
699        name: &str,
700    ) -> FolderApprovalRequestDismisCall<'a, C> {
701        FolderApprovalRequestDismisCall {
702            hub: self.hub,
703            _request: request,
704            _name: name.to_string(),
705            _delegate: Default::default(),
706            _additional_params: Default::default(),
707            _scopes: Default::default(),
708        }
709    }
710
711    /// Create a builder to help you perform the following task:
712    ///
713    /// Gets an approval request. Returns NOT_FOUND if the request does not exist.
714    ///
715    /// # Arguments
716    ///
717    /// * `name` - The name of the approval request to retrieve. Format: "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
718    pub fn approval_requests_get(&self, name: &str) -> FolderApprovalRequestGetCall<'a, C> {
719        FolderApprovalRequestGetCall {
720            hub: self.hub,
721            _name: name.to_string(),
722            _delegate: Default::default(),
723            _additional_params: Default::default(),
724            _scopes: Default::default(),
725        }
726    }
727
728    /// Create a builder to help you perform the following task:
729    ///
730    /// Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. NOTE: This action revokes Google access based on this approval request. If the resource has other active approvals, access will remain granted. Returns FAILED_PRECONDITION if the request exists but is not in an approved state.
731    ///
732    /// # Arguments
733    ///
734    /// * `request` - No description provided.
735    /// * `name` - Name of the ApprovalRequest to invalidate.
736    pub fn approval_requests_invalidate(
737        &self,
738        request: InvalidateApprovalRequestMessage,
739        name: &str,
740    ) -> FolderApprovalRequestInvalidateCall<'a, C> {
741        FolderApprovalRequestInvalidateCall {
742            hub: self.hub,
743            _request: request,
744            _name: name.to_string(),
745            _delegate: Default::default(),
746            _additional_params: Default::default(),
747            _scopes: Default::default(),
748        }
749    }
750
751    /// Create a builder to help you perform the following task:
752    ///
753    /// Lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.
754    ///
755    /// # Arguments
756    ///
757    /// * `parent` - The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".
758    pub fn approval_requests_list(&self, parent: &str) -> FolderApprovalRequestListCall<'a, C> {
759        FolderApprovalRequestListCall {
760            hub: self.hub,
761            _parent: parent.to_string(),
762            _page_token: Default::default(),
763            _page_size: Default::default(),
764            _filter: Default::default(),
765            _delegate: Default::default(),
766            _additional_params: Default::default(),
767            _scopes: Default::default(),
768        }
769    }
770
771    /// Create a builder to help you perform the following task:
772    ///
773    /// Deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the resource. Access Approval may remain active based on parent resource settings. To confirm the effective settings, call GetAccessApprovalSettings and verify effective setting is disabled.
774    ///
775    /// # Arguments
776    ///
777    /// * `name` - Name of the AccessApprovalSettings to delete.
778    pub fn delete_access_approval_settings(
779        &self,
780        name: &str,
781    ) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
782        FolderDeleteAccessApprovalSettingCall {
783            hub: self.hub,
784            _name: name.to_string(),
785            _delegate: Default::default(),
786            _additional_params: Default::default(),
787            _scopes: Default::default(),
788        }
789    }
790
791    /// Create a builder to help you perform the following task:
792    ///
793    /// Gets the Access Approval settings associated with a project, folder, or organization.
794    ///
795    /// # Arguments
796    ///
797    /// * `name` - The name of the AccessApprovalSettings to retrieve. Format: "{projects|folders|organizations}/{id}/accessApprovalSettings"
798    pub fn get_access_approval_settings(
799        &self,
800        name: &str,
801    ) -> FolderGetAccessApprovalSettingCall<'a, C> {
802        FolderGetAccessApprovalSettingCall {
803            hub: self.hub,
804            _name: name.to_string(),
805            _delegate: Default::default(),
806            _additional_params: Default::default(),
807            _scopes: Default::default(),
808        }
809    }
810
811    /// Create a builder to help you perform the following task:
812    ///
813    /// Retrieves the service account that is used by Access Approval to access KMS keys for signing approved approval requests.
814    ///
815    /// # Arguments
816    ///
817    /// * `name` - Name of the AccessApprovalServiceAccount to retrieve.
818    pub fn get_service_account(&self, name: &str) -> FolderGetServiceAccountCall<'a, C> {
819        FolderGetServiceAccountCall {
820            hub: self.hub,
821            _name: name.to_string(),
822            _delegate: Default::default(),
823            _additional_params: Default::default(),
824            _scopes: Default::default(),
825        }
826    }
827
828    /// Create a builder to help you perform the following task:
829    ///
830    /// Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.
831    ///
832    /// # Arguments
833    ///
834    /// * `request` - No description provided.
835    /// * `name` - The resource name of the settings. Format is one of: * "projects/{project}/accessApprovalSettings" * "folders/{folder}/accessApprovalSettings" * "organizations/{organization}/accessApprovalSettings"
836    pub fn update_access_approval_settings(
837        &self,
838        request: AccessApprovalSettings,
839        name: &str,
840    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
841        FolderUpdateAccessApprovalSettingCall {
842            hub: self.hub,
843            _request: request,
844            _name: name.to_string(),
845            _update_mask: Default::default(),
846            _delegate: Default::default(),
847            _additional_params: Default::default(),
848            _scopes: Default::default(),
849        }
850    }
851}
852
853/// A builder providing access to all methods supported on *organization* resources.
854/// It is not used directly, but through the [`AccessApproval`] hub.
855///
856/// # Example
857///
858/// Instantiate a resource builder
859///
860/// ```test_harness,no_run
861/// extern crate hyper;
862/// extern crate hyper_rustls;
863/// extern crate google_accessapproval1 as accessapproval1;
864///
865/// # async fn dox() {
866/// use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
867///
868/// let secret: yup_oauth2::ApplicationSecret = Default::default();
869/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
870///     .with_native_roots()
871///     .unwrap()
872///     .https_only()
873///     .enable_http2()
874///     .build();
875///
876/// let executor = hyper_util::rt::TokioExecutor::new();
877/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
878///     secret,
879///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
880///     yup_oauth2::client::CustomHyperClientBuilder::from(
881///         hyper_util::client::legacy::Client::builder(executor).build(connector),
882///     ),
883/// ).build().await.unwrap();
884///
885/// let client = hyper_util::client::legacy::Client::builder(
886///     hyper_util::rt::TokioExecutor::new()
887/// )
888/// .build(
889///     hyper_rustls::HttpsConnectorBuilder::new()
890///         .with_native_roots()
891///         .unwrap()
892///         .https_or_http()
893///         .enable_http2()
894///         .build()
895/// );
896/// let mut hub = AccessApproval::new(client, auth);
897/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
898/// // like `approval_requests_approve(...)`, `approval_requests_dismiss(...)`, `approval_requests_get(...)`, `approval_requests_invalidate(...)`, `approval_requests_list(...)`, `delete_access_approval_settings(...)`, `get_access_approval_settings(...)`, `get_service_account(...)` and `update_access_approval_settings(...)`
899/// // to build up your call.
900/// let rb = hub.organizations();
901/// # }
902/// ```
903pub struct OrganizationMethods<'a, C>
904where
905    C: 'a,
906{
907    hub: &'a AccessApproval<C>,
908}
909
910impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
911
912impl<'a, C> OrganizationMethods<'a, C> {
913    /// Create a builder to help you perform the following task:
914    ///
915    /// Approves a request and returns the updated ApprovalRequest. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
916    ///
917    /// # Arguments
918    ///
919    /// * `request` - No description provided.
920    /// * `name` - Name of the approval request to approve.
921    pub fn approval_requests_approve(
922        &self,
923        request: ApproveApprovalRequestMessage,
924        name: &str,
925    ) -> OrganizationApprovalRequestApproveCall<'a, C> {
926        OrganizationApprovalRequestApproveCall {
927            hub: self.hub,
928            _request: request,
929            _name: name.to_string(),
930            _delegate: Default::default(),
931            _additional_params: Default::default(),
932            _scopes: Default::default(),
933        }
934    }
935
936    /// Create a builder to help you perform the following task:
937    ///
938    /// Dismisses a request. Returns the updated ApprovalRequest. NOTE: When a request is dismissed, it is considered ignored. Dismissing a request does not prevent access granted by other Access Approval requests. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
939    ///
940    /// # Arguments
941    ///
942    /// * `request` - No description provided.
943    /// * `name` - Name of the ApprovalRequest to dismiss.
944    pub fn approval_requests_dismiss(
945        &self,
946        request: DismissApprovalRequestMessage,
947        name: &str,
948    ) -> OrganizationApprovalRequestDismisCall<'a, C> {
949        OrganizationApprovalRequestDismisCall {
950            hub: self.hub,
951            _request: request,
952            _name: name.to_string(),
953            _delegate: Default::default(),
954            _additional_params: Default::default(),
955            _scopes: Default::default(),
956        }
957    }
958
959    /// Create a builder to help you perform the following task:
960    ///
961    /// Gets an approval request. Returns NOT_FOUND if the request does not exist.
962    ///
963    /// # Arguments
964    ///
965    /// * `name` - The name of the approval request to retrieve. Format: "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
966    pub fn approval_requests_get(&self, name: &str) -> OrganizationApprovalRequestGetCall<'a, C> {
967        OrganizationApprovalRequestGetCall {
968            hub: self.hub,
969            _name: name.to_string(),
970            _delegate: Default::default(),
971            _additional_params: Default::default(),
972            _scopes: Default::default(),
973        }
974    }
975
976    /// Create a builder to help you perform the following task:
977    ///
978    /// Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. NOTE: This action revokes Google access based on this approval request. If the resource has other active approvals, access will remain granted. Returns FAILED_PRECONDITION if the request exists but is not in an approved state.
979    ///
980    /// # Arguments
981    ///
982    /// * `request` - No description provided.
983    /// * `name` - Name of the ApprovalRequest to invalidate.
984    pub fn approval_requests_invalidate(
985        &self,
986        request: InvalidateApprovalRequestMessage,
987        name: &str,
988    ) -> OrganizationApprovalRequestInvalidateCall<'a, C> {
989        OrganizationApprovalRequestInvalidateCall {
990            hub: self.hub,
991            _request: request,
992            _name: name.to_string(),
993            _delegate: Default::default(),
994            _additional_params: Default::default(),
995            _scopes: Default::default(),
996        }
997    }
998
999    /// Create a builder to help you perform the following task:
1000    ///
1001    /// Lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.
1002    ///
1003    /// # Arguments
1004    ///
1005    /// * `parent` - The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".
1006    pub fn approval_requests_list(
1007        &self,
1008        parent: &str,
1009    ) -> OrganizationApprovalRequestListCall<'a, C> {
1010        OrganizationApprovalRequestListCall {
1011            hub: self.hub,
1012            _parent: parent.to_string(),
1013            _page_token: Default::default(),
1014            _page_size: Default::default(),
1015            _filter: Default::default(),
1016            _delegate: Default::default(),
1017            _additional_params: Default::default(),
1018            _scopes: Default::default(),
1019        }
1020    }
1021
1022    /// Create a builder to help you perform the following task:
1023    ///
1024    /// Deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the resource. Access Approval may remain active based on parent resource settings. To confirm the effective settings, call GetAccessApprovalSettings and verify effective setting is disabled.
1025    ///
1026    /// # Arguments
1027    ///
1028    /// * `name` - Name of the AccessApprovalSettings to delete.
1029    pub fn delete_access_approval_settings(
1030        &self,
1031        name: &str,
1032    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
1033        OrganizationDeleteAccessApprovalSettingCall {
1034            hub: self.hub,
1035            _name: name.to_string(),
1036            _delegate: Default::default(),
1037            _additional_params: Default::default(),
1038            _scopes: Default::default(),
1039        }
1040    }
1041
1042    /// Create a builder to help you perform the following task:
1043    ///
1044    /// Gets the Access Approval settings associated with a project, folder, or organization.
1045    ///
1046    /// # Arguments
1047    ///
1048    /// * `name` - The name of the AccessApprovalSettings to retrieve. Format: "{projects|folders|organizations}/{id}/accessApprovalSettings"
1049    pub fn get_access_approval_settings(
1050        &self,
1051        name: &str,
1052    ) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
1053        OrganizationGetAccessApprovalSettingCall {
1054            hub: self.hub,
1055            _name: name.to_string(),
1056            _delegate: Default::default(),
1057            _additional_params: Default::default(),
1058            _scopes: Default::default(),
1059        }
1060    }
1061
1062    /// Create a builder to help you perform the following task:
1063    ///
1064    /// Retrieves the service account that is used by Access Approval to access KMS keys for signing approved approval requests.
1065    ///
1066    /// # Arguments
1067    ///
1068    /// * `name` - Name of the AccessApprovalServiceAccount to retrieve.
1069    pub fn get_service_account(&self, name: &str) -> OrganizationGetServiceAccountCall<'a, C> {
1070        OrganizationGetServiceAccountCall {
1071            hub: self.hub,
1072            _name: name.to_string(),
1073            _delegate: Default::default(),
1074            _additional_params: Default::default(),
1075            _scopes: Default::default(),
1076        }
1077    }
1078
1079    /// Create a builder to help you perform the following task:
1080    ///
1081    /// Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.
1082    ///
1083    /// # Arguments
1084    ///
1085    /// * `request` - No description provided.
1086    /// * `name` - The resource name of the settings. Format is one of: * "projects/{project}/accessApprovalSettings" * "folders/{folder}/accessApprovalSettings" * "organizations/{organization}/accessApprovalSettings"
1087    pub fn update_access_approval_settings(
1088        &self,
1089        request: AccessApprovalSettings,
1090        name: &str,
1091    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
1092        OrganizationUpdateAccessApprovalSettingCall {
1093            hub: self.hub,
1094            _request: request,
1095            _name: name.to_string(),
1096            _update_mask: Default::default(),
1097            _delegate: Default::default(),
1098            _additional_params: Default::default(),
1099            _scopes: Default::default(),
1100        }
1101    }
1102}
1103
1104/// A builder providing access to all methods supported on *project* resources.
1105/// It is not used directly, but through the [`AccessApproval`] hub.
1106///
1107/// # Example
1108///
1109/// Instantiate a resource builder
1110///
1111/// ```test_harness,no_run
1112/// extern crate hyper;
1113/// extern crate hyper_rustls;
1114/// extern crate google_accessapproval1 as accessapproval1;
1115///
1116/// # async fn dox() {
1117/// use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1118///
1119/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1120/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1121///     .with_native_roots()
1122///     .unwrap()
1123///     .https_only()
1124///     .enable_http2()
1125///     .build();
1126///
1127/// let executor = hyper_util::rt::TokioExecutor::new();
1128/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1129///     secret,
1130///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1131///     yup_oauth2::client::CustomHyperClientBuilder::from(
1132///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1133///     ),
1134/// ).build().await.unwrap();
1135///
1136/// let client = hyper_util::client::legacy::Client::builder(
1137///     hyper_util::rt::TokioExecutor::new()
1138/// )
1139/// .build(
1140///     hyper_rustls::HttpsConnectorBuilder::new()
1141///         .with_native_roots()
1142///         .unwrap()
1143///         .https_or_http()
1144///         .enable_http2()
1145///         .build()
1146/// );
1147/// let mut hub = AccessApproval::new(client, auth);
1148/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1149/// // like `approval_requests_approve(...)`, `approval_requests_dismiss(...)`, `approval_requests_get(...)`, `approval_requests_invalidate(...)`, `approval_requests_list(...)`, `delete_access_approval_settings(...)`, `get_access_approval_settings(...)`, `get_service_account(...)` and `update_access_approval_settings(...)`
1150/// // to build up your call.
1151/// let rb = hub.projects();
1152/// # }
1153/// ```
1154pub struct ProjectMethods<'a, C>
1155where
1156    C: 'a,
1157{
1158    hub: &'a AccessApproval<C>,
1159}
1160
1161impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1162
1163impl<'a, C> ProjectMethods<'a, C> {
1164    /// Create a builder to help you perform the following task:
1165    ///
1166    /// Approves a request and returns the updated ApprovalRequest. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
1167    ///
1168    /// # Arguments
1169    ///
1170    /// * `request` - No description provided.
1171    /// * `name` - Name of the approval request to approve.
1172    pub fn approval_requests_approve(
1173        &self,
1174        request: ApproveApprovalRequestMessage,
1175        name: &str,
1176    ) -> ProjectApprovalRequestApproveCall<'a, C> {
1177        ProjectApprovalRequestApproveCall {
1178            hub: self.hub,
1179            _request: request,
1180            _name: name.to_string(),
1181            _delegate: Default::default(),
1182            _additional_params: Default::default(),
1183            _scopes: Default::default(),
1184        }
1185    }
1186
1187    /// Create a builder to help you perform the following task:
1188    ///
1189    /// Dismisses a request. Returns the updated ApprovalRequest. NOTE: When a request is dismissed, it is considered ignored. Dismissing a request does not prevent access granted by other Access Approval requests. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
1190    ///
1191    /// # Arguments
1192    ///
1193    /// * `request` - No description provided.
1194    /// * `name` - Name of the ApprovalRequest to dismiss.
1195    pub fn approval_requests_dismiss(
1196        &self,
1197        request: DismissApprovalRequestMessage,
1198        name: &str,
1199    ) -> ProjectApprovalRequestDismisCall<'a, C> {
1200        ProjectApprovalRequestDismisCall {
1201            hub: self.hub,
1202            _request: request,
1203            _name: name.to_string(),
1204            _delegate: Default::default(),
1205            _additional_params: Default::default(),
1206            _scopes: Default::default(),
1207        }
1208    }
1209
1210    /// Create a builder to help you perform the following task:
1211    ///
1212    /// Gets an approval request. Returns NOT_FOUND if the request does not exist.
1213    ///
1214    /// # Arguments
1215    ///
1216    /// * `name` - The name of the approval request to retrieve. Format: "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
1217    pub fn approval_requests_get(&self, name: &str) -> ProjectApprovalRequestGetCall<'a, C> {
1218        ProjectApprovalRequestGetCall {
1219            hub: self.hub,
1220            _name: name.to_string(),
1221            _delegate: Default::default(),
1222            _additional_params: Default::default(),
1223            _scopes: Default::default(),
1224        }
1225    }
1226
1227    /// Create a builder to help you perform the following task:
1228    ///
1229    /// Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. NOTE: This action revokes Google access based on this approval request. If the resource has other active approvals, access will remain granted. Returns FAILED_PRECONDITION if the request exists but is not in an approved state.
1230    ///
1231    /// # Arguments
1232    ///
1233    /// * `request` - No description provided.
1234    /// * `name` - Name of the ApprovalRequest to invalidate.
1235    pub fn approval_requests_invalidate(
1236        &self,
1237        request: InvalidateApprovalRequestMessage,
1238        name: &str,
1239    ) -> ProjectApprovalRequestInvalidateCall<'a, C> {
1240        ProjectApprovalRequestInvalidateCall {
1241            hub: self.hub,
1242            _request: request,
1243            _name: name.to_string(),
1244            _delegate: Default::default(),
1245            _additional_params: Default::default(),
1246            _scopes: Default::default(),
1247        }
1248    }
1249
1250    /// Create a builder to help you perform the following task:
1251    ///
1252    /// Lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.
1253    ///
1254    /// # Arguments
1255    ///
1256    /// * `parent` - The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".
1257    pub fn approval_requests_list(&self, parent: &str) -> ProjectApprovalRequestListCall<'a, C> {
1258        ProjectApprovalRequestListCall {
1259            hub: self.hub,
1260            _parent: parent.to_string(),
1261            _page_token: Default::default(),
1262            _page_size: Default::default(),
1263            _filter: Default::default(),
1264            _delegate: Default::default(),
1265            _additional_params: Default::default(),
1266            _scopes: Default::default(),
1267        }
1268    }
1269
1270    /// Create a builder to help you perform the following task:
1271    ///
1272    /// Deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the resource. Access Approval may remain active based on parent resource settings. To confirm the effective settings, call GetAccessApprovalSettings and verify effective setting is disabled.
1273    ///
1274    /// # Arguments
1275    ///
1276    /// * `name` - Name of the AccessApprovalSettings to delete.
1277    pub fn delete_access_approval_settings(
1278        &self,
1279        name: &str,
1280    ) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
1281        ProjectDeleteAccessApprovalSettingCall {
1282            hub: self.hub,
1283            _name: name.to_string(),
1284            _delegate: Default::default(),
1285            _additional_params: Default::default(),
1286            _scopes: Default::default(),
1287        }
1288    }
1289
1290    /// Create a builder to help you perform the following task:
1291    ///
1292    /// Gets the Access Approval settings associated with a project, folder, or organization.
1293    ///
1294    /// # Arguments
1295    ///
1296    /// * `name` - The name of the AccessApprovalSettings to retrieve. Format: "{projects|folders|organizations}/{id}/accessApprovalSettings"
1297    pub fn get_access_approval_settings(
1298        &self,
1299        name: &str,
1300    ) -> ProjectGetAccessApprovalSettingCall<'a, C> {
1301        ProjectGetAccessApprovalSettingCall {
1302            hub: self.hub,
1303            _name: name.to_string(),
1304            _delegate: Default::default(),
1305            _additional_params: Default::default(),
1306            _scopes: Default::default(),
1307        }
1308    }
1309
1310    /// Create a builder to help you perform the following task:
1311    ///
1312    /// Retrieves the service account that is used by Access Approval to access KMS keys for signing approved approval requests.
1313    ///
1314    /// # Arguments
1315    ///
1316    /// * `name` - Name of the AccessApprovalServiceAccount to retrieve.
1317    pub fn get_service_account(&self, name: &str) -> ProjectGetServiceAccountCall<'a, C> {
1318        ProjectGetServiceAccountCall {
1319            hub: self.hub,
1320            _name: name.to_string(),
1321            _delegate: Default::default(),
1322            _additional_params: Default::default(),
1323            _scopes: Default::default(),
1324        }
1325    }
1326
1327    /// Create a builder to help you perform the following task:
1328    ///
1329    /// Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.
1330    ///
1331    /// # Arguments
1332    ///
1333    /// * `request` - No description provided.
1334    /// * `name` - The resource name of the settings. Format is one of: * "projects/{project}/accessApprovalSettings" * "folders/{folder}/accessApprovalSettings" * "organizations/{organization}/accessApprovalSettings"
1335    pub fn update_access_approval_settings(
1336        &self,
1337        request: AccessApprovalSettings,
1338        name: &str,
1339    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
1340        ProjectUpdateAccessApprovalSettingCall {
1341            hub: self.hub,
1342            _request: request,
1343            _name: name.to_string(),
1344            _update_mask: Default::default(),
1345            _delegate: Default::default(),
1346            _additional_params: Default::default(),
1347            _scopes: Default::default(),
1348        }
1349    }
1350}
1351
1352// ###################
1353// CallBuilders   ###
1354// #################
1355
1356/// Approves a request and returns the updated ApprovalRequest. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
1357///
1358/// A builder for the *approvalRequests.approve* method supported by a *folder* resource.
1359/// It is not used directly, but through a [`FolderMethods`] instance.
1360///
1361/// # Example
1362///
1363/// Instantiate a resource method builder
1364///
1365/// ```test_harness,no_run
1366/// # extern crate hyper;
1367/// # extern crate hyper_rustls;
1368/// # extern crate google_accessapproval1 as accessapproval1;
1369/// use accessapproval1::api::ApproveApprovalRequestMessage;
1370/// # async fn dox() {
1371/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1372///
1373/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1374/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1375/// #     .with_native_roots()
1376/// #     .unwrap()
1377/// #     .https_only()
1378/// #     .enable_http2()
1379/// #     .build();
1380///
1381/// # let executor = hyper_util::rt::TokioExecutor::new();
1382/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1383/// #     secret,
1384/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1385/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1386/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1387/// #     ),
1388/// # ).build().await.unwrap();
1389///
1390/// # let client = hyper_util::client::legacy::Client::builder(
1391/// #     hyper_util::rt::TokioExecutor::new()
1392/// # )
1393/// # .build(
1394/// #     hyper_rustls::HttpsConnectorBuilder::new()
1395/// #         .with_native_roots()
1396/// #         .unwrap()
1397/// #         .https_or_http()
1398/// #         .enable_http2()
1399/// #         .build()
1400/// # );
1401/// # let mut hub = AccessApproval::new(client, auth);
1402/// // As the method needs a request, you would usually fill it with the desired information
1403/// // into the respective structure. Some of the parts shown here might not be applicable !
1404/// // Values shown here are possibly random and not representative !
1405/// let mut req = ApproveApprovalRequestMessage::default();
1406///
1407/// // You can configure optional parameters by calling the respective setters at will, and
1408/// // execute the final call using `doit()`.
1409/// // Values shown here are possibly random and not representative !
1410/// let result = hub.folders().approval_requests_approve(req, "name")
1411///              .doit().await;
1412/// # }
1413/// ```
1414pub struct FolderApprovalRequestApproveCall<'a, C>
1415where
1416    C: 'a,
1417{
1418    hub: &'a AccessApproval<C>,
1419    _request: ApproveApprovalRequestMessage,
1420    _name: String,
1421    _delegate: Option<&'a mut dyn common::Delegate>,
1422    _additional_params: HashMap<String, String>,
1423    _scopes: BTreeSet<String>,
1424}
1425
1426impl<'a, C> common::CallBuilder for FolderApprovalRequestApproveCall<'a, C> {}
1427
1428impl<'a, C> FolderApprovalRequestApproveCall<'a, C>
1429where
1430    C: common::Connector,
1431{
1432    /// Perform the operation you have build so far.
1433    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
1434        use std::borrow::Cow;
1435        use std::io::{Read, Seek};
1436
1437        use common::{url::Params, ToParts};
1438        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1439
1440        let mut dd = common::DefaultDelegate;
1441        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1442        dlg.begin(common::MethodInfo {
1443            id: "accessapproval.folders.approvalRequests.approve",
1444            http_method: hyper::Method::POST,
1445        });
1446
1447        for &field in ["alt", "name"].iter() {
1448            if self._additional_params.contains_key(field) {
1449                dlg.finished(false);
1450                return Err(common::Error::FieldClash(field));
1451            }
1452        }
1453
1454        let mut params = Params::with_capacity(4 + self._additional_params.len());
1455        params.push("name", self._name);
1456
1457        params.extend(self._additional_params.iter());
1458
1459        params.push("alt", "json");
1460        let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
1461        if self._scopes.is_empty() {
1462            self._scopes
1463                .insert(Scope::CloudPlatform.as_ref().to_string());
1464        }
1465
1466        #[allow(clippy::single_element_loop)]
1467        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1468            url = params.uri_replacement(url, param_name, find_this, true);
1469        }
1470        {
1471            let to_remove = ["name"];
1472            params.remove_params(&to_remove);
1473        }
1474
1475        let url = params.parse_with_url(&url);
1476
1477        let mut json_mime_type = mime::APPLICATION_JSON;
1478        let mut request_value_reader = {
1479            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1480            common::remove_json_null_values(&mut value);
1481            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1482            serde_json::to_writer(&mut dst, &value).unwrap();
1483            dst
1484        };
1485        let request_size = request_value_reader
1486            .seek(std::io::SeekFrom::End(0))
1487            .unwrap();
1488        request_value_reader
1489            .seek(std::io::SeekFrom::Start(0))
1490            .unwrap();
1491
1492        loop {
1493            let token = match self
1494                .hub
1495                .auth
1496                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1497                .await
1498            {
1499                Ok(token) => token,
1500                Err(e) => match dlg.token(e) {
1501                    Ok(token) => token,
1502                    Err(e) => {
1503                        dlg.finished(false);
1504                        return Err(common::Error::MissingToken(e));
1505                    }
1506                },
1507            };
1508            request_value_reader
1509                .seek(std::io::SeekFrom::Start(0))
1510                .unwrap();
1511            let mut req_result = {
1512                let client = &self.hub.client;
1513                dlg.pre_request();
1514                let mut req_builder = hyper::Request::builder()
1515                    .method(hyper::Method::POST)
1516                    .uri(url.as_str())
1517                    .header(USER_AGENT, self.hub._user_agent.clone());
1518
1519                if let Some(token) = token.as_ref() {
1520                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1521                }
1522
1523                let request = req_builder
1524                    .header(CONTENT_TYPE, json_mime_type.to_string())
1525                    .header(CONTENT_LENGTH, request_size as u64)
1526                    .body(common::to_body(
1527                        request_value_reader.get_ref().clone().into(),
1528                    ));
1529
1530                client.request(request.unwrap()).await
1531            };
1532
1533            match req_result {
1534                Err(err) => {
1535                    if let common::Retry::After(d) = dlg.http_error(&err) {
1536                        sleep(d).await;
1537                        continue;
1538                    }
1539                    dlg.finished(false);
1540                    return Err(common::Error::HttpError(err));
1541                }
1542                Ok(res) => {
1543                    let (mut parts, body) = res.into_parts();
1544                    let mut body = common::Body::new(body);
1545                    if !parts.status.is_success() {
1546                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1547                        let error = serde_json::from_str(&common::to_string(&bytes));
1548                        let response = common::to_response(parts, bytes.into());
1549
1550                        if let common::Retry::After(d) =
1551                            dlg.http_failure(&response, error.as_ref().ok())
1552                        {
1553                            sleep(d).await;
1554                            continue;
1555                        }
1556
1557                        dlg.finished(false);
1558
1559                        return Err(match error {
1560                            Ok(value) => common::Error::BadRequest(value),
1561                            _ => common::Error::Failure(response),
1562                        });
1563                    }
1564                    let response = {
1565                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1566                        let encoded = common::to_string(&bytes);
1567                        match serde_json::from_str(&encoded) {
1568                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1569                            Err(error) => {
1570                                dlg.response_json_decode_error(&encoded, &error);
1571                                return Err(common::Error::JsonDecodeError(
1572                                    encoded.to_string(),
1573                                    error,
1574                                ));
1575                            }
1576                        }
1577                    };
1578
1579                    dlg.finished(true);
1580                    return Ok(response);
1581                }
1582            }
1583        }
1584    }
1585
1586    ///
1587    /// Sets the *request* property to the given value.
1588    ///
1589    /// Even though the property as already been set when instantiating this call,
1590    /// we provide this method for API completeness.
1591    pub fn request(
1592        mut self,
1593        new_value: ApproveApprovalRequestMessage,
1594    ) -> FolderApprovalRequestApproveCall<'a, C> {
1595        self._request = new_value;
1596        self
1597    }
1598    /// Name of the approval request to approve.
1599    ///
1600    /// Sets the *name* path property to the given value.
1601    ///
1602    /// Even though the property as already been set when instantiating this call,
1603    /// we provide this method for API completeness.
1604    pub fn name(mut self, new_value: &str) -> FolderApprovalRequestApproveCall<'a, C> {
1605        self._name = new_value.to_string();
1606        self
1607    }
1608    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1609    /// while executing the actual API request.
1610    ///
1611    /// ````text
1612    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1613    /// ````
1614    ///
1615    /// Sets the *delegate* property to the given value.
1616    pub fn delegate(
1617        mut self,
1618        new_value: &'a mut dyn common::Delegate,
1619    ) -> FolderApprovalRequestApproveCall<'a, C> {
1620        self._delegate = Some(new_value);
1621        self
1622    }
1623
1624    /// Set any additional parameter of the query string used in the request.
1625    /// It should be used to set parameters which are not yet available through their own
1626    /// setters.
1627    ///
1628    /// Please note that this method must not be used to set any of the known parameters
1629    /// which have their own setter method. If done anyway, the request will fail.
1630    ///
1631    /// # Additional Parameters
1632    ///
1633    /// * *$.xgafv* (query-string) - V1 error format.
1634    /// * *access_token* (query-string) - OAuth access token.
1635    /// * *alt* (query-string) - Data format for response.
1636    /// * *callback* (query-string) - JSONP
1637    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1638    /// * *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.
1639    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1640    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1641    /// * *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.
1642    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1643    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1644    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestApproveCall<'a, C>
1645    where
1646        T: AsRef<str>,
1647    {
1648        self._additional_params
1649            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1650        self
1651    }
1652
1653    /// Identifies the authorization scope for the method you are building.
1654    ///
1655    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1656    /// [`Scope::CloudPlatform`].
1657    ///
1658    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1659    /// tokens for more than one scope.
1660    ///
1661    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1662    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1663    /// sufficient, a read-write scope will do as well.
1664    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestApproveCall<'a, C>
1665    where
1666        St: AsRef<str>,
1667    {
1668        self._scopes.insert(String::from(scope.as_ref()));
1669        self
1670    }
1671    /// Identifies the authorization scope(s) for the method you are building.
1672    ///
1673    /// See [`Self::add_scope()`] for details.
1674    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestApproveCall<'a, C>
1675    where
1676        I: IntoIterator<Item = St>,
1677        St: AsRef<str>,
1678    {
1679        self._scopes
1680            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1681        self
1682    }
1683
1684    /// Removes all scopes, and no default scope will be used either.
1685    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1686    /// for details).
1687    pub fn clear_scopes(mut self) -> FolderApprovalRequestApproveCall<'a, C> {
1688        self._scopes.clear();
1689        self
1690    }
1691}
1692
1693/// Dismisses a request. Returns the updated ApprovalRequest. NOTE: When a request is dismissed, it is considered ignored. Dismissing a request does not prevent access granted by other Access Approval requests. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
1694///
1695/// A builder for the *approvalRequests.dismiss* method supported by a *folder* resource.
1696/// It is not used directly, but through a [`FolderMethods`] instance.
1697///
1698/// # Example
1699///
1700/// Instantiate a resource method builder
1701///
1702/// ```test_harness,no_run
1703/// # extern crate hyper;
1704/// # extern crate hyper_rustls;
1705/// # extern crate google_accessapproval1 as accessapproval1;
1706/// use accessapproval1::api::DismissApprovalRequestMessage;
1707/// # async fn dox() {
1708/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1709///
1710/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1711/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1712/// #     .with_native_roots()
1713/// #     .unwrap()
1714/// #     .https_only()
1715/// #     .enable_http2()
1716/// #     .build();
1717///
1718/// # let executor = hyper_util::rt::TokioExecutor::new();
1719/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1720/// #     secret,
1721/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1722/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1723/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1724/// #     ),
1725/// # ).build().await.unwrap();
1726///
1727/// # let client = hyper_util::client::legacy::Client::builder(
1728/// #     hyper_util::rt::TokioExecutor::new()
1729/// # )
1730/// # .build(
1731/// #     hyper_rustls::HttpsConnectorBuilder::new()
1732/// #         .with_native_roots()
1733/// #         .unwrap()
1734/// #         .https_or_http()
1735/// #         .enable_http2()
1736/// #         .build()
1737/// # );
1738/// # let mut hub = AccessApproval::new(client, auth);
1739/// // As the method needs a request, you would usually fill it with the desired information
1740/// // into the respective structure. Some of the parts shown here might not be applicable !
1741/// // Values shown here are possibly random and not representative !
1742/// let mut req = DismissApprovalRequestMessage::default();
1743///
1744/// // You can configure optional parameters by calling the respective setters at will, and
1745/// // execute the final call using `doit()`.
1746/// // Values shown here are possibly random and not representative !
1747/// let result = hub.folders().approval_requests_dismiss(req, "name")
1748///              .doit().await;
1749/// # }
1750/// ```
1751pub struct FolderApprovalRequestDismisCall<'a, C>
1752where
1753    C: 'a,
1754{
1755    hub: &'a AccessApproval<C>,
1756    _request: DismissApprovalRequestMessage,
1757    _name: String,
1758    _delegate: Option<&'a mut dyn common::Delegate>,
1759    _additional_params: HashMap<String, String>,
1760    _scopes: BTreeSet<String>,
1761}
1762
1763impl<'a, C> common::CallBuilder for FolderApprovalRequestDismisCall<'a, C> {}
1764
1765impl<'a, C> FolderApprovalRequestDismisCall<'a, C>
1766where
1767    C: common::Connector,
1768{
1769    /// Perform the operation you have build so far.
1770    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
1771        use std::borrow::Cow;
1772        use std::io::{Read, Seek};
1773
1774        use common::{url::Params, ToParts};
1775        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1776
1777        let mut dd = common::DefaultDelegate;
1778        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1779        dlg.begin(common::MethodInfo {
1780            id: "accessapproval.folders.approvalRequests.dismiss",
1781            http_method: hyper::Method::POST,
1782        });
1783
1784        for &field in ["alt", "name"].iter() {
1785            if self._additional_params.contains_key(field) {
1786                dlg.finished(false);
1787                return Err(common::Error::FieldClash(field));
1788            }
1789        }
1790
1791        let mut params = Params::with_capacity(4 + self._additional_params.len());
1792        params.push("name", self._name);
1793
1794        params.extend(self._additional_params.iter());
1795
1796        params.push("alt", "json");
1797        let mut url = self.hub._base_url.clone() + "v1/{+name}:dismiss";
1798        if self._scopes.is_empty() {
1799            self._scopes
1800                .insert(Scope::CloudPlatform.as_ref().to_string());
1801        }
1802
1803        #[allow(clippy::single_element_loop)]
1804        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1805            url = params.uri_replacement(url, param_name, find_this, true);
1806        }
1807        {
1808            let to_remove = ["name"];
1809            params.remove_params(&to_remove);
1810        }
1811
1812        let url = params.parse_with_url(&url);
1813
1814        let mut json_mime_type = mime::APPLICATION_JSON;
1815        let mut request_value_reader = {
1816            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1817            common::remove_json_null_values(&mut value);
1818            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1819            serde_json::to_writer(&mut dst, &value).unwrap();
1820            dst
1821        };
1822        let request_size = request_value_reader
1823            .seek(std::io::SeekFrom::End(0))
1824            .unwrap();
1825        request_value_reader
1826            .seek(std::io::SeekFrom::Start(0))
1827            .unwrap();
1828
1829        loop {
1830            let token = match self
1831                .hub
1832                .auth
1833                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1834                .await
1835            {
1836                Ok(token) => token,
1837                Err(e) => match dlg.token(e) {
1838                    Ok(token) => token,
1839                    Err(e) => {
1840                        dlg.finished(false);
1841                        return Err(common::Error::MissingToken(e));
1842                    }
1843                },
1844            };
1845            request_value_reader
1846                .seek(std::io::SeekFrom::Start(0))
1847                .unwrap();
1848            let mut req_result = {
1849                let client = &self.hub.client;
1850                dlg.pre_request();
1851                let mut req_builder = hyper::Request::builder()
1852                    .method(hyper::Method::POST)
1853                    .uri(url.as_str())
1854                    .header(USER_AGENT, self.hub._user_agent.clone());
1855
1856                if let Some(token) = token.as_ref() {
1857                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1858                }
1859
1860                let request = req_builder
1861                    .header(CONTENT_TYPE, json_mime_type.to_string())
1862                    .header(CONTENT_LENGTH, request_size as u64)
1863                    .body(common::to_body(
1864                        request_value_reader.get_ref().clone().into(),
1865                    ));
1866
1867                client.request(request.unwrap()).await
1868            };
1869
1870            match req_result {
1871                Err(err) => {
1872                    if let common::Retry::After(d) = dlg.http_error(&err) {
1873                        sleep(d).await;
1874                        continue;
1875                    }
1876                    dlg.finished(false);
1877                    return Err(common::Error::HttpError(err));
1878                }
1879                Ok(res) => {
1880                    let (mut parts, body) = res.into_parts();
1881                    let mut body = common::Body::new(body);
1882                    if !parts.status.is_success() {
1883                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1884                        let error = serde_json::from_str(&common::to_string(&bytes));
1885                        let response = common::to_response(parts, bytes.into());
1886
1887                        if let common::Retry::After(d) =
1888                            dlg.http_failure(&response, error.as_ref().ok())
1889                        {
1890                            sleep(d).await;
1891                            continue;
1892                        }
1893
1894                        dlg.finished(false);
1895
1896                        return Err(match error {
1897                            Ok(value) => common::Error::BadRequest(value),
1898                            _ => common::Error::Failure(response),
1899                        });
1900                    }
1901                    let response = {
1902                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1903                        let encoded = common::to_string(&bytes);
1904                        match serde_json::from_str(&encoded) {
1905                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1906                            Err(error) => {
1907                                dlg.response_json_decode_error(&encoded, &error);
1908                                return Err(common::Error::JsonDecodeError(
1909                                    encoded.to_string(),
1910                                    error,
1911                                ));
1912                            }
1913                        }
1914                    };
1915
1916                    dlg.finished(true);
1917                    return Ok(response);
1918                }
1919            }
1920        }
1921    }
1922
1923    ///
1924    /// Sets the *request* property to the given value.
1925    ///
1926    /// Even though the property as already been set when instantiating this call,
1927    /// we provide this method for API completeness.
1928    pub fn request(
1929        mut self,
1930        new_value: DismissApprovalRequestMessage,
1931    ) -> FolderApprovalRequestDismisCall<'a, C> {
1932        self._request = new_value;
1933        self
1934    }
1935    /// Name of the ApprovalRequest to dismiss.
1936    ///
1937    /// Sets the *name* path property to the given value.
1938    ///
1939    /// Even though the property as already been set when instantiating this call,
1940    /// we provide this method for API completeness.
1941    pub fn name(mut self, new_value: &str) -> FolderApprovalRequestDismisCall<'a, C> {
1942        self._name = new_value.to_string();
1943        self
1944    }
1945    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1946    /// while executing the actual API request.
1947    ///
1948    /// ````text
1949    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1950    /// ````
1951    ///
1952    /// Sets the *delegate* property to the given value.
1953    pub fn delegate(
1954        mut self,
1955        new_value: &'a mut dyn common::Delegate,
1956    ) -> FolderApprovalRequestDismisCall<'a, C> {
1957        self._delegate = Some(new_value);
1958        self
1959    }
1960
1961    /// Set any additional parameter of the query string used in the request.
1962    /// It should be used to set parameters which are not yet available through their own
1963    /// setters.
1964    ///
1965    /// Please note that this method must not be used to set any of the known parameters
1966    /// which have their own setter method. If done anyway, the request will fail.
1967    ///
1968    /// # Additional Parameters
1969    ///
1970    /// * *$.xgafv* (query-string) - V1 error format.
1971    /// * *access_token* (query-string) - OAuth access token.
1972    /// * *alt* (query-string) - Data format for response.
1973    /// * *callback* (query-string) - JSONP
1974    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1975    /// * *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.
1976    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1977    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1978    /// * *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.
1979    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1980    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1981    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestDismisCall<'a, C>
1982    where
1983        T: AsRef<str>,
1984    {
1985        self._additional_params
1986            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1987        self
1988    }
1989
1990    /// Identifies the authorization scope for the method you are building.
1991    ///
1992    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1993    /// [`Scope::CloudPlatform`].
1994    ///
1995    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1996    /// tokens for more than one scope.
1997    ///
1998    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1999    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2000    /// sufficient, a read-write scope will do as well.
2001    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestDismisCall<'a, C>
2002    where
2003        St: AsRef<str>,
2004    {
2005        self._scopes.insert(String::from(scope.as_ref()));
2006        self
2007    }
2008    /// Identifies the authorization scope(s) for the method you are building.
2009    ///
2010    /// See [`Self::add_scope()`] for details.
2011    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestDismisCall<'a, C>
2012    where
2013        I: IntoIterator<Item = St>,
2014        St: AsRef<str>,
2015    {
2016        self._scopes
2017            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2018        self
2019    }
2020
2021    /// Removes all scopes, and no default scope will be used either.
2022    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2023    /// for details).
2024    pub fn clear_scopes(mut self) -> FolderApprovalRequestDismisCall<'a, C> {
2025        self._scopes.clear();
2026        self
2027    }
2028}
2029
2030/// Gets an approval request. Returns NOT_FOUND if the request does not exist.
2031///
2032/// A builder for the *approvalRequests.get* method supported by a *folder* resource.
2033/// It is not used directly, but through a [`FolderMethods`] instance.
2034///
2035/// # Example
2036///
2037/// Instantiate a resource method builder
2038///
2039/// ```test_harness,no_run
2040/// # extern crate hyper;
2041/// # extern crate hyper_rustls;
2042/// # extern crate google_accessapproval1 as accessapproval1;
2043/// # async fn dox() {
2044/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2045///
2046/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2047/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2048/// #     .with_native_roots()
2049/// #     .unwrap()
2050/// #     .https_only()
2051/// #     .enable_http2()
2052/// #     .build();
2053///
2054/// # let executor = hyper_util::rt::TokioExecutor::new();
2055/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2056/// #     secret,
2057/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2058/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2059/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2060/// #     ),
2061/// # ).build().await.unwrap();
2062///
2063/// # let client = hyper_util::client::legacy::Client::builder(
2064/// #     hyper_util::rt::TokioExecutor::new()
2065/// # )
2066/// # .build(
2067/// #     hyper_rustls::HttpsConnectorBuilder::new()
2068/// #         .with_native_roots()
2069/// #         .unwrap()
2070/// #         .https_or_http()
2071/// #         .enable_http2()
2072/// #         .build()
2073/// # );
2074/// # let mut hub = AccessApproval::new(client, auth);
2075/// // You can configure optional parameters by calling the respective setters at will, and
2076/// // execute the final call using `doit()`.
2077/// // Values shown here are possibly random and not representative !
2078/// let result = hub.folders().approval_requests_get("name")
2079///              .doit().await;
2080/// # }
2081/// ```
2082pub struct FolderApprovalRequestGetCall<'a, C>
2083where
2084    C: 'a,
2085{
2086    hub: &'a AccessApproval<C>,
2087    _name: String,
2088    _delegate: Option<&'a mut dyn common::Delegate>,
2089    _additional_params: HashMap<String, String>,
2090    _scopes: BTreeSet<String>,
2091}
2092
2093impl<'a, C> common::CallBuilder for FolderApprovalRequestGetCall<'a, C> {}
2094
2095impl<'a, C> FolderApprovalRequestGetCall<'a, C>
2096where
2097    C: common::Connector,
2098{
2099    /// Perform the operation you have build so far.
2100    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
2101        use std::borrow::Cow;
2102        use std::io::{Read, Seek};
2103
2104        use common::{url::Params, ToParts};
2105        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2106
2107        let mut dd = common::DefaultDelegate;
2108        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2109        dlg.begin(common::MethodInfo {
2110            id: "accessapproval.folders.approvalRequests.get",
2111            http_method: hyper::Method::GET,
2112        });
2113
2114        for &field in ["alt", "name"].iter() {
2115            if self._additional_params.contains_key(field) {
2116                dlg.finished(false);
2117                return Err(common::Error::FieldClash(field));
2118            }
2119        }
2120
2121        let mut params = Params::with_capacity(3 + self._additional_params.len());
2122        params.push("name", self._name);
2123
2124        params.extend(self._additional_params.iter());
2125
2126        params.push("alt", "json");
2127        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2128        if self._scopes.is_empty() {
2129            self._scopes
2130                .insert(Scope::CloudPlatform.as_ref().to_string());
2131        }
2132
2133        #[allow(clippy::single_element_loop)]
2134        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2135            url = params.uri_replacement(url, param_name, find_this, true);
2136        }
2137        {
2138            let to_remove = ["name"];
2139            params.remove_params(&to_remove);
2140        }
2141
2142        let url = params.parse_with_url(&url);
2143
2144        loop {
2145            let token = match self
2146                .hub
2147                .auth
2148                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2149                .await
2150            {
2151                Ok(token) => token,
2152                Err(e) => match dlg.token(e) {
2153                    Ok(token) => token,
2154                    Err(e) => {
2155                        dlg.finished(false);
2156                        return Err(common::Error::MissingToken(e));
2157                    }
2158                },
2159            };
2160            let mut req_result = {
2161                let client = &self.hub.client;
2162                dlg.pre_request();
2163                let mut req_builder = hyper::Request::builder()
2164                    .method(hyper::Method::GET)
2165                    .uri(url.as_str())
2166                    .header(USER_AGENT, self.hub._user_agent.clone());
2167
2168                if let Some(token) = token.as_ref() {
2169                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2170                }
2171
2172                let request = req_builder
2173                    .header(CONTENT_LENGTH, 0_u64)
2174                    .body(common::to_body::<String>(None));
2175
2176                client.request(request.unwrap()).await
2177            };
2178
2179            match req_result {
2180                Err(err) => {
2181                    if let common::Retry::After(d) = dlg.http_error(&err) {
2182                        sleep(d).await;
2183                        continue;
2184                    }
2185                    dlg.finished(false);
2186                    return Err(common::Error::HttpError(err));
2187                }
2188                Ok(res) => {
2189                    let (mut parts, body) = res.into_parts();
2190                    let mut body = common::Body::new(body);
2191                    if !parts.status.is_success() {
2192                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2193                        let error = serde_json::from_str(&common::to_string(&bytes));
2194                        let response = common::to_response(parts, bytes.into());
2195
2196                        if let common::Retry::After(d) =
2197                            dlg.http_failure(&response, error.as_ref().ok())
2198                        {
2199                            sleep(d).await;
2200                            continue;
2201                        }
2202
2203                        dlg.finished(false);
2204
2205                        return Err(match error {
2206                            Ok(value) => common::Error::BadRequest(value),
2207                            _ => common::Error::Failure(response),
2208                        });
2209                    }
2210                    let response = {
2211                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2212                        let encoded = common::to_string(&bytes);
2213                        match serde_json::from_str(&encoded) {
2214                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2215                            Err(error) => {
2216                                dlg.response_json_decode_error(&encoded, &error);
2217                                return Err(common::Error::JsonDecodeError(
2218                                    encoded.to_string(),
2219                                    error,
2220                                ));
2221                            }
2222                        }
2223                    };
2224
2225                    dlg.finished(true);
2226                    return Ok(response);
2227                }
2228            }
2229        }
2230    }
2231
2232    /// The name of the approval request to retrieve. Format: "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
2233    ///
2234    /// Sets the *name* path property to the given value.
2235    ///
2236    /// Even though the property as already been set when instantiating this call,
2237    /// we provide this method for API completeness.
2238    pub fn name(mut self, new_value: &str) -> FolderApprovalRequestGetCall<'a, C> {
2239        self._name = new_value.to_string();
2240        self
2241    }
2242    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2243    /// while executing the actual API request.
2244    ///
2245    /// ````text
2246    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2247    /// ````
2248    ///
2249    /// Sets the *delegate* property to the given value.
2250    pub fn delegate(
2251        mut self,
2252        new_value: &'a mut dyn common::Delegate,
2253    ) -> FolderApprovalRequestGetCall<'a, C> {
2254        self._delegate = Some(new_value);
2255        self
2256    }
2257
2258    /// Set any additional parameter of the query string used in the request.
2259    /// It should be used to set parameters which are not yet available through their own
2260    /// setters.
2261    ///
2262    /// Please note that this method must not be used to set any of the known parameters
2263    /// which have their own setter method. If done anyway, the request will fail.
2264    ///
2265    /// # Additional Parameters
2266    ///
2267    /// * *$.xgafv* (query-string) - V1 error format.
2268    /// * *access_token* (query-string) - OAuth access token.
2269    /// * *alt* (query-string) - Data format for response.
2270    /// * *callback* (query-string) - JSONP
2271    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2272    /// * *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.
2273    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2274    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2275    /// * *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.
2276    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2277    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2278    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestGetCall<'a, C>
2279    where
2280        T: AsRef<str>,
2281    {
2282        self._additional_params
2283            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2284        self
2285    }
2286
2287    /// Identifies the authorization scope for the method you are building.
2288    ///
2289    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2290    /// [`Scope::CloudPlatform`].
2291    ///
2292    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2293    /// tokens for more than one scope.
2294    ///
2295    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2296    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2297    /// sufficient, a read-write scope will do as well.
2298    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestGetCall<'a, C>
2299    where
2300        St: AsRef<str>,
2301    {
2302        self._scopes.insert(String::from(scope.as_ref()));
2303        self
2304    }
2305    /// Identifies the authorization scope(s) for the method you are building.
2306    ///
2307    /// See [`Self::add_scope()`] for details.
2308    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestGetCall<'a, C>
2309    where
2310        I: IntoIterator<Item = St>,
2311        St: AsRef<str>,
2312    {
2313        self._scopes
2314            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2315        self
2316    }
2317
2318    /// Removes all scopes, and no default scope will be used either.
2319    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2320    /// for details).
2321    pub fn clear_scopes(mut self) -> FolderApprovalRequestGetCall<'a, C> {
2322        self._scopes.clear();
2323        self
2324    }
2325}
2326
2327/// Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. NOTE: This action revokes Google access based on this approval request. If the resource has other active approvals, access will remain granted. Returns FAILED_PRECONDITION if the request exists but is not in an approved state.
2328///
2329/// A builder for the *approvalRequests.invalidate* method supported by a *folder* resource.
2330/// It is not used directly, but through a [`FolderMethods`] instance.
2331///
2332/// # Example
2333///
2334/// Instantiate a resource method builder
2335///
2336/// ```test_harness,no_run
2337/// # extern crate hyper;
2338/// # extern crate hyper_rustls;
2339/// # extern crate google_accessapproval1 as accessapproval1;
2340/// use accessapproval1::api::InvalidateApprovalRequestMessage;
2341/// # async fn dox() {
2342/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2343///
2344/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2345/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2346/// #     .with_native_roots()
2347/// #     .unwrap()
2348/// #     .https_only()
2349/// #     .enable_http2()
2350/// #     .build();
2351///
2352/// # let executor = hyper_util::rt::TokioExecutor::new();
2353/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2354/// #     secret,
2355/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2356/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2357/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2358/// #     ),
2359/// # ).build().await.unwrap();
2360///
2361/// # let client = hyper_util::client::legacy::Client::builder(
2362/// #     hyper_util::rt::TokioExecutor::new()
2363/// # )
2364/// # .build(
2365/// #     hyper_rustls::HttpsConnectorBuilder::new()
2366/// #         .with_native_roots()
2367/// #         .unwrap()
2368/// #         .https_or_http()
2369/// #         .enable_http2()
2370/// #         .build()
2371/// # );
2372/// # let mut hub = AccessApproval::new(client, auth);
2373/// // As the method needs a request, you would usually fill it with the desired information
2374/// // into the respective structure. Some of the parts shown here might not be applicable !
2375/// // Values shown here are possibly random and not representative !
2376/// let mut req = InvalidateApprovalRequestMessage::default();
2377///
2378/// // You can configure optional parameters by calling the respective setters at will, and
2379/// // execute the final call using `doit()`.
2380/// // Values shown here are possibly random and not representative !
2381/// let result = hub.folders().approval_requests_invalidate(req, "name")
2382///              .doit().await;
2383/// # }
2384/// ```
2385pub struct FolderApprovalRequestInvalidateCall<'a, C>
2386where
2387    C: 'a,
2388{
2389    hub: &'a AccessApproval<C>,
2390    _request: InvalidateApprovalRequestMessage,
2391    _name: String,
2392    _delegate: Option<&'a mut dyn common::Delegate>,
2393    _additional_params: HashMap<String, String>,
2394    _scopes: BTreeSet<String>,
2395}
2396
2397impl<'a, C> common::CallBuilder for FolderApprovalRequestInvalidateCall<'a, C> {}
2398
2399impl<'a, C> FolderApprovalRequestInvalidateCall<'a, C>
2400where
2401    C: common::Connector,
2402{
2403    /// Perform the operation you have build so far.
2404    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
2405        use std::borrow::Cow;
2406        use std::io::{Read, Seek};
2407
2408        use common::{url::Params, ToParts};
2409        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2410
2411        let mut dd = common::DefaultDelegate;
2412        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2413        dlg.begin(common::MethodInfo {
2414            id: "accessapproval.folders.approvalRequests.invalidate",
2415            http_method: hyper::Method::POST,
2416        });
2417
2418        for &field in ["alt", "name"].iter() {
2419            if self._additional_params.contains_key(field) {
2420                dlg.finished(false);
2421                return Err(common::Error::FieldClash(field));
2422            }
2423        }
2424
2425        let mut params = Params::with_capacity(4 + self._additional_params.len());
2426        params.push("name", self._name);
2427
2428        params.extend(self._additional_params.iter());
2429
2430        params.push("alt", "json");
2431        let mut url = self.hub._base_url.clone() + "v1/{+name}:invalidate";
2432        if self._scopes.is_empty() {
2433            self._scopes
2434                .insert(Scope::CloudPlatform.as_ref().to_string());
2435        }
2436
2437        #[allow(clippy::single_element_loop)]
2438        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2439            url = params.uri_replacement(url, param_name, find_this, true);
2440        }
2441        {
2442            let to_remove = ["name"];
2443            params.remove_params(&to_remove);
2444        }
2445
2446        let url = params.parse_with_url(&url);
2447
2448        let mut json_mime_type = mime::APPLICATION_JSON;
2449        let mut request_value_reader = {
2450            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2451            common::remove_json_null_values(&mut value);
2452            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2453            serde_json::to_writer(&mut dst, &value).unwrap();
2454            dst
2455        };
2456        let request_size = request_value_reader
2457            .seek(std::io::SeekFrom::End(0))
2458            .unwrap();
2459        request_value_reader
2460            .seek(std::io::SeekFrom::Start(0))
2461            .unwrap();
2462
2463        loop {
2464            let token = match self
2465                .hub
2466                .auth
2467                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2468                .await
2469            {
2470                Ok(token) => token,
2471                Err(e) => match dlg.token(e) {
2472                    Ok(token) => token,
2473                    Err(e) => {
2474                        dlg.finished(false);
2475                        return Err(common::Error::MissingToken(e));
2476                    }
2477                },
2478            };
2479            request_value_reader
2480                .seek(std::io::SeekFrom::Start(0))
2481                .unwrap();
2482            let mut req_result = {
2483                let client = &self.hub.client;
2484                dlg.pre_request();
2485                let mut req_builder = hyper::Request::builder()
2486                    .method(hyper::Method::POST)
2487                    .uri(url.as_str())
2488                    .header(USER_AGENT, self.hub._user_agent.clone());
2489
2490                if let Some(token) = token.as_ref() {
2491                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2492                }
2493
2494                let request = req_builder
2495                    .header(CONTENT_TYPE, json_mime_type.to_string())
2496                    .header(CONTENT_LENGTH, request_size as u64)
2497                    .body(common::to_body(
2498                        request_value_reader.get_ref().clone().into(),
2499                    ));
2500
2501                client.request(request.unwrap()).await
2502            };
2503
2504            match req_result {
2505                Err(err) => {
2506                    if let common::Retry::After(d) = dlg.http_error(&err) {
2507                        sleep(d).await;
2508                        continue;
2509                    }
2510                    dlg.finished(false);
2511                    return Err(common::Error::HttpError(err));
2512                }
2513                Ok(res) => {
2514                    let (mut parts, body) = res.into_parts();
2515                    let mut body = common::Body::new(body);
2516                    if !parts.status.is_success() {
2517                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2518                        let error = serde_json::from_str(&common::to_string(&bytes));
2519                        let response = common::to_response(parts, bytes.into());
2520
2521                        if let common::Retry::After(d) =
2522                            dlg.http_failure(&response, error.as_ref().ok())
2523                        {
2524                            sleep(d).await;
2525                            continue;
2526                        }
2527
2528                        dlg.finished(false);
2529
2530                        return Err(match error {
2531                            Ok(value) => common::Error::BadRequest(value),
2532                            _ => common::Error::Failure(response),
2533                        });
2534                    }
2535                    let response = {
2536                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2537                        let encoded = common::to_string(&bytes);
2538                        match serde_json::from_str(&encoded) {
2539                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2540                            Err(error) => {
2541                                dlg.response_json_decode_error(&encoded, &error);
2542                                return Err(common::Error::JsonDecodeError(
2543                                    encoded.to_string(),
2544                                    error,
2545                                ));
2546                            }
2547                        }
2548                    };
2549
2550                    dlg.finished(true);
2551                    return Ok(response);
2552                }
2553            }
2554        }
2555    }
2556
2557    ///
2558    /// Sets the *request* property to the given value.
2559    ///
2560    /// Even though the property as already been set when instantiating this call,
2561    /// we provide this method for API completeness.
2562    pub fn request(
2563        mut self,
2564        new_value: InvalidateApprovalRequestMessage,
2565    ) -> FolderApprovalRequestInvalidateCall<'a, C> {
2566        self._request = new_value;
2567        self
2568    }
2569    /// Name of the ApprovalRequest to invalidate.
2570    ///
2571    /// Sets the *name* path property to the given value.
2572    ///
2573    /// Even though the property as already been set when instantiating this call,
2574    /// we provide this method for API completeness.
2575    pub fn name(mut self, new_value: &str) -> FolderApprovalRequestInvalidateCall<'a, C> {
2576        self._name = new_value.to_string();
2577        self
2578    }
2579    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2580    /// while executing the actual API request.
2581    ///
2582    /// ````text
2583    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2584    /// ````
2585    ///
2586    /// Sets the *delegate* property to the given value.
2587    pub fn delegate(
2588        mut self,
2589        new_value: &'a mut dyn common::Delegate,
2590    ) -> FolderApprovalRequestInvalidateCall<'a, C> {
2591        self._delegate = Some(new_value);
2592        self
2593    }
2594
2595    /// Set any additional parameter of the query string used in the request.
2596    /// It should be used to set parameters which are not yet available through their own
2597    /// setters.
2598    ///
2599    /// Please note that this method must not be used to set any of the known parameters
2600    /// which have their own setter method. If done anyway, the request will fail.
2601    ///
2602    /// # Additional Parameters
2603    ///
2604    /// * *$.xgafv* (query-string) - V1 error format.
2605    /// * *access_token* (query-string) - OAuth access token.
2606    /// * *alt* (query-string) - Data format for response.
2607    /// * *callback* (query-string) - JSONP
2608    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2609    /// * *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.
2610    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2611    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2612    /// * *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.
2613    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2614    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2615    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestInvalidateCall<'a, C>
2616    where
2617        T: AsRef<str>,
2618    {
2619        self._additional_params
2620            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2621        self
2622    }
2623
2624    /// Identifies the authorization scope for the method you are building.
2625    ///
2626    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2627    /// [`Scope::CloudPlatform`].
2628    ///
2629    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2630    /// tokens for more than one scope.
2631    ///
2632    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2633    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2634    /// sufficient, a read-write scope will do as well.
2635    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestInvalidateCall<'a, C>
2636    where
2637        St: AsRef<str>,
2638    {
2639        self._scopes.insert(String::from(scope.as_ref()));
2640        self
2641    }
2642    /// Identifies the authorization scope(s) for the method you are building.
2643    ///
2644    /// See [`Self::add_scope()`] for details.
2645    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestInvalidateCall<'a, C>
2646    where
2647        I: IntoIterator<Item = St>,
2648        St: AsRef<str>,
2649    {
2650        self._scopes
2651            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2652        self
2653    }
2654
2655    /// Removes all scopes, and no default scope will be used either.
2656    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2657    /// for details).
2658    pub fn clear_scopes(mut self) -> FolderApprovalRequestInvalidateCall<'a, C> {
2659        self._scopes.clear();
2660        self
2661    }
2662}
2663
2664/// Lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.
2665///
2666/// A builder for the *approvalRequests.list* method supported by a *folder* resource.
2667/// It is not used directly, but through a [`FolderMethods`] instance.
2668///
2669/// # Example
2670///
2671/// Instantiate a resource method builder
2672///
2673/// ```test_harness,no_run
2674/// # extern crate hyper;
2675/// # extern crate hyper_rustls;
2676/// # extern crate google_accessapproval1 as accessapproval1;
2677/// # async fn dox() {
2678/// # use accessapproval1::{AccessApproval, 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 = AccessApproval::new(client, auth);
2709/// // You can configure optional parameters by calling the respective setters at will, and
2710/// // execute the final call using `doit()`.
2711/// // Values shown here are possibly random and not representative !
2712/// let result = hub.folders().approval_requests_list("parent")
2713///              .page_token("amet.")
2714///              .page_size(-59)
2715///              .filter("amet.")
2716///              .doit().await;
2717/// # }
2718/// ```
2719pub struct FolderApprovalRequestListCall<'a, C>
2720where
2721    C: 'a,
2722{
2723    hub: &'a AccessApproval<C>,
2724    _parent: String,
2725    _page_token: Option<String>,
2726    _page_size: Option<i32>,
2727    _filter: Option<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 FolderApprovalRequestListCall<'a, C> {}
2734
2735impl<'a, C> FolderApprovalRequestListCall<'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, ListApprovalRequestsResponse)> {
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: "accessapproval.folders.approvalRequests.list",
2753            http_method: hyper::Method::GET,
2754        });
2755
2756        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].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(6 + self._additional_params.len());
2764        params.push("parent", self._parent);
2765        if let Some(value) = self._page_token.as_ref() {
2766            params.push("pageToken", value);
2767        }
2768        if let Some(value) = self._page_size.as_ref() {
2769            params.push("pageSize", value.to_string());
2770        }
2771        if let Some(value) = self._filter.as_ref() {
2772            params.push("filter", value);
2773        }
2774
2775        params.extend(self._additional_params.iter());
2776
2777        params.push("alt", "json");
2778        let mut url = self.hub._base_url.clone() + "v1/{+parent}/approvalRequests";
2779        if self._scopes.is_empty() {
2780            self._scopes
2781                .insert(Scope::CloudPlatform.as_ref().to_string());
2782        }
2783
2784        #[allow(clippy::single_element_loop)]
2785        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2786            url = params.uri_replacement(url, param_name, find_this, true);
2787        }
2788        {
2789            let to_remove = ["parent"];
2790            params.remove_params(&to_remove);
2791        }
2792
2793        let url = params.parse_with_url(&url);
2794
2795        loop {
2796            let token = match self
2797                .hub
2798                .auth
2799                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2800                .await
2801            {
2802                Ok(token) => token,
2803                Err(e) => match dlg.token(e) {
2804                    Ok(token) => token,
2805                    Err(e) => {
2806                        dlg.finished(false);
2807                        return Err(common::Error::MissingToken(e));
2808                    }
2809                },
2810            };
2811            let mut req_result = {
2812                let client = &self.hub.client;
2813                dlg.pre_request();
2814                let mut req_builder = hyper::Request::builder()
2815                    .method(hyper::Method::GET)
2816                    .uri(url.as_str())
2817                    .header(USER_AGENT, self.hub._user_agent.clone());
2818
2819                if let Some(token) = token.as_ref() {
2820                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2821                }
2822
2823                let request = req_builder
2824                    .header(CONTENT_LENGTH, 0_u64)
2825                    .body(common::to_body::<String>(None));
2826
2827                client.request(request.unwrap()).await
2828            };
2829
2830            match req_result {
2831                Err(err) => {
2832                    if let common::Retry::After(d) = dlg.http_error(&err) {
2833                        sleep(d).await;
2834                        continue;
2835                    }
2836                    dlg.finished(false);
2837                    return Err(common::Error::HttpError(err));
2838                }
2839                Ok(res) => {
2840                    let (mut parts, body) = res.into_parts();
2841                    let mut body = common::Body::new(body);
2842                    if !parts.status.is_success() {
2843                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2844                        let error = serde_json::from_str(&common::to_string(&bytes));
2845                        let response = common::to_response(parts, bytes.into());
2846
2847                        if let common::Retry::After(d) =
2848                            dlg.http_failure(&response, error.as_ref().ok())
2849                        {
2850                            sleep(d).await;
2851                            continue;
2852                        }
2853
2854                        dlg.finished(false);
2855
2856                        return Err(match error {
2857                            Ok(value) => common::Error::BadRequest(value),
2858                            _ => common::Error::Failure(response),
2859                        });
2860                    }
2861                    let response = {
2862                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2863                        let encoded = common::to_string(&bytes);
2864                        match serde_json::from_str(&encoded) {
2865                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2866                            Err(error) => {
2867                                dlg.response_json_decode_error(&encoded, &error);
2868                                return Err(common::Error::JsonDecodeError(
2869                                    encoded.to_string(),
2870                                    error,
2871                                ));
2872                            }
2873                        }
2874                    };
2875
2876                    dlg.finished(true);
2877                    return Ok(response);
2878                }
2879            }
2880        }
2881    }
2882
2883    /// The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".
2884    ///
2885    /// Sets the *parent* path property to the given value.
2886    ///
2887    /// Even though the property as already been set when instantiating this call,
2888    /// we provide this method for API completeness.
2889    pub fn parent(mut self, new_value: &str) -> FolderApprovalRequestListCall<'a, C> {
2890        self._parent = new_value.to_string();
2891        self
2892    }
2893    /// A token identifying the page of results to return.
2894    ///
2895    /// Sets the *page token* query property to the given value.
2896    pub fn page_token(mut self, new_value: &str) -> FolderApprovalRequestListCall<'a, C> {
2897        self._page_token = Some(new_value.to_string());
2898        self
2899    }
2900    /// Requested page size.
2901    ///
2902    /// Sets the *page size* query property to the given value.
2903    pub fn page_size(mut self, new_value: i32) -> FolderApprovalRequestListCall<'a, C> {
2904        self._page_size = Some(new_value);
2905        self
2906    }
2907    /// A filter on the type of approval requests to retrieve. Must be one of the following values: * [not set]: Requests that are pending or have active approvals. * ALL: All requests. * PENDING: Only pending requests. * ACTIVE: Only active (i.e. currently approved) requests. * DISMISSED: Only requests that have been dismissed, or requests that are not approved and past expiration. * EXPIRED: Only requests that have been approved, and the approval has expired. * HISTORY: Active, dismissed and expired requests.
2908    ///
2909    /// Sets the *filter* query property to the given value.
2910    pub fn filter(mut self, new_value: &str) -> FolderApprovalRequestListCall<'a, C> {
2911        self._filter = Some(new_value.to_string());
2912        self
2913    }
2914    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2915    /// while executing the actual API request.
2916    ///
2917    /// ````text
2918    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2919    /// ````
2920    ///
2921    /// Sets the *delegate* property to the given value.
2922    pub fn delegate(
2923        mut self,
2924        new_value: &'a mut dyn common::Delegate,
2925    ) -> FolderApprovalRequestListCall<'a, C> {
2926        self._delegate = Some(new_value);
2927        self
2928    }
2929
2930    /// Set any additional parameter of the query string used in the request.
2931    /// It should be used to set parameters which are not yet available through their own
2932    /// setters.
2933    ///
2934    /// Please note that this method must not be used to set any of the known parameters
2935    /// which have their own setter method. If done anyway, the request will fail.
2936    ///
2937    /// # Additional Parameters
2938    ///
2939    /// * *$.xgafv* (query-string) - V1 error format.
2940    /// * *access_token* (query-string) - OAuth access token.
2941    /// * *alt* (query-string) - Data format for response.
2942    /// * *callback* (query-string) - JSONP
2943    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2944    /// * *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.
2945    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2946    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2947    /// * *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.
2948    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2949    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2950    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestListCall<'a, C>
2951    where
2952        T: AsRef<str>,
2953    {
2954        self._additional_params
2955            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2956        self
2957    }
2958
2959    /// Identifies the authorization scope for the method you are building.
2960    ///
2961    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2962    /// [`Scope::CloudPlatform`].
2963    ///
2964    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2965    /// tokens for more than one scope.
2966    ///
2967    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2968    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2969    /// sufficient, a read-write scope will do as well.
2970    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestListCall<'a, C>
2971    where
2972        St: AsRef<str>,
2973    {
2974        self._scopes.insert(String::from(scope.as_ref()));
2975        self
2976    }
2977    /// Identifies the authorization scope(s) for the method you are building.
2978    ///
2979    /// See [`Self::add_scope()`] for details.
2980    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestListCall<'a, C>
2981    where
2982        I: IntoIterator<Item = St>,
2983        St: AsRef<str>,
2984    {
2985        self._scopes
2986            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2987        self
2988    }
2989
2990    /// Removes all scopes, and no default scope will be used either.
2991    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2992    /// for details).
2993    pub fn clear_scopes(mut self) -> FolderApprovalRequestListCall<'a, C> {
2994        self._scopes.clear();
2995        self
2996    }
2997}
2998
2999/// Deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the resource. Access Approval may remain active based on parent resource settings. To confirm the effective settings, call GetAccessApprovalSettings and verify effective setting is disabled.
3000///
3001/// A builder for the *deleteAccessApprovalSettings* method supported by a *folder* resource.
3002/// It is not used directly, but through a [`FolderMethods`] instance.
3003///
3004/// # Example
3005///
3006/// Instantiate a resource method builder
3007///
3008/// ```test_harness,no_run
3009/// # extern crate hyper;
3010/// # extern crate hyper_rustls;
3011/// # extern crate google_accessapproval1 as accessapproval1;
3012/// # async fn dox() {
3013/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3014///
3015/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3016/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3017/// #     .with_native_roots()
3018/// #     .unwrap()
3019/// #     .https_only()
3020/// #     .enable_http2()
3021/// #     .build();
3022///
3023/// # let executor = hyper_util::rt::TokioExecutor::new();
3024/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3025/// #     secret,
3026/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3027/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3028/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3029/// #     ),
3030/// # ).build().await.unwrap();
3031///
3032/// # let client = hyper_util::client::legacy::Client::builder(
3033/// #     hyper_util::rt::TokioExecutor::new()
3034/// # )
3035/// # .build(
3036/// #     hyper_rustls::HttpsConnectorBuilder::new()
3037/// #         .with_native_roots()
3038/// #         .unwrap()
3039/// #         .https_or_http()
3040/// #         .enable_http2()
3041/// #         .build()
3042/// # );
3043/// # let mut hub = AccessApproval::new(client, auth);
3044/// // You can configure optional parameters by calling the respective setters at will, and
3045/// // execute the final call using `doit()`.
3046/// // Values shown here are possibly random and not representative !
3047/// let result = hub.folders().delete_access_approval_settings("name")
3048///              .doit().await;
3049/// # }
3050/// ```
3051pub struct FolderDeleteAccessApprovalSettingCall<'a, C>
3052where
3053    C: 'a,
3054{
3055    hub: &'a AccessApproval<C>,
3056    _name: String,
3057    _delegate: Option<&'a mut dyn common::Delegate>,
3058    _additional_params: HashMap<String, String>,
3059    _scopes: BTreeSet<String>,
3060}
3061
3062impl<'a, C> common::CallBuilder for FolderDeleteAccessApprovalSettingCall<'a, C> {}
3063
3064impl<'a, C> FolderDeleteAccessApprovalSettingCall<'a, C>
3065where
3066    C: common::Connector,
3067{
3068    /// Perform the operation you have build so far.
3069    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3070        use std::borrow::Cow;
3071        use std::io::{Read, Seek};
3072
3073        use common::{url::Params, ToParts};
3074        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3075
3076        let mut dd = common::DefaultDelegate;
3077        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3078        dlg.begin(common::MethodInfo {
3079            id: "accessapproval.folders.deleteAccessApprovalSettings",
3080            http_method: hyper::Method::DELETE,
3081        });
3082
3083        for &field in ["alt", "name"].iter() {
3084            if self._additional_params.contains_key(field) {
3085                dlg.finished(false);
3086                return Err(common::Error::FieldClash(field));
3087            }
3088        }
3089
3090        let mut params = Params::with_capacity(3 + self._additional_params.len());
3091        params.push("name", self._name);
3092
3093        params.extend(self._additional_params.iter());
3094
3095        params.push("alt", "json");
3096        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3097        if self._scopes.is_empty() {
3098            self._scopes
3099                .insert(Scope::CloudPlatform.as_ref().to_string());
3100        }
3101
3102        #[allow(clippy::single_element_loop)]
3103        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3104            url = params.uri_replacement(url, param_name, find_this, true);
3105        }
3106        {
3107            let to_remove = ["name"];
3108            params.remove_params(&to_remove);
3109        }
3110
3111        let url = params.parse_with_url(&url);
3112
3113        loop {
3114            let token = match self
3115                .hub
3116                .auth
3117                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3118                .await
3119            {
3120                Ok(token) => token,
3121                Err(e) => match dlg.token(e) {
3122                    Ok(token) => token,
3123                    Err(e) => {
3124                        dlg.finished(false);
3125                        return Err(common::Error::MissingToken(e));
3126                    }
3127                },
3128            };
3129            let mut req_result = {
3130                let client = &self.hub.client;
3131                dlg.pre_request();
3132                let mut req_builder = hyper::Request::builder()
3133                    .method(hyper::Method::DELETE)
3134                    .uri(url.as_str())
3135                    .header(USER_AGENT, self.hub._user_agent.clone());
3136
3137                if let Some(token) = token.as_ref() {
3138                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3139                }
3140
3141                let request = req_builder
3142                    .header(CONTENT_LENGTH, 0_u64)
3143                    .body(common::to_body::<String>(None));
3144
3145                client.request(request.unwrap()).await
3146            };
3147
3148            match req_result {
3149                Err(err) => {
3150                    if let common::Retry::After(d) = dlg.http_error(&err) {
3151                        sleep(d).await;
3152                        continue;
3153                    }
3154                    dlg.finished(false);
3155                    return Err(common::Error::HttpError(err));
3156                }
3157                Ok(res) => {
3158                    let (mut parts, body) = res.into_parts();
3159                    let mut body = common::Body::new(body);
3160                    if !parts.status.is_success() {
3161                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3162                        let error = serde_json::from_str(&common::to_string(&bytes));
3163                        let response = common::to_response(parts, bytes.into());
3164
3165                        if let common::Retry::After(d) =
3166                            dlg.http_failure(&response, error.as_ref().ok())
3167                        {
3168                            sleep(d).await;
3169                            continue;
3170                        }
3171
3172                        dlg.finished(false);
3173
3174                        return Err(match error {
3175                            Ok(value) => common::Error::BadRequest(value),
3176                            _ => common::Error::Failure(response),
3177                        });
3178                    }
3179                    let response = {
3180                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3181                        let encoded = common::to_string(&bytes);
3182                        match serde_json::from_str(&encoded) {
3183                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3184                            Err(error) => {
3185                                dlg.response_json_decode_error(&encoded, &error);
3186                                return Err(common::Error::JsonDecodeError(
3187                                    encoded.to_string(),
3188                                    error,
3189                                ));
3190                            }
3191                        }
3192                    };
3193
3194                    dlg.finished(true);
3195                    return Ok(response);
3196                }
3197            }
3198        }
3199    }
3200
3201    /// Name of the AccessApprovalSettings to delete.
3202    ///
3203    /// Sets the *name* path property to the given value.
3204    ///
3205    /// Even though the property as already been set when instantiating this call,
3206    /// we provide this method for API completeness.
3207    pub fn name(mut self, new_value: &str) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
3208        self._name = new_value.to_string();
3209        self
3210    }
3211    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3212    /// while executing the actual API request.
3213    ///
3214    /// ````text
3215    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3216    /// ````
3217    ///
3218    /// Sets the *delegate* property to the given value.
3219    pub fn delegate(
3220        mut self,
3221        new_value: &'a mut dyn common::Delegate,
3222    ) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
3223        self._delegate = Some(new_value);
3224        self
3225    }
3226
3227    /// Set any additional parameter of the query string used in the request.
3228    /// It should be used to set parameters which are not yet available through their own
3229    /// setters.
3230    ///
3231    /// Please note that this method must not be used to set any of the known parameters
3232    /// which have their own setter method. If done anyway, the request will fail.
3233    ///
3234    /// # Additional Parameters
3235    ///
3236    /// * *$.xgafv* (query-string) - V1 error format.
3237    /// * *access_token* (query-string) - OAuth access token.
3238    /// * *alt* (query-string) - Data format for response.
3239    /// * *callback* (query-string) - JSONP
3240    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3241    /// * *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.
3242    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3243    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3244    /// * *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.
3245    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3246    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3247    pub fn param<T>(mut self, name: T, value: T) -> FolderDeleteAccessApprovalSettingCall<'a, C>
3248    where
3249        T: AsRef<str>,
3250    {
3251        self._additional_params
3252            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3253        self
3254    }
3255
3256    /// Identifies the authorization scope for the method you are building.
3257    ///
3258    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3259    /// [`Scope::CloudPlatform`].
3260    ///
3261    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3262    /// tokens for more than one scope.
3263    ///
3264    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3265    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3266    /// sufficient, a read-write scope will do as well.
3267    pub fn add_scope<St>(mut self, scope: St) -> FolderDeleteAccessApprovalSettingCall<'a, C>
3268    where
3269        St: AsRef<str>,
3270    {
3271        self._scopes.insert(String::from(scope.as_ref()));
3272        self
3273    }
3274    /// Identifies the authorization scope(s) for the method you are building.
3275    ///
3276    /// See [`Self::add_scope()`] for details.
3277    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderDeleteAccessApprovalSettingCall<'a, C>
3278    where
3279        I: IntoIterator<Item = St>,
3280        St: AsRef<str>,
3281    {
3282        self._scopes
3283            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3284        self
3285    }
3286
3287    /// Removes all scopes, and no default scope will be used either.
3288    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3289    /// for details).
3290    pub fn clear_scopes(mut self) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
3291        self._scopes.clear();
3292        self
3293    }
3294}
3295
3296/// Gets the Access Approval settings associated with a project, folder, or organization.
3297///
3298/// A builder for the *getAccessApprovalSettings* method supported by a *folder* resource.
3299/// It is not used directly, but through a [`FolderMethods`] instance.
3300///
3301/// # Example
3302///
3303/// Instantiate a resource method builder
3304///
3305/// ```test_harness,no_run
3306/// # extern crate hyper;
3307/// # extern crate hyper_rustls;
3308/// # extern crate google_accessapproval1 as accessapproval1;
3309/// # async fn dox() {
3310/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3311///
3312/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3313/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3314/// #     .with_native_roots()
3315/// #     .unwrap()
3316/// #     .https_only()
3317/// #     .enable_http2()
3318/// #     .build();
3319///
3320/// # let executor = hyper_util::rt::TokioExecutor::new();
3321/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3322/// #     secret,
3323/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3324/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3325/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3326/// #     ),
3327/// # ).build().await.unwrap();
3328///
3329/// # let client = hyper_util::client::legacy::Client::builder(
3330/// #     hyper_util::rt::TokioExecutor::new()
3331/// # )
3332/// # .build(
3333/// #     hyper_rustls::HttpsConnectorBuilder::new()
3334/// #         .with_native_roots()
3335/// #         .unwrap()
3336/// #         .https_or_http()
3337/// #         .enable_http2()
3338/// #         .build()
3339/// # );
3340/// # let mut hub = AccessApproval::new(client, auth);
3341/// // You can configure optional parameters by calling the respective setters at will, and
3342/// // execute the final call using `doit()`.
3343/// // Values shown here are possibly random and not representative !
3344/// let result = hub.folders().get_access_approval_settings("name")
3345///              .doit().await;
3346/// # }
3347/// ```
3348pub struct FolderGetAccessApprovalSettingCall<'a, C>
3349where
3350    C: 'a,
3351{
3352    hub: &'a AccessApproval<C>,
3353    _name: String,
3354    _delegate: Option<&'a mut dyn common::Delegate>,
3355    _additional_params: HashMap<String, String>,
3356    _scopes: BTreeSet<String>,
3357}
3358
3359impl<'a, C> common::CallBuilder for FolderGetAccessApprovalSettingCall<'a, C> {}
3360
3361impl<'a, C> FolderGetAccessApprovalSettingCall<'a, C>
3362where
3363    C: common::Connector,
3364{
3365    /// Perform the operation you have build so far.
3366    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
3367        use std::borrow::Cow;
3368        use std::io::{Read, Seek};
3369
3370        use common::{url::Params, ToParts};
3371        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3372
3373        let mut dd = common::DefaultDelegate;
3374        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3375        dlg.begin(common::MethodInfo {
3376            id: "accessapproval.folders.getAccessApprovalSettings",
3377            http_method: hyper::Method::GET,
3378        });
3379
3380        for &field in ["alt", "name"].iter() {
3381            if self._additional_params.contains_key(field) {
3382                dlg.finished(false);
3383                return Err(common::Error::FieldClash(field));
3384            }
3385        }
3386
3387        let mut params = Params::with_capacity(3 + self._additional_params.len());
3388        params.push("name", self._name);
3389
3390        params.extend(self._additional_params.iter());
3391
3392        params.push("alt", "json");
3393        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3394        if self._scopes.is_empty() {
3395            self._scopes
3396                .insert(Scope::CloudPlatform.as_ref().to_string());
3397        }
3398
3399        #[allow(clippy::single_element_loop)]
3400        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3401            url = params.uri_replacement(url, param_name, find_this, true);
3402        }
3403        {
3404            let to_remove = ["name"];
3405            params.remove_params(&to_remove);
3406        }
3407
3408        let url = params.parse_with_url(&url);
3409
3410        loop {
3411            let token = match self
3412                .hub
3413                .auth
3414                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3415                .await
3416            {
3417                Ok(token) => token,
3418                Err(e) => match dlg.token(e) {
3419                    Ok(token) => token,
3420                    Err(e) => {
3421                        dlg.finished(false);
3422                        return Err(common::Error::MissingToken(e));
3423                    }
3424                },
3425            };
3426            let mut req_result = {
3427                let client = &self.hub.client;
3428                dlg.pre_request();
3429                let mut req_builder = hyper::Request::builder()
3430                    .method(hyper::Method::GET)
3431                    .uri(url.as_str())
3432                    .header(USER_AGENT, self.hub._user_agent.clone());
3433
3434                if let Some(token) = token.as_ref() {
3435                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3436                }
3437
3438                let request = req_builder
3439                    .header(CONTENT_LENGTH, 0_u64)
3440                    .body(common::to_body::<String>(None));
3441
3442                client.request(request.unwrap()).await
3443            };
3444
3445            match req_result {
3446                Err(err) => {
3447                    if let common::Retry::After(d) = dlg.http_error(&err) {
3448                        sleep(d).await;
3449                        continue;
3450                    }
3451                    dlg.finished(false);
3452                    return Err(common::Error::HttpError(err));
3453                }
3454                Ok(res) => {
3455                    let (mut parts, body) = res.into_parts();
3456                    let mut body = common::Body::new(body);
3457                    if !parts.status.is_success() {
3458                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3459                        let error = serde_json::from_str(&common::to_string(&bytes));
3460                        let response = common::to_response(parts, bytes.into());
3461
3462                        if let common::Retry::After(d) =
3463                            dlg.http_failure(&response, error.as_ref().ok())
3464                        {
3465                            sleep(d).await;
3466                            continue;
3467                        }
3468
3469                        dlg.finished(false);
3470
3471                        return Err(match error {
3472                            Ok(value) => common::Error::BadRequest(value),
3473                            _ => common::Error::Failure(response),
3474                        });
3475                    }
3476                    let response = {
3477                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3478                        let encoded = common::to_string(&bytes);
3479                        match serde_json::from_str(&encoded) {
3480                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3481                            Err(error) => {
3482                                dlg.response_json_decode_error(&encoded, &error);
3483                                return Err(common::Error::JsonDecodeError(
3484                                    encoded.to_string(),
3485                                    error,
3486                                ));
3487                            }
3488                        }
3489                    };
3490
3491                    dlg.finished(true);
3492                    return Ok(response);
3493                }
3494            }
3495        }
3496    }
3497
3498    /// The name of the AccessApprovalSettings to retrieve. Format: "{projects|folders|organizations}/{id}/accessApprovalSettings"
3499    ///
3500    /// Sets the *name* path property to the given value.
3501    ///
3502    /// Even though the property as already been set when instantiating this call,
3503    /// we provide this method for API completeness.
3504    pub fn name(mut self, new_value: &str) -> FolderGetAccessApprovalSettingCall<'a, C> {
3505        self._name = new_value.to_string();
3506        self
3507    }
3508    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3509    /// while executing the actual API request.
3510    ///
3511    /// ````text
3512    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3513    /// ````
3514    ///
3515    /// Sets the *delegate* property to the given value.
3516    pub fn delegate(
3517        mut self,
3518        new_value: &'a mut dyn common::Delegate,
3519    ) -> FolderGetAccessApprovalSettingCall<'a, C> {
3520        self._delegate = Some(new_value);
3521        self
3522    }
3523
3524    /// Set any additional parameter of the query string used in the request.
3525    /// It should be used to set parameters which are not yet available through their own
3526    /// setters.
3527    ///
3528    /// Please note that this method must not be used to set any of the known parameters
3529    /// which have their own setter method. If done anyway, the request will fail.
3530    ///
3531    /// # Additional Parameters
3532    ///
3533    /// * *$.xgafv* (query-string) - V1 error format.
3534    /// * *access_token* (query-string) - OAuth access token.
3535    /// * *alt* (query-string) - Data format for response.
3536    /// * *callback* (query-string) - JSONP
3537    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3538    /// * *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.
3539    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3540    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3541    /// * *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.
3542    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3543    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3544    pub fn param<T>(mut self, name: T, value: T) -> FolderGetAccessApprovalSettingCall<'a, C>
3545    where
3546        T: AsRef<str>,
3547    {
3548        self._additional_params
3549            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3550        self
3551    }
3552
3553    /// Identifies the authorization scope for the method you are building.
3554    ///
3555    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3556    /// [`Scope::CloudPlatform`].
3557    ///
3558    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3559    /// tokens for more than one scope.
3560    ///
3561    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3562    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3563    /// sufficient, a read-write scope will do as well.
3564    pub fn add_scope<St>(mut self, scope: St) -> FolderGetAccessApprovalSettingCall<'a, C>
3565    where
3566        St: AsRef<str>,
3567    {
3568        self._scopes.insert(String::from(scope.as_ref()));
3569        self
3570    }
3571    /// Identifies the authorization scope(s) for the method you are building.
3572    ///
3573    /// See [`Self::add_scope()`] for details.
3574    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetAccessApprovalSettingCall<'a, C>
3575    where
3576        I: IntoIterator<Item = St>,
3577        St: AsRef<str>,
3578    {
3579        self._scopes
3580            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3581        self
3582    }
3583
3584    /// Removes all scopes, and no default scope will be used either.
3585    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3586    /// for details).
3587    pub fn clear_scopes(mut self) -> FolderGetAccessApprovalSettingCall<'a, C> {
3588        self._scopes.clear();
3589        self
3590    }
3591}
3592
3593/// Retrieves the service account that is used by Access Approval to access KMS keys for signing approved approval requests.
3594///
3595/// A builder for the *getServiceAccount* method supported by a *folder* resource.
3596/// It is not used directly, but through a [`FolderMethods`] instance.
3597///
3598/// # Example
3599///
3600/// Instantiate a resource method builder
3601///
3602/// ```test_harness,no_run
3603/// # extern crate hyper;
3604/// # extern crate hyper_rustls;
3605/// # extern crate google_accessapproval1 as accessapproval1;
3606/// # async fn dox() {
3607/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3608///
3609/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3610/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3611/// #     .with_native_roots()
3612/// #     .unwrap()
3613/// #     .https_only()
3614/// #     .enable_http2()
3615/// #     .build();
3616///
3617/// # let executor = hyper_util::rt::TokioExecutor::new();
3618/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3619/// #     secret,
3620/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3621/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3622/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3623/// #     ),
3624/// # ).build().await.unwrap();
3625///
3626/// # let client = hyper_util::client::legacy::Client::builder(
3627/// #     hyper_util::rt::TokioExecutor::new()
3628/// # )
3629/// # .build(
3630/// #     hyper_rustls::HttpsConnectorBuilder::new()
3631/// #         .with_native_roots()
3632/// #         .unwrap()
3633/// #         .https_or_http()
3634/// #         .enable_http2()
3635/// #         .build()
3636/// # );
3637/// # let mut hub = AccessApproval::new(client, auth);
3638/// // You can configure optional parameters by calling the respective setters at will, and
3639/// // execute the final call using `doit()`.
3640/// // Values shown here are possibly random and not representative !
3641/// let result = hub.folders().get_service_account("name")
3642///              .doit().await;
3643/// # }
3644/// ```
3645pub struct FolderGetServiceAccountCall<'a, C>
3646where
3647    C: 'a,
3648{
3649    hub: &'a AccessApproval<C>,
3650    _name: String,
3651    _delegate: Option<&'a mut dyn common::Delegate>,
3652    _additional_params: HashMap<String, String>,
3653    _scopes: BTreeSet<String>,
3654}
3655
3656impl<'a, C> common::CallBuilder for FolderGetServiceAccountCall<'a, C> {}
3657
3658impl<'a, C> FolderGetServiceAccountCall<'a, C>
3659where
3660    C: common::Connector,
3661{
3662    /// Perform the operation you have build so far.
3663    pub async fn doit(
3664        mut self,
3665    ) -> common::Result<(common::Response, AccessApprovalServiceAccount)> {
3666        use std::borrow::Cow;
3667        use std::io::{Read, Seek};
3668
3669        use common::{url::Params, ToParts};
3670        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3671
3672        let mut dd = common::DefaultDelegate;
3673        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3674        dlg.begin(common::MethodInfo {
3675            id: "accessapproval.folders.getServiceAccount",
3676            http_method: hyper::Method::GET,
3677        });
3678
3679        for &field in ["alt", "name"].iter() {
3680            if self._additional_params.contains_key(field) {
3681                dlg.finished(false);
3682                return Err(common::Error::FieldClash(field));
3683            }
3684        }
3685
3686        let mut params = Params::with_capacity(3 + self._additional_params.len());
3687        params.push("name", self._name);
3688
3689        params.extend(self._additional_params.iter());
3690
3691        params.push("alt", "json");
3692        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3693        if self._scopes.is_empty() {
3694            self._scopes
3695                .insert(Scope::CloudPlatform.as_ref().to_string());
3696        }
3697
3698        #[allow(clippy::single_element_loop)]
3699        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3700            url = params.uri_replacement(url, param_name, find_this, true);
3701        }
3702        {
3703            let to_remove = ["name"];
3704            params.remove_params(&to_remove);
3705        }
3706
3707        let url = params.parse_with_url(&url);
3708
3709        loop {
3710            let token = match self
3711                .hub
3712                .auth
3713                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3714                .await
3715            {
3716                Ok(token) => token,
3717                Err(e) => match dlg.token(e) {
3718                    Ok(token) => token,
3719                    Err(e) => {
3720                        dlg.finished(false);
3721                        return Err(common::Error::MissingToken(e));
3722                    }
3723                },
3724            };
3725            let mut req_result = {
3726                let client = &self.hub.client;
3727                dlg.pre_request();
3728                let mut req_builder = hyper::Request::builder()
3729                    .method(hyper::Method::GET)
3730                    .uri(url.as_str())
3731                    .header(USER_AGENT, self.hub._user_agent.clone());
3732
3733                if let Some(token) = token.as_ref() {
3734                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3735                }
3736
3737                let request = req_builder
3738                    .header(CONTENT_LENGTH, 0_u64)
3739                    .body(common::to_body::<String>(None));
3740
3741                client.request(request.unwrap()).await
3742            };
3743
3744            match req_result {
3745                Err(err) => {
3746                    if let common::Retry::After(d) = dlg.http_error(&err) {
3747                        sleep(d).await;
3748                        continue;
3749                    }
3750                    dlg.finished(false);
3751                    return Err(common::Error::HttpError(err));
3752                }
3753                Ok(res) => {
3754                    let (mut parts, body) = res.into_parts();
3755                    let mut body = common::Body::new(body);
3756                    if !parts.status.is_success() {
3757                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3758                        let error = serde_json::from_str(&common::to_string(&bytes));
3759                        let response = common::to_response(parts, bytes.into());
3760
3761                        if let common::Retry::After(d) =
3762                            dlg.http_failure(&response, error.as_ref().ok())
3763                        {
3764                            sleep(d).await;
3765                            continue;
3766                        }
3767
3768                        dlg.finished(false);
3769
3770                        return Err(match error {
3771                            Ok(value) => common::Error::BadRequest(value),
3772                            _ => common::Error::Failure(response),
3773                        });
3774                    }
3775                    let response = {
3776                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3777                        let encoded = common::to_string(&bytes);
3778                        match serde_json::from_str(&encoded) {
3779                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3780                            Err(error) => {
3781                                dlg.response_json_decode_error(&encoded, &error);
3782                                return Err(common::Error::JsonDecodeError(
3783                                    encoded.to_string(),
3784                                    error,
3785                                ));
3786                            }
3787                        }
3788                    };
3789
3790                    dlg.finished(true);
3791                    return Ok(response);
3792                }
3793            }
3794        }
3795    }
3796
3797    /// Name of the AccessApprovalServiceAccount to retrieve.
3798    ///
3799    /// Sets the *name* path property to the given value.
3800    ///
3801    /// Even though the property as already been set when instantiating this call,
3802    /// we provide this method for API completeness.
3803    pub fn name(mut self, new_value: &str) -> FolderGetServiceAccountCall<'a, C> {
3804        self._name = new_value.to_string();
3805        self
3806    }
3807    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3808    /// while executing the actual API request.
3809    ///
3810    /// ````text
3811    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3812    /// ````
3813    ///
3814    /// Sets the *delegate* property to the given value.
3815    pub fn delegate(
3816        mut self,
3817        new_value: &'a mut dyn common::Delegate,
3818    ) -> FolderGetServiceAccountCall<'a, C> {
3819        self._delegate = Some(new_value);
3820        self
3821    }
3822
3823    /// Set any additional parameter of the query string used in the request.
3824    /// It should be used to set parameters which are not yet available through their own
3825    /// setters.
3826    ///
3827    /// Please note that this method must not be used to set any of the known parameters
3828    /// which have their own setter method. If done anyway, the request will fail.
3829    ///
3830    /// # Additional Parameters
3831    ///
3832    /// * *$.xgafv* (query-string) - V1 error format.
3833    /// * *access_token* (query-string) - OAuth access token.
3834    /// * *alt* (query-string) - Data format for response.
3835    /// * *callback* (query-string) - JSONP
3836    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3837    /// * *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.
3838    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3839    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3840    /// * *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.
3841    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3842    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3843    pub fn param<T>(mut self, name: T, value: T) -> FolderGetServiceAccountCall<'a, C>
3844    where
3845        T: AsRef<str>,
3846    {
3847        self._additional_params
3848            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3849        self
3850    }
3851
3852    /// Identifies the authorization scope for the method you are building.
3853    ///
3854    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3855    /// [`Scope::CloudPlatform`].
3856    ///
3857    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3858    /// tokens for more than one scope.
3859    ///
3860    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3861    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3862    /// sufficient, a read-write scope will do as well.
3863    pub fn add_scope<St>(mut self, scope: St) -> FolderGetServiceAccountCall<'a, C>
3864    where
3865        St: AsRef<str>,
3866    {
3867        self._scopes.insert(String::from(scope.as_ref()));
3868        self
3869    }
3870    /// Identifies the authorization scope(s) for the method you are building.
3871    ///
3872    /// See [`Self::add_scope()`] for details.
3873    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetServiceAccountCall<'a, C>
3874    where
3875        I: IntoIterator<Item = St>,
3876        St: AsRef<str>,
3877    {
3878        self._scopes
3879            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3880        self
3881    }
3882
3883    /// Removes all scopes, and no default scope will be used either.
3884    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3885    /// for details).
3886    pub fn clear_scopes(mut self) -> FolderGetServiceAccountCall<'a, C> {
3887        self._scopes.clear();
3888        self
3889    }
3890}
3891
3892/// Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.
3893///
3894/// A builder for the *updateAccessApprovalSettings* method supported by a *folder* resource.
3895/// It is not used directly, but through a [`FolderMethods`] instance.
3896///
3897/// # Example
3898///
3899/// Instantiate a resource method builder
3900///
3901/// ```test_harness,no_run
3902/// # extern crate hyper;
3903/// # extern crate hyper_rustls;
3904/// # extern crate google_accessapproval1 as accessapproval1;
3905/// use accessapproval1::api::AccessApprovalSettings;
3906/// # async fn dox() {
3907/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3908///
3909/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3910/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3911/// #     .with_native_roots()
3912/// #     .unwrap()
3913/// #     .https_only()
3914/// #     .enable_http2()
3915/// #     .build();
3916///
3917/// # let executor = hyper_util::rt::TokioExecutor::new();
3918/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3919/// #     secret,
3920/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3921/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3922/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3923/// #     ),
3924/// # ).build().await.unwrap();
3925///
3926/// # let client = hyper_util::client::legacy::Client::builder(
3927/// #     hyper_util::rt::TokioExecutor::new()
3928/// # )
3929/// # .build(
3930/// #     hyper_rustls::HttpsConnectorBuilder::new()
3931/// #         .with_native_roots()
3932/// #         .unwrap()
3933/// #         .https_or_http()
3934/// #         .enable_http2()
3935/// #         .build()
3936/// # );
3937/// # let mut hub = AccessApproval::new(client, auth);
3938/// // As the method needs a request, you would usually fill it with the desired information
3939/// // into the respective structure. Some of the parts shown here might not be applicable !
3940/// // Values shown here are possibly random and not representative !
3941/// let mut req = AccessApprovalSettings::default();
3942///
3943/// // You can configure optional parameters by calling the respective setters at will, and
3944/// // execute the final call using `doit()`.
3945/// // Values shown here are possibly random and not representative !
3946/// let result = hub.folders().update_access_approval_settings(req, "name")
3947///              .update_mask(FieldMask::new::<&str>(&[]))
3948///              .doit().await;
3949/// # }
3950/// ```
3951pub struct FolderUpdateAccessApprovalSettingCall<'a, C>
3952where
3953    C: 'a,
3954{
3955    hub: &'a AccessApproval<C>,
3956    _request: AccessApprovalSettings,
3957    _name: String,
3958    _update_mask: Option<common::FieldMask>,
3959    _delegate: Option<&'a mut dyn common::Delegate>,
3960    _additional_params: HashMap<String, String>,
3961    _scopes: BTreeSet<String>,
3962}
3963
3964impl<'a, C> common::CallBuilder for FolderUpdateAccessApprovalSettingCall<'a, C> {}
3965
3966impl<'a, C> FolderUpdateAccessApprovalSettingCall<'a, C>
3967where
3968    C: common::Connector,
3969{
3970    /// Perform the operation you have build so far.
3971    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
3972        use std::borrow::Cow;
3973        use std::io::{Read, Seek};
3974
3975        use common::{url::Params, ToParts};
3976        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3977
3978        let mut dd = common::DefaultDelegate;
3979        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3980        dlg.begin(common::MethodInfo {
3981            id: "accessapproval.folders.updateAccessApprovalSettings",
3982            http_method: hyper::Method::PATCH,
3983        });
3984
3985        for &field in ["alt", "name", "updateMask"].iter() {
3986            if self._additional_params.contains_key(field) {
3987                dlg.finished(false);
3988                return Err(common::Error::FieldClash(field));
3989            }
3990        }
3991
3992        let mut params = Params::with_capacity(5 + self._additional_params.len());
3993        params.push("name", self._name);
3994        if let Some(value) = self._update_mask.as_ref() {
3995            params.push("updateMask", value.to_string());
3996        }
3997
3998        params.extend(self._additional_params.iter());
3999
4000        params.push("alt", "json");
4001        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4002        if self._scopes.is_empty() {
4003            self._scopes
4004                .insert(Scope::CloudPlatform.as_ref().to_string());
4005        }
4006
4007        #[allow(clippy::single_element_loop)]
4008        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4009            url = params.uri_replacement(url, param_name, find_this, true);
4010        }
4011        {
4012            let to_remove = ["name"];
4013            params.remove_params(&to_remove);
4014        }
4015
4016        let url = params.parse_with_url(&url);
4017
4018        let mut json_mime_type = mime::APPLICATION_JSON;
4019        let mut request_value_reader = {
4020            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4021            common::remove_json_null_values(&mut value);
4022            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4023            serde_json::to_writer(&mut dst, &value).unwrap();
4024            dst
4025        };
4026        let request_size = request_value_reader
4027            .seek(std::io::SeekFrom::End(0))
4028            .unwrap();
4029        request_value_reader
4030            .seek(std::io::SeekFrom::Start(0))
4031            .unwrap();
4032
4033        loop {
4034            let token = match self
4035                .hub
4036                .auth
4037                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4038                .await
4039            {
4040                Ok(token) => token,
4041                Err(e) => match dlg.token(e) {
4042                    Ok(token) => token,
4043                    Err(e) => {
4044                        dlg.finished(false);
4045                        return Err(common::Error::MissingToken(e));
4046                    }
4047                },
4048            };
4049            request_value_reader
4050                .seek(std::io::SeekFrom::Start(0))
4051                .unwrap();
4052            let mut req_result = {
4053                let client = &self.hub.client;
4054                dlg.pre_request();
4055                let mut req_builder = hyper::Request::builder()
4056                    .method(hyper::Method::PATCH)
4057                    .uri(url.as_str())
4058                    .header(USER_AGENT, self.hub._user_agent.clone());
4059
4060                if let Some(token) = token.as_ref() {
4061                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4062                }
4063
4064                let request = req_builder
4065                    .header(CONTENT_TYPE, json_mime_type.to_string())
4066                    .header(CONTENT_LENGTH, request_size as u64)
4067                    .body(common::to_body(
4068                        request_value_reader.get_ref().clone().into(),
4069                    ));
4070
4071                client.request(request.unwrap()).await
4072            };
4073
4074            match req_result {
4075                Err(err) => {
4076                    if let common::Retry::After(d) = dlg.http_error(&err) {
4077                        sleep(d).await;
4078                        continue;
4079                    }
4080                    dlg.finished(false);
4081                    return Err(common::Error::HttpError(err));
4082                }
4083                Ok(res) => {
4084                    let (mut parts, body) = res.into_parts();
4085                    let mut body = common::Body::new(body);
4086                    if !parts.status.is_success() {
4087                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4088                        let error = serde_json::from_str(&common::to_string(&bytes));
4089                        let response = common::to_response(parts, bytes.into());
4090
4091                        if let common::Retry::After(d) =
4092                            dlg.http_failure(&response, error.as_ref().ok())
4093                        {
4094                            sleep(d).await;
4095                            continue;
4096                        }
4097
4098                        dlg.finished(false);
4099
4100                        return Err(match error {
4101                            Ok(value) => common::Error::BadRequest(value),
4102                            _ => common::Error::Failure(response),
4103                        });
4104                    }
4105                    let response = {
4106                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4107                        let encoded = common::to_string(&bytes);
4108                        match serde_json::from_str(&encoded) {
4109                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4110                            Err(error) => {
4111                                dlg.response_json_decode_error(&encoded, &error);
4112                                return Err(common::Error::JsonDecodeError(
4113                                    encoded.to_string(),
4114                                    error,
4115                                ));
4116                            }
4117                        }
4118                    };
4119
4120                    dlg.finished(true);
4121                    return Ok(response);
4122                }
4123            }
4124        }
4125    }
4126
4127    ///
4128    /// Sets the *request* property to the given value.
4129    ///
4130    /// Even though the property as already been set when instantiating this call,
4131    /// we provide this method for API completeness.
4132    pub fn request(
4133        mut self,
4134        new_value: AccessApprovalSettings,
4135    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
4136        self._request = new_value;
4137        self
4138    }
4139    /// The resource name of the settings. Format is one of: * "projects/{project}/accessApprovalSettings" * "folders/{folder}/accessApprovalSettings" * "organizations/{organization}/accessApprovalSettings"
4140    ///
4141    /// Sets the *name* path property to the given value.
4142    ///
4143    /// Even though the property as already been set when instantiating this call,
4144    /// we provide this method for API completeness.
4145    pub fn name(mut self, new_value: &str) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
4146        self._name = new_value.to_string();
4147        self
4148    }
4149    /// The update mask applies to the settings. Only the top level fields of AccessApprovalSettings (notification_emails & enrolled_services) are supported. For each field, if it is included, the currently stored value will be entirely overwritten with the value of the field passed in this request. For the `FieldMask` definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask If this field is left unset, only the notification_emails field will be updated.
4150    ///
4151    /// Sets the *update mask* query property to the given value.
4152    pub fn update_mask(
4153        mut self,
4154        new_value: common::FieldMask,
4155    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
4156        self._update_mask = Some(new_value);
4157        self
4158    }
4159    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4160    /// while executing the actual API request.
4161    ///
4162    /// ````text
4163    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4164    /// ````
4165    ///
4166    /// Sets the *delegate* property to the given value.
4167    pub fn delegate(
4168        mut self,
4169        new_value: &'a mut dyn common::Delegate,
4170    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
4171        self._delegate = Some(new_value);
4172        self
4173    }
4174
4175    /// Set any additional parameter of the query string used in the request.
4176    /// It should be used to set parameters which are not yet available through their own
4177    /// setters.
4178    ///
4179    /// Please note that this method must not be used to set any of the known parameters
4180    /// which have their own setter method. If done anyway, the request will fail.
4181    ///
4182    /// # Additional Parameters
4183    ///
4184    /// * *$.xgafv* (query-string) - V1 error format.
4185    /// * *access_token* (query-string) - OAuth access token.
4186    /// * *alt* (query-string) - Data format for response.
4187    /// * *callback* (query-string) - JSONP
4188    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4189    /// * *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.
4190    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4191    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4192    /// * *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.
4193    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4194    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4195    pub fn param<T>(mut self, name: T, value: T) -> FolderUpdateAccessApprovalSettingCall<'a, C>
4196    where
4197        T: AsRef<str>,
4198    {
4199        self._additional_params
4200            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4201        self
4202    }
4203
4204    /// Identifies the authorization scope for the method you are building.
4205    ///
4206    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4207    /// [`Scope::CloudPlatform`].
4208    ///
4209    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4210    /// tokens for more than one scope.
4211    ///
4212    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4213    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4214    /// sufficient, a read-write scope will do as well.
4215    pub fn add_scope<St>(mut self, scope: St) -> FolderUpdateAccessApprovalSettingCall<'a, C>
4216    where
4217        St: AsRef<str>,
4218    {
4219        self._scopes.insert(String::from(scope.as_ref()));
4220        self
4221    }
4222    /// Identifies the authorization scope(s) for the method you are building.
4223    ///
4224    /// See [`Self::add_scope()`] for details.
4225    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderUpdateAccessApprovalSettingCall<'a, C>
4226    where
4227        I: IntoIterator<Item = St>,
4228        St: AsRef<str>,
4229    {
4230        self._scopes
4231            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4232        self
4233    }
4234
4235    /// Removes all scopes, and no default scope will be used either.
4236    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4237    /// for details).
4238    pub fn clear_scopes(mut self) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
4239        self._scopes.clear();
4240        self
4241    }
4242}
4243
4244/// Approves a request and returns the updated ApprovalRequest. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
4245///
4246/// A builder for the *approvalRequests.approve* method supported by a *organization* resource.
4247/// It is not used directly, but through a [`OrganizationMethods`] instance.
4248///
4249/// # Example
4250///
4251/// Instantiate a resource method builder
4252///
4253/// ```test_harness,no_run
4254/// # extern crate hyper;
4255/// # extern crate hyper_rustls;
4256/// # extern crate google_accessapproval1 as accessapproval1;
4257/// use accessapproval1::api::ApproveApprovalRequestMessage;
4258/// # async fn dox() {
4259/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4260///
4261/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4262/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4263/// #     .with_native_roots()
4264/// #     .unwrap()
4265/// #     .https_only()
4266/// #     .enable_http2()
4267/// #     .build();
4268///
4269/// # let executor = hyper_util::rt::TokioExecutor::new();
4270/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4271/// #     secret,
4272/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4273/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4274/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4275/// #     ),
4276/// # ).build().await.unwrap();
4277///
4278/// # let client = hyper_util::client::legacy::Client::builder(
4279/// #     hyper_util::rt::TokioExecutor::new()
4280/// # )
4281/// # .build(
4282/// #     hyper_rustls::HttpsConnectorBuilder::new()
4283/// #         .with_native_roots()
4284/// #         .unwrap()
4285/// #         .https_or_http()
4286/// #         .enable_http2()
4287/// #         .build()
4288/// # );
4289/// # let mut hub = AccessApproval::new(client, auth);
4290/// // As the method needs a request, you would usually fill it with the desired information
4291/// // into the respective structure. Some of the parts shown here might not be applicable !
4292/// // Values shown here are possibly random and not representative !
4293/// let mut req = ApproveApprovalRequestMessage::default();
4294///
4295/// // You can configure optional parameters by calling the respective setters at will, and
4296/// // execute the final call using `doit()`.
4297/// // Values shown here are possibly random and not representative !
4298/// let result = hub.organizations().approval_requests_approve(req, "name")
4299///              .doit().await;
4300/// # }
4301/// ```
4302pub struct OrganizationApprovalRequestApproveCall<'a, C>
4303where
4304    C: 'a,
4305{
4306    hub: &'a AccessApproval<C>,
4307    _request: ApproveApprovalRequestMessage,
4308    _name: String,
4309    _delegate: Option<&'a mut dyn common::Delegate>,
4310    _additional_params: HashMap<String, String>,
4311    _scopes: BTreeSet<String>,
4312}
4313
4314impl<'a, C> common::CallBuilder for OrganizationApprovalRequestApproveCall<'a, C> {}
4315
4316impl<'a, C> OrganizationApprovalRequestApproveCall<'a, C>
4317where
4318    C: common::Connector,
4319{
4320    /// Perform the operation you have build so far.
4321    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
4322        use std::borrow::Cow;
4323        use std::io::{Read, Seek};
4324
4325        use common::{url::Params, ToParts};
4326        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4327
4328        let mut dd = common::DefaultDelegate;
4329        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4330        dlg.begin(common::MethodInfo {
4331            id: "accessapproval.organizations.approvalRequests.approve",
4332            http_method: hyper::Method::POST,
4333        });
4334
4335        for &field in ["alt", "name"].iter() {
4336            if self._additional_params.contains_key(field) {
4337                dlg.finished(false);
4338                return Err(common::Error::FieldClash(field));
4339            }
4340        }
4341
4342        let mut params = Params::with_capacity(4 + self._additional_params.len());
4343        params.push("name", self._name);
4344
4345        params.extend(self._additional_params.iter());
4346
4347        params.push("alt", "json");
4348        let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
4349        if self._scopes.is_empty() {
4350            self._scopes
4351                .insert(Scope::CloudPlatform.as_ref().to_string());
4352        }
4353
4354        #[allow(clippy::single_element_loop)]
4355        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4356            url = params.uri_replacement(url, param_name, find_this, true);
4357        }
4358        {
4359            let to_remove = ["name"];
4360            params.remove_params(&to_remove);
4361        }
4362
4363        let url = params.parse_with_url(&url);
4364
4365        let mut json_mime_type = mime::APPLICATION_JSON;
4366        let mut request_value_reader = {
4367            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4368            common::remove_json_null_values(&mut value);
4369            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4370            serde_json::to_writer(&mut dst, &value).unwrap();
4371            dst
4372        };
4373        let request_size = request_value_reader
4374            .seek(std::io::SeekFrom::End(0))
4375            .unwrap();
4376        request_value_reader
4377            .seek(std::io::SeekFrom::Start(0))
4378            .unwrap();
4379
4380        loop {
4381            let token = match self
4382                .hub
4383                .auth
4384                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4385                .await
4386            {
4387                Ok(token) => token,
4388                Err(e) => match dlg.token(e) {
4389                    Ok(token) => token,
4390                    Err(e) => {
4391                        dlg.finished(false);
4392                        return Err(common::Error::MissingToken(e));
4393                    }
4394                },
4395            };
4396            request_value_reader
4397                .seek(std::io::SeekFrom::Start(0))
4398                .unwrap();
4399            let mut req_result = {
4400                let client = &self.hub.client;
4401                dlg.pre_request();
4402                let mut req_builder = hyper::Request::builder()
4403                    .method(hyper::Method::POST)
4404                    .uri(url.as_str())
4405                    .header(USER_AGENT, self.hub._user_agent.clone());
4406
4407                if let Some(token) = token.as_ref() {
4408                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4409                }
4410
4411                let request = req_builder
4412                    .header(CONTENT_TYPE, json_mime_type.to_string())
4413                    .header(CONTENT_LENGTH, request_size as u64)
4414                    .body(common::to_body(
4415                        request_value_reader.get_ref().clone().into(),
4416                    ));
4417
4418                client.request(request.unwrap()).await
4419            };
4420
4421            match req_result {
4422                Err(err) => {
4423                    if let common::Retry::After(d) = dlg.http_error(&err) {
4424                        sleep(d).await;
4425                        continue;
4426                    }
4427                    dlg.finished(false);
4428                    return Err(common::Error::HttpError(err));
4429                }
4430                Ok(res) => {
4431                    let (mut parts, body) = res.into_parts();
4432                    let mut body = common::Body::new(body);
4433                    if !parts.status.is_success() {
4434                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4435                        let error = serde_json::from_str(&common::to_string(&bytes));
4436                        let response = common::to_response(parts, bytes.into());
4437
4438                        if let common::Retry::After(d) =
4439                            dlg.http_failure(&response, error.as_ref().ok())
4440                        {
4441                            sleep(d).await;
4442                            continue;
4443                        }
4444
4445                        dlg.finished(false);
4446
4447                        return Err(match error {
4448                            Ok(value) => common::Error::BadRequest(value),
4449                            _ => common::Error::Failure(response),
4450                        });
4451                    }
4452                    let response = {
4453                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4454                        let encoded = common::to_string(&bytes);
4455                        match serde_json::from_str(&encoded) {
4456                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4457                            Err(error) => {
4458                                dlg.response_json_decode_error(&encoded, &error);
4459                                return Err(common::Error::JsonDecodeError(
4460                                    encoded.to_string(),
4461                                    error,
4462                                ));
4463                            }
4464                        }
4465                    };
4466
4467                    dlg.finished(true);
4468                    return Ok(response);
4469                }
4470            }
4471        }
4472    }
4473
4474    ///
4475    /// Sets the *request* property to the given value.
4476    ///
4477    /// Even though the property as already been set when instantiating this call,
4478    /// we provide this method for API completeness.
4479    pub fn request(
4480        mut self,
4481        new_value: ApproveApprovalRequestMessage,
4482    ) -> OrganizationApprovalRequestApproveCall<'a, C> {
4483        self._request = new_value;
4484        self
4485    }
4486    /// Name of the approval request to approve.
4487    ///
4488    /// Sets the *name* path property to the given value.
4489    ///
4490    /// Even though the property as already been set when instantiating this call,
4491    /// we provide this method for API completeness.
4492    pub fn name(mut self, new_value: &str) -> OrganizationApprovalRequestApproveCall<'a, C> {
4493        self._name = new_value.to_string();
4494        self
4495    }
4496    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4497    /// while executing the actual API request.
4498    ///
4499    /// ````text
4500    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4501    /// ````
4502    ///
4503    /// Sets the *delegate* property to the given value.
4504    pub fn delegate(
4505        mut self,
4506        new_value: &'a mut dyn common::Delegate,
4507    ) -> OrganizationApprovalRequestApproveCall<'a, C> {
4508        self._delegate = Some(new_value);
4509        self
4510    }
4511
4512    /// Set any additional parameter of the query string used in the request.
4513    /// It should be used to set parameters which are not yet available through their own
4514    /// setters.
4515    ///
4516    /// Please note that this method must not be used to set any of the known parameters
4517    /// which have their own setter method. If done anyway, the request will fail.
4518    ///
4519    /// # Additional Parameters
4520    ///
4521    /// * *$.xgafv* (query-string) - V1 error format.
4522    /// * *access_token* (query-string) - OAuth access token.
4523    /// * *alt* (query-string) - Data format for response.
4524    /// * *callback* (query-string) - JSONP
4525    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4526    /// * *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.
4527    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4528    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4529    /// * *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.
4530    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4531    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4532    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestApproveCall<'a, C>
4533    where
4534        T: AsRef<str>,
4535    {
4536        self._additional_params
4537            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4538        self
4539    }
4540
4541    /// Identifies the authorization scope for the method you are building.
4542    ///
4543    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4544    /// [`Scope::CloudPlatform`].
4545    ///
4546    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4547    /// tokens for more than one scope.
4548    ///
4549    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4550    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4551    /// sufficient, a read-write scope will do as well.
4552    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestApproveCall<'a, C>
4553    where
4554        St: AsRef<str>,
4555    {
4556        self._scopes.insert(String::from(scope.as_ref()));
4557        self
4558    }
4559    /// Identifies the authorization scope(s) for the method you are building.
4560    ///
4561    /// See [`Self::add_scope()`] for details.
4562    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestApproveCall<'a, C>
4563    where
4564        I: IntoIterator<Item = St>,
4565        St: AsRef<str>,
4566    {
4567        self._scopes
4568            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4569        self
4570    }
4571
4572    /// Removes all scopes, and no default scope will be used either.
4573    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4574    /// for details).
4575    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestApproveCall<'a, C> {
4576        self._scopes.clear();
4577        self
4578    }
4579}
4580
4581/// Dismisses a request. Returns the updated ApprovalRequest. NOTE: When a request is dismissed, it is considered ignored. Dismissing a request does not prevent access granted by other Access Approval requests. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
4582///
4583/// A builder for the *approvalRequests.dismiss* method supported by a *organization* resource.
4584/// It is not used directly, but through a [`OrganizationMethods`] instance.
4585///
4586/// # Example
4587///
4588/// Instantiate a resource method builder
4589///
4590/// ```test_harness,no_run
4591/// # extern crate hyper;
4592/// # extern crate hyper_rustls;
4593/// # extern crate google_accessapproval1 as accessapproval1;
4594/// use accessapproval1::api::DismissApprovalRequestMessage;
4595/// # async fn dox() {
4596/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4597///
4598/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4599/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4600/// #     .with_native_roots()
4601/// #     .unwrap()
4602/// #     .https_only()
4603/// #     .enable_http2()
4604/// #     .build();
4605///
4606/// # let executor = hyper_util::rt::TokioExecutor::new();
4607/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4608/// #     secret,
4609/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4610/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4611/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4612/// #     ),
4613/// # ).build().await.unwrap();
4614///
4615/// # let client = hyper_util::client::legacy::Client::builder(
4616/// #     hyper_util::rt::TokioExecutor::new()
4617/// # )
4618/// # .build(
4619/// #     hyper_rustls::HttpsConnectorBuilder::new()
4620/// #         .with_native_roots()
4621/// #         .unwrap()
4622/// #         .https_or_http()
4623/// #         .enable_http2()
4624/// #         .build()
4625/// # );
4626/// # let mut hub = AccessApproval::new(client, auth);
4627/// // As the method needs a request, you would usually fill it with the desired information
4628/// // into the respective structure. Some of the parts shown here might not be applicable !
4629/// // Values shown here are possibly random and not representative !
4630/// let mut req = DismissApprovalRequestMessage::default();
4631///
4632/// // You can configure optional parameters by calling the respective setters at will, and
4633/// // execute the final call using `doit()`.
4634/// // Values shown here are possibly random and not representative !
4635/// let result = hub.organizations().approval_requests_dismiss(req, "name")
4636///              .doit().await;
4637/// # }
4638/// ```
4639pub struct OrganizationApprovalRequestDismisCall<'a, C>
4640where
4641    C: 'a,
4642{
4643    hub: &'a AccessApproval<C>,
4644    _request: DismissApprovalRequestMessage,
4645    _name: String,
4646    _delegate: Option<&'a mut dyn common::Delegate>,
4647    _additional_params: HashMap<String, String>,
4648    _scopes: BTreeSet<String>,
4649}
4650
4651impl<'a, C> common::CallBuilder for OrganizationApprovalRequestDismisCall<'a, C> {}
4652
4653impl<'a, C> OrganizationApprovalRequestDismisCall<'a, C>
4654where
4655    C: common::Connector,
4656{
4657    /// Perform the operation you have build so far.
4658    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
4659        use std::borrow::Cow;
4660        use std::io::{Read, Seek};
4661
4662        use common::{url::Params, ToParts};
4663        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4664
4665        let mut dd = common::DefaultDelegate;
4666        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4667        dlg.begin(common::MethodInfo {
4668            id: "accessapproval.organizations.approvalRequests.dismiss",
4669            http_method: hyper::Method::POST,
4670        });
4671
4672        for &field in ["alt", "name"].iter() {
4673            if self._additional_params.contains_key(field) {
4674                dlg.finished(false);
4675                return Err(common::Error::FieldClash(field));
4676            }
4677        }
4678
4679        let mut params = Params::with_capacity(4 + self._additional_params.len());
4680        params.push("name", self._name);
4681
4682        params.extend(self._additional_params.iter());
4683
4684        params.push("alt", "json");
4685        let mut url = self.hub._base_url.clone() + "v1/{+name}:dismiss";
4686        if self._scopes.is_empty() {
4687            self._scopes
4688                .insert(Scope::CloudPlatform.as_ref().to_string());
4689        }
4690
4691        #[allow(clippy::single_element_loop)]
4692        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4693            url = params.uri_replacement(url, param_name, find_this, true);
4694        }
4695        {
4696            let to_remove = ["name"];
4697            params.remove_params(&to_remove);
4698        }
4699
4700        let url = params.parse_with_url(&url);
4701
4702        let mut json_mime_type = mime::APPLICATION_JSON;
4703        let mut request_value_reader = {
4704            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4705            common::remove_json_null_values(&mut value);
4706            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4707            serde_json::to_writer(&mut dst, &value).unwrap();
4708            dst
4709        };
4710        let request_size = request_value_reader
4711            .seek(std::io::SeekFrom::End(0))
4712            .unwrap();
4713        request_value_reader
4714            .seek(std::io::SeekFrom::Start(0))
4715            .unwrap();
4716
4717        loop {
4718            let token = match self
4719                .hub
4720                .auth
4721                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4722                .await
4723            {
4724                Ok(token) => token,
4725                Err(e) => match dlg.token(e) {
4726                    Ok(token) => token,
4727                    Err(e) => {
4728                        dlg.finished(false);
4729                        return Err(common::Error::MissingToken(e));
4730                    }
4731                },
4732            };
4733            request_value_reader
4734                .seek(std::io::SeekFrom::Start(0))
4735                .unwrap();
4736            let mut req_result = {
4737                let client = &self.hub.client;
4738                dlg.pre_request();
4739                let mut req_builder = hyper::Request::builder()
4740                    .method(hyper::Method::POST)
4741                    .uri(url.as_str())
4742                    .header(USER_AGENT, self.hub._user_agent.clone());
4743
4744                if let Some(token) = token.as_ref() {
4745                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4746                }
4747
4748                let request = req_builder
4749                    .header(CONTENT_TYPE, json_mime_type.to_string())
4750                    .header(CONTENT_LENGTH, request_size as u64)
4751                    .body(common::to_body(
4752                        request_value_reader.get_ref().clone().into(),
4753                    ));
4754
4755                client.request(request.unwrap()).await
4756            };
4757
4758            match req_result {
4759                Err(err) => {
4760                    if let common::Retry::After(d) = dlg.http_error(&err) {
4761                        sleep(d).await;
4762                        continue;
4763                    }
4764                    dlg.finished(false);
4765                    return Err(common::Error::HttpError(err));
4766                }
4767                Ok(res) => {
4768                    let (mut parts, body) = res.into_parts();
4769                    let mut body = common::Body::new(body);
4770                    if !parts.status.is_success() {
4771                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4772                        let error = serde_json::from_str(&common::to_string(&bytes));
4773                        let response = common::to_response(parts, bytes.into());
4774
4775                        if let common::Retry::After(d) =
4776                            dlg.http_failure(&response, error.as_ref().ok())
4777                        {
4778                            sleep(d).await;
4779                            continue;
4780                        }
4781
4782                        dlg.finished(false);
4783
4784                        return Err(match error {
4785                            Ok(value) => common::Error::BadRequest(value),
4786                            _ => common::Error::Failure(response),
4787                        });
4788                    }
4789                    let response = {
4790                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4791                        let encoded = common::to_string(&bytes);
4792                        match serde_json::from_str(&encoded) {
4793                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4794                            Err(error) => {
4795                                dlg.response_json_decode_error(&encoded, &error);
4796                                return Err(common::Error::JsonDecodeError(
4797                                    encoded.to_string(),
4798                                    error,
4799                                ));
4800                            }
4801                        }
4802                    };
4803
4804                    dlg.finished(true);
4805                    return Ok(response);
4806                }
4807            }
4808        }
4809    }
4810
4811    ///
4812    /// Sets the *request* property to the given value.
4813    ///
4814    /// Even though the property as already been set when instantiating this call,
4815    /// we provide this method for API completeness.
4816    pub fn request(
4817        mut self,
4818        new_value: DismissApprovalRequestMessage,
4819    ) -> OrganizationApprovalRequestDismisCall<'a, C> {
4820        self._request = new_value;
4821        self
4822    }
4823    /// Name of the ApprovalRequest to dismiss.
4824    ///
4825    /// Sets the *name* path property to the given value.
4826    ///
4827    /// Even though the property as already been set when instantiating this call,
4828    /// we provide this method for API completeness.
4829    pub fn name(mut self, new_value: &str) -> OrganizationApprovalRequestDismisCall<'a, C> {
4830        self._name = new_value.to_string();
4831        self
4832    }
4833    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4834    /// while executing the actual API request.
4835    ///
4836    /// ````text
4837    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4838    /// ````
4839    ///
4840    /// Sets the *delegate* property to the given value.
4841    pub fn delegate(
4842        mut self,
4843        new_value: &'a mut dyn common::Delegate,
4844    ) -> OrganizationApprovalRequestDismisCall<'a, C> {
4845        self._delegate = Some(new_value);
4846        self
4847    }
4848
4849    /// Set any additional parameter of the query string used in the request.
4850    /// It should be used to set parameters which are not yet available through their own
4851    /// setters.
4852    ///
4853    /// Please note that this method must not be used to set any of the known parameters
4854    /// which have their own setter method. If done anyway, the request will fail.
4855    ///
4856    /// # Additional Parameters
4857    ///
4858    /// * *$.xgafv* (query-string) - V1 error format.
4859    /// * *access_token* (query-string) - OAuth access token.
4860    /// * *alt* (query-string) - Data format for response.
4861    /// * *callback* (query-string) - JSONP
4862    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4863    /// * *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.
4864    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4865    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4866    /// * *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.
4867    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4868    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4869    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestDismisCall<'a, C>
4870    where
4871        T: AsRef<str>,
4872    {
4873        self._additional_params
4874            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4875        self
4876    }
4877
4878    /// Identifies the authorization scope for the method you are building.
4879    ///
4880    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4881    /// [`Scope::CloudPlatform`].
4882    ///
4883    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4884    /// tokens for more than one scope.
4885    ///
4886    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4887    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4888    /// sufficient, a read-write scope will do as well.
4889    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestDismisCall<'a, C>
4890    where
4891        St: AsRef<str>,
4892    {
4893        self._scopes.insert(String::from(scope.as_ref()));
4894        self
4895    }
4896    /// Identifies the authorization scope(s) for the method you are building.
4897    ///
4898    /// See [`Self::add_scope()`] for details.
4899    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestDismisCall<'a, C>
4900    where
4901        I: IntoIterator<Item = St>,
4902        St: AsRef<str>,
4903    {
4904        self._scopes
4905            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4906        self
4907    }
4908
4909    /// Removes all scopes, and no default scope will be used either.
4910    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4911    /// for details).
4912    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestDismisCall<'a, C> {
4913        self._scopes.clear();
4914        self
4915    }
4916}
4917
4918/// Gets an approval request. Returns NOT_FOUND if the request does not exist.
4919///
4920/// A builder for the *approvalRequests.get* method supported by a *organization* resource.
4921/// It is not used directly, but through a [`OrganizationMethods`] instance.
4922///
4923/// # Example
4924///
4925/// Instantiate a resource method builder
4926///
4927/// ```test_harness,no_run
4928/// # extern crate hyper;
4929/// # extern crate hyper_rustls;
4930/// # extern crate google_accessapproval1 as accessapproval1;
4931/// # async fn dox() {
4932/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4933///
4934/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4935/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4936/// #     .with_native_roots()
4937/// #     .unwrap()
4938/// #     .https_only()
4939/// #     .enable_http2()
4940/// #     .build();
4941///
4942/// # let executor = hyper_util::rt::TokioExecutor::new();
4943/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4944/// #     secret,
4945/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4946/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4947/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4948/// #     ),
4949/// # ).build().await.unwrap();
4950///
4951/// # let client = hyper_util::client::legacy::Client::builder(
4952/// #     hyper_util::rt::TokioExecutor::new()
4953/// # )
4954/// # .build(
4955/// #     hyper_rustls::HttpsConnectorBuilder::new()
4956/// #         .with_native_roots()
4957/// #         .unwrap()
4958/// #         .https_or_http()
4959/// #         .enable_http2()
4960/// #         .build()
4961/// # );
4962/// # let mut hub = AccessApproval::new(client, auth);
4963/// // You can configure optional parameters by calling the respective setters at will, and
4964/// // execute the final call using `doit()`.
4965/// // Values shown here are possibly random and not representative !
4966/// let result = hub.organizations().approval_requests_get("name")
4967///              .doit().await;
4968/// # }
4969/// ```
4970pub struct OrganizationApprovalRequestGetCall<'a, C>
4971where
4972    C: 'a,
4973{
4974    hub: &'a AccessApproval<C>,
4975    _name: String,
4976    _delegate: Option<&'a mut dyn common::Delegate>,
4977    _additional_params: HashMap<String, String>,
4978    _scopes: BTreeSet<String>,
4979}
4980
4981impl<'a, C> common::CallBuilder for OrganizationApprovalRequestGetCall<'a, C> {}
4982
4983impl<'a, C> OrganizationApprovalRequestGetCall<'a, C>
4984where
4985    C: common::Connector,
4986{
4987    /// Perform the operation you have build so far.
4988    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
4989        use std::borrow::Cow;
4990        use std::io::{Read, Seek};
4991
4992        use common::{url::Params, ToParts};
4993        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4994
4995        let mut dd = common::DefaultDelegate;
4996        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4997        dlg.begin(common::MethodInfo {
4998            id: "accessapproval.organizations.approvalRequests.get",
4999            http_method: hyper::Method::GET,
5000        });
5001
5002        for &field in ["alt", "name"].iter() {
5003            if self._additional_params.contains_key(field) {
5004                dlg.finished(false);
5005                return Err(common::Error::FieldClash(field));
5006            }
5007        }
5008
5009        let mut params = Params::with_capacity(3 + self._additional_params.len());
5010        params.push("name", self._name);
5011
5012        params.extend(self._additional_params.iter());
5013
5014        params.push("alt", "json");
5015        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5016        if self._scopes.is_empty() {
5017            self._scopes
5018                .insert(Scope::CloudPlatform.as_ref().to_string());
5019        }
5020
5021        #[allow(clippy::single_element_loop)]
5022        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5023            url = params.uri_replacement(url, param_name, find_this, true);
5024        }
5025        {
5026            let to_remove = ["name"];
5027            params.remove_params(&to_remove);
5028        }
5029
5030        let url = params.parse_with_url(&url);
5031
5032        loop {
5033            let token = match self
5034                .hub
5035                .auth
5036                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5037                .await
5038            {
5039                Ok(token) => token,
5040                Err(e) => match dlg.token(e) {
5041                    Ok(token) => token,
5042                    Err(e) => {
5043                        dlg.finished(false);
5044                        return Err(common::Error::MissingToken(e));
5045                    }
5046                },
5047            };
5048            let mut req_result = {
5049                let client = &self.hub.client;
5050                dlg.pre_request();
5051                let mut req_builder = hyper::Request::builder()
5052                    .method(hyper::Method::GET)
5053                    .uri(url.as_str())
5054                    .header(USER_AGENT, self.hub._user_agent.clone());
5055
5056                if let Some(token) = token.as_ref() {
5057                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5058                }
5059
5060                let request = req_builder
5061                    .header(CONTENT_LENGTH, 0_u64)
5062                    .body(common::to_body::<String>(None));
5063
5064                client.request(request.unwrap()).await
5065            };
5066
5067            match req_result {
5068                Err(err) => {
5069                    if let common::Retry::After(d) = dlg.http_error(&err) {
5070                        sleep(d).await;
5071                        continue;
5072                    }
5073                    dlg.finished(false);
5074                    return Err(common::Error::HttpError(err));
5075                }
5076                Ok(res) => {
5077                    let (mut parts, body) = res.into_parts();
5078                    let mut body = common::Body::new(body);
5079                    if !parts.status.is_success() {
5080                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5081                        let error = serde_json::from_str(&common::to_string(&bytes));
5082                        let response = common::to_response(parts, bytes.into());
5083
5084                        if let common::Retry::After(d) =
5085                            dlg.http_failure(&response, error.as_ref().ok())
5086                        {
5087                            sleep(d).await;
5088                            continue;
5089                        }
5090
5091                        dlg.finished(false);
5092
5093                        return Err(match error {
5094                            Ok(value) => common::Error::BadRequest(value),
5095                            _ => common::Error::Failure(response),
5096                        });
5097                    }
5098                    let response = {
5099                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5100                        let encoded = common::to_string(&bytes);
5101                        match serde_json::from_str(&encoded) {
5102                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5103                            Err(error) => {
5104                                dlg.response_json_decode_error(&encoded, &error);
5105                                return Err(common::Error::JsonDecodeError(
5106                                    encoded.to_string(),
5107                                    error,
5108                                ));
5109                            }
5110                        }
5111                    };
5112
5113                    dlg.finished(true);
5114                    return Ok(response);
5115                }
5116            }
5117        }
5118    }
5119
5120    /// The name of the approval request to retrieve. Format: "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
5121    ///
5122    /// Sets the *name* path property to the given value.
5123    ///
5124    /// Even though the property as already been set when instantiating this call,
5125    /// we provide this method for API completeness.
5126    pub fn name(mut self, new_value: &str) -> OrganizationApprovalRequestGetCall<'a, C> {
5127        self._name = new_value.to_string();
5128        self
5129    }
5130    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5131    /// while executing the actual API request.
5132    ///
5133    /// ````text
5134    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5135    /// ````
5136    ///
5137    /// Sets the *delegate* property to the given value.
5138    pub fn delegate(
5139        mut self,
5140        new_value: &'a mut dyn common::Delegate,
5141    ) -> OrganizationApprovalRequestGetCall<'a, C> {
5142        self._delegate = Some(new_value);
5143        self
5144    }
5145
5146    /// Set any additional parameter of the query string used in the request.
5147    /// It should be used to set parameters which are not yet available through their own
5148    /// setters.
5149    ///
5150    /// Please note that this method must not be used to set any of the known parameters
5151    /// which have their own setter method. If done anyway, the request will fail.
5152    ///
5153    /// # Additional Parameters
5154    ///
5155    /// * *$.xgafv* (query-string) - V1 error format.
5156    /// * *access_token* (query-string) - OAuth access token.
5157    /// * *alt* (query-string) - Data format for response.
5158    /// * *callback* (query-string) - JSONP
5159    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5160    /// * *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.
5161    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5162    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5163    /// * *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.
5164    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5165    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5166    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestGetCall<'a, C>
5167    where
5168        T: AsRef<str>,
5169    {
5170        self._additional_params
5171            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5172        self
5173    }
5174
5175    /// Identifies the authorization scope for the method you are building.
5176    ///
5177    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5178    /// [`Scope::CloudPlatform`].
5179    ///
5180    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5181    /// tokens for more than one scope.
5182    ///
5183    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5184    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5185    /// sufficient, a read-write scope will do as well.
5186    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestGetCall<'a, C>
5187    where
5188        St: AsRef<str>,
5189    {
5190        self._scopes.insert(String::from(scope.as_ref()));
5191        self
5192    }
5193    /// Identifies the authorization scope(s) for the method you are building.
5194    ///
5195    /// See [`Self::add_scope()`] for details.
5196    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestGetCall<'a, C>
5197    where
5198        I: IntoIterator<Item = St>,
5199        St: AsRef<str>,
5200    {
5201        self._scopes
5202            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5203        self
5204    }
5205
5206    /// Removes all scopes, and no default scope will be used either.
5207    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5208    /// for details).
5209    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestGetCall<'a, C> {
5210        self._scopes.clear();
5211        self
5212    }
5213}
5214
5215/// Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. NOTE: This action revokes Google access based on this approval request. If the resource has other active approvals, access will remain granted. Returns FAILED_PRECONDITION if the request exists but is not in an approved state.
5216///
5217/// A builder for the *approvalRequests.invalidate* method supported by a *organization* resource.
5218/// It is not used directly, but through a [`OrganizationMethods`] instance.
5219///
5220/// # Example
5221///
5222/// Instantiate a resource method builder
5223///
5224/// ```test_harness,no_run
5225/// # extern crate hyper;
5226/// # extern crate hyper_rustls;
5227/// # extern crate google_accessapproval1 as accessapproval1;
5228/// use accessapproval1::api::InvalidateApprovalRequestMessage;
5229/// # async fn dox() {
5230/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5231///
5232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5233/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5234/// #     .with_native_roots()
5235/// #     .unwrap()
5236/// #     .https_only()
5237/// #     .enable_http2()
5238/// #     .build();
5239///
5240/// # let executor = hyper_util::rt::TokioExecutor::new();
5241/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5242/// #     secret,
5243/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5244/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5245/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5246/// #     ),
5247/// # ).build().await.unwrap();
5248///
5249/// # let client = hyper_util::client::legacy::Client::builder(
5250/// #     hyper_util::rt::TokioExecutor::new()
5251/// # )
5252/// # .build(
5253/// #     hyper_rustls::HttpsConnectorBuilder::new()
5254/// #         .with_native_roots()
5255/// #         .unwrap()
5256/// #         .https_or_http()
5257/// #         .enable_http2()
5258/// #         .build()
5259/// # );
5260/// # let mut hub = AccessApproval::new(client, auth);
5261/// // As the method needs a request, you would usually fill it with the desired information
5262/// // into the respective structure. Some of the parts shown here might not be applicable !
5263/// // Values shown here are possibly random and not representative !
5264/// let mut req = InvalidateApprovalRequestMessage::default();
5265///
5266/// // You can configure optional parameters by calling the respective setters at will, and
5267/// // execute the final call using `doit()`.
5268/// // Values shown here are possibly random and not representative !
5269/// let result = hub.organizations().approval_requests_invalidate(req, "name")
5270///              .doit().await;
5271/// # }
5272/// ```
5273pub struct OrganizationApprovalRequestInvalidateCall<'a, C>
5274where
5275    C: 'a,
5276{
5277    hub: &'a AccessApproval<C>,
5278    _request: InvalidateApprovalRequestMessage,
5279    _name: String,
5280    _delegate: Option<&'a mut dyn common::Delegate>,
5281    _additional_params: HashMap<String, String>,
5282    _scopes: BTreeSet<String>,
5283}
5284
5285impl<'a, C> common::CallBuilder for OrganizationApprovalRequestInvalidateCall<'a, C> {}
5286
5287impl<'a, C> OrganizationApprovalRequestInvalidateCall<'a, C>
5288where
5289    C: common::Connector,
5290{
5291    /// Perform the operation you have build so far.
5292    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
5293        use std::borrow::Cow;
5294        use std::io::{Read, Seek};
5295
5296        use common::{url::Params, ToParts};
5297        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5298
5299        let mut dd = common::DefaultDelegate;
5300        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5301        dlg.begin(common::MethodInfo {
5302            id: "accessapproval.organizations.approvalRequests.invalidate",
5303            http_method: hyper::Method::POST,
5304        });
5305
5306        for &field in ["alt", "name"].iter() {
5307            if self._additional_params.contains_key(field) {
5308                dlg.finished(false);
5309                return Err(common::Error::FieldClash(field));
5310            }
5311        }
5312
5313        let mut params = Params::with_capacity(4 + self._additional_params.len());
5314        params.push("name", self._name);
5315
5316        params.extend(self._additional_params.iter());
5317
5318        params.push("alt", "json");
5319        let mut url = self.hub._base_url.clone() + "v1/{+name}:invalidate";
5320        if self._scopes.is_empty() {
5321            self._scopes
5322                .insert(Scope::CloudPlatform.as_ref().to_string());
5323        }
5324
5325        #[allow(clippy::single_element_loop)]
5326        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5327            url = params.uri_replacement(url, param_name, find_this, true);
5328        }
5329        {
5330            let to_remove = ["name"];
5331            params.remove_params(&to_remove);
5332        }
5333
5334        let url = params.parse_with_url(&url);
5335
5336        let mut json_mime_type = mime::APPLICATION_JSON;
5337        let mut request_value_reader = {
5338            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5339            common::remove_json_null_values(&mut value);
5340            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5341            serde_json::to_writer(&mut dst, &value).unwrap();
5342            dst
5343        };
5344        let request_size = request_value_reader
5345            .seek(std::io::SeekFrom::End(0))
5346            .unwrap();
5347        request_value_reader
5348            .seek(std::io::SeekFrom::Start(0))
5349            .unwrap();
5350
5351        loop {
5352            let token = match self
5353                .hub
5354                .auth
5355                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5356                .await
5357            {
5358                Ok(token) => token,
5359                Err(e) => match dlg.token(e) {
5360                    Ok(token) => token,
5361                    Err(e) => {
5362                        dlg.finished(false);
5363                        return Err(common::Error::MissingToken(e));
5364                    }
5365                },
5366            };
5367            request_value_reader
5368                .seek(std::io::SeekFrom::Start(0))
5369                .unwrap();
5370            let mut req_result = {
5371                let client = &self.hub.client;
5372                dlg.pre_request();
5373                let mut req_builder = hyper::Request::builder()
5374                    .method(hyper::Method::POST)
5375                    .uri(url.as_str())
5376                    .header(USER_AGENT, self.hub._user_agent.clone());
5377
5378                if let Some(token) = token.as_ref() {
5379                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5380                }
5381
5382                let request = req_builder
5383                    .header(CONTENT_TYPE, json_mime_type.to_string())
5384                    .header(CONTENT_LENGTH, request_size as u64)
5385                    .body(common::to_body(
5386                        request_value_reader.get_ref().clone().into(),
5387                    ));
5388
5389                client.request(request.unwrap()).await
5390            };
5391
5392            match req_result {
5393                Err(err) => {
5394                    if let common::Retry::After(d) = dlg.http_error(&err) {
5395                        sleep(d).await;
5396                        continue;
5397                    }
5398                    dlg.finished(false);
5399                    return Err(common::Error::HttpError(err));
5400                }
5401                Ok(res) => {
5402                    let (mut parts, body) = res.into_parts();
5403                    let mut body = common::Body::new(body);
5404                    if !parts.status.is_success() {
5405                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5406                        let error = serde_json::from_str(&common::to_string(&bytes));
5407                        let response = common::to_response(parts, bytes.into());
5408
5409                        if let common::Retry::After(d) =
5410                            dlg.http_failure(&response, error.as_ref().ok())
5411                        {
5412                            sleep(d).await;
5413                            continue;
5414                        }
5415
5416                        dlg.finished(false);
5417
5418                        return Err(match error {
5419                            Ok(value) => common::Error::BadRequest(value),
5420                            _ => common::Error::Failure(response),
5421                        });
5422                    }
5423                    let response = {
5424                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5425                        let encoded = common::to_string(&bytes);
5426                        match serde_json::from_str(&encoded) {
5427                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5428                            Err(error) => {
5429                                dlg.response_json_decode_error(&encoded, &error);
5430                                return Err(common::Error::JsonDecodeError(
5431                                    encoded.to_string(),
5432                                    error,
5433                                ));
5434                            }
5435                        }
5436                    };
5437
5438                    dlg.finished(true);
5439                    return Ok(response);
5440                }
5441            }
5442        }
5443    }
5444
5445    ///
5446    /// Sets the *request* property to the given value.
5447    ///
5448    /// Even though the property as already been set when instantiating this call,
5449    /// we provide this method for API completeness.
5450    pub fn request(
5451        mut self,
5452        new_value: InvalidateApprovalRequestMessage,
5453    ) -> OrganizationApprovalRequestInvalidateCall<'a, C> {
5454        self._request = new_value;
5455        self
5456    }
5457    /// Name of the ApprovalRequest to invalidate.
5458    ///
5459    /// Sets the *name* path property to the given value.
5460    ///
5461    /// Even though the property as already been set when instantiating this call,
5462    /// we provide this method for API completeness.
5463    pub fn name(mut self, new_value: &str) -> OrganizationApprovalRequestInvalidateCall<'a, C> {
5464        self._name = new_value.to_string();
5465        self
5466    }
5467    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5468    /// while executing the actual API request.
5469    ///
5470    /// ````text
5471    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5472    /// ````
5473    ///
5474    /// Sets the *delegate* property to the given value.
5475    pub fn delegate(
5476        mut self,
5477        new_value: &'a mut dyn common::Delegate,
5478    ) -> OrganizationApprovalRequestInvalidateCall<'a, C> {
5479        self._delegate = Some(new_value);
5480        self
5481    }
5482
5483    /// Set any additional parameter of the query string used in the request.
5484    /// It should be used to set parameters which are not yet available through their own
5485    /// setters.
5486    ///
5487    /// Please note that this method must not be used to set any of the known parameters
5488    /// which have their own setter method. If done anyway, the request will fail.
5489    ///
5490    /// # Additional Parameters
5491    ///
5492    /// * *$.xgafv* (query-string) - V1 error format.
5493    /// * *access_token* (query-string) - OAuth access token.
5494    /// * *alt* (query-string) - Data format for response.
5495    /// * *callback* (query-string) - JSONP
5496    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5497    /// * *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.
5498    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5499    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5500    /// * *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.
5501    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5502    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5503    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestInvalidateCall<'a, C>
5504    where
5505        T: AsRef<str>,
5506    {
5507        self._additional_params
5508            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5509        self
5510    }
5511
5512    /// Identifies the authorization scope for the method you are building.
5513    ///
5514    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5515    /// [`Scope::CloudPlatform`].
5516    ///
5517    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5518    /// tokens for more than one scope.
5519    ///
5520    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5521    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5522    /// sufficient, a read-write scope will do as well.
5523    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestInvalidateCall<'a, C>
5524    where
5525        St: AsRef<str>,
5526    {
5527        self._scopes.insert(String::from(scope.as_ref()));
5528        self
5529    }
5530    /// Identifies the authorization scope(s) for the method you are building.
5531    ///
5532    /// See [`Self::add_scope()`] for details.
5533    pub fn add_scopes<I, St>(
5534        mut self,
5535        scopes: I,
5536    ) -> OrganizationApprovalRequestInvalidateCall<'a, C>
5537    where
5538        I: IntoIterator<Item = St>,
5539        St: AsRef<str>,
5540    {
5541        self._scopes
5542            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5543        self
5544    }
5545
5546    /// Removes all scopes, and no default scope will be used either.
5547    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5548    /// for details).
5549    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestInvalidateCall<'a, C> {
5550        self._scopes.clear();
5551        self
5552    }
5553}
5554
5555/// Lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.
5556///
5557/// A builder for the *approvalRequests.list* method supported by a *organization* resource.
5558/// It is not used directly, but through a [`OrganizationMethods`] instance.
5559///
5560/// # Example
5561///
5562/// Instantiate a resource method builder
5563///
5564/// ```test_harness,no_run
5565/// # extern crate hyper;
5566/// # extern crate hyper_rustls;
5567/// # extern crate google_accessapproval1 as accessapproval1;
5568/// # async fn dox() {
5569/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5570///
5571/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5572/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5573/// #     .with_native_roots()
5574/// #     .unwrap()
5575/// #     .https_only()
5576/// #     .enable_http2()
5577/// #     .build();
5578///
5579/// # let executor = hyper_util::rt::TokioExecutor::new();
5580/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5581/// #     secret,
5582/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5583/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5584/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5585/// #     ),
5586/// # ).build().await.unwrap();
5587///
5588/// # let client = hyper_util::client::legacy::Client::builder(
5589/// #     hyper_util::rt::TokioExecutor::new()
5590/// # )
5591/// # .build(
5592/// #     hyper_rustls::HttpsConnectorBuilder::new()
5593/// #         .with_native_roots()
5594/// #         .unwrap()
5595/// #         .https_or_http()
5596/// #         .enable_http2()
5597/// #         .build()
5598/// # );
5599/// # let mut hub = AccessApproval::new(client, auth);
5600/// // You can configure optional parameters by calling the respective setters at will, and
5601/// // execute the final call using `doit()`.
5602/// // Values shown here are possibly random and not representative !
5603/// let result = hub.organizations().approval_requests_list("parent")
5604///              .page_token("invidunt")
5605///              .page_size(-47)
5606///              .filter("duo")
5607///              .doit().await;
5608/// # }
5609/// ```
5610pub struct OrganizationApprovalRequestListCall<'a, C>
5611where
5612    C: 'a,
5613{
5614    hub: &'a AccessApproval<C>,
5615    _parent: String,
5616    _page_token: Option<String>,
5617    _page_size: Option<i32>,
5618    _filter: Option<String>,
5619    _delegate: Option<&'a mut dyn common::Delegate>,
5620    _additional_params: HashMap<String, String>,
5621    _scopes: BTreeSet<String>,
5622}
5623
5624impl<'a, C> common::CallBuilder for OrganizationApprovalRequestListCall<'a, C> {}
5625
5626impl<'a, C> OrganizationApprovalRequestListCall<'a, C>
5627where
5628    C: common::Connector,
5629{
5630    /// Perform the operation you have build so far.
5631    pub async fn doit(
5632        mut self,
5633    ) -> common::Result<(common::Response, ListApprovalRequestsResponse)> {
5634        use std::borrow::Cow;
5635        use std::io::{Read, Seek};
5636
5637        use common::{url::Params, ToParts};
5638        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5639
5640        let mut dd = common::DefaultDelegate;
5641        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5642        dlg.begin(common::MethodInfo {
5643            id: "accessapproval.organizations.approvalRequests.list",
5644            http_method: hyper::Method::GET,
5645        });
5646
5647        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5648            if self._additional_params.contains_key(field) {
5649                dlg.finished(false);
5650                return Err(common::Error::FieldClash(field));
5651            }
5652        }
5653
5654        let mut params = Params::with_capacity(6 + self._additional_params.len());
5655        params.push("parent", self._parent);
5656        if let Some(value) = self._page_token.as_ref() {
5657            params.push("pageToken", value);
5658        }
5659        if let Some(value) = self._page_size.as_ref() {
5660            params.push("pageSize", value.to_string());
5661        }
5662        if let Some(value) = self._filter.as_ref() {
5663            params.push("filter", value);
5664        }
5665
5666        params.extend(self._additional_params.iter());
5667
5668        params.push("alt", "json");
5669        let mut url = self.hub._base_url.clone() + "v1/{+parent}/approvalRequests";
5670        if self._scopes.is_empty() {
5671            self._scopes
5672                .insert(Scope::CloudPlatform.as_ref().to_string());
5673        }
5674
5675        #[allow(clippy::single_element_loop)]
5676        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5677            url = params.uri_replacement(url, param_name, find_this, true);
5678        }
5679        {
5680            let to_remove = ["parent"];
5681            params.remove_params(&to_remove);
5682        }
5683
5684        let url = params.parse_with_url(&url);
5685
5686        loop {
5687            let token = match self
5688                .hub
5689                .auth
5690                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5691                .await
5692            {
5693                Ok(token) => token,
5694                Err(e) => match dlg.token(e) {
5695                    Ok(token) => token,
5696                    Err(e) => {
5697                        dlg.finished(false);
5698                        return Err(common::Error::MissingToken(e));
5699                    }
5700                },
5701            };
5702            let mut req_result = {
5703                let client = &self.hub.client;
5704                dlg.pre_request();
5705                let mut req_builder = hyper::Request::builder()
5706                    .method(hyper::Method::GET)
5707                    .uri(url.as_str())
5708                    .header(USER_AGENT, self.hub._user_agent.clone());
5709
5710                if let Some(token) = token.as_ref() {
5711                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5712                }
5713
5714                let request = req_builder
5715                    .header(CONTENT_LENGTH, 0_u64)
5716                    .body(common::to_body::<String>(None));
5717
5718                client.request(request.unwrap()).await
5719            };
5720
5721            match req_result {
5722                Err(err) => {
5723                    if let common::Retry::After(d) = dlg.http_error(&err) {
5724                        sleep(d).await;
5725                        continue;
5726                    }
5727                    dlg.finished(false);
5728                    return Err(common::Error::HttpError(err));
5729                }
5730                Ok(res) => {
5731                    let (mut parts, body) = res.into_parts();
5732                    let mut body = common::Body::new(body);
5733                    if !parts.status.is_success() {
5734                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5735                        let error = serde_json::from_str(&common::to_string(&bytes));
5736                        let response = common::to_response(parts, bytes.into());
5737
5738                        if let common::Retry::After(d) =
5739                            dlg.http_failure(&response, error.as_ref().ok())
5740                        {
5741                            sleep(d).await;
5742                            continue;
5743                        }
5744
5745                        dlg.finished(false);
5746
5747                        return Err(match error {
5748                            Ok(value) => common::Error::BadRequest(value),
5749                            _ => common::Error::Failure(response),
5750                        });
5751                    }
5752                    let response = {
5753                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5754                        let encoded = common::to_string(&bytes);
5755                        match serde_json::from_str(&encoded) {
5756                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5757                            Err(error) => {
5758                                dlg.response_json_decode_error(&encoded, &error);
5759                                return Err(common::Error::JsonDecodeError(
5760                                    encoded.to_string(),
5761                                    error,
5762                                ));
5763                            }
5764                        }
5765                    };
5766
5767                    dlg.finished(true);
5768                    return Ok(response);
5769                }
5770            }
5771        }
5772    }
5773
5774    /// The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".
5775    ///
5776    /// Sets the *parent* path property to the given value.
5777    ///
5778    /// Even though the property as already been set when instantiating this call,
5779    /// we provide this method for API completeness.
5780    pub fn parent(mut self, new_value: &str) -> OrganizationApprovalRequestListCall<'a, C> {
5781        self._parent = new_value.to_string();
5782        self
5783    }
5784    /// A token identifying the page of results to return.
5785    ///
5786    /// Sets the *page token* query property to the given value.
5787    pub fn page_token(mut self, new_value: &str) -> OrganizationApprovalRequestListCall<'a, C> {
5788        self._page_token = Some(new_value.to_string());
5789        self
5790    }
5791    /// Requested page size.
5792    ///
5793    /// Sets the *page size* query property to the given value.
5794    pub fn page_size(mut self, new_value: i32) -> OrganizationApprovalRequestListCall<'a, C> {
5795        self._page_size = Some(new_value);
5796        self
5797    }
5798    /// A filter on the type of approval requests to retrieve. Must be one of the following values: * [not set]: Requests that are pending or have active approvals. * ALL: All requests. * PENDING: Only pending requests. * ACTIVE: Only active (i.e. currently approved) requests. * DISMISSED: Only requests that have been dismissed, or requests that are not approved and past expiration. * EXPIRED: Only requests that have been approved, and the approval has expired. * HISTORY: Active, dismissed and expired requests.
5799    ///
5800    /// Sets the *filter* query property to the given value.
5801    pub fn filter(mut self, new_value: &str) -> OrganizationApprovalRequestListCall<'a, C> {
5802        self._filter = Some(new_value.to_string());
5803        self
5804    }
5805    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5806    /// while executing the actual API request.
5807    ///
5808    /// ````text
5809    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5810    /// ````
5811    ///
5812    /// Sets the *delegate* property to the given value.
5813    pub fn delegate(
5814        mut self,
5815        new_value: &'a mut dyn common::Delegate,
5816    ) -> OrganizationApprovalRequestListCall<'a, C> {
5817        self._delegate = Some(new_value);
5818        self
5819    }
5820
5821    /// Set any additional parameter of the query string used in the request.
5822    /// It should be used to set parameters which are not yet available through their own
5823    /// setters.
5824    ///
5825    /// Please note that this method must not be used to set any of the known parameters
5826    /// which have their own setter method. If done anyway, the request will fail.
5827    ///
5828    /// # Additional Parameters
5829    ///
5830    /// * *$.xgafv* (query-string) - V1 error format.
5831    /// * *access_token* (query-string) - OAuth access token.
5832    /// * *alt* (query-string) - Data format for response.
5833    /// * *callback* (query-string) - JSONP
5834    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5835    /// * *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.
5836    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5837    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5838    /// * *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.
5839    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5840    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5841    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestListCall<'a, C>
5842    where
5843        T: AsRef<str>,
5844    {
5845        self._additional_params
5846            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5847        self
5848    }
5849
5850    /// Identifies the authorization scope for the method you are building.
5851    ///
5852    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5853    /// [`Scope::CloudPlatform`].
5854    ///
5855    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5856    /// tokens for more than one scope.
5857    ///
5858    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5859    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5860    /// sufficient, a read-write scope will do as well.
5861    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestListCall<'a, C>
5862    where
5863        St: AsRef<str>,
5864    {
5865        self._scopes.insert(String::from(scope.as_ref()));
5866        self
5867    }
5868    /// Identifies the authorization scope(s) for the method you are building.
5869    ///
5870    /// See [`Self::add_scope()`] for details.
5871    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestListCall<'a, C>
5872    where
5873        I: IntoIterator<Item = St>,
5874        St: AsRef<str>,
5875    {
5876        self._scopes
5877            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5878        self
5879    }
5880
5881    /// Removes all scopes, and no default scope will be used either.
5882    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5883    /// for details).
5884    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestListCall<'a, C> {
5885        self._scopes.clear();
5886        self
5887    }
5888}
5889
5890/// Deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the resource. Access Approval may remain active based on parent resource settings. To confirm the effective settings, call GetAccessApprovalSettings and verify effective setting is disabled.
5891///
5892/// A builder for the *deleteAccessApprovalSettings* method supported by a *organization* resource.
5893/// It is not used directly, but through a [`OrganizationMethods`] instance.
5894///
5895/// # Example
5896///
5897/// Instantiate a resource method builder
5898///
5899/// ```test_harness,no_run
5900/// # extern crate hyper;
5901/// # extern crate hyper_rustls;
5902/// # extern crate google_accessapproval1 as accessapproval1;
5903/// # async fn dox() {
5904/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5905///
5906/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5907/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5908/// #     .with_native_roots()
5909/// #     .unwrap()
5910/// #     .https_only()
5911/// #     .enable_http2()
5912/// #     .build();
5913///
5914/// # let executor = hyper_util::rt::TokioExecutor::new();
5915/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5916/// #     secret,
5917/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5918/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5919/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5920/// #     ),
5921/// # ).build().await.unwrap();
5922///
5923/// # let client = hyper_util::client::legacy::Client::builder(
5924/// #     hyper_util::rt::TokioExecutor::new()
5925/// # )
5926/// # .build(
5927/// #     hyper_rustls::HttpsConnectorBuilder::new()
5928/// #         .with_native_roots()
5929/// #         .unwrap()
5930/// #         .https_or_http()
5931/// #         .enable_http2()
5932/// #         .build()
5933/// # );
5934/// # let mut hub = AccessApproval::new(client, auth);
5935/// // You can configure optional parameters by calling the respective setters at will, and
5936/// // execute the final call using `doit()`.
5937/// // Values shown here are possibly random and not representative !
5938/// let result = hub.organizations().delete_access_approval_settings("name")
5939///              .doit().await;
5940/// # }
5941/// ```
5942pub struct OrganizationDeleteAccessApprovalSettingCall<'a, C>
5943where
5944    C: 'a,
5945{
5946    hub: &'a AccessApproval<C>,
5947    _name: String,
5948    _delegate: Option<&'a mut dyn common::Delegate>,
5949    _additional_params: HashMap<String, String>,
5950    _scopes: BTreeSet<String>,
5951}
5952
5953impl<'a, C> common::CallBuilder for OrganizationDeleteAccessApprovalSettingCall<'a, C> {}
5954
5955impl<'a, C> OrganizationDeleteAccessApprovalSettingCall<'a, C>
5956where
5957    C: common::Connector,
5958{
5959    /// Perform the operation you have build so far.
5960    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5961        use std::borrow::Cow;
5962        use std::io::{Read, Seek};
5963
5964        use common::{url::Params, ToParts};
5965        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5966
5967        let mut dd = common::DefaultDelegate;
5968        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5969        dlg.begin(common::MethodInfo {
5970            id: "accessapproval.organizations.deleteAccessApprovalSettings",
5971            http_method: hyper::Method::DELETE,
5972        });
5973
5974        for &field in ["alt", "name"].iter() {
5975            if self._additional_params.contains_key(field) {
5976                dlg.finished(false);
5977                return Err(common::Error::FieldClash(field));
5978            }
5979        }
5980
5981        let mut params = Params::with_capacity(3 + self._additional_params.len());
5982        params.push("name", self._name);
5983
5984        params.extend(self._additional_params.iter());
5985
5986        params.push("alt", "json");
5987        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5988        if self._scopes.is_empty() {
5989            self._scopes
5990                .insert(Scope::CloudPlatform.as_ref().to_string());
5991        }
5992
5993        #[allow(clippy::single_element_loop)]
5994        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5995            url = params.uri_replacement(url, param_name, find_this, true);
5996        }
5997        {
5998            let to_remove = ["name"];
5999            params.remove_params(&to_remove);
6000        }
6001
6002        let url = params.parse_with_url(&url);
6003
6004        loop {
6005            let token = match self
6006                .hub
6007                .auth
6008                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6009                .await
6010            {
6011                Ok(token) => token,
6012                Err(e) => match dlg.token(e) {
6013                    Ok(token) => token,
6014                    Err(e) => {
6015                        dlg.finished(false);
6016                        return Err(common::Error::MissingToken(e));
6017                    }
6018                },
6019            };
6020            let mut req_result = {
6021                let client = &self.hub.client;
6022                dlg.pre_request();
6023                let mut req_builder = hyper::Request::builder()
6024                    .method(hyper::Method::DELETE)
6025                    .uri(url.as_str())
6026                    .header(USER_AGENT, self.hub._user_agent.clone());
6027
6028                if let Some(token) = token.as_ref() {
6029                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6030                }
6031
6032                let request = req_builder
6033                    .header(CONTENT_LENGTH, 0_u64)
6034                    .body(common::to_body::<String>(None));
6035
6036                client.request(request.unwrap()).await
6037            };
6038
6039            match req_result {
6040                Err(err) => {
6041                    if let common::Retry::After(d) = dlg.http_error(&err) {
6042                        sleep(d).await;
6043                        continue;
6044                    }
6045                    dlg.finished(false);
6046                    return Err(common::Error::HttpError(err));
6047                }
6048                Ok(res) => {
6049                    let (mut parts, body) = res.into_parts();
6050                    let mut body = common::Body::new(body);
6051                    if !parts.status.is_success() {
6052                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6053                        let error = serde_json::from_str(&common::to_string(&bytes));
6054                        let response = common::to_response(parts, bytes.into());
6055
6056                        if let common::Retry::After(d) =
6057                            dlg.http_failure(&response, error.as_ref().ok())
6058                        {
6059                            sleep(d).await;
6060                            continue;
6061                        }
6062
6063                        dlg.finished(false);
6064
6065                        return Err(match error {
6066                            Ok(value) => common::Error::BadRequest(value),
6067                            _ => common::Error::Failure(response),
6068                        });
6069                    }
6070                    let response = {
6071                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6072                        let encoded = common::to_string(&bytes);
6073                        match serde_json::from_str(&encoded) {
6074                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6075                            Err(error) => {
6076                                dlg.response_json_decode_error(&encoded, &error);
6077                                return Err(common::Error::JsonDecodeError(
6078                                    encoded.to_string(),
6079                                    error,
6080                                ));
6081                            }
6082                        }
6083                    };
6084
6085                    dlg.finished(true);
6086                    return Ok(response);
6087                }
6088            }
6089        }
6090    }
6091
6092    /// Name of the AccessApprovalSettings to delete.
6093    ///
6094    /// Sets the *name* path property to the given value.
6095    ///
6096    /// Even though the property as already been set when instantiating this call,
6097    /// we provide this method for API completeness.
6098    pub fn name(mut self, new_value: &str) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
6099        self._name = new_value.to_string();
6100        self
6101    }
6102    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6103    /// while executing the actual API request.
6104    ///
6105    /// ````text
6106    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6107    /// ````
6108    ///
6109    /// Sets the *delegate* property to the given value.
6110    pub fn delegate(
6111        mut self,
6112        new_value: &'a mut dyn common::Delegate,
6113    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
6114        self._delegate = Some(new_value);
6115        self
6116    }
6117
6118    /// Set any additional parameter of the query string used in the request.
6119    /// It should be used to set parameters which are not yet available through their own
6120    /// setters.
6121    ///
6122    /// Please note that this method must not be used to set any of the known parameters
6123    /// which have their own setter method. If done anyway, the request will fail.
6124    ///
6125    /// # Additional Parameters
6126    ///
6127    /// * *$.xgafv* (query-string) - V1 error format.
6128    /// * *access_token* (query-string) - OAuth access token.
6129    /// * *alt* (query-string) - Data format for response.
6130    /// * *callback* (query-string) - JSONP
6131    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6132    /// * *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.
6133    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6134    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6135    /// * *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.
6136    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6137    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6138    pub fn param<T>(
6139        mut self,
6140        name: T,
6141        value: T,
6142    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C>
6143    where
6144        T: AsRef<str>,
6145    {
6146        self._additional_params
6147            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6148        self
6149    }
6150
6151    /// Identifies the authorization scope for the method you are building.
6152    ///
6153    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6154    /// [`Scope::CloudPlatform`].
6155    ///
6156    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6157    /// tokens for more than one scope.
6158    ///
6159    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6160    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6161    /// sufficient, a read-write scope will do as well.
6162    pub fn add_scope<St>(mut self, scope: St) -> OrganizationDeleteAccessApprovalSettingCall<'a, C>
6163    where
6164        St: AsRef<str>,
6165    {
6166        self._scopes.insert(String::from(scope.as_ref()));
6167        self
6168    }
6169    /// Identifies the authorization scope(s) for the method you are building.
6170    ///
6171    /// See [`Self::add_scope()`] for details.
6172    pub fn add_scopes<I, St>(
6173        mut self,
6174        scopes: I,
6175    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C>
6176    where
6177        I: IntoIterator<Item = St>,
6178        St: AsRef<str>,
6179    {
6180        self._scopes
6181            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6182        self
6183    }
6184
6185    /// Removes all scopes, and no default scope will be used either.
6186    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6187    /// for details).
6188    pub fn clear_scopes(mut self) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
6189        self._scopes.clear();
6190        self
6191    }
6192}
6193
6194/// Gets the Access Approval settings associated with a project, folder, or organization.
6195///
6196/// A builder for the *getAccessApprovalSettings* method supported by a *organization* resource.
6197/// It is not used directly, but through a [`OrganizationMethods`] instance.
6198///
6199/// # Example
6200///
6201/// Instantiate a resource method builder
6202///
6203/// ```test_harness,no_run
6204/// # extern crate hyper;
6205/// # extern crate hyper_rustls;
6206/// # extern crate google_accessapproval1 as accessapproval1;
6207/// # async fn dox() {
6208/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6209///
6210/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6211/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6212/// #     .with_native_roots()
6213/// #     .unwrap()
6214/// #     .https_only()
6215/// #     .enable_http2()
6216/// #     .build();
6217///
6218/// # let executor = hyper_util::rt::TokioExecutor::new();
6219/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6220/// #     secret,
6221/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6222/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6223/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6224/// #     ),
6225/// # ).build().await.unwrap();
6226///
6227/// # let client = hyper_util::client::legacy::Client::builder(
6228/// #     hyper_util::rt::TokioExecutor::new()
6229/// # )
6230/// # .build(
6231/// #     hyper_rustls::HttpsConnectorBuilder::new()
6232/// #         .with_native_roots()
6233/// #         .unwrap()
6234/// #         .https_or_http()
6235/// #         .enable_http2()
6236/// #         .build()
6237/// # );
6238/// # let mut hub = AccessApproval::new(client, auth);
6239/// // You can configure optional parameters by calling the respective setters at will, and
6240/// // execute the final call using `doit()`.
6241/// // Values shown here are possibly random and not representative !
6242/// let result = hub.organizations().get_access_approval_settings("name")
6243///              .doit().await;
6244/// # }
6245/// ```
6246pub struct OrganizationGetAccessApprovalSettingCall<'a, C>
6247where
6248    C: 'a,
6249{
6250    hub: &'a AccessApproval<C>,
6251    _name: String,
6252    _delegate: Option<&'a mut dyn common::Delegate>,
6253    _additional_params: HashMap<String, String>,
6254    _scopes: BTreeSet<String>,
6255}
6256
6257impl<'a, C> common::CallBuilder for OrganizationGetAccessApprovalSettingCall<'a, C> {}
6258
6259impl<'a, C> OrganizationGetAccessApprovalSettingCall<'a, C>
6260where
6261    C: common::Connector,
6262{
6263    /// Perform the operation you have build so far.
6264    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
6265        use std::borrow::Cow;
6266        use std::io::{Read, Seek};
6267
6268        use common::{url::Params, ToParts};
6269        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6270
6271        let mut dd = common::DefaultDelegate;
6272        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6273        dlg.begin(common::MethodInfo {
6274            id: "accessapproval.organizations.getAccessApprovalSettings",
6275            http_method: hyper::Method::GET,
6276        });
6277
6278        for &field in ["alt", "name"].iter() {
6279            if self._additional_params.contains_key(field) {
6280                dlg.finished(false);
6281                return Err(common::Error::FieldClash(field));
6282            }
6283        }
6284
6285        let mut params = Params::with_capacity(3 + self._additional_params.len());
6286        params.push("name", self._name);
6287
6288        params.extend(self._additional_params.iter());
6289
6290        params.push("alt", "json");
6291        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6292        if self._scopes.is_empty() {
6293            self._scopes
6294                .insert(Scope::CloudPlatform.as_ref().to_string());
6295        }
6296
6297        #[allow(clippy::single_element_loop)]
6298        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6299            url = params.uri_replacement(url, param_name, find_this, true);
6300        }
6301        {
6302            let to_remove = ["name"];
6303            params.remove_params(&to_remove);
6304        }
6305
6306        let url = params.parse_with_url(&url);
6307
6308        loop {
6309            let token = match self
6310                .hub
6311                .auth
6312                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6313                .await
6314            {
6315                Ok(token) => token,
6316                Err(e) => match dlg.token(e) {
6317                    Ok(token) => token,
6318                    Err(e) => {
6319                        dlg.finished(false);
6320                        return Err(common::Error::MissingToken(e));
6321                    }
6322                },
6323            };
6324            let mut req_result = {
6325                let client = &self.hub.client;
6326                dlg.pre_request();
6327                let mut req_builder = hyper::Request::builder()
6328                    .method(hyper::Method::GET)
6329                    .uri(url.as_str())
6330                    .header(USER_AGENT, self.hub._user_agent.clone());
6331
6332                if let Some(token) = token.as_ref() {
6333                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6334                }
6335
6336                let request = req_builder
6337                    .header(CONTENT_LENGTH, 0_u64)
6338                    .body(common::to_body::<String>(None));
6339
6340                client.request(request.unwrap()).await
6341            };
6342
6343            match req_result {
6344                Err(err) => {
6345                    if let common::Retry::After(d) = dlg.http_error(&err) {
6346                        sleep(d).await;
6347                        continue;
6348                    }
6349                    dlg.finished(false);
6350                    return Err(common::Error::HttpError(err));
6351                }
6352                Ok(res) => {
6353                    let (mut parts, body) = res.into_parts();
6354                    let mut body = common::Body::new(body);
6355                    if !parts.status.is_success() {
6356                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6357                        let error = serde_json::from_str(&common::to_string(&bytes));
6358                        let response = common::to_response(parts, bytes.into());
6359
6360                        if let common::Retry::After(d) =
6361                            dlg.http_failure(&response, error.as_ref().ok())
6362                        {
6363                            sleep(d).await;
6364                            continue;
6365                        }
6366
6367                        dlg.finished(false);
6368
6369                        return Err(match error {
6370                            Ok(value) => common::Error::BadRequest(value),
6371                            _ => common::Error::Failure(response),
6372                        });
6373                    }
6374                    let response = {
6375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6376                        let encoded = common::to_string(&bytes);
6377                        match serde_json::from_str(&encoded) {
6378                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6379                            Err(error) => {
6380                                dlg.response_json_decode_error(&encoded, &error);
6381                                return Err(common::Error::JsonDecodeError(
6382                                    encoded.to_string(),
6383                                    error,
6384                                ));
6385                            }
6386                        }
6387                    };
6388
6389                    dlg.finished(true);
6390                    return Ok(response);
6391                }
6392            }
6393        }
6394    }
6395
6396    /// The name of the AccessApprovalSettings to retrieve. Format: "{projects|folders|organizations}/{id}/accessApprovalSettings"
6397    ///
6398    /// Sets the *name* path property to the given value.
6399    ///
6400    /// Even though the property as already been set when instantiating this call,
6401    /// we provide this method for API completeness.
6402    pub fn name(mut self, new_value: &str) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
6403        self._name = new_value.to_string();
6404        self
6405    }
6406    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6407    /// while executing the actual API request.
6408    ///
6409    /// ````text
6410    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6411    /// ````
6412    ///
6413    /// Sets the *delegate* property to the given value.
6414    pub fn delegate(
6415        mut self,
6416        new_value: &'a mut dyn common::Delegate,
6417    ) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
6418        self._delegate = Some(new_value);
6419        self
6420    }
6421
6422    /// Set any additional parameter of the query string used in the request.
6423    /// It should be used to set parameters which are not yet available through their own
6424    /// setters.
6425    ///
6426    /// Please note that this method must not be used to set any of the known parameters
6427    /// which have their own setter method. If done anyway, the request will fail.
6428    ///
6429    /// # Additional Parameters
6430    ///
6431    /// * *$.xgafv* (query-string) - V1 error format.
6432    /// * *access_token* (query-string) - OAuth access token.
6433    /// * *alt* (query-string) - Data format for response.
6434    /// * *callback* (query-string) - JSONP
6435    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6436    /// * *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.
6437    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6438    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6439    /// * *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.
6440    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6441    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6442    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetAccessApprovalSettingCall<'a, C>
6443    where
6444        T: AsRef<str>,
6445    {
6446        self._additional_params
6447            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6448        self
6449    }
6450
6451    /// Identifies the authorization scope for the method you are building.
6452    ///
6453    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6454    /// [`Scope::CloudPlatform`].
6455    ///
6456    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6457    /// tokens for more than one scope.
6458    ///
6459    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6460    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6461    /// sufficient, a read-write scope will do as well.
6462    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetAccessApprovalSettingCall<'a, C>
6463    where
6464        St: AsRef<str>,
6465    {
6466        self._scopes.insert(String::from(scope.as_ref()));
6467        self
6468    }
6469    /// Identifies the authorization scope(s) for the method you are building.
6470    ///
6471    /// See [`Self::add_scope()`] for details.
6472    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetAccessApprovalSettingCall<'a, C>
6473    where
6474        I: IntoIterator<Item = St>,
6475        St: AsRef<str>,
6476    {
6477        self._scopes
6478            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6479        self
6480    }
6481
6482    /// Removes all scopes, and no default scope will be used either.
6483    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6484    /// for details).
6485    pub fn clear_scopes(mut self) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
6486        self._scopes.clear();
6487        self
6488    }
6489}
6490
6491/// Retrieves the service account that is used by Access Approval to access KMS keys for signing approved approval requests.
6492///
6493/// A builder for the *getServiceAccount* method supported by a *organization* resource.
6494/// It is not used directly, but through a [`OrganizationMethods`] instance.
6495///
6496/// # Example
6497///
6498/// Instantiate a resource method builder
6499///
6500/// ```test_harness,no_run
6501/// # extern crate hyper;
6502/// # extern crate hyper_rustls;
6503/// # extern crate google_accessapproval1 as accessapproval1;
6504/// # async fn dox() {
6505/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6506///
6507/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6508/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6509/// #     .with_native_roots()
6510/// #     .unwrap()
6511/// #     .https_only()
6512/// #     .enable_http2()
6513/// #     .build();
6514///
6515/// # let executor = hyper_util::rt::TokioExecutor::new();
6516/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6517/// #     secret,
6518/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6519/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6520/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6521/// #     ),
6522/// # ).build().await.unwrap();
6523///
6524/// # let client = hyper_util::client::legacy::Client::builder(
6525/// #     hyper_util::rt::TokioExecutor::new()
6526/// # )
6527/// # .build(
6528/// #     hyper_rustls::HttpsConnectorBuilder::new()
6529/// #         .with_native_roots()
6530/// #         .unwrap()
6531/// #         .https_or_http()
6532/// #         .enable_http2()
6533/// #         .build()
6534/// # );
6535/// # let mut hub = AccessApproval::new(client, auth);
6536/// // You can configure optional parameters by calling the respective setters at will, and
6537/// // execute the final call using `doit()`.
6538/// // Values shown here are possibly random and not representative !
6539/// let result = hub.organizations().get_service_account("name")
6540///              .doit().await;
6541/// # }
6542/// ```
6543pub struct OrganizationGetServiceAccountCall<'a, C>
6544where
6545    C: 'a,
6546{
6547    hub: &'a AccessApproval<C>,
6548    _name: String,
6549    _delegate: Option<&'a mut dyn common::Delegate>,
6550    _additional_params: HashMap<String, String>,
6551    _scopes: BTreeSet<String>,
6552}
6553
6554impl<'a, C> common::CallBuilder for OrganizationGetServiceAccountCall<'a, C> {}
6555
6556impl<'a, C> OrganizationGetServiceAccountCall<'a, C>
6557where
6558    C: common::Connector,
6559{
6560    /// Perform the operation you have build so far.
6561    pub async fn doit(
6562        mut self,
6563    ) -> common::Result<(common::Response, AccessApprovalServiceAccount)> {
6564        use std::borrow::Cow;
6565        use std::io::{Read, Seek};
6566
6567        use common::{url::Params, ToParts};
6568        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6569
6570        let mut dd = common::DefaultDelegate;
6571        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6572        dlg.begin(common::MethodInfo {
6573            id: "accessapproval.organizations.getServiceAccount",
6574            http_method: hyper::Method::GET,
6575        });
6576
6577        for &field in ["alt", "name"].iter() {
6578            if self._additional_params.contains_key(field) {
6579                dlg.finished(false);
6580                return Err(common::Error::FieldClash(field));
6581            }
6582        }
6583
6584        let mut params = Params::with_capacity(3 + self._additional_params.len());
6585        params.push("name", self._name);
6586
6587        params.extend(self._additional_params.iter());
6588
6589        params.push("alt", "json");
6590        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6591        if self._scopes.is_empty() {
6592            self._scopes
6593                .insert(Scope::CloudPlatform.as_ref().to_string());
6594        }
6595
6596        #[allow(clippy::single_element_loop)]
6597        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6598            url = params.uri_replacement(url, param_name, find_this, true);
6599        }
6600        {
6601            let to_remove = ["name"];
6602            params.remove_params(&to_remove);
6603        }
6604
6605        let url = params.parse_with_url(&url);
6606
6607        loop {
6608            let token = match self
6609                .hub
6610                .auth
6611                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6612                .await
6613            {
6614                Ok(token) => token,
6615                Err(e) => match dlg.token(e) {
6616                    Ok(token) => token,
6617                    Err(e) => {
6618                        dlg.finished(false);
6619                        return Err(common::Error::MissingToken(e));
6620                    }
6621                },
6622            };
6623            let mut req_result = {
6624                let client = &self.hub.client;
6625                dlg.pre_request();
6626                let mut req_builder = hyper::Request::builder()
6627                    .method(hyper::Method::GET)
6628                    .uri(url.as_str())
6629                    .header(USER_AGENT, self.hub._user_agent.clone());
6630
6631                if let Some(token) = token.as_ref() {
6632                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6633                }
6634
6635                let request = req_builder
6636                    .header(CONTENT_LENGTH, 0_u64)
6637                    .body(common::to_body::<String>(None));
6638
6639                client.request(request.unwrap()).await
6640            };
6641
6642            match req_result {
6643                Err(err) => {
6644                    if let common::Retry::After(d) = dlg.http_error(&err) {
6645                        sleep(d).await;
6646                        continue;
6647                    }
6648                    dlg.finished(false);
6649                    return Err(common::Error::HttpError(err));
6650                }
6651                Ok(res) => {
6652                    let (mut parts, body) = res.into_parts();
6653                    let mut body = common::Body::new(body);
6654                    if !parts.status.is_success() {
6655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6656                        let error = serde_json::from_str(&common::to_string(&bytes));
6657                        let response = common::to_response(parts, bytes.into());
6658
6659                        if let common::Retry::After(d) =
6660                            dlg.http_failure(&response, error.as_ref().ok())
6661                        {
6662                            sleep(d).await;
6663                            continue;
6664                        }
6665
6666                        dlg.finished(false);
6667
6668                        return Err(match error {
6669                            Ok(value) => common::Error::BadRequest(value),
6670                            _ => common::Error::Failure(response),
6671                        });
6672                    }
6673                    let response = {
6674                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6675                        let encoded = common::to_string(&bytes);
6676                        match serde_json::from_str(&encoded) {
6677                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6678                            Err(error) => {
6679                                dlg.response_json_decode_error(&encoded, &error);
6680                                return Err(common::Error::JsonDecodeError(
6681                                    encoded.to_string(),
6682                                    error,
6683                                ));
6684                            }
6685                        }
6686                    };
6687
6688                    dlg.finished(true);
6689                    return Ok(response);
6690                }
6691            }
6692        }
6693    }
6694
6695    /// Name of the AccessApprovalServiceAccount to retrieve.
6696    ///
6697    /// Sets the *name* path property to the given value.
6698    ///
6699    /// Even though the property as already been set when instantiating this call,
6700    /// we provide this method for API completeness.
6701    pub fn name(mut self, new_value: &str) -> OrganizationGetServiceAccountCall<'a, C> {
6702        self._name = new_value.to_string();
6703        self
6704    }
6705    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6706    /// while executing the actual API request.
6707    ///
6708    /// ````text
6709    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6710    /// ````
6711    ///
6712    /// Sets the *delegate* property to the given value.
6713    pub fn delegate(
6714        mut self,
6715        new_value: &'a mut dyn common::Delegate,
6716    ) -> OrganizationGetServiceAccountCall<'a, C> {
6717        self._delegate = Some(new_value);
6718        self
6719    }
6720
6721    /// Set any additional parameter of the query string used in the request.
6722    /// It should be used to set parameters which are not yet available through their own
6723    /// setters.
6724    ///
6725    /// Please note that this method must not be used to set any of the known parameters
6726    /// which have their own setter method. If done anyway, the request will fail.
6727    ///
6728    /// # Additional Parameters
6729    ///
6730    /// * *$.xgafv* (query-string) - V1 error format.
6731    /// * *access_token* (query-string) - OAuth access token.
6732    /// * *alt* (query-string) - Data format for response.
6733    /// * *callback* (query-string) - JSONP
6734    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6735    /// * *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.
6736    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6737    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6738    /// * *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.
6739    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6740    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6741    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetServiceAccountCall<'a, C>
6742    where
6743        T: AsRef<str>,
6744    {
6745        self._additional_params
6746            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6747        self
6748    }
6749
6750    /// Identifies the authorization scope for the method you are building.
6751    ///
6752    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6753    /// [`Scope::CloudPlatform`].
6754    ///
6755    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6756    /// tokens for more than one scope.
6757    ///
6758    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6759    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6760    /// sufficient, a read-write scope will do as well.
6761    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetServiceAccountCall<'a, C>
6762    where
6763        St: AsRef<str>,
6764    {
6765        self._scopes.insert(String::from(scope.as_ref()));
6766        self
6767    }
6768    /// Identifies the authorization scope(s) for the method you are building.
6769    ///
6770    /// See [`Self::add_scope()`] for details.
6771    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetServiceAccountCall<'a, C>
6772    where
6773        I: IntoIterator<Item = St>,
6774        St: AsRef<str>,
6775    {
6776        self._scopes
6777            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6778        self
6779    }
6780
6781    /// Removes all scopes, and no default scope will be used either.
6782    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6783    /// for details).
6784    pub fn clear_scopes(mut self) -> OrganizationGetServiceAccountCall<'a, C> {
6785        self._scopes.clear();
6786        self
6787    }
6788}
6789
6790/// Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.
6791///
6792/// A builder for the *updateAccessApprovalSettings* method supported by a *organization* resource.
6793/// It is not used directly, but through a [`OrganizationMethods`] instance.
6794///
6795/// # Example
6796///
6797/// Instantiate a resource method builder
6798///
6799/// ```test_harness,no_run
6800/// # extern crate hyper;
6801/// # extern crate hyper_rustls;
6802/// # extern crate google_accessapproval1 as accessapproval1;
6803/// use accessapproval1::api::AccessApprovalSettings;
6804/// # async fn dox() {
6805/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6806///
6807/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6808/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6809/// #     .with_native_roots()
6810/// #     .unwrap()
6811/// #     .https_only()
6812/// #     .enable_http2()
6813/// #     .build();
6814///
6815/// # let executor = hyper_util::rt::TokioExecutor::new();
6816/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6817/// #     secret,
6818/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6819/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6820/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6821/// #     ),
6822/// # ).build().await.unwrap();
6823///
6824/// # let client = hyper_util::client::legacy::Client::builder(
6825/// #     hyper_util::rt::TokioExecutor::new()
6826/// # )
6827/// # .build(
6828/// #     hyper_rustls::HttpsConnectorBuilder::new()
6829/// #         .with_native_roots()
6830/// #         .unwrap()
6831/// #         .https_or_http()
6832/// #         .enable_http2()
6833/// #         .build()
6834/// # );
6835/// # let mut hub = AccessApproval::new(client, auth);
6836/// // As the method needs a request, you would usually fill it with the desired information
6837/// // into the respective structure. Some of the parts shown here might not be applicable !
6838/// // Values shown here are possibly random and not representative !
6839/// let mut req = AccessApprovalSettings::default();
6840///
6841/// // You can configure optional parameters by calling the respective setters at will, and
6842/// // execute the final call using `doit()`.
6843/// // Values shown here are possibly random and not representative !
6844/// let result = hub.organizations().update_access_approval_settings(req, "name")
6845///              .update_mask(FieldMask::new::<&str>(&[]))
6846///              .doit().await;
6847/// # }
6848/// ```
6849pub struct OrganizationUpdateAccessApprovalSettingCall<'a, C>
6850where
6851    C: 'a,
6852{
6853    hub: &'a AccessApproval<C>,
6854    _request: AccessApprovalSettings,
6855    _name: String,
6856    _update_mask: Option<common::FieldMask>,
6857    _delegate: Option<&'a mut dyn common::Delegate>,
6858    _additional_params: HashMap<String, String>,
6859    _scopes: BTreeSet<String>,
6860}
6861
6862impl<'a, C> common::CallBuilder for OrganizationUpdateAccessApprovalSettingCall<'a, C> {}
6863
6864impl<'a, C> OrganizationUpdateAccessApprovalSettingCall<'a, C>
6865where
6866    C: common::Connector,
6867{
6868    /// Perform the operation you have build so far.
6869    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
6870        use std::borrow::Cow;
6871        use std::io::{Read, Seek};
6872
6873        use common::{url::Params, ToParts};
6874        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6875
6876        let mut dd = common::DefaultDelegate;
6877        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6878        dlg.begin(common::MethodInfo {
6879            id: "accessapproval.organizations.updateAccessApprovalSettings",
6880            http_method: hyper::Method::PATCH,
6881        });
6882
6883        for &field in ["alt", "name", "updateMask"].iter() {
6884            if self._additional_params.contains_key(field) {
6885                dlg.finished(false);
6886                return Err(common::Error::FieldClash(field));
6887            }
6888        }
6889
6890        let mut params = Params::with_capacity(5 + self._additional_params.len());
6891        params.push("name", self._name);
6892        if let Some(value) = self._update_mask.as_ref() {
6893            params.push("updateMask", value.to_string());
6894        }
6895
6896        params.extend(self._additional_params.iter());
6897
6898        params.push("alt", "json");
6899        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6900        if self._scopes.is_empty() {
6901            self._scopes
6902                .insert(Scope::CloudPlatform.as_ref().to_string());
6903        }
6904
6905        #[allow(clippy::single_element_loop)]
6906        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6907            url = params.uri_replacement(url, param_name, find_this, true);
6908        }
6909        {
6910            let to_remove = ["name"];
6911            params.remove_params(&to_remove);
6912        }
6913
6914        let url = params.parse_with_url(&url);
6915
6916        let mut json_mime_type = mime::APPLICATION_JSON;
6917        let mut request_value_reader = {
6918            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6919            common::remove_json_null_values(&mut value);
6920            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6921            serde_json::to_writer(&mut dst, &value).unwrap();
6922            dst
6923        };
6924        let request_size = request_value_reader
6925            .seek(std::io::SeekFrom::End(0))
6926            .unwrap();
6927        request_value_reader
6928            .seek(std::io::SeekFrom::Start(0))
6929            .unwrap();
6930
6931        loop {
6932            let token = match self
6933                .hub
6934                .auth
6935                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6936                .await
6937            {
6938                Ok(token) => token,
6939                Err(e) => match dlg.token(e) {
6940                    Ok(token) => token,
6941                    Err(e) => {
6942                        dlg.finished(false);
6943                        return Err(common::Error::MissingToken(e));
6944                    }
6945                },
6946            };
6947            request_value_reader
6948                .seek(std::io::SeekFrom::Start(0))
6949                .unwrap();
6950            let mut req_result = {
6951                let client = &self.hub.client;
6952                dlg.pre_request();
6953                let mut req_builder = hyper::Request::builder()
6954                    .method(hyper::Method::PATCH)
6955                    .uri(url.as_str())
6956                    .header(USER_AGENT, self.hub._user_agent.clone());
6957
6958                if let Some(token) = token.as_ref() {
6959                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6960                }
6961
6962                let request = req_builder
6963                    .header(CONTENT_TYPE, json_mime_type.to_string())
6964                    .header(CONTENT_LENGTH, request_size as u64)
6965                    .body(common::to_body(
6966                        request_value_reader.get_ref().clone().into(),
6967                    ));
6968
6969                client.request(request.unwrap()).await
6970            };
6971
6972            match req_result {
6973                Err(err) => {
6974                    if let common::Retry::After(d) = dlg.http_error(&err) {
6975                        sleep(d).await;
6976                        continue;
6977                    }
6978                    dlg.finished(false);
6979                    return Err(common::Error::HttpError(err));
6980                }
6981                Ok(res) => {
6982                    let (mut parts, body) = res.into_parts();
6983                    let mut body = common::Body::new(body);
6984                    if !parts.status.is_success() {
6985                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6986                        let error = serde_json::from_str(&common::to_string(&bytes));
6987                        let response = common::to_response(parts, bytes.into());
6988
6989                        if let common::Retry::After(d) =
6990                            dlg.http_failure(&response, error.as_ref().ok())
6991                        {
6992                            sleep(d).await;
6993                            continue;
6994                        }
6995
6996                        dlg.finished(false);
6997
6998                        return Err(match error {
6999                            Ok(value) => common::Error::BadRequest(value),
7000                            _ => common::Error::Failure(response),
7001                        });
7002                    }
7003                    let response = {
7004                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7005                        let encoded = common::to_string(&bytes);
7006                        match serde_json::from_str(&encoded) {
7007                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7008                            Err(error) => {
7009                                dlg.response_json_decode_error(&encoded, &error);
7010                                return Err(common::Error::JsonDecodeError(
7011                                    encoded.to_string(),
7012                                    error,
7013                                ));
7014                            }
7015                        }
7016                    };
7017
7018                    dlg.finished(true);
7019                    return Ok(response);
7020                }
7021            }
7022        }
7023    }
7024
7025    ///
7026    /// Sets the *request* property to the given value.
7027    ///
7028    /// Even though the property as already been set when instantiating this call,
7029    /// we provide this method for API completeness.
7030    pub fn request(
7031        mut self,
7032        new_value: AccessApprovalSettings,
7033    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
7034        self._request = new_value;
7035        self
7036    }
7037    /// The resource name of the settings. Format is one of: * "projects/{project}/accessApprovalSettings" * "folders/{folder}/accessApprovalSettings" * "organizations/{organization}/accessApprovalSettings"
7038    ///
7039    /// Sets the *name* path property to the given value.
7040    ///
7041    /// Even though the property as already been set when instantiating this call,
7042    /// we provide this method for API completeness.
7043    pub fn name(mut self, new_value: &str) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
7044        self._name = new_value.to_string();
7045        self
7046    }
7047    /// The update mask applies to the settings. Only the top level fields of AccessApprovalSettings (notification_emails & enrolled_services) are supported. For each field, if it is included, the currently stored value will be entirely overwritten with the value of the field passed in this request. For the `FieldMask` definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask If this field is left unset, only the notification_emails field will be updated.
7048    ///
7049    /// Sets the *update mask* query property to the given value.
7050    pub fn update_mask(
7051        mut self,
7052        new_value: common::FieldMask,
7053    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
7054        self._update_mask = Some(new_value);
7055        self
7056    }
7057    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7058    /// while executing the actual API request.
7059    ///
7060    /// ````text
7061    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7062    /// ````
7063    ///
7064    /// Sets the *delegate* property to the given value.
7065    pub fn delegate(
7066        mut self,
7067        new_value: &'a mut dyn common::Delegate,
7068    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
7069        self._delegate = Some(new_value);
7070        self
7071    }
7072
7073    /// Set any additional parameter of the query string used in the request.
7074    /// It should be used to set parameters which are not yet available through their own
7075    /// setters.
7076    ///
7077    /// Please note that this method must not be used to set any of the known parameters
7078    /// which have their own setter method. If done anyway, the request will fail.
7079    ///
7080    /// # Additional Parameters
7081    ///
7082    /// * *$.xgafv* (query-string) - V1 error format.
7083    /// * *access_token* (query-string) - OAuth access token.
7084    /// * *alt* (query-string) - Data format for response.
7085    /// * *callback* (query-string) - JSONP
7086    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7087    /// * *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.
7088    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7089    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7090    /// * *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.
7091    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7092    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7093    pub fn param<T>(
7094        mut self,
7095        name: T,
7096        value: T,
7097    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C>
7098    where
7099        T: AsRef<str>,
7100    {
7101        self._additional_params
7102            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7103        self
7104    }
7105
7106    /// Identifies the authorization scope for the method you are building.
7107    ///
7108    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7109    /// [`Scope::CloudPlatform`].
7110    ///
7111    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7112    /// tokens for more than one scope.
7113    ///
7114    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7115    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7116    /// sufficient, a read-write scope will do as well.
7117    pub fn add_scope<St>(mut self, scope: St) -> OrganizationUpdateAccessApprovalSettingCall<'a, C>
7118    where
7119        St: AsRef<str>,
7120    {
7121        self._scopes.insert(String::from(scope.as_ref()));
7122        self
7123    }
7124    /// Identifies the authorization scope(s) for the method you are building.
7125    ///
7126    /// See [`Self::add_scope()`] for details.
7127    pub fn add_scopes<I, St>(
7128        mut self,
7129        scopes: I,
7130    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C>
7131    where
7132        I: IntoIterator<Item = St>,
7133        St: AsRef<str>,
7134    {
7135        self._scopes
7136            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7137        self
7138    }
7139
7140    /// Removes all scopes, and no default scope will be used either.
7141    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7142    /// for details).
7143    pub fn clear_scopes(mut self) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
7144        self._scopes.clear();
7145        self
7146    }
7147}
7148
7149/// Approves a request and returns the updated ApprovalRequest. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
7150///
7151/// A builder for the *approvalRequests.approve* method supported by a *project* resource.
7152/// It is not used directly, but through a [`ProjectMethods`] instance.
7153///
7154/// # Example
7155///
7156/// Instantiate a resource method builder
7157///
7158/// ```test_harness,no_run
7159/// # extern crate hyper;
7160/// # extern crate hyper_rustls;
7161/// # extern crate google_accessapproval1 as accessapproval1;
7162/// use accessapproval1::api::ApproveApprovalRequestMessage;
7163/// # async fn dox() {
7164/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7165///
7166/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7167/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7168/// #     .with_native_roots()
7169/// #     .unwrap()
7170/// #     .https_only()
7171/// #     .enable_http2()
7172/// #     .build();
7173///
7174/// # let executor = hyper_util::rt::TokioExecutor::new();
7175/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7176/// #     secret,
7177/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7178/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7179/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7180/// #     ),
7181/// # ).build().await.unwrap();
7182///
7183/// # let client = hyper_util::client::legacy::Client::builder(
7184/// #     hyper_util::rt::TokioExecutor::new()
7185/// # )
7186/// # .build(
7187/// #     hyper_rustls::HttpsConnectorBuilder::new()
7188/// #         .with_native_roots()
7189/// #         .unwrap()
7190/// #         .https_or_http()
7191/// #         .enable_http2()
7192/// #         .build()
7193/// # );
7194/// # let mut hub = AccessApproval::new(client, auth);
7195/// // As the method needs a request, you would usually fill it with the desired information
7196/// // into the respective structure. Some of the parts shown here might not be applicable !
7197/// // Values shown here are possibly random and not representative !
7198/// let mut req = ApproveApprovalRequestMessage::default();
7199///
7200/// // You can configure optional parameters by calling the respective setters at will, and
7201/// // execute the final call using `doit()`.
7202/// // Values shown here are possibly random and not representative !
7203/// let result = hub.projects().approval_requests_approve(req, "name")
7204///              .doit().await;
7205/// # }
7206/// ```
7207pub struct ProjectApprovalRequestApproveCall<'a, C>
7208where
7209    C: 'a,
7210{
7211    hub: &'a AccessApproval<C>,
7212    _request: ApproveApprovalRequestMessage,
7213    _name: String,
7214    _delegate: Option<&'a mut dyn common::Delegate>,
7215    _additional_params: HashMap<String, String>,
7216    _scopes: BTreeSet<String>,
7217}
7218
7219impl<'a, C> common::CallBuilder for ProjectApprovalRequestApproveCall<'a, C> {}
7220
7221impl<'a, C> ProjectApprovalRequestApproveCall<'a, C>
7222where
7223    C: common::Connector,
7224{
7225    /// Perform the operation you have build so far.
7226    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
7227        use std::borrow::Cow;
7228        use std::io::{Read, Seek};
7229
7230        use common::{url::Params, ToParts};
7231        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7232
7233        let mut dd = common::DefaultDelegate;
7234        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7235        dlg.begin(common::MethodInfo {
7236            id: "accessapproval.projects.approvalRequests.approve",
7237            http_method: hyper::Method::POST,
7238        });
7239
7240        for &field in ["alt", "name"].iter() {
7241            if self._additional_params.contains_key(field) {
7242                dlg.finished(false);
7243                return Err(common::Error::FieldClash(field));
7244            }
7245        }
7246
7247        let mut params = Params::with_capacity(4 + self._additional_params.len());
7248        params.push("name", self._name);
7249
7250        params.extend(self._additional_params.iter());
7251
7252        params.push("alt", "json");
7253        let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
7254        if self._scopes.is_empty() {
7255            self._scopes
7256                .insert(Scope::CloudPlatform.as_ref().to_string());
7257        }
7258
7259        #[allow(clippy::single_element_loop)]
7260        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7261            url = params.uri_replacement(url, param_name, find_this, true);
7262        }
7263        {
7264            let to_remove = ["name"];
7265            params.remove_params(&to_remove);
7266        }
7267
7268        let url = params.parse_with_url(&url);
7269
7270        let mut json_mime_type = mime::APPLICATION_JSON;
7271        let mut request_value_reader = {
7272            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7273            common::remove_json_null_values(&mut value);
7274            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7275            serde_json::to_writer(&mut dst, &value).unwrap();
7276            dst
7277        };
7278        let request_size = request_value_reader
7279            .seek(std::io::SeekFrom::End(0))
7280            .unwrap();
7281        request_value_reader
7282            .seek(std::io::SeekFrom::Start(0))
7283            .unwrap();
7284
7285        loop {
7286            let token = match self
7287                .hub
7288                .auth
7289                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7290                .await
7291            {
7292                Ok(token) => token,
7293                Err(e) => match dlg.token(e) {
7294                    Ok(token) => token,
7295                    Err(e) => {
7296                        dlg.finished(false);
7297                        return Err(common::Error::MissingToken(e));
7298                    }
7299                },
7300            };
7301            request_value_reader
7302                .seek(std::io::SeekFrom::Start(0))
7303                .unwrap();
7304            let mut req_result = {
7305                let client = &self.hub.client;
7306                dlg.pre_request();
7307                let mut req_builder = hyper::Request::builder()
7308                    .method(hyper::Method::POST)
7309                    .uri(url.as_str())
7310                    .header(USER_AGENT, self.hub._user_agent.clone());
7311
7312                if let Some(token) = token.as_ref() {
7313                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7314                }
7315
7316                let request = req_builder
7317                    .header(CONTENT_TYPE, json_mime_type.to_string())
7318                    .header(CONTENT_LENGTH, request_size as u64)
7319                    .body(common::to_body(
7320                        request_value_reader.get_ref().clone().into(),
7321                    ));
7322
7323                client.request(request.unwrap()).await
7324            };
7325
7326            match req_result {
7327                Err(err) => {
7328                    if let common::Retry::After(d) = dlg.http_error(&err) {
7329                        sleep(d).await;
7330                        continue;
7331                    }
7332                    dlg.finished(false);
7333                    return Err(common::Error::HttpError(err));
7334                }
7335                Ok(res) => {
7336                    let (mut parts, body) = res.into_parts();
7337                    let mut body = common::Body::new(body);
7338                    if !parts.status.is_success() {
7339                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7340                        let error = serde_json::from_str(&common::to_string(&bytes));
7341                        let response = common::to_response(parts, bytes.into());
7342
7343                        if let common::Retry::After(d) =
7344                            dlg.http_failure(&response, error.as_ref().ok())
7345                        {
7346                            sleep(d).await;
7347                            continue;
7348                        }
7349
7350                        dlg.finished(false);
7351
7352                        return Err(match error {
7353                            Ok(value) => common::Error::BadRequest(value),
7354                            _ => common::Error::Failure(response),
7355                        });
7356                    }
7357                    let response = {
7358                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7359                        let encoded = common::to_string(&bytes);
7360                        match serde_json::from_str(&encoded) {
7361                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7362                            Err(error) => {
7363                                dlg.response_json_decode_error(&encoded, &error);
7364                                return Err(common::Error::JsonDecodeError(
7365                                    encoded.to_string(),
7366                                    error,
7367                                ));
7368                            }
7369                        }
7370                    };
7371
7372                    dlg.finished(true);
7373                    return Ok(response);
7374                }
7375            }
7376        }
7377    }
7378
7379    ///
7380    /// Sets the *request* property to the given value.
7381    ///
7382    /// Even though the property as already been set when instantiating this call,
7383    /// we provide this method for API completeness.
7384    pub fn request(
7385        mut self,
7386        new_value: ApproveApprovalRequestMessage,
7387    ) -> ProjectApprovalRequestApproveCall<'a, C> {
7388        self._request = new_value;
7389        self
7390    }
7391    /// Name of the approval request to approve.
7392    ///
7393    /// Sets the *name* path property to the given value.
7394    ///
7395    /// Even though the property as already been set when instantiating this call,
7396    /// we provide this method for API completeness.
7397    pub fn name(mut self, new_value: &str) -> ProjectApprovalRequestApproveCall<'a, C> {
7398        self._name = new_value.to_string();
7399        self
7400    }
7401    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7402    /// while executing the actual API request.
7403    ///
7404    /// ````text
7405    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7406    /// ````
7407    ///
7408    /// Sets the *delegate* property to the given value.
7409    pub fn delegate(
7410        mut self,
7411        new_value: &'a mut dyn common::Delegate,
7412    ) -> ProjectApprovalRequestApproveCall<'a, C> {
7413        self._delegate = Some(new_value);
7414        self
7415    }
7416
7417    /// Set any additional parameter of the query string used in the request.
7418    /// It should be used to set parameters which are not yet available through their own
7419    /// setters.
7420    ///
7421    /// Please note that this method must not be used to set any of the known parameters
7422    /// which have their own setter method. If done anyway, the request will fail.
7423    ///
7424    /// # Additional Parameters
7425    ///
7426    /// * *$.xgafv* (query-string) - V1 error format.
7427    /// * *access_token* (query-string) - OAuth access token.
7428    /// * *alt* (query-string) - Data format for response.
7429    /// * *callback* (query-string) - JSONP
7430    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7431    /// * *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.
7432    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7433    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7434    /// * *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.
7435    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7436    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7437    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestApproveCall<'a, C>
7438    where
7439        T: AsRef<str>,
7440    {
7441        self._additional_params
7442            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7443        self
7444    }
7445
7446    /// Identifies the authorization scope for the method you are building.
7447    ///
7448    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7449    /// [`Scope::CloudPlatform`].
7450    ///
7451    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7452    /// tokens for more than one scope.
7453    ///
7454    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7455    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7456    /// sufficient, a read-write scope will do as well.
7457    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestApproveCall<'a, C>
7458    where
7459        St: AsRef<str>,
7460    {
7461        self._scopes.insert(String::from(scope.as_ref()));
7462        self
7463    }
7464    /// Identifies the authorization scope(s) for the method you are building.
7465    ///
7466    /// See [`Self::add_scope()`] for details.
7467    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestApproveCall<'a, C>
7468    where
7469        I: IntoIterator<Item = St>,
7470        St: AsRef<str>,
7471    {
7472        self._scopes
7473            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7474        self
7475    }
7476
7477    /// Removes all scopes, and no default scope will be used either.
7478    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7479    /// for details).
7480    pub fn clear_scopes(mut self) -> ProjectApprovalRequestApproveCall<'a, C> {
7481        self._scopes.clear();
7482        self
7483    }
7484}
7485
7486/// Dismisses a request. Returns the updated ApprovalRequest. NOTE: When a request is dismissed, it is considered ignored. Dismissing a request does not prevent access granted by other Access Approval requests. Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.
7487///
7488/// A builder for the *approvalRequests.dismiss* method supported by a *project* resource.
7489/// It is not used directly, but through a [`ProjectMethods`] instance.
7490///
7491/// # Example
7492///
7493/// Instantiate a resource method builder
7494///
7495/// ```test_harness,no_run
7496/// # extern crate hyper;
7497/// # extern crate hyper_rustls;
7498/// # extern crate google_accessapproval1 as accessapproval1;
7499/// use accessapproval1::api::DismissApprovalRequestMessage;
7500/// # async fn dox() {
7501/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7502///
7503/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7504/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7505/// #     .with_native_roots()
7506/// #     .unwrap()
7507/// #     .https_only()
7508/// #     .enable_http2()
7509/// #     .build();
7510///
7511/// # let executor = hyper_util::rt::TokioExecutor::new();
7512/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7513/// #     secret,
7514/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7515/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7516/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7517/// #     ),
7518/// # ).build().await.unwrap();
7519///
7520/// # let client = hyper_util::client::legacy::Client::builder(
7521/// #     hyper_util::rt::TokioExecutor::new()
7522/// # )
7523/// # .build(
7524/// #     hyper_rustls::HttpsConnectorBuilder::new()
7525/// #         .with_native_roots()
7526/// #         .unwrap()
7527/// #         .https_or_http()
7528/// #         .enable_http2()
7529/// #         .build()
7530/// # );
7531/// # let mut hub = AccessApproval::new(client, auth);
7532/// // As the method needs a request, you would usually fill it with the desired information
7533/// // into the respective structure. Some of the parts shown here might not be applicable !
7534/// // Values shown here are possibly random and not representative !
7535/// let mut req = DismissApprovalRequestMessage::default();
7536///
7537/// // You can configure optional parameters by calling the respective setters at will, and
7538/// // execute the final call using `doit()`.
7539/// // Values shown here are possibly random and not representative !
7540/// let result = hub.projects().approval_requests_dismiss(req, "name")
7541///              .doit().await;
7542/// # }
7543/// ```
7544pub struct ProjectApprovalRequestDismisCall<'a, C>
7545where
7546    C: 'a,
7547{
7548    hub: &'a AccessApproval<C>,
7549    _request: DismissApprovalRequestMessage,
7550    _name: String,
7551    _delegate: Option<&'a mut dyn common::Delegate>,
7552    _additional_params: HashMap<String, String>,
7553    _scopes: BTreeSet<String>,
7554}
7555
7556impl<'a, C> common::CallBuilder for ProjectApprovalRequestDismisCall<'a, C> {}
7557
7558impl<'a, C> ProjectApprovalRequestDismisCall<'a, C>
7559where
7560    C: common::Connector,
7561{
7562    /// Perform the operation you have build so far.
7563    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
7564        use std::borrow::Cow;
7565        use std::io::{Read, Seek};
7566
7567        use common::{url::Params, ToParts};
7568        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7569
7570        let mut dd = common::DefaultDelegate;
7571        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7572        dlg.begin(common::MethodInfo {
7573            id: "accessapproval.projects.approvalRequests.dismiss",
7574            http_method: hyper::Method::POST,
7575        });
7576
7577        for &field in ["alt", "name"].iter() {
7578            if self._additional_params.contains_key(field) {
7579                dlg.finished(false);
7580                return Err(common::Error::FieldClash(field));
7581            }
7582        }
7583
7584        let mut params = Params::with_capacity(4 + self._additional_params.len());
7585        params.push("name", self._name);
7586
7587        params.extend(self._additional_params.iter());
7588
7589        params.push("alt", "json");
7590        let mut url = self.hub._base_url.clone() + "v1/{+name}:dismiss";
7591        if self._scopes.is_empty() {
7592            self._scopes
7593                .insert(Scope::CloudPlatform.as_ref().to_string());
7594        }
7595
7596        #[allow(clippy::single_element_loop)]
7597        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7598            url = params.uri_replacement(url, param_name, find_this, true);
7599        }
7600        {
7601            let to_remove = ["name"];
7602            params.remove_params(&to_remove);
7603        }
7604
7605        let url = params.parse_with_url(&url);
7606
7607        let mut json_mime_type = mime::APPLICATION_JSON;
7608        let mut request_value_reader = {
7609            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7610            common::remove_json_null_values(&mut value);
7611            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7612            serde_json::to_writer(&mut dst, &value).unwrap();
7613            dst
7614        };
7615        let request_size = request_value_reader
7616            .seek(std::io::SeekFrom::End(0))
7617            .unwrap();
7618        request_value_reader
7619            .seek(std::io::SeekFrom::Start(0))
7620            .unwrap();
7621
7622        loop {
7623            let token = match self
7624                .hub
7625                .auth
7626                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7627                .await
7628            {
7629                Ok(token) => token,
7630                Err(e) => match dlg.token(e) {
7631                    Ok(token) => token,
7632                    Err(e) => {
7633                        dlg.finished(false);
7634                        return Err(common::Error::MissingToken(e));
7635                    }
7636                },
7637            };
7638            request_value_reader
7639                .seek(std::io::SeekFrom::Start(0))
7640                .unwrap();
7641            let mut req_result = {
7642                let client = &self.hub.client;
7643                dlg.pre_request();
7644                let mut req_builder = hyper::Request::builder()
7645                    .method(hyper::Method::POST)
7646                    .uri(url.as_str())
7647                    .header(USER_AGENT, self.hub._user_agent.clone());
7648
7649                if let Some(token) = token.as_ref() {
7650                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7651                }
7652
7653                let request = req_builder
7654                    .header(CONTENT_TYPE, json_mime_type.to_string())
7655                    .header(CONTENT_LENGTH, request_size as u64)
7656                    .body(common::to_body(
7657                        request_value_reader.get_ref().clone().into(),
7658                    ));
7659
7660                client.request(request.unwrap()).await
7661            };
7662
7663            match req_result {
7664                Err(err) => {
7665                    if let common::Retry::After(d) = dlg.http_error(&err) {
7666                        sleep(d).await;
7667                        continue;
7668                    }
7669                    dlg.finished(false);
7670                    return Err(common::Error::HttpError(err));
7671                }
7672                Ok(res) => {
7673                    let (mut parts, body) = res.into_parts();
7674                    let mut body = common::Body::new(body);
7675                    if !parts.status.is_success() {
7676                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7677                        let error = serde_json::from_str(&common::to_string(&bytes));
7678                        let response = common::to_response(parts, bytes.into());
7679
7680                        if let common::Retry::After(d) =
7681                            dlg.http_failure(&response, error.as_ref().ok())
7682                        {
7683                            sleep(d).await;
7684                            continue;
7685                        }
7686
7687                        dlg.finished(false);
7688
7689                        return Err(match error {
7690                            Ok(value) => common::Error::BadRequest(value),
7691                            _ => common::Error::Failure(response),
7692                        });
7693                    }
7694                    let response = {
7695                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7696                        let encoded = common::to_string(&bytes);
7697                        match serde_json::from_str(&encoded) {
7698                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7699                            Err(error) => {
7700                                dlg.response_json_decode_error(&encoded, &error);
7701                                return Err(common::Error::JsonDecodeError(
7702                                    encoded.to_string(),
7703                                    error,
7704                                ));
7705                            }
7706                        }
7707                    };
7708
7709                    dlg.finished(true);
7710                    return Ok(response);
7711                }
7712            }
7713        }
7714    }
7715
7716    ///
7717    /// Sets the *request* property to the given value.
7718    ///
7719    /// Even though the property as already been set when instantiating this call,
7720    /// we provide this method for API completeness.
7721    pub fn request(
7722        mut self,
7723        new_value: DismissApprovalRequestMessage,
7724    ) -> ProjectApprovalRequestDismisCall<'a, C> {
7725        self._request = new_value;
7726        self
7727    }
7728    /// Name of the ApprovalRequest to dismiss.
7729    ///
7730    /// Sets the *name* path property to the given value.
7731    ///
7732    /// Even though the property as already been set when instantiating this call,
7733    /// we provide this method for API completeness.
7734    pub fn name(mut self, new_value: &str) -> ProjectApprovalRequestDismisCall<'a, C> {
7735        self._name = new_value.to_string();
7736        self
7737    }
7738    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7739    /// while executing the actual API request.
7740    ///
7741    /// ````text
7742    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7743    /// ````
7744    ///
7745    /// Sets the *delegate* property to the given value.
7746    pub fn delegate(
7747        mut self,
7748        new_value: &'a mut dyn common::Delegate,
7749    ) -> ProjectApprovalRequestDismisCall<'a, C> {
7750        self._delegate = Some(new_value);
7751        self
7752    }
7753
7754    /// Set any additional parameter of the query string used in the request.
7755    /// It should be used to set parameters which are not yet available through their own
7756    /// setters.
7757    ///
7758    /// Please note that this method must not be used to set any of the known parameters
7759    /// which have their own setter method. If done anyway, the request will fail.
7760    ///
7761    /// # Additional Parameters
7762    ///
7763    /// * *$.xgafv* (query-string) - V1 error format.
7764    /// * *access_token* (query-string) - OAuth access token.
7765    /// * *alt* (query-string) - Data format for response.
7766    /// * *callback* (query-string) - JSONP
7767    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7768    /// * *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.
7769    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7770    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7771    /// * *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.
7772    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7773    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7774    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestDismisCall<'a, C>
7775    where
7776        T: AsRef<str>,
7777    {
7778        self._additional_params
7779            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7780        self
7781    }
7782
7783    /// Identifies the authorization scope for the method you are building.
7784    ///
7785    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7786    /// [`Scope::CloudPlatform`].
7787    ///
7788    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7789    /// tokens for more than one scope.
7790    ///
7791    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7792    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7793    /// sufficient, a read-write scope will do as well.
7794    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestDismisCall<'a, C>
7795    where
7796        St: AsRef<str>,
7797    {
7798        self._scopes.insert(String::from(scope.as_ref()));
7799        self
7800    }
7801    /// Identifies the authorization scope(s) for the method you are building.
7802    ///
7803    /// See [`Self::add_scope()`] for details.
7804    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestDismisCall<'a, C>
7805    where
7806        I: IntoIterator<Item = St>,
7807        St: AsRef<str>,
7808    {
7809        self._scopes
7810            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7811        self
7812    }
7813
7814    /// Removes all scopes, and no default scope will be used either.
7815    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7816    /// for details).
7817    pub fn clear_scopes(mut self) -> ProjectApprovalRequestDismisCall<'a, C> {
7818        self._scopes.clear();
7819        self
7820    }
7821}
7822
7823/// Gets an approval request. Returns NOT_FOUND if the request does not exist.
7824///
7825/// A builder for the *approvalRequests.get* method supported by a *project* resource.
7826/// It is not used directly, but through a [`ProjectMethods`] instance.
7827///
7828/// # Example
7829///
7830/// Instantiate a resource method builder
7831///
7832/// ```test_harness,no_run
7833/// # extern crate hyper;
7834/// # extern crate hyper_rustls;
7835/// # extern crate google_accessapproval1 as accessapproval1;
7836/// # async fn dox() {
7837/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7838///
7839/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7840/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7841/// #     .with_native_roots()
7842/// #     .unwrap()
7843/// #     .https_only()
7844/// #     .enable_http2()
7845/// #     .build();
7846///
7847/// # let executor = hyper_util::rt::TokioExecutor::new();
7848/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7849/// #     secret,
7850/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7851/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7852/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7853/// #     ),
7854/// # ).build().await.unwrap();
7855///
7856/// # let client = hyper_util::client::legacy::Client::builder(
7857/// #     hyper_util::rt::TokioExecutor::new()
7858/// # )
7859/// # .build(
7860/// #     hyper_rustls::HttpsConnectorBuilder::new()
7861/// #         .with_native_roots()
7862/// #         .unwrap()
7863/// #         .https_or_http()
7864/// #         .enable_http2()
7865/// #         .build()
7866/// # );
7867/// # let mut hub = AccessApproval::new(client, auth);
7868/// // You can configure optional parameters by calling the respective setters at will, and
7869/// // execute the final call using `doit()`.
7870/// // Values shown here are possibly random and not representative !
7871/// let result = hub.projects().approval_requests_get("name")
7872///              .doit().await;
7873/// # }
7874/// ```
7875pub struct ProjectApprovalRequestGetCall<'a, C>
7876where
7877    C: 'a,
7878{
7879    hub: &'a AccessApproval<C>,
7880    _name: String,
7881    _delegate: Option<&'a mut dyn common::Delegate>,
7882    _additional_params: HashMap<String, String>,
7883    _scopes: BTreeSet<String>,
7884}
7885
7886impl<'a, C> common::CallBuilder for ProjectApprovalRequestGetCall<'a, C> {}
7887
7888impl<'a, C> ProjectApprovalRequestGetCall<'a, C>
7889where
7890    C: common::Connector,
7891{
7892    /// Perform the operation you have build so far.
7893    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
7894        use std::borrow::Cow;
7895        use std::io::{Read, Seek};
7896
7897        use common::{url::Params, ToParts};
7898        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7899
7900        let mut dd = common::DefaultDelegate;
7901        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7902        dlg.begin(common::MethodInfo {
7903            id: "accessapproval.projects.approvalRequests.get",
7904            http_method: hyper::Method::GET,
7905        });
7906
7907        for &field in ["alt", "name"].iter() {
7908            if self._additional_params.contains_key(field) {
7909                dlg.finished(false);
7910                return Err(common::Error::FieldClash(field));
7911            }
7912        }
7913
7914        let mut params = Params::with_capacity(3 + self._additional_params.len());
7915        params.push("name", self._name);
7916
7917        params.extend(self._additional_params.iter());
7918
7919        params.push("alt", "json");
7920        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7921        if self._scopes.is_empty() {
7922            self._scopes
7923                .insert(Scope::CloudPlatform.as_ref().to_string());
7924        }
7925
7926        #[allow(clippy::single_element_loop)]
7927        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7928            url = params.uri_replacement(url, param_name, find_this, true);
7929        }
7930        {
7931            let to_remove = ["name"];
7932            params.remove_params(&to_remove);
7933        }
7934
7935        let url = params.parse_with_url(&url);
7936
7937        loop {
7938            let token = match self
7939                .hub
7940                .auth
7941                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7942                .await
7943            {
7944                Ok(token) => token,
7945                Err(e) => match dlg.token(e) {
7946                    Ok(token) => token,
7947                    Err(e) => {
7948                        dlg.finished(false);
7949                        return Err(common::Error::MissingToken(e));
7950                    }
7951                },
7952            };
7953            let mut req_result = {
7954                let client = &self.hub.client;
7955                dlg.pre_request();
7956                let mut req_builder = hyper::Request::builder()
7957                    .method(hyper::Method::GET)
7958                    .uri(url.as_str())
7959                    .header(USER_AGENT, self.hub._user_agent.clone());
7960
7961                if let Some(token) = token.as_ref() {
7962                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7963                }
7964
7965                let request = req_builder
7966                    .header(CONTENT_LENGTH, 0_u64)
7967                    .body(common::to_body::<String>(None));
7968
7969                client.request(request.unwrap()).await
7970            };
7971
7972            match req_result {
7973                Err(err) => {
7974                    if let common::Retry::After(d) = dlg.http_error(&err) {
7975                        sleep(d).await;
7976                        continue;
7977                    }
7978                    dlg.finished(false);
7979                    return Err(common::Error::HttpError(err));
7980                }
7981                Ok(res) => {
7982                    let (mut parts, body) = res.into_parts();
7983                    let mut body = common::Body::new(body);
7984                    if !parts.status.is_success() {
7985                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7986                        let error = serde_json::from_str(&common::to_string(&bytes));
7987                        let response = common::to_response(parts, bytes.into());
7988
7989                        if let common::Retry::After(d) =
7990                            dlg.http_failure(&response, error.as_ref().ok())
7991                        {
7992                            sleep(d).await;
7993                            continue;
7994                        }
7995
7996                        dlg.finished(false);
7997
7998                        return Err(match error {
7999                            Ok(value) => common::Error::BadRequest(value),
8000                            _ => common::Error::Failure(response),
8001                        });
8002                    }
8003                    let response = {
8004                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8005                        let encoded = common::to_string(&bytes);
8006                        match serde_json::from_str(&encoded) {
8007                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8008                            Err(error) => {
8009                                dlg.response_json_decode_error(&encoded, &error);
8010                                return Err(common::Error::JsonDecodeError(
8011                                    encoded.to_string(),
8012                                    error,
8013                                ));
8014                            }
8015                        }
8016                    };
8017
8018                    dlg.finished(true);
8019                    return Ok(response);
8020                }
8021            }
8022        }
8023    }
8024
8025    /// The name of the approval request to retrieve. Format: "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"
8026    ///
8027    /// Sets the *name* path property to the given value.
8028    ///
8029    /// Even though the property as already been set when instantiating this call,
8030    /// we provide this method for API completeness.
8031    pub fn name(mut self, new_value: &str) -> ProjectApprovalRequestGetCall<'a, C> {
8032        self._name = new_value.to_string();
8033        self
8034    }
8035    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8036    /// while executing the actual API request.
8037    ///
8038    /// ````text
8039    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8040    /// ````
8041    ///
8042    /// Sets the *delegate* property to the given value.
8043    pub fn delegate(
8044        mut self,
8045        new_value: &'a mut dyn common::Delegate,
8046    ) -> ProjectApprovalRequestGetCall<'a, C> {
8047        self._delegate = Some(new_value);
8048        self
8049    }
8050
8051    /// Set any additional parameter of the query string used in the request.
8052    /// It should be used to set parameters which are not yet available through their own
8053    /// setters.
8054    ///
8055    /// Please note that this method must not be used to set any of the known parameters
8056    /// which have their own setter method. If done anyway, the request will fail.
8057    ///
8058    /// # Additional Parameters
8059    ///
8060    /// * *$.xgafv* (query-string) - V1 error format.
8061    /// * *access_token* (query-string) - OAuth access token.
8062    /// * *alt* (query-string) - Data format for response.
8063    /// * *callback* (query-string) - JSONP
8064    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8065    /// * *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.
8066    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8067    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8068    /// * *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.
8069    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8070    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8071    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestGetCall<'a, C>
8072    where
8073        T: AsRef<str>,
8074    {
8075        self._additional_params
8076            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8077        self
8078    }
8079
8080    /// Identifies the authorization scope for the method you are building.
8081    ///
8082    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8083    /// [`Scope::CloudPlatform`].
8084    ///
8085    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8086    /// tokens for more than one scope.
8087    ///
8088    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8089    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8090    /// sufficient, a read-write scope will do as well.
8091    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestGetCall<'a, C>
8092    where
8093        St: AsRef<str>,
8094    {
8095        self._scopes.insert(String::from(scope.as_ref()));
8096        self
8097    }
8098    /// Identifies the authorization scope(s) for the method you are building.
8099    ///
8100    /// See [`Self::add_scope()`] for details.
8101    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestGetCall<'a, C>
8102    where
8103        I: IntoIterator<Item = St>,
8104        St: AsRef<str>,
8105    {
8106        self._scopes
8107            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8108        self
8109    }
8110
8111    /// Removes all scopes, and no default scope will be used either.
8112    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8113    /// for details).
8114    pub fn clear_scopes(mut self) -> ProjectApprovalRequestGetCall<'a, C> {
8115        self._scopes.clear();
8116        self
8117    }
8118}
8119
8120/// Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest. NOTE: This action revokes Google access based on this approval request. If the resource has other active approvals, access will remain granted. Returns FAILED_PRECONDITION if the request exists but is not in an approved state.
8121///
8122/// A builder for the *approvalRequests.invalidate* method supported by a *project* resource.
8123/// It is not used directly, but through a [`ProjectMethods`] instance.
8124///
8125/// # Example
8126///
8127/// Instantiate a resource method builder
8128///
8129/// ```test_harness,no_run
8130/// # extern crate hyper;
8131/// # extern crate hyper_rustls;
8132/// # extern crate google_accessapproval1 as accessapproval1;
8133/// use accessapproval1::api::InvalidateApprovalRequestMessage;
8134/// # async fn dox() {
8135/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8136///
8137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8138/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8139/// #     .with_native_roots()
8140/// #     .unwrap()
8141/// #     .https_only()
8142/// #     .enable_http2()
8143/// #     .build();
8144///
8145/// # let executor = hyper_util::rt::TokioExecutor::new();
8146/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8147/// #     secret,
8148/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8149/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8150/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8151/// #     ),
8152/// # ).build().await.unwrap();
8153///
8154/// # let client = hyper_util::client::legacy::Client::builder(
8155/// #     hyper_util::rt::TokioExecutor::new()
8156/// # )
8157/// # .build(
8158/// #     hyper_rustls::HttpsConnectorBuilder::new()
8159/// #         .with_native_roots()
8160/// #         .unwrap()
8161/// #         .https_or_http()
8162/// #         .enable_http2()
8163/// #         .build()
8164/// # );
8165/// # let mut hub = AccessApproval::new(client, auth);
8166/// // As the method needs a request, you would usually fill it with the desired information
8167/// // into the respective structure. Some of the parts shown here might not be applicable !
8168/// // Values shown here are possibly random and not representative !
8169/// let mut req = InvalidateApprovalRequestMessage::default();
8170///
8171/// // You can configure optional parameters by calling the respective setters at will, and
8172/// // execute the final call using `doit()`.
8173/// // Values shown here are possibly random and not representative !
8174/// let result = hub.projects().approval_requests_invalidate(req, "name")
8175///              .doit().await;
8176/// # }
8177/// ```
8178pub struct ProjectApprovalRequestInvalidateCall<'a, C>
8179where
8180    C: 'a,
8181{
8182    hub: &'a AccessApproval<C>,
8183    _request: InvalidateApprovalRequestMessage,
8184    _name: String,
8185    _delegate: Option<&'a mut dyn common::Delegate>,
8186    _additional_params: HashMap<String, String>,
8187    _scopes: BTreeSet<String>,
8188}
8189
8190impl<'a, C> common::CallBuilder for ProjectApprovalRequestInvalidateCall<'a, C> {}
8191
8192impl<'a, C> ProjectApprovalRequestInvalidateCall<'a, C>
8193where
8194    C: common::Connector,
8195{
8196    /// Perform the operation you have build so far.
8197    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
8198        use std::borrow::Cow;
8199        use std::io::{Read, Seek};
8200
8201        use common::{url::Params, ToParts};
8202        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8203
8204        let mut dd = common::DefaultDelegate;
8205        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8206        dlg.begin(common::MethodInfo {
8207            id: "accessapproval.projects.approvalRequests.invalidate",
8208            http_method: hyper::Method::POST,
8209        });
8210
8211        for &field in ["alt", "name"].iter() {
8212            if self._additional_params.contains_key(field) {
8213                dlg.finished(false);
8214                return Err(common::Error::FieldClash(field));
8215            }
8216        }
8217
8218        let mut params = Params::with_capacity(4 + self._additional_params.len());
8219        params.push("name", self._name);
8220
8221        params.extend(self._additional_params.iter());
8222
8223        params.push("alt", "json");
8224        let mut url = self.hub._base_url.clone() + "v1/{+name}:invalidate";
8225        if self._scopes.is_empty() {
8226            self._scopes
8227                .insert(Scope::CloudPlatform.as_ref().to_string());
8228        }
8229
8230        #[allow(clippy::single_element_loop)]
8231        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8232            url = params.uri_replacement(url, param_name, find_this, true);
8233        }
8234        {
8235            let to_remove = ["name"];
8236            params.remove_params(&to_remove);
8237        }
8238
8239        let url = params.parse_with_url(&url);
8240
8241        let mut json_mime_type = mime::APPLICATION_JSON;
8242        let mut request_value_reader = {
8243            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8244            common::remove_json_null_values(&mut value);
8245            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8246            serde_json::to_writer(&mut dst, &value).unwrap();
8247            dst
8248        };
8249        let request_size = request_value_reader
8250            .seek(std::io::SeekFrom::End(0))
8251            .unwrap();
8252        request_value_reader
8253            .seek(std::io::SeekFrom::Start(0))
8254            .unwrap();
8255
8256        loop {
8257            let token = match self
8258                .hub
8259                .auth
8260                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8261                .await
8262            {
8263                Ok(token) => token,
8264                Err(e) => match dlg.token(e) {
8265                    Ok(token) => token,
8266                    Err(e) => {
8267                        dlg.finished(false);
8268                        return Err(common::Error::MissingToken(e));
8269                    }
8270                },
8271            };
8272            request_value_reader
8273                .seek(std::io::SeekFrom::Start(0))
8274                .unwrap();
8275            let mut req_result = {
8276                let client = &self.hub.client;
8277                dlg.pre_request();
8278                let mut req_builder = hyper::Request::builder()
8279                    .method(hyper::Method::POST)
8280                    .uri(url.as_str())
8281                    .header(USER_AGENT, self.hub._user_agent.clone());
8282
8283                if let Some(token) = token.as_ref() {
8284                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8285                }
8286
8287                let request = req_builder
8288                    .header(CONTENT_TYPE, json_mime_type.to_string())
8289                    .header(CONTENT_LENGTH, request_size as u64)
8290                    .body(common::to_body(
8291                        request_value_reader.get_ref().clone().into(),
8292                    ));
8293
8294                client.request(request.unwrap()).await
8295            };
8296
8297            match req_result {
8298                Err(err) => {
8299                    if let common::Retry::After(d) = dlg.http_error(&err) {
8300                        sleep(d).await;
8301                        continue;
8302                    }
8303                    dlg.finished(false);
8304                    return Err(common::Error::HttpError(err));
8305                }
8306                Ok(res) => {
8307                    let (mut parts, body) = res.into_parts();
8308                    let mut body = common::Body::new(body);
8309                    if !parts.status.is_success() {
8310                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8311                        let error = serde_json::from_str(&common::to_string(&bytes));
8312                        let response = common::to_response(parts, bytes.into());
8313
8314                        if let common::Retry::After(d) =
8315                            dlg.http_failure(&response, error.as_ref().ok())
8316                        {
8317                            sleep(d).await;
8318                            continue;
8319                        }
8320
8321                        dlg.finished(false);
8322
8323                        return Err(match error {
8324                            Ok(value) => common::Error::BadRequest(value),
8325                            _ => common::Error::Failure(response),
8326                        });
8327                    }
8328                    let response = {
8329                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8330                        let encoded = common::to_string(&bytes);
8331                        match serde_json::from_str(&encoded) {
8332                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8333                            Err(error) => {
8334                                dlg.response_json_decode_error(&encoded, &error);
8335                                return Err(common::Error::JsonDecodeError(
8336                                    encoded.to_string(),
8337                                    error,
8338                                ));
8339                            }
8340                        }
8341                    };
8342
8343                    dlg.finished(true);
8344                    return Ok(response);
8345                }
8346            }
8347        }
8348    }
8349
8350    ///
8351    /// Sets the *request* property to the given value.
8352    ///
8353    /// Even though the property as already been set when instantiating this call,
8354    /// we provide this method for API completeness.
8355    pub fn request(
8356        mut self,
8357        new_value: InvalidateApprovalRequestMessage,
8358    ) -> ProjectApprovalRequestInvalidateCall<'a, C> {
8359        self._request = new_value;
8360        self
8361    }
8362    /// Name of the ApprovalRequest to invalidate.
8363    ///
8364    /// Sets the *name* path property to the given value.
8365    ///
8366    /// Even though the property as already been set when instantiating this call,
8367    /// we provide this method for API completeness.
8368    pub fn name(mut self, new_value: &str) -> ProjectApprovalRequestInvalidateCall<'a, C> {
8369        self._name = new_value.to_string();
8370        self
8371    }
8372    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8373    /// while executing the actual API request.
8374    ///
8375    /// ````text
8376    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8377    /// ````
8378    ///
8379    /// Sets the *delegate* property to the given value.
8380    pub fn delegate(
8381        mut self,
8382        new_value: &'a mut dyn common::Delegate,
8383    ) -> ProjectApprovalRequestInvalidateCall<'a, C> {
8384        self._delegate = Some(new_value);
8385        self
8386    }
8387
8388    /// Set any additional parameter of the query string used in the request.
8389    /// It should be used to set parameters which are not yet available through their own
8390    /// setters.
8391    ///
8392    /// Please note that this method must not be used to set any of the known parameters
8393    /// which have their own setter method. If done anyway, the request will fail.
8394    ///
8395    /// # Additional Parameters
8396    ///
8397    /// * *$.xgafv* (query-string) - V1 error format.
8398    /// * *access_token* (query-string) - OAuth access token.
8399    /// * *alt* (query-string) - Data format for response.
8400    /// * *callback* (query-string) - JSONP
8401    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8402    /// * *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.
8403    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8404    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8405    /// * *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.
8406    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8407    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8408    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestInvalidateCall<'a, C>
8409    where
8410        T: AsRef<str>,
8411    {
8412        self._additional_params
8413            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8414        self
8415    }
8416
8417    /// Identifies the authorization scope for the method you are building.
8418    ///
8419    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8420    /// [`Scope::CloudPlatform`].
8421    ///
8422    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8423    /// tokens for more than one scope.
8424    ///
8425    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8426    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8427    /// sufficient, a read-write scope will do as well.
8428    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestInvalidateCall<'a, C>
8429    where
8430        St: AsRef<str>,
8431    {
8432        self._scopes.insert(String::from(scope.as_ref()));
8433        self
8434    }
8435    /// Identifies the authorization scope(s) for the method you are building.
8436    ///
8437    /// See [`Self::add_scope()`] for details.
8438    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestInvalidateCall<'a, C>
8439    where
8440        I: IntoIterator<Item = St>,
8441        St: AsRef<str>,
8442    {
8443        self._scopes
8444            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8445        self
8446    }
8447
8448    /// Removes all scopes, and no default scope will be used either.
8449    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8450    /// for details).
8451    pub fn clear_scopes(mut self) -> ProjectApprovalRequestInvalidateCall<'a, C> {
8452        self._scopes.clear();
8453        self
8454    }
8455}
8456
8457/// Lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.
8458///
8459/// A builder for the *approvalRequests.list* method supported by a *project* resource.
8460/// It is not used directly, but through a [`ProjectMethods`] instance.
8461///
8462/// # Example
8463///
8464/// Instantiate a resource method builder
8465///
8466/// ```test_harness,no_run
8467/// # extern crate hyper;
8468/// # extern crate hyper_rustls;
8469/// # extern crate google_accessapproval1 as accessapproval1;
8470/// # async fn dox() {
8471/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8472///
8473/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8474/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8475/// #     .with_native_roots()
8476/// #     .unwrap()
8477/// #     .https_only()
8478/// #     .enable_http2()
8479/// #     .build();
8480///
8481/// # let executor = hyper_util::rt::TokioExecutor::new();
8482/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8483/// #     secret,
8484/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8485/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8486/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8487/// #     ),
8488/// # ).build().await.unwrap();
8489///
8490/// # let client = hyper_util::client::legacy::Client::builder(
8491/// #     hyper_util::rt::TokioExecutor::new()
8492/// # )
8493/// # .build(
8494/// #     hyper_rustls::HttpsConnectorBuilder::new()
8495/// #         .with_native_roots()
8496/// #         .unwrap()
8497/// #         .https_or_http()
8498/// #         .enable_http2()
8499/// #         .build()
8500/// # );
8501/// # let mut hub = AccessApproval::new(client, auth);
8502/// // You can configure optional parameters by calling the respective setters at will, and
8503/// // execute the final call using `doit()`.
8504/// // Values shown here are possibly random and not representative !
8505/// let result = hub.projects().approval_requests_list("parent")
8506///              .page_token("gubergren")
8507///              .page_size(-17)
8508///              .filter("dolor")
8509///              .doit().await;
8510/// # }
8511/// ```
8512pub struct ProjectApprovalRequestListCall<'a, C>
8513where
8514    C: 'a,
8515{
8516    hub: &'a AccessApproval<C>,
8517    _parent: String,
8518    _page_token: Option<String>,
8519    _page_size: Option<i32>,
8520    _filter: Option<String>,
8521    _delegate: Option<&'a mut dyn common::Delegate>,
8522    _additional_params: HashMap<String, String>,
8523    _scopes: BTreeSet<String>,
8524}
8525
8526impl<'a, C> common::CallBuilder for ProjectApprovalRequestListCall<'a, C> {}
8527
8528impl<'a, C> ProjectApprovalRequestListCall<'a, C>
8529where
8530    C: common::Connector,
8531{
8532    /// Perform the operation you have build so far.
8533    pub async fn doit(
8534        mut self,
8535    ) -> common::Result<(common::Response, ListApprovalRequestsResponse)> {
8536        use std::borrow::Cow;
8537        use std::io::{Read, Seek};
8538
8539        use common::{url::Params, ToParts};
8540        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8541
8542        let mut dd = common::DefaultDelegate;
8543        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8544        dlg.begin(common::MethodInfo {
8545            id: "accessapproval.projects.approvalRequests.list",
8546            http_method: hyper::Method::GET,
8547        });
8548
8549        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
8550            if self._additional_params.contains_key(field) {
8551                dlg.finished(false);
8552                return Err(common::Error::FieldClash(field));
8553            }
8554        }
8555
8556        let mut params = Params::with_capacity(6 + self._additional_params.len());
8557        params.push("parent", self._parent);
8558        if let Some(value) = self._page_token.as_ref() {
8559            params.push("pageToken", value);
8560        }
8561        if let Some(value) = self._page_size.as_ref() {
8562            params.push("pageSize", value.to_string());
8563        }
8564        if let Some(value) = self._filter.as_ref() {
8565            params.push("filter", value);
8566        }
8567
8568        params.extend(self._additional_params.iter());
8569
8570        params.push("alt", "json");
8571        let mut url = self.hub._base_url.clone() + "v1/{+parent}/approvalRequests";
8572        if self._scopes.is_empty() {
8573            self._scopes
8574                .insert(Scope::CloudPlatform.as_ref().to_string());
8575        }
8576
8577        #[allow(clippy::single_element_loop)]
8578        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8579            url = params.uri_replacement(url, param_name, find_this, true);
8580        }
8581        {
8582            let to_remove = ["parent"];
8583            params.remove_params(&to_remove);
8584        }
8585
8586        let url = params.parse_with_url(&url);
8587
8588        loop {
8589            let token = match self
8590                .hub
8591                .auth
8592                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8593                .await
8594            {
8595                Ok(token) => token,
8596                Err(e) => match dlg.token(e) {
8597                    Ok(token) => token,
8598                    Err(e) => {
8599                        dlg.finished(false);
8600                        return Err(common::Error::MissingToken(e));
8601                    }
8602                },
8603            };
8604            let mut req_result = {
8605                let client = &self.hub.client;
8606                dlg.pre_request();
8607                let mut req_builder = hyper::Request::builder()
8608                    .method(hyper::Method::GET)
8609                    .uri(url.as_str())
8610                    .header(USER_AGENT, self.hub._user_agent.clone());
8611
8612                if let Some(token) = token.as_ref() {
8613                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8614                }
8615
8616                let request = req_builder
8617                    .header(CONTENT_LENGTH, 0_u64)
8618                    .body(common::to_body::<String>(None));
8619
8620                client.request(request.unwrap()).await
8621            };
8622
8623            match req_result {
8624                Err(err) => {
8625                    if let common::Retry::After(d) = dlg.http_error(&err) {
8626                        sleep(d).await;
8627                        continue;
8628                    }
8629                    dlg.finished(false);
8630                    return Err(common::Error::HttpError(err));
8631                }
8632                Ok(res) => {
8633                    let (mut parts, body) = res.into_parts();
8634                    let mut body = common::Body::new(body);
8635                    if !parts.status.is_success() {
8636                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8637                        let error = serde_json::from_str(&common::to_string(&bytes));
8638                        let response = common::to_response(parts, bytes.into());
8639
8640                        if let common::Retry::After(d) =
8641                            dlg.http_failure(&response, error.as_ref().ok())
8642                        {
8643                            sleep(d).await;
8644                            continue;
8645                        }
8646
8647                        dlg.finished(false);
8648
8649                        return Err(match error {
8650                            Ok(value) => common::Error::BadRequest(value),
8651                            _ => common::Error::Failure(response),
8652                        });
8653                    }
8654                    let response = {
8655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8656                        let encoded = common::to_string(&bytes);
8657                        match serde_json::from_str(&encoded) {
8658                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8659                            Err(error) => {
8660                                dlg.response_json_decode_error(&encoded, &error);
8661                                return Err(common::Error::JsonDecodeError(
8662                                    encoded.to_string(),
8663                                    error,
8664                                ));
8665                            }
8666                        }
8667                    };
8668
8669                    dlg.finished(true);
8670                    return Ok(response);
8671                }
8672            }
8673        }
8674    }
8675
8676    /// The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".
8677    ///
8678    /// Sets the *parent* path property to the given value.
8679    ///
8680    /// Even though the property as already been set when instantiating this call,
8681    /// we provide this method for API completeness.
8682    pub fn parent(mut self, new_value: &str) -> ProjectApprovalRequestListCall<'a, C> {
8683        self._parent = new_value.to_string();
8684        self
8685    }
8686    /// A token identifying the page of results to return.
8687    ///
8688    /// Sets the *page token* query property to the given value.
8689    pub fn page_token(mut self, new_value: &str) -> ProjectApprovalRequestListCall<'a, C> {
8690        self._page_token = Some(new_value.to_string());
8691        self
8692    }
8693    /// Requested page size.
8694    ///
8695    /// Sets the *page size* query property to the given value.
8696    pub fn page_size(mut self, new_value: i32) -> ProjectApprovalRequestListCall<'a, C> {
8697        self._page_size = Some(new_value);
8698        self
8699    }
8700    /// A filter on the type of approval requests to retrieve. Must be one of the following values: * [not set]: Requests that are pending or have active approvals. * ALL: All requests. * PENDING: Only pending requests. * ACTIVE: Only active (i.e. currently approved) requests. * DISMISSED: Only requests that have been dismissed, or requests that are not approved and past expiration. * EXPIRED: Only requests that have been approved, and the approval has expired. * HISTORY: Active, dismissed and expired requests.
8701    ///
8702    /// Sets the *filter* query property to the given value.
8703    pub fn filter(mut self, new_value: &str) -> ProjectApprovalRequestListCall<'a, C> {
8704        self._filter = Some(new_value.to_string());
8705        self
8706    }
8707    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8708    /// while executing the actual API request.
8709    ///
8710    /// ````text
8711    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8712    /// ````
8713    ///
8714    /// Sets the *delegate* property to the given value.
8715    pub fn delegate(
8716        mut self,
8717        new_value: &'a mut dyn common::Delegate,
8718    ) -> ProjectApprovalRequestListCall<'a, C> {
8719        self._delegate = Some(new_value);
8720        self
8721    }
8722
8723    /// Set any additional parameter of the query string used in the request.
8724    /// It should be used to set parameters which are not yet available through their own
8725    /// setters.
8726    ///
8727    /// Please note that this method must not be used to set any of the known parameters
8728    /// which have their own setter method. If done anyway, the request will fail.
8729    ///
8730    /// # Additional Parameters
8731    ///
8732    /// * *$.xgafv* (query-string) - V1 error format.
8733    /// * *access_token* (query-string) - OAuth access token.
8734    /// * *alt* (query-string) - Data format for response.
8735    /// * *callback* (query-string) - JSONP
8736    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8737    /// * *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.
8738    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8739    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8740    /// * *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.
8741    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8742    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8743    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestListCall<'a, C>
8744    where
8745        T: AsRef<str>,
8746    {
8747        self._additional_params
8748            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8749        self
8750    }
8751
8752    /// Identifies the authorization scope for the method you are building.
8753    ///
8754    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8755    /// [`Scope::CloudPlatform`].
8756    ///
8757    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8758    /// tokens for more than one scope.
8759    ///
8760    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8761    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8762    /// sufficient, a read-write scope will do as well.
8763    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestListCall<'a, C>
8764    where
8765        St: AsRef<str>,
8766    {
8767        self._scopes.insert(String::from(scope.as_ref()));
8768        self
8769    }
8770    /// Identifies the authorization scope(s) for the method you are building.
8771    ///
8772    /// See [`Self::add_scope()`] for details.
8773    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestListCall<'a, C>
8774    where
8775        I: IntoIterator<Item = St>,
8776        St: AsRef<str>,
8777    {
8778        self._scopes
8779            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8780        self
8781    }
8782
8783    /// Removes all scopes, and no default scope will be used either.
8784    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8785    /// for details).
8786    pub fn clear_scopes(mut self) -> ProjectApprovalRequestListCall<'a, C> {
8787        self._scopes.clear();
8788        self
8789    }
8790}
8791
8792/// Deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the resource. Access Approval may remain active based on parent resource settings. To confirm the effective settings, call GetAccessApprovalSettings and verify effective setting is disabled.
8793///
8794/// A builder for the *deleteAccessApprovalSettings* method supported by a *project* resource.
8795/// It is not used directly, but through a [`ProjectMethods`] instance.
8796///
8797/// # Example
8798///
8799/// Instantiate a resource method builder
8800///
8801/// ```test_harness,no_run
8802/// # extern crate hyper;
8803/// # extern crate hyper_rustls;
8804/// # extern crate google_accessapproval1 as accessapproval1;
8805/// # async fn dox() {
8806/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8807///
8808/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8809/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8810/// #     .with_native_roots()
8811/// #     .unwrap()
8812/// #     .https_only()
8813/// #     .enable_http2()
8814/// #     .build();
8815///
8816/// # let executor = hyper_util::rt::TokioExecutor::new();
8817/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8818/// #     secret,
8819/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8820/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8821/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8822/// #     ),
8823/// # ).build().await.unwrap();
8824///
8825/// # let client = hyper_util::client::legacy::Client::builder(
8826/// #     hyper_util::rt::TokioExecutor::new()
8827/// # )
8828/// # .build(
8829/// #     hyper_rustls::HttpsConnectorBuilder::new()
8830/// #         .with_native_roots()
8831/// #         .unwrap()
8832/// #         .https_or_http()
8833/// #         .enable_http2()
8834/// #         .build()
8835/// # );
8836/// # let mut hub = AccessApproval::new(client, auth);
8837/// // You can configure optional parameters by calling the respective setters at will, and
8838/// // execute the final call using `doit()`.
8839/// // Values shown here are possibly random and not representative !
8840/// let result = hub.projects().delete_access_approval_settings("name")
8841///              .doit().await;
8842/// # }
8843/// ```
8844pub struct ProjectDeleteAccessApprovalSettingCall<'a, C>
8845where
8846    C: 'a,
8847{
8848    hub: &'a AccessApproval<C>,
8849    _name: String,
8850    _delegate: Option<&'a mut dyn common::Delegate>,
8851    _additional_params: HashMap<String, String>,
8852    _scopes: BTreeSet<String>,
8853}
8854
8855impl<'a, C> common::CallBuilder for ProjectDeleteAccessApprovalSettingCall<'a, C> {}
8856
8857impl<'a, C> ProjectDeleteAccessApprovalSettingCall<'a, C>
8858where
8859    C: common::Connector,
8860{
8861    /// Perform the operation you have build so far.
8862    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8863        use std::borrow::Cow;
8864        use std::io::{Read, Seek};
8865
8866        use common::{url::Params, ToParts};
8867        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8868
8869        let mut dd = common::DefaultDelegate;
8870        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8871        dlg.begin(common::MethodInfo {
8872            id: "accessapproval.projects.deleteAccessApprovalSettings",
8873            http_method: hyper::Method::DELETE,
8874        });
8875
8876        for &field in ["alt", "name"].iter() {
8877            if self._additional_params.contains_key(field) {
8878                dlg.finished(false);
8879                return Err(common::Error::FieldClash(field));
8880            }
8881        }
8882
8883        let mut params = Params::with_capacity(3 + self._additional_params.len());
8884        params.push("name", self._name);
8885
8886        params.extend(self._additional_params.iter());
8887
8888        params.push("alt", "json");
8889        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8890        if self._scopes.is_empty() {
8891            self._scopes
8892                .insert(Scope::CloudPlatform.as_ref().to_string());
8893        }
8894
8895        #[allow(clippy::single_element_loop)]
8896        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8897            url = params.uri_replacement(url, param_name, find_this, true);
8898        }
8899        {
8900            let to_remove = ["name"];
8901            params.remove_params(&to_remove);
8902        }
8903
8904        let url = params.parse_with_url(&url);
8905
8906        loop {
8907            let token = match self
8908                .hub
8909                .auth
8910                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8911                .await
8912            {
8913                Ok(token) => token,
8914                Err(e) => match dlg.token(e) {
8915                    Ok(token) => token,
8916                    Err(e) => {
8917                        dlg.finished(false);
8918                        return Err(common::Error::MissingToken(e));
8919                    }
8920                },
8921            };
8922            let mut req_result = {
8923                let client = &self.hub.client;
8924                dlg.pre_request();
8925                let mut req_builder = hyper::Request::builder()
8926                    .method(hyper::Method::DELETE)
8927                    .uri(url.as_str())
8928                    .header(USER_AGENT, self.hub._user_agent.clone());
8929
8930                if let Some(token) = token.as_ref() {
8931                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8932                }
8933
8934                let request = req_builder
8935                    .header(CONTENT_LENGTH, 0_u64)
8936                    .body(common::to_body::<String>(None));
8937
8938                client.request(request.unwrap()).await
8939            };
8940
8941            match req_result {
8942                Err(err) => {
8943                    if let common::Retry::After(d) = dlg.http_error(&err) {
8944                        sleep(d).await;
8945                        continue;
8946                    }
8947                    dlg.finished(false);
8948                    return Err(common::Error::HttpError(err));
8949                }
8950                Ok(res) => {
8951                    let (mut parts, body) = res.into_parts();
8952                    let mut body = common::Body::new(body);
8953                    if !parts.status.is_success() {
8954                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8955                        let error = serde_json::from_str(&common::to_string(&bytes));
8956                        let response = common::to_response(parts, bytes.into());
8957
8958                        if let common::Retry::After(d) =
8959                            dlg.http_failure(&response, error.as_ref().ok())
8960                        {
8961                            sleep(d).await;
8962                            continue;
8963                        }
8964
8965                        dlg.finished(false);
8966
8967                        return Err(match error {
8968                            Ok(value) => common::Error::BadRequest(value),
8969                            _ => common::Error::Failure(response),
8970                        });
8971                    }
8972                    let response = {
8973                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8974                        let encoded = common::to_string(&bytes);
8975                        match serde_json::from_str(&encoded) {
8976                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8977                            Err(error) => {
8978                                dlg.response_json_decode_error(&encoded, &error);
8979                                return Err(common::Error::JsonDecodeError(
8980                                    encoded.to_string(),
8981                                    error,
8982                                ));
8983                            }
8984                        }
8985                    };
8986
8987                    dlg.finished(true);
8988                    return Ok(response);
8989                }
8990            }
8991        }
8992    }
8993
8994    /// Name of the AccessApprovalSettings to delete.
8995    ///
8996    /// Sets the *name* path property to the given value.
8997    ///
8998    /// Even though the property as already been set when instantiating this call,
8999    /// we provide this method for API completeness.
9000    pub fn name(mut self, new_value: &str) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
9001        self._name = new_value.to_string();
9002        self
9003    }
9004    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9005    /// while executing the actual API request.
9006    ///
9007    /// ````text
9008    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9009    /// ````
9010    ///
9011    /// Sets the *delegate* property to the given value.
9012    pub fn delegate(
9013        mut self,
9014        new_value: &'a mut dyn common::Delegate,
9015    ) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
9016        self._delegate = Some(new_value);
9017        self
9018    }
9019
9020    /// Set any additional parameter of the query string used in the request.
9021    /// It should be used to set parameters which are not yet available through their own
9022    /// setters.
9023    ///
9024    /// Please note that this method must not be used to set any of the known parameters
9025    /// which have their own setter method. If done anyway, the request will fail.
9026    ///
9027    /// # Additional Parameters
9028    ///
9029    /// * *$.xgafv* (query-string) - V1 error format.
9030    /// * *access_token* (query-string) - OAuth access token.
9031    /// * *alt* (query-string) - Data format for response.
9032    /// * *callback* (query-string) - JSONP
9033    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9034    /// * *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.
9035    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9036    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9037    /// * *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.
9038    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9039    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9040    pub fn param<T>(mut self, name: T, value: T) -> ProjectDeleteAccessApprovalSettingCall<'a, C>
9041    where
9042        T: AsRef<str>,
9043    {
9044        self._additional_params
9045            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9046        self
9047    }
9048
9049    /// Identifies the authorization scope for the method you are building.
9050    ///
9051    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9052    /// [`Scope::CloudPlatform`].
9053    ///
9054    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9055    /// tokens for more than one scope.
9056    ///
9057    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9058    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9059    /// sufficient, a read-write scope will do as well.
9060    pub fn add_scope<St>(mut self, scope: St) -> ProjectDeleteAccessApprovalSettingCall<'a, C>
9061    where
9062        St: AsRef<str>,
9063    {
9064        self._scopes.insert(String::from(scope.as_ref()));
9065        self
9066    }
9067    /// Identifies the authorization scope(s) for the method you are building.
9068    ///
9069    /// See [`Self::add_scope()`] for details.
9070    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDeleteAccessApprovalSettingCall<'a, C>
9071    where
9072        I: IntoIterator<Item = St>,
9073        St: AsRef<str>,
9074    {
9075        self._scopes
9076            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9077        self
9078    }
9079
9080    /// Removes all scopes, and no default scope will be used either.
9081    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9082    /// for details).
9083    pub fn clear_scopes(mut self) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
9084        self._scopes.clear();
9085        self
9086    }
9087}
9088
9089/// Gets the Access Approval settings associated with a project, folder, or organization.
9090///
9091/// A builder for the *getAccessApprovalSettings* method supported by a *project* resource.
9092/// It is not used directly, but through a [`ProjectMethods`] instance.
9093///
9094/// # Example
9095///
9096/// Instantiate a resource method builder
9097///
9098/// ```test_harness,no_run
9099/// # extern crate hyper;
9100/// # extern crate hyper_rustls;
9101/// # extern crate google_accessapproval1 as accessapproval1;
9102/// # async fn dox() {
9103/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9104///
9105/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9106/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9107/// #     .with_native_roots()
9108/// #     .unwrap()
9109/// #     .https_only()
9110/// #     .enable_http2()
9111/// #     .build();
9112///
9113/// # let executor = hyper_util::rt::TokioExecutor::new();
9114/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9115/// #     secret,
9116/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9117/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9118/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9119/// #     ),
9120/// # ).build().await.unwrap();
9121///
9122/// # let client = hyper_util::client::legacy::Client::builder(
9123/// #     hyper_util::rt::TokioExecutor::new()
9124/// # )
9125/// # .build(
9126/// #     hyper_rustls::HttpsConnectorBuilder::new()
9127/// #         .with_native_roots()
9128/// #         .unwrap()
9129/// #         .https_or_http()
9130/// #         .enable_http2()
9131/// #         .build()
9132/// # );
9133/// # let mut hub = AccessApproval::new(client, auth);
9134/// // You can configure optional parameters by calling the respective setters at will, and
9135/// // execute the final call using `doit()`.
9136/// // Values shown here are possibly random and not representative !
9137/// let result = hub.projects().get_access_approval_settings("name")
9138///              .doit().await;
9139/// # }
9140/// ```
9141pub struct ProjectGetAccessApprovalSettingCall<'a, C>
9142where
9143    C: 'a,
9144{
9145    hub: &'a AccessApproval<C>,
9146    _name: String,
9147    _delegate: Option<&'a mut dyn common::Delegate>,
9148    _additional_params: HashMap<String, String>,
9149    _scopes: BTreeSet<String>,
9150}
9151
9152impl<'a, C> common::CallBuilder for ProjectGetAccessApprovalSettingCall<'a, C> {}
9153
9154impl<'a, C> ProjectGetAccessApprovalSettingCall<'a, C>
9155where
9156    C: common::Connector,
9157{
9158    /// Perform the operation you have build so far.
9159    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
9160        use std::borrow::Cow;
9161        use std::io::{Read, Seek};
9162
9163        use common::{url::Params, ToParts};
9164        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9165
9166        let mut dd = common::DefaultDelegate;
9167        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9168        dlg.begin(common::MethodInfo {
9169            id: "accessapproval.projects.getAccessApprovalSettings",
9170            http_method: hyper::Method::GET,
9171        });
9172
9173        for &field in ["alt", "name"].iter() {
9174            if self._additional_params.contains_key(field) {
9175                dlg.finished(false);
9176                return Err(common::Error::FieldClash(field));
9177            }
9178        }
9179
9180        let mut params = Params::with_capacity(3 + self._additional_params.len());
9181        params.push("name", self._name);
9182
9183        params.extend(self._additional_params.iter());
9184
9185        params.push("alt", "json");
9186        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9187        if self._scopes.is_empty() {
9188            self._scopes
9189                .insert(Scope::CloudPlatform.as_ref().to_string());
9190        }
9191
9192        #[allow(clippy::single_element_loop)]
9193        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9194            url = params.uri_replacement(url, param_name, find_this, true);
9195        }
9196        {
9197            let to_remove = ["name"];
9198            params.remove_params(&to_remove);
9199        }
9200
9201        let url = params.parse_with_url(&url);
9202
9203        loop {
9204            let token = match self
9205                .hub
9206                .auth
9207                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9208                .await
9209            {
9210                Ok(token) => token,
9211                Err(e) => match dlg.token(e) {
9212                    Ok(token) => token,
9213                    Err(e) => {
9214                        dlg.finished(false);
9215                        return Err(common::Error::MissingToken(e));
9216                    }
9217                },
9218            };
9219            let mut req_result = {
9220                let client = &self.hub.client;
9221                dlg.pre_request();
9222                let mut req_builder = hyper::Request::builder()
9223                    .method(hyper::Method::GET)
9224                    .uri(url.as_str())
9225                    .header(USER_AGENT, self.hub._user_agent.clone());
9226
9227                if let Some(token) = token.as_ref() {
9228                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9229                }
9230
9231                let request = req_builder
9232                    .header(CONTENT_LENGTH, 0_u64)
9233                    .body(common::to_body::<String>(None));
9234
9235                client.request(request.unwrap()).await
9236            };
9237
9238            match req_result {
9239                Err(err) => {
9240                    if let common::Retry::After(d) = dlg.http_error(&err) {
9241                        sleep(d).await;
9242                        continue;
9243                    }
9244                    dlg.finished(false);
9245                    return Err(common::Error::HttpError(err));
9246                }
9247                Ok(res) => {
9248                    let (mut parts, body) = res.into_parts();
9249                    let mut body = common::Body::new(body);
9250                    if !parts.status.is_success() {
9251                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9252                        let error = serde_json::from_str(&common::to_string(&bytes));
9253                        let response = common::to_response(parts, bytes.into());
9254
9255                        if let common::Retry::After(d) =
9256                            dlg.http_failure(&response, error.as_ref().ok())
9257                        {
9258                            sleep(d).await;
9259                            continue;
9260                        }
9261
9262                        dlg.finished(false);
9263
9264                        return Err(match error {
9265                            Ok(value) => common::Error::BadRequest(value),
9266                            _ => common::Error::Failure(response),
9267                        });
9268                    }
9269                    let response = {
9270                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9271                        let encoded = common::to_string(&bytes);
9272                        match serde_json::from_str(&encoded) {
9273                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9274                            Err(error) => {
9275                                dlg.response_json_decode_error(&encoded, &error);
9276                                return Err(common::Error::JsonDecodeError(
9277                                    encoded.to_string(),
9278                                    error,
9279                                ));
9280                            }
9281                        }
9282                    };
9283
9284                    dlg.finished(true);
9285                    return Ok(response);
9286                }
9287            }
9288        }
9289    }
9290
9291    /// The name of the AccessApprovalSettings to retrieve. Format: "{projects|folders|organizations}/{id}/accessApprovalSettings"
9292    ///
9293    /// Sets the *name* path property to the given value.
9294    ///
9295    /// Even though the property as already been set when instantiating this call,
9296    /// we provide this method for API completeness.
9297    pub fn name(mut self, new_value: &str) -> ProjectGetAccessApprovalSettingCall<'a, C> {
9298        self._name = new_value.to_string();
9299        self
9300    }
9301    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9302    /// while executing the actual API request.
9303    ///
9304    /// ````text
9305    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9306    /// ````
9307    ///
9308    /// Sets the *delegate* property to the given value.
9309    pub fn delegate(
9310        mut self,
9311        new_value: &'a mut dyn common::Delegate,
9312    ) -> ProjectGetAccessApprovalSettingCall<'a, C> {
9313        self._delegate = Some(new_value);
9314        self
9315    }
9316
9317    /// Set any additional parameter of the query string used in the request.
9318    /// It should be used to set parameters which are not yet available through their own
9319    /// setters.
9320    ///
9321    /// Please note that this method must not be used to set any of the known parameters
9322    /// which have their own setter method. If done anyway, the request will fail.
9323    ///
9324    /// # Additional Parameters
9325    ///
9326    /// * *$.xgafv* (query-string) - V1 error format.
9327    /// * *access_token* (query-string) - OAuth access token.
9328    /// * *alt* (query-string) - Data format for response.
9329    /// * *callback* (query-string) - JSONP
9330    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9331    /// * *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.
9332    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9333    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9334    /// * *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.
9335    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9336    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9337    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetAccessApprovalSettingCall<'a, C>
9338    where
9339        T: AsRef<str>,
9340    {
9341        self._additional_params
9342            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9343        self
9344    }
9345
9346    /// Identifies the authorization scope for the method you are building.
9347    ///
9348    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9349    /// [`Scope::CloudPlatform`].
9350    ///
9351    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9352    /// tokens for more than one scope.
9353    ///
9354    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9355    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9356    /// sufficient, a read-write scope will do as well.
9357    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetAccessApprovalSettingCall<'a, C>
9358    where
9359        St: AsRef<str>,
9360    {
9361        self._scopes.insert(String::from(scope.as_ref()));
9362        self
9363    }
9364    /// Identifies the authorization scope(s) for the method you are building.
9365    ///
9366    /// See [`Self::add_scope()`] for details.
9367    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetAccessApprovalSettingCall<'a, C>
9368    where
9369        I: IntoIterator<Item = St>,
9370        St: AsRef<str>,
9371    {
9372        self._scopes
9373            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9374        self
9375    }
9376
9377    /// Removes all scopes, and no default scope will be used either.
9378    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9379    /// for details).
9380    pub fn clear_scopes(mut self) -> ProjectGetAccessApprovalSettingCall<'a, C> {
9381        self._scopes.clear();
9382        self
9383    }
9384}
9385
9386/// Retrieves the service account that is used by Access Approval to access KMS keys for signing approved approval requests.
9387///
9388/// A builder for the *getServiceAccount* method supported by a *project* resource.
9389/// It is not used directly, but through a [`ProjectMethods`] instance.
9390///
9391/// # Example
9392///
9393/// Instantiate a resource method builder
9394///
9395/// ```test_harness,no_run
9396/// # extern crate hyper;
9397/// # extern crate hyper_rustls;
9398/// # extern crate google_accessapproval1 as accessapproval1;
9399/// # async fn dox() {
9400/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9401///
9402/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9403/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9404/// #     .with_native_roots()
9405/// #     .unwrap()
9406/// #     .https_only()
9407/// #     .enable_http2()
9408/// #     .build();
9409///
9410/// # let executor = hyper_util::rt::TokioExecutor::new();
9411/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9412/// #     secret,
9413/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9414/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9415/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9416/// #     ),
9417/// # ).build().await.unwrap();
9418///
9419/// # let client = hyper_util::client::legacy::Client::builder(
9420/// #     hyper_util::rt::TokioExecutor::new()
9421/// # )
9422/// # .build(
9423/// #     hyper_rustls::HttpsConnectorBuilder::new()
9424/// #         .with_native_roots()
9425/// #         .unwrap()
9426/// #         .https_or_http()
9427/// #         .enable_http2()
9428/// #         .build()
9429/// # );
9430/// # let mut hub = AccessApproval::new(client, auth);
9431/// // You can configure optional parameters by calling the respective setters at will, and
9432/// // execute the final call using `doit()`.
9433/// // Values shown here are possibly random and not representative !
9434/// let result = hub.projects().get_service_account("name")
9435///              .doit().await;
9436/// # }
9437/// ```
9438pub struct ProjectGetServiceAccountCall<'a, C>
9439where
9440    C: 'a,
9441{
9442    hub: &'a AccessApproval<C>,
9443    _name: String,
9444    _delegate: Option<&'a mut dyn common::Delegate>,
9445    _additional_params: HashMap<String, String>,
9446    _scopes: BTreeSet<String>,
9447}
9448
9449impl<'a, C> common::CallBuilder for ProjectGetServiceAccountCall<'a, C> {}
9450
9451impl<'a, C> ProjectGetServiceAccountCall<'a, C>
9452where
9453    C: common::Connector,
9454{
9455    /// Perform the operation you have build so far.
9456    pub async fn doit(
9457        mut self,
9458    ) -> common::Result<(common::Response, AccessApprovalServiceAccount)> {
9459        use std::borrow::Cow;
9460        use std::io::{Read, Seek};
9461
9462        use common::{url::Params, ToParts};
9463        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9464
9465        let mut dd = common::DefaultDelegate;
9466        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9467        dlg.begin(common::MethodInfo {
9468            id: "accessapproval.projects.getServiceAccount",
9469            http_method: hyper::Method::GET,
9470        });
9471
9472        for &field in ["alt", "name"].iter() {
9473            if self._additional_params.contains_key(field) {
9474                dlg.finished(false);
9475                return Err(common::Error::FieldClash(field));
9476            }
9477        }
9478
9479        let mut params = Params::with_capacity(3 + self._additional_params.len());
9480        params.push("name", self._name);
9481
9482        params.extend(self._additional_params.iter());
9483
9484        params.push("alt", "json");
9485        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9486        if self._scopes.is_empty() {
9487            self._scopes
9488                .insert(Scope::CloudPlatform.as_ref().to_string());
9489        }
9490
9491        #[allow(clippy::single_element_loop)]
9492        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9493            url = params.uri_replacement(url, param_name, find_this, true);
9494        }
9495        {
9496            let to_remove = ["name"];
9497            params.remove_params(&to_remove);
9498        }
9499
9500        let url = params.parse_with_url(&url);
9501
9502        loop {
9503            let token = match self
9504                .hub
9505                .auth
9506                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9507                .await
9508            {
9509                Ok(token) => token,
9510                Err(e) => match dlg.token(e) {
9511                    Ok(token) => token,
9512                    Err(e) => {
9513                        dlg.finished(false);
9514                        return Err(common::Error::MissingToken(e));
9515                    }
9516                },
9517            };
9518            let mut req_result = {
9519                let client = &self.hub.client;
9520                dlg.pre_request();
9521                let mut req_builder = hyper::Request::builder()
9522                    .method(hyper::Method::GET)
9523                    .uri(url.as_str())
9524                    .header(USER_AGENT, self.hub._user_agent.clone());
9525
9526                if let Some(token) = token.as_ref() {
9527                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9528                }
9529
9530                let request = req_builder
9531                    .header(CONTENT_LENGTH, 0_u64)
9532                    .body(common::to_body::<String>(None));
9533
9534                client.request(request.unwrap()).await
9535            };
9536
9537            match req_result {
9538                Err(err) => {
9539                    if let common::Retry::After(d) = dlg.http_error(&err) {
9540                        sleep(d).await;
9541                        continue;
9542                    }
9543                    dlg.finished(false);
9544                    return Err(common::Error::HttpError(err));
9545                }
9546                Ok(res) => {
9547                    let (mut parts, body) = res.into_parts();
9548                    let mut body = common::Body::new(body);
9549                    if !parts.status.is_success() {
9550                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9551                        let error = serde_json::from_str(&common::to_string(&bytes));
9552                        let response = common::to_response(parts, bytes.into());
9553
9554                        if let common::Retry::After(d) =
9555                            dlg.http_failure(&response, error.as_ref().ok())
9556                        {
9557                            sleep(d).await;
9558                            continue;
9559                        }
9560
9561                        dlg.finished(false);
9562
9563                        return Err(match error {
9564                            Ok(value) => common::Error::BadRequest(value),
9565                            _ => common::Error::Failure(response),
9566                        });
9567                    }
9568                    let response = {
9569                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9570                        let encoded = common::to_string(&bytes);
9571                        match serde_json::from_str(&encoded) {
9572                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9573                            Err(error) => {
9574                                dlg.response_json_decode_error(&encoded, &error);
9575                                return Err(common::Error::JsonDecodeError(
9576                                    encoded.to_string(),
9577                                    error,
9578                                ));
9579                            }
9580                        }
9581                    };
9582
9583                    dlg.finished(true);
9584                    return Ok(response);
9585                }
9586            }
9587        }
9588    }
9589
9590    /// Name of the AccessApprovalServiceAccount to retrieve.
9591    ///
9592    /// Sets the *name* path property to the given value.
9593    ///
9594    /// Even though the property as already been set when instantiating this call,
9595    /// we provide this method for API completeness.
9596    pub fn name(mut self, new_value: &str) -> ProjectGetServiceAccountCall<'a, C> {
9597        self._name = new_value.to_string();
9598        self
9599    }
9600    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9601    /// while executing the actual API request.
9602    ///
9603    /// ````text
9604    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9605    /// ````
9606    ///
9607    /// Sets the *delegate* property to the given value.
9608    pub fn delegate(
9609        mut self,
9610        new_value: &'a mut dyn common::Delegate,
9611    ) -> ProjectGetServiceAccountCall<'a, C> {
9612        self._delegate = Some(new_value);
9613        self
9614    }
9615
9616    /// Set any additional parameter of the query string used in the request.
9617    /// It should be used to set parameters which are not yet available through their own
9618    /// setters.
9619    ///
9620    /// Please note that this method must not be used to set any of the known parameters
9621    /// which have their own setter method. If done anyway, the request will fail.
9622    ///
9623    /// # Additional Parameters
9624    ///
9625    /// * *$.xgafv* (query-string) - V1 error format.
9626    /// * *access_token* (query-string) - OAuth access token.
9627    /// * *alt* (query-string) - Data format for response.
9628    /// * *callback* (query-string) - JSONP
9629    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9630    /// * *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.
9631    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9632    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9633    /// * *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.
9634    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9635    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9636    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetServiceAccountCall<'a, C>
9637    where
9638        T: AsRef<str>,
9639    {
9640        self._additional_params
9641            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9642        self
9643    }
9644
9645    /// Identifies the authorization scope for the method you are building.
9646    ///
9647    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9648    /// [`Scope::CloudPlatform`].
9649    ///
9650    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9651    /// tokens for more than one scope.
9652    ///
9653    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9654    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9655    /// sufficient, a read-write scope will do as well.
9656    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetServiceAccountCall<'a, C>
9657    where
9658        St: AsRef<str>,
9659    {
9660        self._scopes.insert(String::from(scope.as_ref()));
9661        self
9662    }
9663    /// Identifies the authorization scope(s) for the method you are building.
9664    ///
9665    /// See [`Self::add_scope()`] for details.
9666    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetServiceAccountCall<'a, C>
9667    where
9668        I: IntoIterator<Item = St>,
9669        St: AsRef<str>,
9670    {
9671        self._scopes
9672            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9673        self
9674    }
9675
9676    /// Removes all scopes, and no default scope will be used either.
9677    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9678    /// for details).
9679    pub fn clear_scopes(mut self) -> ProjectGetServiceAccountCall<'a, C> {
9680        self._scopes.clear();
9681        self
9682    }
9683}
9684
9685/// Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.
9686///
9687/// A builder for the *updateAccessApprovalSettings* method supported by a *project* resource.
9688/// It is not used directly, but through a [`ProjectMethods`] instance.
9689///
9690/// # Example
9691///
9692/// Instantiate a resource method builder
9693///
9694/// ```test_harness,no_run
9695/// # extern crate hyper;
9696/// # extern crate hyper_rustls;
9697/// # extern crate google_accessapproval1 as accessapproval1;
9698/// use accessapproval1::api::AccessApprovalSettings;
9699/// # async fn dox() {
9700/// # use accessapproval1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9701///
9702/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9703/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9704/// #     .with_native_roots()
9705/// #     .unwrap()
9706/// #     .https_only()
9707/// #     .enable_http2()
9708/// #     .build();
9709///
9710/// # let executor = hyper_util::rt::TokioExecutor::new();
9711/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9712/// #     secret,
9713/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9714/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9715/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9716/// #     ),
9717/// # ).build().await.unwrap();
9718///
9719/// # let client = hyper_util::client::legacy::Client::builder(
9720/// #     hyper_util::rt::TokioExecutor::new()
9721/// # )
9722/// # .build(
9723/// #     hyper_rustls::HttpsConnectorBuilder::new()
9724/// #         .with_native_roots()
9725/// #         .unwrap()
9726/// #         .https_or_http()
9727/// #         .enable_http2()
9728/// #         .build()
9729/// # );
9730/// # let mut hub = AccessApproval::new(client, auth);
9731/// // As the method needs a request, you would usually fill it with the desired information
9732/// // into the respective structure. Some of the parts shown here might not be applicable !
9733/// // Values shown here are possibly random and not representative !
9734/// let mut req = AccessApprovalSettings::default();
9735///
9736/// // You can configure optional parameters by calling the respective setters at will, and
9737/// // execute the final call using `doit()`.
9738/// // Values shown here are possibly random and not representative !
9739/// let result = hub.projects().update_access_approval_settings(req, "name")
9740///              .update_mask(FieldMask::new::<&str>(&[]))
9741///              .doit().await;
9742/// # }
9743/// ```
9744pub struct ProjectUpdateAccessApprovalSettingCall<'a, C>
9745where
9746    C: 'a,
9747{
9748    hub: &'a AccessApproval<C>,
9749    _request: AccessApprovalSettings,
9750    _name: String,
9751    _update_mask: Option<common::FieldMask>,
9752    _delegate: Option<&'a mut dyn common::Delegate>,
9753    _additional_params: HashMap<String, String>,
9754    _scopes: BTreeSet<String>,
9755}
9756
9757impl<'a, C> common::CallBuilder for ProjectUpdateAccessApprovalSettingCall<'a, C> {}
9758
9759impl<'a, C> ProjectUpdateAccessApprovalSettingCall<'a, C>
9760where
9761    C: common::Connector,
9762{
9763    /// Perform the operation you have build so far.
9764    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
9765        use std::borrow::Cow;
9766        use std::io::{Read, Seek};
9767
9768        use common::{url::Params, ToParts};
9769        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9770
9771        let mut dd = common::DefaultDelegate;
9772        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9773        dlg.begin(common::MethodInfo {
9774            id: "accessapproval.projects.updateAccessApprovalSettings",
9775            http_method: hyper::Method::PATCH,
9776        });
9777
9778        for &field in ["alt", "name", "updateMask"].iter() {
9779            if self._additional_params.contains_key(field) {
9780                dlg.finished(false);
9781                return Err(common::Error::FieldClash(field));
9782            }
9783        }
9784
9785        let mut params = Params::with_capacity(5 + self._additional_params.len());
9786        params.push("name", self._name);
9787        if let Some(value) = self._update_mask.as_ref() {
9788            params.push("updateMask", value.to_string());
9789        }
9790
9791        params.extend(self._additional_params.iter());
9792
9793        params.push("alt", "json");
9794        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9795        if self._scopes.is_empty() {
9796            self._scopes
9797                .insert(Scope::CloudPlatform.as_ref().to_string());
9798        }
9799
9800        #[allow(clippy::single_element_loop)]
9801        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9802            url = params.uri_replacement(url, param_name, find_this, true);
9803        }
9804        {
9805            let to_remove = ["name"];
9806            params.remove_params(&to_remove);
9807        }
9808
9809        let url = params.parse_with_url(&url);
9810
9811        let mut json_mime_type = mime::APPLICATION_JSON;
9812        let mut request_value_reader = {
9813            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9814            common::remove_json_null_values(&mut value);
9815            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9816            serde_json::to_writer(&mut dst, &value).unwrap();
9817            dst
9818        };
9819        let request_size = request_value_reader
9820            .seek(std::io::SeekFrom::End(0))
9821            .unwrap();
9822        request_value_reader
9823            .seek(std::io::SeekFrom::Start(0))
9824            .unwrap();
9825
9826        loop {
9827            let token = match self
9828                .hub
9829                .auth
9830                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9831                .await
9832            {
9833                Ok(token) => token,
9834                Err(e) => match dlg.token(e) {
9835                    Ok(token) => token,
9836                    Err(e) => {
9837                        dlg.finished(false);
9838                        return Err(common::Error::MissingToken(e));
9839                    }
9840                },
9841            };
9842            request_value_reader
9843                .seek(std::io::SeekFrom::Start(0))
9844                .unwrap();
9845            let mut req_result = {
9846                let client = &self.hub.client;
9847                dlg.pre_request();
9848                let mut req_builder = hyper::Request::builder()
9849                    .method(hyper::Method::PATCH)
9850                    .uri(url.as_str())
9851                    .header(USER_AGENT, self.hub._user_agent.clone());
9852
9853                if let Some(token) = token.as_ref() {
9854                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9855                }
9856
9857                let request = req_builder
9858                    .header(CONTENT_TYPE, json_mime_type.to_string())
9859                    .header(CONTENT_LENGTH, request_size as u64)
9860                    .body(common::to_body(
9861                        request_value_reader.get_ref().clone().into(),
9862                    ));
9863
9864                client.request(request.unwrap()).await
9865            };
9866
9867            match req_result {
9868                Err(err) => {
9869                    if let common::Retry::After(d) = dlg.http_error(&err) {
9870                        sleep(d).await;
9871                        continue;
9872                    }
9873                    dlg.finished(false);
9874                    return Err(common::Error::HttpError(err));
9875                }
9876                Ok(res) => {
9877                    let (mut parts, body) = res.into_parts();
9878                    let mut body = common::Body::new(body);
9879                    if !parts.status.is_success() {
9880                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9881                        let error = serde_json::from_str(&common::to_string(&bytes));
9882                        let response = common::to_response(parts, bytes.into());
9883
9884                        if let common::Retry::After(d) =
9885                            dlg.http_failure(&response, error.as_ref().ok())
9886                        {
9887                            sleep(d).await;
9888                            continue;
9889                        }
9890
9891                        dlg.finished(false);
9892
9893                        return Err(match error {
9894                            Ok(value) => common::Error::BadRequest(value),
9895                            _ => common::Error::Failure(response),
9896                        });
9897                    }
9898                    let response = {
9899                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9900                        let encoded = common::to_string(&bytes);
9901                        match serde_json::from_str(&encoded) {
9902                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9903                            Err(error) => {
9904                                dlg.response_json_decode_error(&encoded, &error);
9905                                return Err(common::Error::JsonDecodeError(
9906                                    encoded.to_string(),
9907                                    error,
9908                                ));
9909                            }
9910                        }
9911                    };
9912
9913                    dlg.finished(true);
9914                    return Ok(response);
9915                }
9916            }
9917        }
9918    }
9919
9920    ///
9921    /// Sets the *request* property to the given value.
9922    ///
9923    /// Even though the property as already been set when instantiating this call,
9924    /// we provide this method for API completeness.
9925    pub fn request(
9926        mut self,
9927        new_value: AccessApprovalSettings,
9928    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
9929        self._request = new_value;
9930        self
9931    }
9932    /// The resource name of the settings. Format is one of: * "projects/{project}/accessApprovalSettings" * "folders/{folder}/accessApprovalSettings" * "organizations/{organization}/accessApprovalSettings"
9933    ///
9934    /// Sets the *name* path property to the given value.
9935    ///
9936    /// Even though the property as already been set when instantiating this call,
9937    /// we provide this method for API completeness.
9938    pub fn name(mut self, new_value: &str) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
9939        self._name = new_value.to_string();
9940        self
9941    }
9942    /// The update mask applies to the settings. Only the top level fields of AccessApprovalSettings (notification_emails & enrolled_services) are supported. For each field, if it is included, the currently stored value will be entirely overwritten with the value of the field passed in this request. For the `FieldMask` definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask If this field is left unset, only the notification_emails field will be updated.
9943    ///
9944    /// Sets the *update mask* query property to the given value.
9945    pub fn update_mask(
9946        mut self,
9947        new_value: common::FieldMask,
9948    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
9949        self._update_mask = Some(new_value);
9950        self
9951    }
9952    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9953    /// while executing the actual API request.
9954    ///
9955    /// ````text
9956    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9957    /// ````
9958    ///
9959    /// Sets the *delegate* property to the given value.
9960    pub fn delegate(
9961        mut self,
9962        new_value: &'a mut dyn common::Delegate,
9963    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
9964        self._delegate = Some(new_value);
9965        self
9966    }
9967
9968    /// Set any additional parameter of the query string used in the request.
9969    /// It should be used to set parameters which are not yet available through their own
9970    /// setters.
9971    ///
9972    /// Please note that this method must not be used to set any of the known parameters
9973    /// which have their own setter method. If done anyway, the request will fail.
9974    ///
9975    /// # Additional Parameters
9976    ///
9977    /// * *$.xgafv* (query-string) - V1 error format.
9978    /// * *access_token* (query-string) - OAuth access token.
9979    /// * *alt* (query-string) - Data format for response.
9980    /// * *callback* (query-string) - JSONP
9981    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9982    /// * *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.
9983    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9984    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9985    /// * *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.
9986    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9987    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9988    pub fn param<T>(mut self, name: T, value: T) -> ProjectUpdateAccessApprovalSettingCall<'a, C>
9989    where
9990        T: AsRef<str>,
9991    {
9992        self._additional_params
9993            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9994        self
9995    }
9996
9997    /// Identifies the authorization scope for the method you are building.
9998    ///
9999    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10000    /// [`Scope::CloudPlatform`].
10001    ///
10002    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10003    /// tokens for more than one scope.
10004    ///
10005    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10006    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10007    /// sufficient, a read-write scope will do as well.
10008    pub fn add_scope<St>(mut self, scope: St) -> ProjectUpdateAccessApprovalSettingCall<'a, C>
10009    where
10010        St: AsRef<str>,
10011    {
10012        self._scopes.insert(String::from(scope.as_ref()));
10013        self
10014    }
10015    /// Identifies the authorization scope(s) for the method you are building.
10016    ///
10017    /// See [`Self::add_scope()`] for details.
10018    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUpdateAccessApprovalSettingCall<'a, C>
10019    where
10020        I: IntoIterator<Item = St>,
10021        St: AsRef<str>,
10022    {
10023        self._scopes
10024            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10025        self
10026    }
10027
10028    /// Removes all scopes, and no default scope will be used either.
10029    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10030    /// for details).
10031    pub fn clear_scopes(mut self) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
10032        self._scopes.clear();
10033        self
10034    }
10035}