google_accessapproval1_beta1/
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    /// View and manage your data across Google Cloud Platform services
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_beta1 as accessapproval1_beta1;
49/// use accessapproval1_beta1::api::ApproveApprovalRequestMessage;
50/// use accessapproval1_beta1::{Result, Error};
51/// # async fn dox() {
52/// use accessapproval1_beta1::{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/// Settings on a Project/Folder/Organization related to Access Approval.
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 access approval settings folders](FolderGetAccessApprovalSettingCall) (response)
191/// * [update access approval settings folders](FolderUpdateAccessApprovalSettingCall) (request|response)
192/// * [get access approval settings organizations](OrganizationGetAccessApprovalSettingCall) (response)
193/// * [update access approval settings organizations](OrganizationUpdateAccessApprovalSettingCall) (request|response)
194/// * [get access approval settings projects](ProjectGetAccessApprovalSettingCall) (response)
195/// * [update access approval settings projects](ProjectUpdateAccessApprovalSettingCall) (request|response)
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct AccessApprovalSettings {
200    /// Output only. This field is read only (not settable via
201    /// UpdateAccessAccessApprovalSettings method). If the field is true, that
202    /// indicates that at least one service is enrolled for Access Approval in one
203    /// or more ancestors of the Project or Folder (this field will always be
204    /// unset for the organization since organizations do not have ancestors).
205    #[serde(rename = "enrolledAncestor")]
206    pub enrolled_ancestor: Option<bool>,
207    /// A list of Google Cloud Services for which the given resource has Access
208    /// Approval enrolled. Access requests for the resource given by name against
209    /// any of these services contained here will be required to have explicit
210    /// approval. If name refers to an organization, enrollment can be done for
211    /// individual services. If name refers to a folder or project, enrollment can
212    /// only be done on an all or nothing basis.
213    ///
214    /// If a cloud_product is repeated in this list, the first entry will be
215    /// honored and all following entries will be discarded. A maximum of 10
216    /// enrolled services will be enforced, to be expanded as the set of supported
217    /// services is expanded.
218    #[serde(rename = "enrolledServices")]
219    pub enrolled_services: Option<Vec<EnrolledService>>,
220    /// The resource name of the settings. Format is one of:
221    /// <ol>
222    ///   <li>"projects/{project_id}/accessApprovalSettings"</li>
223    ///   <li>"folders/{folder_id}/accessApprovalSettings"</li>
224    ///   <li>"organizations/{organization_id}/accessApprovalSettings"</li>
225    /// <ol>
226    pub name: Option<String>,
227    /// A list of email addresses to which notifications relating to approval
228    /// requests should be sent. Notifications relating to a resource will be sent
229    /// to all emails in the settings of ancestor resources of that resource. A
230    /// maximum of 50 email addresses are allowed.
231    #[serde(rename = "notificationEmails")]
232    pub notification_emails: Option<Vec<String>>,
233}
234
235impl common::RequestValue for AccessApprovalSettings {}
236impl common::ResponseResult for AccessApprovalSettings {}
237
238/// Home office and physical location of the principal.
239///
240/// This type is not used in any activity, and only used as *part* of another schema.
241///
242#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
243#[serde_with::serde_as]
244#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
245pub struct AccessLocations {
246    /// The "home office" location of the principal. A two-letter country code
247    /// (ISO 3166-1 alpha-2), such as "US", "DE" or "GB" or a region code. In some
248    /// limited situations Google systems may refer refer to a region code instead
249    /// of a country code.
250    /// Possible Region Codes:
251    /// <ol>
252    ///   <li>ASI: Asia</li>
253    ///   <li>EUR: Europe</li>
254    ///   <li>OCE: Oceania</li>
255    ///   <li>AFR: Africa</li>
256    ///   <li>NAM: North America</li>
257    ///   <li>SAM: South America</li>
258    ///   <li>ANT: Antarctica</li>
259    ///   <li>ANY: Any location</li>
260    /// </ol>
261    #[serde(rename = "principalOfficeCountry")]
262    pub principal_office_country: Option<String>,
263    /// Physical location of the principal at the time of the access. A
264    /// two-letter country code (ISO 3166-1 alpha-2), such as "US", "DE" or "GB" or
265    /// a region code. In some limited situations Google systems may refer refer to
266    /// a region code instead of a country code.
267    /// Possible Region Codes:
268    /// <ol>
269    ///   <li>ASI: Asia</li>
270    ///   <li>EUR: Europe</li>
271    ///   <li>OCE: Oceania</li>
272    ///   <li>AFR: Africa</li>
273    ///   <li>NAM: North America</li>
274    ///   <li>SAM: South America</li>
275    ///   <li>ANT: Antarctica</li>
276    ///   <li>ANY: Any location</li>
277    /// </ol>
278    #[serde(rename = "principalPhysicalLocationCountry")]
279    pub principal_physical_location_country: Option<String>,
280}
281
282impl common::Part for AccessLocations {}
283
284/// There is no detailed description.
285///
286/// This type is not used in any activity, and only used as *part* of another schema.
287///
288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
289#[serde_with::serde_as]
290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
291pub struct AccessReason {
292    /// More detail about certain reason types. See comments for each type above.
293    pub detail: Option<String>,
294    /// Type of access justification.
295    #[serde(rename = "type")]
296    pub type_: Option<String>,
297}
298
299impl common::Part for AccessReason {}
300
301/// A request for the customer to approve access to a resource.
302///
303/// # Activities
304///
305/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
306/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
307///
308/// * [approval requests approve folders](FolderApprovalRequestApproveCall) (response)
309/// * [approval requests dismiss folders](FolderApprovalRequestDismisCall) (response)
310/// * [approval requests get folders](FolderApprovalRequestGetCall) (response)
311/// * [approval requests approve organizations](OrganizationApprovalRequestApproveCall) (response)
312/// * [approval requests dismiss organizations](OrganizationApprovalRequestDismisCall) (response)
313/// * [approval requests get organizations](OrganizationApprovalRequestGetCall) (response)
314/// * [approval requests approve projects](ProjectApprovalRequestApproveCall) (response)
315/// * [approval requests dismiss projects](ProjectApprovalRequestDismisCall) (response)
316/// * [approval requests get projects](ProjectApprovalRequestGetCall) (response)
317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
318#[serde_with::serde_as]
319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
320pub struct ApprovalRequest {
321    /// Access was approved.
322    pub approve: Option<ApproveDecision>,
323    /// The request was dismissed.
324    pub dismiss: Option<DismissDecision>,
325    /// The resource name of the request. Format is
326    /// "{projects|folders|organizations}/{id}/approvalRequests/{approval_request_id}".
327    pub name: Option<String>,
328    /// The time at which approval was requested.
329    #[serde(rename = "requestTime")]
330    pub request_time: Option<chrono::DateTime<chrono::offset::Utc>>,
331    /// The requested expiration for the approval. If the request is approved,
332    /// access will be granted from the time of approval until the expiration time.
333    #[serde(rename = "requestedExpiration")]
334    pub requested_expiration: Option<chrono::DateTime<chrono::offset::Utc>>,
335    /// The locations for which approval is being requested.
336    #[serde(rename = "requestedLocations")]
337    pub requested_locations: Option<AccessLocations>,
338    /// The justification for which approval is being requested.
339    #[serde(rename = "requestedReason")]
340    pub requested_reason: Option<AccessReason>,
341    /// The resource for which approval is being requested. The format of the
342    /// resource name is defined at
343    /// https://cloud.google.com/apis/design/resource_names. The resource name here
344    /// may either be a "full" resource name (e.g.
345    /// "//library.googleapis.com/shelves/shelf1/books/book2") or a "relative"
346    /// resource name (e.g. "shelves/shelf1/books/book2") as described in the
347    /// resource name specification.
348    #[serde(rename = "requestedResourceName")]
349    pub requested_resource_name: Option<String>,
350    /// Properties related to the resource represented by requested_resource_name.
351    #[serde(rename = "requestedResourceProperties")]
352    pub requested_resource_properties: Option<ResourceProperties>,
353}
354
355impl common::ResponseResult for ApprovalRequest {}
356
357/// Request to approve an ApprovalRequest.
358///
359/// # Activities
360///
361/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
362/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
363///
364/// * [approval requests approve folders](FolderApprovalRequestApproveCall) (request)
365/// * [approval requests approve organizations](OrganizationApprovalRequestApproveCall) (request)
366/// * [approval requests approve projects](ProjectApprovalRequestApproveCall) (request)
367#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
368#[serde_with::serde_as]
369#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
370pub struct ApproveApprovalRequestMessage {
371    /// The expiration time of this approval.
372    #[serde(rename = "expireTime")]
373    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
374}
375
376impl common::RequestValue for ApproveApprovalRequestMessage {}
377
378/// A decision that has been made to approve access to a resource.
379///
380/// This type is not used in any activity, and only used as *part* of another schema.
381///
382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
383#[serde_with::serde_as]
384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
385pub struct ApproveDecision {
386    /// The time at which approval was granted.
387    #[serde(rename = "approveTime")]
388    pub approve_time: Option<chrono::DateTime<chrono::offset::Utc>>,
389    /// The time at which the approval expires.
390    #[serde(rename = "expireTime")]
391    pub expire_time: Option<chrono::DateTime<chrono::offset::Utc>>,
392}
393
394impl common::Part for ApproveDecision {}
395
396/// Request to dismiss an approval request.
397///
398/// # Activities
399///
400/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
401/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
402///
403/// * [approval requests dismiss folders](FolderApprovalRequestDismisCall) (request)
404/// * [approval requests dismiss organizations](OrganizationApprovalRequestDismisCall) (request)
405/// * [approval requests dismiss projects](ProjectApprovalRequestDismisCall) (request)
406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
407#[serde_with::serde_as]
408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
409pub struct DismissApprovalRequestMessage {
410    _never_set: Option<bool>,
411}
412
413impl common::RequestValue for DismissApprovalRequestMessage {}
414
415/// A decision that has been made to dismiss an approval request.
416///
417/// This type is not used in any activity, and only used as *part* of another schema.
418///
419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
420#[serde_with::serde_as]
421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
422pub struct DismissDecision {
423    /// The time at which the approval request was dismissed.
424    #[serde(rename = "dismissTime")]
425    pub dismiss_time: Option<chrono::DateTime<chrono::offset::Utc>>,
426}
427
428impl common::Part for DismissDecision {}
429
430/// A generic empty message that you can re-use to avoid defining duplicated
431/// empty messages in your APIs. A typical example is to use it as the request
432/// or the response type of an API method. For instance:
433///
434/// ````text
435/// service Foo {
436///   rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
437/// }
438/// ````
439///
440/// The JSON representation for `Empty` is empty JSON object `{}`.
441///
442/// # Activities
443///
444/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
445/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
446///
447/// * [delete access approval settings folders](FolderDeleteAccessApprovalSettingCall) (response)
448/// * [delete access approval settings organizations](OrganizationDeleteAccessApprovalSettingCall) (response)
449/// * [delete access approval settings projects](ProjectDeleteAccessApprovalSettingCall) (response)
450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
451#[serde_with::serde_as]
452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
453pub struct Empty {
454    _never_set: Option<bool>,
455}
456
457impl common::ResponseResult for Empty {}
458
459/// Represents the enrollment of a cloud resource into a specific service.
460///
461/// This type is not used in any activity, and only used as *part* of another schema.
462///
463#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
464#[serde_with::serde_as]
465#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
466pub struct EnrolledService {
467    /// The product for which Access Approval will be enrolled. Allowed values are
468    /// listed below (case-sensitive):
469    /// <ol>
470    ///   <li>all</li>
471    ///   <li>appengine.googleapis.com</li>
472    ///   <li>bigquery.googleapis.com</li>
473    ///   <li>bigtable.googleapis.com</li>
474    ///   <li>cloudkms.googleapis.com</li>
475    ///   <li>compute.googleapis.com</li>
476    ///   <li>dataflow.googleapis.com</li>
477    ///   <li>iam.googleapis.com</li>
478    ///   <li>pubsub.googleapis.com</li>
479    ///   <li>storage.googleapis.com</li>
480    /// <ol>
481    #[serde(rename = "cloudProduct")]
482    pub cloud_product: Option<String>,
483    /// The enrollment level of the service.
484    #[serde(rename = "enrollmentLevel")]
485    pub enrollment_level: Option<String>,
486}
487
488impl common::Part for EnrolledService {}
489
490/// Response to listing of ApprovalRequest objects.
491///
492/// # Activities
493///
494/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
495/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
496///
497/// * [approval requests list folders](FolderApprovalRequestListCall) (response)
498/// * [approval requests list organizations](OrganizationApprovalRequestListCall) (response)
499/// * [approval requests list projects](ProjectApprovalRequestListCall) (response)
500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
501#[serde_with::serde_as]
502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
503pub struct ListApprovalRequestsResponse {
504    /// Approval request details.
505    #[serde(rename = "approvalRequests")]
506    pub approval_requests: Option<Vec<ApprovalRequest>>,
507    /// Token to retrieve the next page of results, or empty if there are no more.
508    #[serde(rename = "nextPageToken")]
509    pub next_page_token: Option<String>,
510}
511
512impl common::ResponseResult for ListApprovalRequestsResponse {}
513
514/// The properties associated with the resource of the request.
515///
516/// This type is not used in any activity, and only used as *part* of another schema.
517///
518#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
519#[serde_with::serde_as]
520#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
521pub struct ResourceProperties {
522    /// Whether an approval will exclude the descendants of the resource being
523    /// requested.
524    #[serde(rename = "excludesDescendants")]
525    pub excludes_descendants: Option<bool>,
526}
527
528impl common::Part for ResourceProperties {}
529
530// ###################
531// MethodBuilders ###
532// #################
533
534/// A builder providing access to all methods supported on *folder* resources.
535/// It is not used directly, but through the [`AccessApproval`] hub.
536///
537/// # Example
538///
539/// Instantiate a resource builder
540///
541/// ```test_harness,no_run
542/// extern crate hyper;
543/// extern crate hyper_rustls;
544/// extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
545///
546/// # async fn dox() {
547/// use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
548///
549/// let secret: yup_oauth2::ApplicationSecret = Default::default();
550/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
551///     .with_native_roots()
552///     .unwrap()
553///     .https_only()
554///     .enable_http2()
555///     .build();
556///
557/// let executor = hyper_util::rt::TokioExecutor::new();
558/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
559///     secret,
560///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
561///     yup_oauth2::client::CustomHyperClientBuilder::from(
562///         hyper_util::client::legacy::Client::builder(executor).build(connector),
563///     ),
564/// ).build().await.unwrap();
565///
566/// let client = hyper_util::client::legacy::Client::builder(
567///     hyper_util::rt::TokioExecutor::new()
568/// )
569/// .build(
570///     hyper_rustls::HttpsConnectorBuilder::new()
571///         .with_native_roots()
572///         .unwrap()
573///         .https_or_http()
574///         .enable_http2()
575///         .build()
576/// );
577/// let mut hub = AccessApproval::new(client, auth);
578/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
579/// // like `approval_requests_approve(...)`, `approval_requests_dismiss(...)`, `approval_requests_get(...)`, `approval_requests_list(...)`, `delete_access_approval_settings(...)`, `get_access_approval_settings(...)` and `update_access_approval_settings(...)`
580/// // to build up your call.
581/// let rb = hub.folders();
582/// # }
583/// ```
584pub struct FolderMethods<'a, C>
585where
586    C: 'a,
587{
588    hub: &'a AccessApproval<C>,
589}
590
591impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
592
593impl<'a, C> FolderMethods<'a, C> {
594    /// Create a builder to help you perform the following task:
595    ///
596    /// Approves a request and returns the updated ApprovalRequest.
597    ///
598    /// Returns NOT_FOUND if the request does not exist. Returns
599    /// FAILED_PRECONDITION if the request exists but is not in a pending state.
600    ///
601    /// # Arguments
602    ///
603    /// * `request` - No description provided.
604    /// * `name` - Name of the approval request to approve.
605    pub fn approval_requests_approve(
606        &self,
607        request: ApproveApprovalRequestMessage,
608        name: &str,
609    ) -> FolderApprovalRequestApproveCall<'a, C> {
610        FolderApprovalRequestApproveCall {
611            hub: self.hub,
612            _request: request,
613            _name: name.to_string(),
614            _delegate: Default::default(),
615            _additional_params: Default::default(),
616            _scopes: Default::default(),
617        }
618    }
619
620    /// Create a builder to help you perform the following task:
621    ///
622    /// Dismisses a request. Returns the updated ApprovalRequest.
623    ///
624    /// NOTE: This does not deny access to the resource if another request has been
625    /// made and approved. It is equivalent in effect to ignoring the request
626    /// altogether.
627    ///
628    /// Returns NOT_FOUND if the request does not exist.
629    ///
630    /// Returns FAILED_PRECONDITION if the request exists but is not in a pending
631    /// state.
632    ///
633    /// # Arguments
634    ///
635    /// * `request` - No description provided.
636    /// * `name` - Name of the ApprovalRequest to dismiss.
637    pub fn approval_requests_dismiss(
638        &self,
639        request: DismissApprovalRequestMessage,
640        name: &str,
641    ) -> FolderApprovalRequestDismisCall<'a, C> {
642        FolderApprovalRequestDismisCall {
643            hub: self.hub,
644            _request: request,
645            _name: name.to_string(),
646            _delegate: Default::default(),
647            _additional_params: Default::default(),
648            _scopes: Default::default(),
649        }
650    }
651
652    /// Create a builder to help you perform the following task:
653    ///
654    /// Gets an approval request. Returns NOT_FOUND if the request does not exist.
655    ///
656    /// # Arguments
657    ///
658    /// * `name` - Name of the approval request to retrieve.
659    pub fn approval_requests_get(&self, name: &str) -> FolderApprovalRequestGetCall<'a, C> {
660        FolderApprovalRequestGetCall {
661            hub: self.hub,
662            _name: name.to_string(),
663            _delegate: Default::default(),
664            _additional_params: Default::default(),
665            _scopes: Default::default(),
666        }
667    }
668
669    /// Create a builder to help you perform the following task:
670    ///
671    /// Lists approval requests associated with a project, folder, or organization.
672    /// Approval requests can be filtered by state (pending, active, dismissed).
673    /// The order is reverse chronological.
674    ///
675    /// # Arguments
676    ///
677    /// * `parent` - The parent resource. This may be "projects/{project_id}",
678    ///              "folders/{folder_id}", or "organizations/{organization_id}".
679    pub fn approval_requests_list(&self, parent: &str) -> FolderApprovalRequestListCall<'a, C> {
680        FolderApprovalRequestListCall {
681            hub: self.hub,
682            _parent: parent.to_string(),
683            _page_token: Default::default(),
684            _page_size: Default::default(),
685            _filter: Default::default(),
686            _delegate: Default::default(),
687            _additional_params: Default::default(),
688            _scopes: Default::default(),
689        }
690    }
691
692    /// Create a builder to help you perform the following task:
693    ///
694    /// Deletes the settings associated with a project, folder, or organization.
695    /// This will have the effect of disabling Access Approval for the project,
696    /// folder, or organization, but only if all ancestors also have Access
697    /// Approval disabled. If Access Approval is enabled at a higher level of the
698    /// hierarchy, then Access Approval will still be enabled at this level as
699    /// the settings are inherited.
700    ///
701    /// # Arguments
702    ///
703    /// * `name` - Name of the AccessApprovalSettings to delete.
704    pub fn delete_access_approval_settings(
705        &self,
706        name: &str,
707    ) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
708        FolderDeleteAccessApprovalSettingCall {
709            hub: self.hub,
710            _name: name.to_string(),
711            _delegate: Default::default(),
712            _additional_params: Default::default(),
713            _scopes: Default::default(),
714        }
715    }
716
717    /// Create a builder to help you perform the following task:
718    ///
719    /// Gets the settings associated with a project, folder, or organization.
720    ///
721    /// # Arguments
722    ///
723    /// * `name` - Name of the AccessApprovalSettings to retrieve.
724    pub fn get_access_approval_settings(
725        &self,
726        name: &str,
727    ) -> FolderGetAccessApprovalSettingCall<'a, C> {
728        FolderGetAccessApprovalSettingCall {
729            hub: self.hub,
730            _name: name.to_string(),
731            _delegate: Default::default(),
732            _additional_params: Default::default(),
733            _scopes: Default::default(),
734        }
735    }
736
737    /// Create a builder to help you perform the following task:
738    ///
739    /// Updates the settings associated with a project, folder, or organization.
740    /// Settings to update are determined by the value of field_mask.
741    ///
742    /// # Arguments
743    ///
744    /// * `request` - No description provided.
745    /// * `name` - The resource name of the settings. Format is one of:
746    ///            <ol>
747    ///              <li>"projects/{project_id}/accessApprovalSettings"</li>
748    ///              <li>"folders/{folder_id}/accessApprovalSettings"</li>
749    ///              <li>"organizations/{organization_id}/accessApprovalSettings"</li>
750    ///            <ol>
751    pub fn update_access_approval_settings(
752        &self,
753        request: AccessApprovalSettings,
754        name: &str,
755    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
756        FolderUpdateAccessApprovalSettingCall {
757            hub: self.hub,
758            _request: request,
759            _name: name.to_string(),
760            _update_mask: Default::default(),
761            _delegate: Default::default(),
762            _additional_params: Default::default(),
763            _scopes: Default::default(),
764        }
765    }
766}
767
768/// A builder providing access to all methods supported on *organization* resources.
769/// It is not used directly, but through the [`AccessApproval`] hub.
770///
771/// # Example
772///
773/// Instantiate a resource builder
774///
775/// ```test_harness,no_run
776/// extern crate hyper;
777/// extern crate hyper_rustls;
778/// extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
779///
780/// # async fn dox() {
781/// use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
782///
783/// let secret: yup_oauth2::ApplicationSecret = Default::default();
784/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
785///     .with_native_roots()
786///     .unwrap()
787///     .https_only()
788///     .enable_http2()
789///     .build();
790///
791/// let executor = hyper_util::rt::TokioExecutor::new();
792/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
793///     secret,
794///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
795///     yup_oauth2::client::CustomHyperClientBuilder::from(
796///         hyper_util::client::legacy::Client::builder(executor).build(connector),
797///     ),
798/// ).build().await.unwrap();
799///
800/// let client = hyper_util::client::legacy::Client::builder(
801///     hyper_util::rt::TokioExecutor::new()
802/// )
803/// .build(
804///     hyper_rustls::HttpsConnectorBuilder::new()
805///         .with_native_roots()
806///         .unwrap()
807///         .https_or_http()
808///         .enable_http2()
809///         .build()
810/// );
811/// let mut hub = AccessApproval::new(client, auth);
812/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
813/// // like `approval_requests_approve(...)`, `approval_requests_dismiss(...)`, `approval_requests_get(...)`, `approval_requests_list(...)`, `delete_access_approval_settings(...)`, `get_access_approval_settings(...)` and `update_access_approval_settings(...)`
814/// // to build up your call.
815/// let rb = hub.organizations();
816/// # }
817/// ```
818pub struct OrganizationMethods<'a, C>
819where
820    C: 'a,
821{
822    hub: &'a AccessApproval<C>,
823}
824
825impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
826
827impl<'a, C> OrganizationMethods<'a, C> {
828    /// Create a builder to help you perform the following task:
829    ///
830    /// Approves a request and returns the updated ApprovalRequest.
831    ///
832    /// Returns NOT_FOUND if the request does not exist. Returns
833    /// FAILED_PRECONDITION if the request exists but is not in a pending state.
834    ///
835    /// # Arguments
836    ///
837    /// * `request` - No description provided.
838    /// * `name` - Name of the approval request to approve.
839    pub fn approval_requests_approve(
840        &self,
841        request: ApproveApprovalRequestMessage,
842        name: &str,
843    ) -> OrganizationApprovalRequestApproveCall<'a, C> {
844        OrganizationApprovalRequestApproveCall {
845            hub: self.hub,
846            _request: request,
847            _name: name.to_string(),
848            _delegate: Default::default(),
849            _additional_params: Default::default(),
850            _scopes: Default::default(),
851        }
852    }
853
854    /// Create a builder to help you perform the following task:
855    ///
856    /// Dismisses a request. Returns the updated ApprovalRequest.
857    ///
858    /// NOTE: This does not deny access to the resource if another request has been
859    /// made and approved. It is equivalent in effect to ignoring the request
860    /// altogether.
861    ///
862    /// Returns NOT_FOUND if the request does not exist.
863    ///
864    /// Returns FAILED_PRECONDITION if the request exists but is not in a pending
865    /// state.
866    ///
867    /// # Arguments
868    ///
869    /// * `request` - No description provided.
870    /// * `name` - Name of the ApprovalRequest to dismiss.
871    pub fn approval_requests_dismiss(
872        &self,
873        request: DismissApprovalRequestMessage,
874        name: &str,
875    ) -> OrganizationApprovalRequestDismisCall<'a, C> {
876        OrganizationApprovalRequestDismisCall {
877            hub: self.hub,
878            _request: request,
879            _name: name.to_string(),
880            _delegate: Default::default(),
881            _additional_params: Default::default(),
882            _scopes: Default::default(),
883        }
884    }
885
886    /// Create a builder to help you perform the following task:
887    ///
888    /// Gets an approval request. Returns NOT_FOUND if the request does not exist.
889    ///
890    /// # Arguments
891    ///
892    /// * `name` - Name of the approval request to retrieve.
893    pub fn approval_requests_get(&self, name: &str) -> OrganizationApprovalRequestGetCall<'a, C> {
894        OrganizationApprovalRequestGetCall {
895            hub: self.hub,
896            _name: name.to_string(),
897            _delegate: Default::default(),
898            _additional_params: Default::default(),
899            _scopes: Default::default(),
900        }
901    }
902
903    /// Create a builder to help you perform the following task:
904    ///
905    /// Lists approval requests associated with a project, folder, or organization.
906    /// Approval requests can be filtered by state (pending, active, dismissed).
907    /// The order is reverse chronological.
908    ///
909    /// # Arguments
910    ///
911    /// * `parent` - The parent resource. This may be "projects/{project_id}",
912    ///              "folders/{folder_id}", or "organizations/{organization_id}".
913    pub fn approval_requests_list(
914        &self,
915        parent: &str,
916    ) -> OrganizationApprovalRequestListCall<'a, C> {
917        OrganizationApprovalRequestListCall {
918            hub: self.hub,
919            _parent: parent.to_string(),
920            _page_token: Default::default(),
921            _page_size: Default::default(),
922            _filter: Default::default(),
923            _delegate: Default::default(),
924            _additional_params: Default::default(),
925            _scopes: Default::default(),
926        }
927    }
928
929    /// Create a builder to help you perform the following task:
930    ///
931    /// Deletes the settings associated with a project, folder, or organization.
932    /// This will have the effect of disabling Access Approval for the project,
933    /// folder, or organization, but only if all ancestors also have Access
934    /// Approval disabled. If Access Approval is enabled at a higher level of the
935    /// hierarchy, then Access Approval will still be enabled at this level as
936    /// the settings are inherited.
937    ///
938    /// # Arguments
939    ///
940    /// * `name` - Name of the AccessApprovalSettings to delete.
941    pub fn delete_access_approval_settings(
942        &self,
943        name: &str,
944    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
945        OrganizationDeleteAccessApprovalSettingCall {
946            hub: self.hub,
947            _name: name.to_string(),
948            _delegate: Default::default(),
949            _additional_params: Default::default(),
950            _scopes: Default::default(),
951        }
952    }
953
954    /// Create a builder to help you perform the following task:
955    ///
956    /// Gets the settings associated with a project, folder, or organization.
957    ///
958    /// # Arguments
959    ///
960    /// * `name` - Name of the AccessApprovalSettings to retrieve.
961    pub fn get_access_approval_settings(
962        &self,
963        name: &str,
964    ) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
965        OrganizationGetAccessApprovalSettingCall {
966            hub: self.hub,
967            _name: name.to_string(),
968            _delegate: Default::default(),
969            _additional_params: Default::default(),
970            _scopes: Default::default(),
971        }
972    }
973
974    /// Create a builder to help you perform the following task:
975    ///
976    /// Updates the settings associated with a project, folder, or organization.
977    /// Settings to update are determined by the value of field_mask.
978    ///
979    /// # Arguments
980    ///
981    /// * `request` - No description provided.
982    /// * `name` - The resource name of the settings. Format is one of:
983    ///            <ol>
984    ///              <li>"projects/{project_id}/accessApprovalSettings"</li>
985    ///              <li>"folders/{folder_id}/accessApprovalSettings"</li>
986    ///              <li>"organizations/{organization_id}/accessApprovalSettings"</li>
987    ///            <ol>
988    pub fn update_access_approval_settings(
989        &self,
990        request: AccessApprovalSettings,
991        name: &str,
992    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
993        OrganizationUpdateAccessApprovalSettingCall {
994            hub: self.hub,
995            _request: request,
996            _name: name.to_string(),
997            _update_mask: Default::default(),
998            _delegate: Default::default(),
999            _additional_params: Default::default(),
1000            _scopes: Default::default(),
1001        }
1002    }
1003}
1004
1005/// A builder providing access to all methods supported on *project* resources.
1006/// It is not used directly, but through the [`AccessApproval`] hub.
1007///
1008/// # Example
1009///
1010/// Instantiate a resource builder
1011///
1012/// ```test_harness,no_run
1013/// extern crate hyper;
1014/// extern crate hyper_rustls;
1015/// extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
1016///
1017/// # async fn dox() {
1018/// use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1019///
1020/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1021/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1022///     .with_native_roots()
1023///     .unwrap()
1024///     .https_only()
1025///     .enable_http2()
1026///     .build();
1027///
1028/// let executor = hyper_util::rt::TokioExecutor::new();
1029/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1030///     secret,
1031///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1032///     yup_oauth2::client::CustomHyperClientBuilder::from(
1033///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1034///     ),
1035/// ).build().await.unwrap();
1036///
1037/// let client = hyper_util::client::legacy::Client::builder(
1038///     hyper_util::rt::TokioExecutor::new()
1039/// )
1040/// .build(
1041///     hyper_rustls::HttpsConnectorBuilder::new()
1042///         .with_native_roots()
1043///         .unwrap()
1044///         .https_or_http()
1045///         .enable_http2()
1046///         .build()
1047/// );
1048/// let mut hub = AccessApproval::new(client, auth);
1049/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1050/// // like `approval_requests_approve(...)`, `approval_requests_dismiss(...)`, `approval_requests_get(...)`, `approval_requests_list(...)`, `delete_access_approval_settings(...)`, `get_access_approval_settings(...)` and `update_access_approval_settings(...)`
1051/// // to build up your call.
1052/// let rb = hub.projects();
1053/// # }
1054/// ```
1055pub struct ProjectMethods<'a, C>
1056where
1057    C: 'a,
1058{
1059    hub: &'a AccessApproval<C>,
1060}
1061
1062impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1063
1064impl<'a, C> ProjectMethods<'a, C> {
1065    /// Create a builder to help you perform the following task:
1066    ///
1067    /// Approves a request and returns the updated ApprovalRequest.
1068    ///
1069    /// Returns NOT_FOUND if the request does not exist. Returns
1070    /// FAILED_PRECONDITION if the request exists but is not in a pending state.
1071    ///
1072    /// # Arguments
1073    ///
1074    /// * `request` - No description provided.
1075    /// * `name` - Name of the approval request to approve.
1076    pub fn approval_requests_approve(
1077        &self,
1078        request: ApproveApprovalRequestMessage,
1079        name: &str,
1080    ) -> ProjectApprovalRequestApproveCall<'a, C> {
1081        ProjectApprovalRequestApproveCall {
1082            hub: self.hub,
1083            _request: request,
1084            _name: name.to_string(),
1085            _delegate: Default::default(),
1086            _additional_params: Default::default(),
1087            _scopes: Default::default(),
1088        }
1089    }
1090
1091    /// Create a builder to help you perform the following task:
1092    ///
1093    /// Dismisses a request. Returns the updated ApprovalRequest.
1094    ///
1095    /// NOTE: This does not deny access to the resource if another request has been
1096    /// made and approved. It is equivalent in effect to ignoring the request
1097    /// altogether.
1098    ///
1099    /// Returns NOT_FOUND if the request does not exist.
1100    ///
1101    /// Returns FAILED_PRECONDITION if the request exists but is not in a pending
1102    /// state.
1103    ///
1104    /// # Arguments
1105    ///
1106    /// * `request` - No description provided.
1107    /// * `name` - Name of the ApprovalRequest to dismiss.
1108    pub fn approval_requests_dismiss(
1109        &self,
1110        request: DismissApprovalRequestMessage,
1111        name: &str,
1112    ) -> ProjectApprovalRequestDismisCall<'a, C> {
1113        ProjectApprovalRequestDismisCall {
1114            hub: self.hub,
1115            _request: request,
1116            _name: name.to_string(),
1117            _delegate: Default::default(),
1118            _additional_params: Default::default(),
1119            _scopes: Default::default(),
1120        }
1121    }
1122
1123    /// Create a builder to help you perform the following task:
1124    ///
1125    /// Gets an approval request. Returns NOT_FOUND if the request does not exist.
1126    ///
1127    /// # Arguments
1128    ///
1129    /// * `name` - Name of the approval request to retrieve.
1130    pub fn approval_requests_get(&self, name: &str) -> ProjectApprovalRequestGetCall<'a, C> {
1131        ProjectApprovalRequestGetCall {
1132            hub: self.hub,
1133            _name: name.to_string(),
1134            _delegate: Default::default(),
1135            _additional_params: Default::default(),
1136            _scopes: Default::default(),
1137        }
1138    }
1139
1140    /// Create a builder to help you perform the following task:
1141    ///
1142    /// Lists approval requests associated with a project, folder, or organization.
1143    /// Approval requests can be filtered by state (pending, active, dismissed).
1144    /// The order is reverse chronological.
1145    ///
1146    /// # Arguments
1147    ///
1148    /// * `parent` - The parent resource. This may be "projects/{project_id}",
1149    ///              "folders/{folder_id}", or "organizations/{organization_id}".
1150    pub fn approval_requests_list(&self, parent: &str) -> ProjectApprovalRequestListCall<'a, C> {
1151        ProjectApprovalRequestListCall {
1152            hub: self.hub,
1153            _parent: parent.to_string(),
1154            _page_token: Default::default(),
1155            _page_size: Default::default(),
1156            _filter: Default::default(),
1157            _delegate: Default::default(),
1158            _additional_params: Default::default(),
1159            _scopes: Default::default(),
1160        }
1161    }
1162
1163    /// Create a builder to help you perform the following task:
1164    ///
1165    /// Deletes the settings associated with a project, folder, or organization.
1166    /// This will have the effect of disabling Access Approval for the project,
1167    /// folder, or organization, but only if all ancestors also have Access
1168    /// Approval disabled. If Access Approval is enabled at a higher level of the
1169    /// hierarchy, then Access Approval will still be enabled at this level as
1170    /// the settings are inherited.
1171    ///
1172    /// # Arguments
1173    ///
1174    /// * `name` - Name of the AccessApprovalSettings to delete.
1175    pub fn delete_access_approval_settings(
1176        &self,
1177        name: &str,
1178    ) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
1179        ProjectDeleteAccessApprovalSettingCall {
1180            hub: self.hub,
1181            _name: name.to_string(),
1182            _delegate: Default::default(),
1183            _additional_params: Default::default(),
1184            _scopes: Default::default(),
1185        }
1186    }
1187
1188    /// Create a builder to help you perform the following task:
1189    ///
1190    /// Gets the settings associated with a project, folder, or organization.
1191    ///
1192    /// # Arguments
1193    ///
1194    /// * `name` - Name of the AccessApprovalSettings to retrieve.
1195    pub fn get_access_approval_settings(
1196        &self,
1197        name: &str,
1198    ) -> ProjectGetAccessApprovalSettingCall<'a, C> {
1199        ProjectGetAccessApprovalSettingCall {
1200            hub: self.hub,
1201            _name: name.to_string(),
1202            _delegate: Default::default(),
1203            _additional_params: Default::default(),
1204            _scopes: Default::default(),
1205        }
1206    }
1207
1208    /// Create a builder to help you perform the following task:
1209    ///
1210    /// Updates the settings associated with a project, folder, or organization.
1211    /// Settings to update are determined by the value of field_mask.
1212    ///
1213    /// # Arguments
1214    ///
1215    /// * `request` - No description provided.
1216    /// * `name` - The resource name of the settings. Format is one of:
1217    ///            <ol>
1218    ///              <li>"projects/{project_id}/accessApprovalSettings"</li>
1219    ///              <li>"folders/{folder_id}/accessApprovalSettings"</li>
1220    ///              <li>"organizations/{organization_id}/accessApprovalSettings"</li>
1221    ///            <ol>
1222    pub fn update_access_approval_settings(
1223        &self,
1224        request: AccessApprovalSettings,
1225        name: &str,
1226    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
1227        ProjectUpdateAccessApprovalSettingCall {
1228            hub: self.hub,
1229            _request: request,
1230            _name: name.to_string(),
1231            _update_mask: Default::default(),
1232            _delegate: Default::default(),
1233            _additional_params: Default::default(),
1234            _scopes: Default::default(),
1235        }
1236    }
1237}
1238
1239// ###################
1240// CallBuilders   ###
1241// #################
1242
1243/// Approves a request and returns the updated ApprovalRequest.
1244///
1245/// Returns NOT_FOUND if the request does not exist. Returns
1246/// FAILED_PRECONDITION if the request exists but is not in a pending state.
1247///
1248/// A builder for the *approvalRequests.approve* method supported by a *folder* resource.
1249/// It is not used directly, but through a [`FolderMethods`] instance.
1250///
1251/// # Example
1252///
1253/// Instantiate a resource method builder
1254///
1255/// ```test_harness,no_run
1256/// # extern crate hyper;
1257/// # extern crate hyper_rustls;
1258/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
1259/// use accessapproval1_beta1::api::ApproveApprovalRequestMessage;
1260/// # async fn dox() {
1261/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1262///
1263/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1264/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1265/// #     .with_native_roots()
1266/// #     .unwrap()
1267/// #     .https_only()
1268/// #     .enable_http2()
1269/// #     .build();
1270///
1271/// # let executor = hyper_util::rt::TokioExecutor::new();
1272/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1273/// #     secret,
1274/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1275/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1276/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1277/// #     ),
1278/// # ).build().await.unwrap();
1279///
1280/// # let client = hyper_util::client::legacy::Client::builder(
1281/// #     hyper_util::rt::TokioExecutor::new()
1282/// # )
1283/// # .build(
1284/// #     hyper_rustls::HttpsConnectorBuilder::new()
1285/// #         .with_native_roots()
1286/// #         .unwrap()
1287/// #         .https_or_http()
1288/// #         .enable_http2()
1289/// #         .build()
1290/// # );
1291/// # let mut hub = AccessApproval::new(client, auth);
1292/// // As the method needs a request, you would usually fill it with the desired information
1293/// // into the respective structure. Some of the parts shown here might not be applicable !
1294/// // Values shown here are possibly random and not representative !
1295/// let mut req = ApproveApprovalRequestMessage::default();
1296///
1297/// // You can configure optional parameters by calling the respective setters at will, and
1298/// // execute the final call using `doit()`.
1299/// // Values shown here are possibly random and not representative !
1300/// let result = hub.folders().approval_requests_approve(req, "name")
1301///              .doit().await;
1302/// # }
1303/// ```
1304pub struct FolderApprovalRequestApproveCall<'a, C>
1305where
1306    C: 'a,
1307{
1308    hub: &'a AccessApproval<C>,
1309    _request: ApproveApprovalRequestMessage,
1310    _name: String,
1311    _delegate: Option<&'a mut dyn common::Delegate>,
1312    _additional_params: HashMap<String, String>,
1313    _scopes: BTreeSet<String>,
1314}
1315
1316impl<'a, C> common::CallBuilder for FolderApprovalRequestApproveCall<'a, C> {}
1317
1318impl<'a, C> FolderApprovalRequestApproveCall<'a, C>
1319where
1320    C: common::Connector,
1321{
1322    /// Perform the operation you have build so far.
1323    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
1324        use std::borrow::Cow;
1325        use std::io::{Read, Seek};
1326
1327        use common::{url::Params, ToParts};
1328        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1329
1330        let mut dd = common::DefaultDelegate;
1331        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1332        dlg.begin(common::MethodInfo {
1333            id: "accessapproval.folders.approvalRequests.approve",
1334            http_method: hyper::Method::POST,
1335        });
1336
1337        for &field in ["alt", "name"].iter() {
1338            if self._additional_params.contains_key(field) {
1339                dlg.finished(false);
1340                return Err(common::Error::FieldClash(field));
1341            }
1342        }
1343
1344        let mut params = Params::with_capacity(4 + self._additional_params.len());
1345        params.push("name", self._name);
1346
1347        params.extend(self._additional_params.iter());
1348
1349        params.push("alt", "json");
1350        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:approve";
1351        if self._scopes.is_empty() {
1352            self._scopes
1353                .insert(Scope::CloudPlatform.as_ref().to_string());
1354        }
1355
1356        #[allow(clippy::single_element_loop)]
1357        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1358            url = params.uri_replacement(url, param_name, find_this, true);
1359        }
1360        {
1361            let to_remove = ["name"];
1362            params.remove_params(&to_remove);
1363        }
1364
1365        let url = params.parse_with_url(&url);
1366
1367        let mut json_mime_type = mime::APPLICATION_JSON;
1368        let mut request_value_reader = {
1369            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1370            common::remove_json_null_values(&mut value);
1371            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1372            serde_json::to_writer(&mut dst, &value).unwrap();
1373            dst
1374        };
1375        let request_size = request_value_reader
1376            .seek(std::io::SeekFrom::End(0))
1377            .unwrap();
1378        request_value_reader
1379            .seek(std::io::SeekFrom::Start(0))
1380            .unwrap();
1381
1382        loop {
1383            let token = match self
1384                .hub
1385                .auth
1386                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1387                .await
1388            {
1389                Ok(token) => token,
1390                Err(e) => match dlg.token(e) {
1391                    Ok(token) => token,
1392                    Err(e) => {
1393                        dlg.finished(false);
1394                        return Err(common::Error::MissingToken(e));
1395                    }
1396                },
1397            };
1398            request_value_reader
1399                .seek(std::io::SeekFrom::Start(0))
1400                .unwrap();
1401            let mut req_result = {
1402                let client = &self.hub.client;
1403                dlg.pre_request();
1404                let mut req_builder = hyper::Request::builder()
1405                    .method(hyper::Method::POST)
1406                    .uri(url.as_str())
1407                    .header(USER_AGENT, self.hub._user_agent.clone());
1408
1409                if let Some(token) = token.as_ref() {
1410                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1411                }
1412
1413                let request = req_builder
1414                    .header(CONTENT_TYPE, json_mime_type.to_string())
1415                    .header(CONTENT_LENGTH, request_size as u64)
1416                    .body(common::to_body(
1417                        request_value_reader.get_ref().clone().into(),
1418                    ));
1419
1420                client.request(request.unwrap()).await
1421            };
1422
1423            match req_result {
1424                Err(err) => {
1425                    if let common::Retry::After(d) = dlg.http_error(&err) {
1426                        sleep(d).await;
1427                        continue;
1428                    }
1429                    dlg.finished(false);
1430                    return Err(common::Error::HttpError(err));
1431                }
1432                Ok(res) => {
1433                    let (mut parts, body) = res.into_parts();
1434                    let mut body = common::Body::new(body);
1435                    if !parts.status.is_success() {
1436                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1437                        let error = serde_json::from_str(&common::to_string(&bytes));
1438                        let response = common::to_response(parts, bytes.into());
1439
1440                        if let common::Retry::After(d) =
1441                            dlg.http_failure(&response, error.as_ref().ok())
1442                        {
1443                            sleep(d).await;
1444                            continue;
1445                        }
1446
1447                        dlg.finished(false);
1448
1449                        return Err(match error {
1450                            Ok(value) => common::Error::BadRequest(value),
1451                            _ => common::Error::Failure(response),
1452                        });
1453                    }
1454                    let response = {
1455                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1456                        let encoded = common::to_string(&bytes);
1457                        match serde_json::from_str(&encoded) {
1458                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1459                            Err(error) => {
1460                                dlg.response_json_decode_error(&encoded, &error);
1461                                return Err(common::Error::JsonDecodeError(
1462                                    encoded.to_string(),
1463                                    error,
1464                                ));
1465                            }
1466                        }
1467                    };
1468
1469                    dlg.finished(true);
1470                    return Ok(response);
1471                }
1472            }
1473        }
1474    }
1475
1476    ///
1477    /// Sets the *request* property to the given value.
1478    ///
1479    /// Even though the property as already been set when instantiating this call,
1480    /// we provide this method for API completeness.
1481    pub fn request(
1482        mut self,
1483        new_value: ApproveApprovalRequestMessage,
1484    ) -> FolderApprovalRequestApproveCall<'a, C> {
1485        self._request = new_value;
1486        self
1487    }
1488    /// Name of the approval request to approve.
1489    ///
1490    /// Sets the *name* path property to the given value.
1491    ///
1492    /// Even though the property as already been set when instantiating this call,
1493    /// we provide this method for API completeness.
1494    pub fn name(mut self, new_value: &str) -> FolderApprovalRequestApproveCall<'a, C> {
1495        self._name = new_value.to_string();
1496        self
1497    }
1498    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1499    /// while executing the actual API request.
1500    ///
1501    /// ````text
1502    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1503    /// ````
1504    ///
1505    /// Sets the *delegate* property to the given value.
1506    pub fn delegate(
1507        mut self,
1508        new_value: &'a mut dyn common::Delegate,
1509    ) -> FolderApprovalRequestApproveCall<'a, C> {
1510        self._delegate = Some(new_value);
1511        self
1512    }
1513
1514    /// Set any additional parameter of the query string used in the request.
1515    /// It should be used to set parameters which are not yet available through their own
1516    /// setters.
1517    ///
1518    /// Please note that this method must not be used to set any of the known parameters
1519    /// which have their own setter method. If done anyway, the request will fail.
1520    ///
1521    /// # Additional Parameters
1522    ///
1523    /// * *$.xgafv* (query-string) - V1 error format.
1524    /// * *access_token* (query-string) - OAuth access token.
1525    /// * *alt* (query-string) - Data format for response.
1526    /// * *callback* (query-string) - JSONP
1527    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1528    /// * *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.
1529    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1530    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1531    /// * *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.
1532    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1533    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1534    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestApproveCall<'a, C>
1535    where
1536        T: AsRef<str>,
1537    {
1538        self._additional_params
1539            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1540        self
1541    }
1542
1543    /// Identifies the authorization scope for the method you are building.
1544    ///
1545    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1546    /// [`Scope::CloudPlatform`].
1547    ///
1548    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1549    /// tokens for more than one scope.
1550    ///
1551    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1552    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1553    /// sufficient, a read-write scope will do as well.
1554    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestApproveCall<'a, C>
1555    where
1556        St: AsRef<str>,
1557    {
1558        self._scopes.insert(String::from(scope.as_ref()));
1559        self
1560    }
1561    /// Identifies the authorization scope(s) for the method you are building.
1562    ///
1563    /// See [`Self::add_scope()`] for details.
1564    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestApproveCall<'a, C>
1565    where
1566        I: IntoIterator<Item = St>,
1567        St: AsRef<str>,
1568    {
1569        self._scopes
1570            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1571        self
1572    }
1573
1574    /// Removes all scopes, and no default scope will be used either.
1575    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1576    /// for details).
1577    pub fn clear_scopes(mut self) -> FolderApprovalRequestApproveCall<'a, C> {
1578        self._scopes.clear();
1579        self
1580    }
1581}
1582
1583/// Dismisses a request. Returns the updated ApprovalRequest.
1584///
1585/// NOTE: This does not deny access to the resource if another request has been
1586/// made and approved. It is equivalent in effect to ignoring the request
1587/// altogether.
1588///
1589/// Returns NOT_FOUND if the request does not exist.
1590///
1591/// Returns FAILED_PRECONDITION if the request exists but is not in a pending
1592/// state.
1593///
1594/// A builder for the *approvalRequests.dismiss* method supported by a *folder* resource.
1595/// It is not used directly, but through a [`FolderMethods`] instance.
1596///
1597/// # Example
1598///
1599/// Instantiate a resource method builder
1600///
1601/// ```test_harness,no_run
1602/// # extern crate hyper;
1603/// # extern crate hyper_rustls;
1604/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
1605/// use accessapproval1_beta1::api::DismissApprovalRequestMessage;
1606/// # async fn dox() {
1607/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1608///
1609/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1610/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1611/// #     .with_native_roots()
1612/// #     .unwrap()
1613/// #     .https_only()
1614/// #     .enable_http2()
1615/// #     .build();
1616///
1617/// # let executor = hyper_util::rt::TokioExecutor::new();
1618/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1619/// #     secret,
1620/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1621/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1622/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1623/// #     ),
1624/// # ).build().await.unwrap();
1625///
1626/// # let client = hyper_util::client::legacy::Client::builder(
1627/// #     hyper_util::rt::TokioExecutor::new()
1628/// # )
1629/// # .build(
1630/// #     hyper_rustls::HttpsConnectorBuilder::new()
1631/// #         .with_native_roots()
1632/// #         .unwrap()
1633/// #         .https_or_http()
1634/// #         .enable_http2()
1635/// #         .build()
1636/// # );
1637/// # let mut hub = AccessApproval::new(client, auth);
1638/// // As the method needs a request, you would usually fill it with the desired information
1639/// // into the respective structure. Some of the parts shown here might not be applicable !
1640/// // Values shown here are possibly random and not representative !
1641/// let mut req = DismissApprovalRequestMessage::default();
1642///
1643/// // You can configure optional parameters by calling the respective setters at will, and
1644/// // execute the final call using `doit()`.
1645/// // Values shown here are possibly random and not representative !
1646/// let result = hub.folders().approval_requests_dismiss(req, "name")
1647///              .doit().await;
1648/// # }
1649/// ```
1650pub struct FolderApprovalRequestDismisCall<'a, C>
1651where
1652    C: 'a,
1653{
1654    hub: &'a AccessApproval<C>,
1655    _request: DismissApprovalRequestMessage,
1656    _name: String,
1657    _delegate: Option<&'a mut dyn common::Delegate>,
1658    _additional_params: HashMap<String, String>,
1659    _scopes: BTreeSet<String>,
1660}
1661
1662impl<'a, C> common::CallBuilder for FolderApprovalRequestDismisCall<'a, C> {}
1663
1664impl<'a, C> FolderApprovalRequestDismisCall<'a, C>
1665where
1666    C: common::Connector,
1667{
1668    /// Perform the operation you have build so far.
1669    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
1670        use std::borrow::Cow;
1671        use std::io::{Read, Seek};
1672
1673        use common::{url::Params, ToParts};
1674        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1675
1676        let mut dd = common::DefaultDelegate;
1677        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1678        dlg.begin(common::MethodInfo {
1679            id: "accessapproval.folders.approvalRequests.dismiss",
1680            http_method: hyper::Method::POST,
1681        });
1682
1683        for &field in ["alt", "name"].iter() {
1684            if self._additional_params.contains_key(field) {
1685                dlg.finished(false);
1686                return Err(common::Error::FieldClash(field));
1687            }
1688        }
1689
1690        let mut params = Params::with_capacity(4 + self._additional_params.len());
1691        params.push("name", self._name);
1692
1693        params.extend(self._additional_params.iter());
1694
1695        params.push("alt", "json");
1696        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:dismiss";
1697        if self._scopes.is_empty() {
1698            self._scopes
1699                .insert(Scope::CloudPlatform.as_ref().to_string());
1700        }
1701
1702        #[allow(clippy::single_element_loop)]
1703        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1704            url = params.uri_replacement(url, param_name, find_this, true);
1705        }
1706        {
1707            let to_remove = ["name"];
1708            params.remove_params(&to_remove);
1709        }
1710
1711        let url = params.parse_with_url(&url);
1712
1713        let mut json_mime_type = mime::APPLICATION_JSON;
1714        let mut request_value_reader = {
1715            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1716            common::remove_json_null_values(&mut value);
1717            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1718            serde_json::to_writer(&mut dst, &value).unwrap();
1719            dst
1720        };
1721        let request_size = request_value_reader
1722            .seek(std::io::SeekFrom::End(0))
1723            .unwrap();
1724        request_value_reader
1725            .seek(std::io::SeekFrom::Start(0))
1726            .unwrap();
1727
1728        loop {
1729            let token = match self
1730                .hub
1731                .auth
1732                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1733                .await
1734            {
1735                Ok(token) => token,
1736                Err(e) => match dlg.token(e) {
1737                    Ok(token) => token,
1738                    Err(e) => {
1739                        dlg.finished(false);
1740                        return Err(common::Error::MissingToken(e));
1741                    }
1742                },
1743            };
1744            request_value_reader
1745                .seek(std::io::SeekFrom::Start(0))
1746                .unwrap();
1747            let mut req_result = {
1748                let client = &self.hub.client;
1749                dlg.pre_request();
1750                let mut req_builder = hyper::Request::builder()
1751                    .method(hyper::Method::POST)
1752                    .uri(url.as_str())
1753                    .header(USER_AGENT, self.hub._user_agent.clone());
1754
1755                if let Some(token) = token.as_ref() {
1756                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1757                }
1758
1759                let request = req_builder
1760                    .header(CONTENT_TYPE, json_mime_type.to_string())
1761                    .header(CONTENT_LENGTH, request_size as u64)
1762                    .body(common::to_body(
1763                        request_value_reader.get_ref().clone().into(),
1764                    ));
1765
1766                client.request(request.unwrap()).await
1767            };
1768
1769            match req_result {
1770                Err(err) => {
1771                    if let common::Retry::After(d) = dlg.http_error(&err) {
1772                        sleep(d).await;
1773                        continue;
1774                    }
1775                    dlg.finished(false);
1776                    return Err(common::Error::HttpError(err));
1777                }
1778                Ok(res) => {
1779                    let (mut parts, body) = res.into_parts();
1780                    let mut body = common::Body::new(body);
1781                    if !parts.status.is_success() {
1782                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1783                        let error = serde_json::from_str(&common::to_string(&bytes));
1784                        let response = common::to_response(parts, bytes.into());
1785
1786                        if let common::Retry::After(d) =
1787                            dlg.http_failure(&response, error.as_ref().ok())
1788                        {
1789                            sleep(d).await;
1790                            continue;
1791                        }
1792
1793                        dlg.finished(false);
1794
1795                        return Err(match error {
1796                            Ok(value) => common::Error::BadRequest(value),
1797                            _ => common::Error::Failure(response),
1798                        });
1799                    }
1800                    let response = {
1801                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1802                        let encoded = common::to_string(&bytes);
1803                        match serde_json::from_str(&encoded) {
1804                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1805                            Err(error) => {
1806                                dlg.response_json_decode_error(&encoded, &error);
1807                                return Err(common::Error::JsonDecodeError(
1808                                    encoded.to_string(),
1809                                    error,
1810                                ));
1811                            }
1812                        }
1813                    };
1814
1815                    dlg.finished(true);
1816                    return Ok(response);
1817                }
1818            }
1819        }
1820    }
1821
1822    ///
1823    /// Sets the *request* property to the given value.
1824    ///
1825    /// Even though the property as already been set when instantiating this call,
1826    /// we provide this method for API completeness.
1827    pub fn request(
1828        mut self,
1829        new_value: DismissApprovalRequestMessage,
1830    ) -> FolderApprovalRequestDismisCall<'a, C> {
1831        self._request = new_value;
1832        self
1833    }
1834    /// Name of the ApprovalRequest to dismiss.
1835    ///
1836    /// Sets the *name* path property to the given value.
1837    ///
1838    /// Even though the property as already been set when instantiating this call,
1839    /// we provide this method for API completeness.
1840    pub fn name(mut self, new_value: &str) -> FolderApprovalRequestDismisCall<'a, C> {
1841        self._name = new_value.to_string();
1842        self
1843    }
1844    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1845    /// while executing the actual API request.
1846    ///
1847    /// ````text
1848    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1849    /// ````
1850    ///
1851    /// Sets the *delegate* property to the given value.
1852    pub fn delegate(
1853        mut self,
1854        new_value: &'a mut dyn common::Delegate,
1855    ) -> FolderApprovalRequestDismisCall<'a, C> {
1856        self._delegate = Some(new_value);
1857        self
1858    }
1859
1860    /// Set any additional parameter of the query string used in the request.
1861    /// It should be used to set parameters which are not yet available through their own
1862    /// setters.
1863    ///
1864    /// Please note that this method must not be used to set any of the known parameters
1865    /// which have their own setter method. If done anyway, the request will fail.
1866    ///
1867    /// # Additional Parameters
1868    ///
1869    /// * *$.xgafv* (query-string) - V1 error format.
1870    /// * *access_token* (query-string) - OAuth access token.
1871    /// * *alt* (query-string) - Data format for response.
1872    /// * *callback* (query-string) - JSONP
1873    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1874    /// * *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.
1875    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1876    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1877    /// * *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.
1878    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1879    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1880    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestDismisCall<'a, C>
1881    where
1882        T: AsRef<str>,
1883    {
1884        self._additional_params
1885            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1886        self
1887    }
1888
1889    /// Identifies the authorization scope for the method you are building.
1890    ///
1891    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1892    /// [`Scope::CloudPlatform`].
1893    ///
1894    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1895    /// tokens for more than one scope.
1896    ///
1897    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1898    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1899    /// sufficient, a read-write scope will do as well.
1900    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestDismisCall<'a, C>
1901    where
1902        St: AsRef<str>,
1903    {
1904        self._scopes.insert(String::from(scope.as_ref()));
1905        self
1906    }
1907    /// Identifies the authorization scope(s) for the method you are building.
1908    ///
1909    /// See [`Self::add_scope()`] for details.
1910    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestDismisCall<'a, C>
1911    where
1912        I: IntoIterator<Item = St>,
1913        St: AsRef<str>,
1914    {
1915        self._scopes
1916            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1917        self
1918    }
1919
1920    /// Removes all scopes, and no default scope will be used either.
1921    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1922    /// for details).
1923    pub fn clear_scopes(mut self) -> FolderApprovalRequestDismisCall<'a, C> {
1924        self._scopes.clear();
1925        self
1926    }
1927}
1928
1929/// Gets an approval request. Returns NOT_FOUND if the request does not exist.
1930///
1931/// A builder for the *approvalRequests.get* method supported by a *folder* resource.
1932/// It is not used directly, but through a [`FolderMethods`] instance.
1933///
1934/// # Example
1935///
1936/// Instantiate a resource method builder
1937///
1938/// ```test_harness,no_run
1939/// # extern crate hyper;
1940/// # extern crate hyper_rustls;
1941/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
1942/// # async fn dox() {
1943/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1944///
1945/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1946/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1947/// #     .with_native_roots()
1948/// #     .unwrap()
1949/// #     .https_only()
1950/// #     .enable_http2()
1951/// #     .build();
1952///
1953/// # let executor = hyper_util::rt::TokioExecutor::new();
1954/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1955/// #     secret,
1956/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1957/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1958/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1959/// #     ),
1960/// # ).build().await.unwrap();
1961///
1962/// # let client = hyper_util::client::legacy::Client::builder(
1963/// #     hyper_util::rt::TokioExecutor::new()
1964/// # )
1965/// # .build(
1966/// #     hyper_rustls::HttpsConnectorBuilder::new()
1967/// #         .with_native_roots()
1968/// #         .unwrap()
1969/// #         .https_or_http()
1970/// #         .enable_http2()
1971/// #         .build()
1972/// # );
1973/// # let mut hub = AccessApproval::new(client, auth);
1974/// // You can configure optional parameters by calling the respective setters at will, and
1975/// // execute the final call using `doit()`.
1976/// // Values shown here are possibly random and not representative !
1977/// let result = hub.folders().approval_requests_get("name")
1978///              .doit().await;
1979/// # }
1980/// ```
1981pub struct FolderApprovalRequestGetCall<'a, C>
1982where
1983    C: 'a,
1984{
1985    hub: &'a AccessApproval<C>,
1986    _name: String,
1987    _delegate: Option<&'a mut dyn common::Delegate>,
1988    _additional_params: HashMap<String, String>,
1989    _scopes: BTreeSet<String>,
1990}
1991
1992impl<'a, C> common::CallBuilder for FolderApprovalRequestGetCall<'a, C> {}
1993
1994impl<'a, C> FolderApprovalRequestGetCall<'a, C>
1995where
1996    C: common::Connector,
1997{
1998    /// Perform the operation you have build so far.
1999    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
2000        use std::borrow::Cow;
2001        use std::io::{Read, Seek};
2002
2003        use common::{url::Params, ToParts};
2004        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2005
2006        let mut dd = common::DefaultDelegate;
2007        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2008        dlg.begin(common::MethodInfo {
2009            id: "accessapproval.folders.approvalRequests.get",
2010            http_method: hyper::Method::GET,
2011        });
2012
2013        for &field in ["alt", "name"].iter() {
2014            if self._additional_params.contains_key(field) {
2015                dlg.finished(false);
2016                return Err(common::Error::FieldClash(field));
2017            }
2018        }
2019
2020        let mut params = Params::with_capacity(3 + self._additional_params.len());
2021        params.push("name", self._name);
2022
2023        params.extend(self._additional_params.iter());
2024
2025        params.push("alt", "json");
2026        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2027        if self._scopes.is_empty() {
2028            self._scopes
2029                .insert(Scope::CloudPlatform.as_ref().to_string());
2030        }
2031
2032        #[allow(clippy::single_element_loop)]
2033        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2034            url = params.uri_replacement(url, param_name, find_this, true);
2035        }
2036        {
2037            let to_remove = ["name"];
2038            params.remove_params(&to_remove);
2039        }
2040
2041        let url = params.parse_with_url(&url);
2042
2043        loop {
2044            let token = match self
2045                .hub
2046                .auth
2047                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2048                .await
2049            {
2050                Ok(token) => token,
2051                Err(e) => match dlg.token(e) {
2052                    Ok(token) => token,
2053                    Err(e) => {
2054                        dlg.finished(false);
2055                        return Err(common::Error::MissingToken(e));
2056                    }
2057                },
2058            };
2059            let mut req_result = {
2060                let client = &self.hub.client;
2061                dlg.pre_request();
2062                let mut req_builder = hyper::Request::builder()
2063                    .method(hyper::Method::GET)
2064                    .uri(url.as_str())
2065                    .header(USER_AGENT, self.hub._user_agent.clone());
2066
2067                if let Some(token) = token.as_ref() {
2068                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2069                }
2070
2071                let request = req_builder
2072                    .header(CONTENT_LENGTH, 0_u64)
2073                    .body(common::to_body::<String>(None));
2074
2075                client.request(request.unwrap()).await
2076            };
2077
2078            match req_result {
2079                Err(err) => {
2080                    if let common::Retry::After(d) = dlg.http_error(&err) {
2081                        sleep(d).await;
2082                        continue;
2083                    }
2084                    dlg.finished(false);
2085                    return Err(common::Error::HttpError(err));
2086                }
2087                Ok(res) => {
2088                    let (mut parts, body) = res.into_parts();
2089                    let mut body = common::Body::new(body);
2090                    if !parts.status.is_success() {
2091                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2092                        let error = serde_json::from_str(&common::to_string(&bytes));
2093                        let response = common::to_response(parts, bytes.into());
2094
2095                        if let common::Retry::After(d) =
2096                            dlg.http_failure(&response, error.as_ref().ok())
2097                        {
2098                            sleep(d).await;
2099                            continue;
2100                        }
2101
2102                        dlg.finished(false);
2103
2104                        return Err(match error {
2105                            Ok(value) => common::Error::BadRequest(value),
2106                            _ => common::Error::Failure(response),
2107                        });
2108                    }
2109                    let response = {
2110                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2111                        let encoded = common::to_string(&bytes);
2112                        match serde_json::from_str(&encoded) {
2113                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2114                            Err(error) => {
2115                                dlg.response_json_decode_error(&encoded, &error);
2116                                return Err(common::Error::JsonDecodeError(
2117                                    encoded.to_string(),
2118                                    error,
2119                                ));
2120                            }
2121                        }
2122                    };
2123
2124                    dlg.finished(true);
2125                    return Ok(response);
2126                }
2127            }
2128        }
2129    }
2130
2131    /// Name of the approval request to retrieve.
2132    ///
2133    /// Sets the *name* path property to the given value.
2134    ///
2135    /// Even though the property as already been set when instantiating this call,
2136    /// we provide this method for API completeness.
2137    pub fn name(mut self, new_value: &str) -> FolderApprovalRequestGetCall<'a, C> {
2138        self._name = new_value.to_string();
2139        self
2140    }
2141    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2142    /// while executing the actual API request.
2143    ///
2144    /// ````text
2145    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2146    /// ````
2147    ///
2148    /// Sets the *delegate* property to the given value.
2149    pub fn delegate(
2150        mut self,
2151        new_value: &'a mut dyn common::Delegate,
2152    ) -> FolderApprovalRequestGetCall<'a, C> {
2153        self._delegate = Some(new_value);
2154        self
2155    }
2156
2157    /// Set any additional parameter of the query string used in the request.
2158    /// It should be used to set parameters which are not yet available through their own
2159    /// setters.
2160    ///
2161    /// Please note that this method must not be used to set any of the known parameters
2162    /// which have their own setter method. If done anyway, the request will fail.
2163    ///
2164    /// # Additional Parameters
2165    ///
2166    /// * *$.xgafv* (query-string) - V1 error format.
2167    /// * *access_token* (query-string) - OAuth access token.
2168    /// * *alt* (query-string) - Data format for response.
2169    /// * *callback* (query-string) - JSONP
2170    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2171    /// * *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.
2172    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2173    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2174    /// * *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.
2175    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2176    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2177    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestGetCall<'a, C>
2178    where
2179        T: AsRef<str>,
2180    {
2181        self._additional_params
2182            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2183        self
2184    }
2185
2186    /// Identifies the authorization scope for the method you are building.
2187    ///
2188    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2189    /// [`Scope::CloudPlatform`].
2190    ///
2191    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2192    /// tokens for more than one scope.
2193    ///
2194    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2195    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2196    /// sufficient, a read-write scope will do as well.
2197    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestGetCall<'a, C>
2198    where
2199        St: AsRef<str>,
2200    {
2201        self._scopes.insert(String::from(scope.as_ref()));
2202        self
2203    }
2204    /// Identifies the authorization scope(s) for the method you are building.
2205    ///
2206    /// See [`Self::add_scope()`] for details.
2207    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestGetCall<'a, C>
2208    where
2209        I: IntoIterator<Item = St>,
2210        St: AsRef<str>,
2211    {
2212        self._scopes
2213            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2214        self
2215    }
2216
2217    /// Removes all scopes, and no default scope will be used either.
2218    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2219    /// for details).
2220    pub fn clear_scopes(mut self) -> FolderApprovalRequestGetCall<'a, C> {
2221        self._scopes.clear();
2222        self
2223    }
2224}
2225
2226/// Lists approval requests associated with a project, folder, or organization.
2227/// Approval requests can be filtered by state (pending, active, dismissed).
2228/// The order is reverse chronological.
2229///
2230/// A builder for the *approvalRequests.list* method supported by a *folder* resource.
2231/// It is not used directly, but through a [`FolderMethods`] instance.
2232///
2233/// # Example
2234///
2235/// Instantiate a resource method builder
2236///
2237/// ```test_harness,no_run
2238/// # extern crate hyper;
2239/// # extern crate hyper_rustls;
2240/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
2241/// # async fn dox() {
2242/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2243///
2244/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2245/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2246/// #     .with_native_roots()
2247/// #     .unwrap()
2248/// #     .https_only()
2249/// #     .enable_http2()
2250/// #     .build();
2251///
2252/// # let executor = hyper_util::rt::TokioExecutor::new();
2253/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2254/// #     secret,
2255/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2256/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2257/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2258/// #     ),
2259/// # ).build().await.unwrap();
2260///
2261/// # let client = hyper_util::client::legacy::Client::builder(
2262/// #     hyper_util::rt::TokioExecutor::new()
2263/// # )
2264/// # .build(
2265/// #     hyper_rustls::HttpsConnectorBuilder::new()
2266/// #         .with_native_roots()
2267/// #         .unwrap()
2268/// #         .https_or_http()
2269/// #         .enable_http2()
2270/// #         .build()
2271/// # );
2272/// # let mut hub = AccessApproval::new(client, auth);
2273/// // You can configure optional parameters by calling the respective setters at will, and
2274/// // execute the final call using `doit()`.
2275/// // Values shown here are possibly random and not representative !
2276/// let result = hub.folders().approval_requests_list("parent")
2277///              .page_token("sed")
2278///              .page_size(-2)
2279///              .filter("takimata")
2280///              .doit().await;
2281/// # }
2282/// ```
2283pub struct FolderApprovalRequestListCall<'a, C>
2284where
2285    C: 'a,
2286{
2287    hub: &'a AccessApproval<C>,
2288    _parent: String,
2289    _page_token: Option<String>,
2290    _page_size: Option<i32>,
2291    _filter: Option<String>,
2292    _delegate: Option<&'a mut dyn common::Delegate>,
2293    _additional_params: HashMap<String, String>,
2294    _scopes: BTreeSet<String>,
2295}
2296
2297impl<'a, C> common::CallBuilder for FolderApprovalRequestListCall<'a, C> {}
2298
2299impl<'a, C> FolderApprovalRequestListCall<'a, C>
2300where
2301    C: common::Connector,
2302{
2303    /// Perform the operation you have build so far.
2304    pub async fn doit(
2305        mut self,
2306    ) -> common::Result<(common::Response, ListApprovalRequestsResponse)> {
2307        use std::borrow::Cow;
2308        use std::io::{Read, Seek};
2309
2310        use common::{url::Params, ToParts};
2311        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2312
2313        let mut dd = common::DefaultDelegate;
2314        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2315        dlg.begin(common::MethodInfo {
2316            id: "accessapproval.folders.approvalRequests.list",
2317            http_method: hyper::Method::GET,
2318        });
2319
2320        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
2321            if self._additional_params.contains_key(field) {
2322                dlg.finished(false);
2323                return Err(common::Error::FieldClash(field));
2324            }
2325        }
2326
2327        let mut params = Params::with_capacity(6 + self._additional_params.len());
2328        params.push("parent", self._parent);
2329        if let Some(value) = self._page_token.as_ref() {
2330            params.push("pageToken", value);
2331        }
2332        if let Some(value) = self._page_size.as_ref() {
2333            params.push("pageSize", value.to_string());
2334        }
2335        if let Some(value) = self._filter.as_ref() {
2336            params.push("filter", value);
2337        }
2338
2339        params.extend(self._additional_params.iter());
2340
2341        params.push("alt", "json");
2342        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/approvalRequests";
2343        if self._scopes.is_empty() {
2344            self._scopes
2345                .insert(Scope::CloudPlatform.as_ref().to_string());
2346        }
2347
2348        #[allow(clippy::single_element_loop)]
2349        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2350            url = params.uri_replacement(url, param_name, find_this, true);
2351        }
2352        {
2353            let to_remove = ["parent"];
2354            params.remove_params(&to_remove);
2355        }
2356
2357        let url = params.parse_with_url(&url);
2358
2359        loop {
2360            let token = match self
2361                .hub
2362                .auth
2363                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2364                .await
2365            {
2366                Ok(token) => token,
2367                Err(e) => match dlg.token(e) {
2368                    Ok(token) => token,
2369                    Err(e) => {
2370                        dlg.finished(false);
2371                        return Err(common::Error::MissingToken(e));
2372                    }
2373                },
2374            };
2375            let mut req_result = {
2376                let client = &self.hub.client;
2377                dlg.pre_request();
2378                let mut req_builder = hyper::Request::builder()
2379                    .method(hyper::Method::GET)
2380                    .uri(url.as_str())
2381                    .header(USER_AGENT, self.hub._user_agent.clone());
2382
2383                if let Some(token) = token.as_ref() {
2384                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2385                }
2386
2387                let request = req_builder
2388                    .header(CONTENT_LENGTH, 0_u64)
2389                    .body(common::to_body::<String>(None));
2390
2391                client.request(request.unwrap()).await
2392            };
2393
2394            match req_result {
2395                Err(err) => {
2396                    if let common::Retry::After(d) = dlg.http_error(&err) {
2397                        sleep(d).await;
2398                        continue;
2399                    }
2400                    dlg.finished(false);
2401                    return Err(common::Error::HttpError(err));
2402                }
2403                Ok(res) => {
2404                    let (mut parts, body) = res.into_parts();
2405                    let mut body = common::Body::new(body);
2406                    if !parts.status.is_success() {
2407                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2408                        let error = serde_json::from_str(&common::to_string(&bytes));
2409                        let response = common::to_response(parts, bytes.into());
2410
2411                        if let common::Retry::After(d) =
2412                            dlg.http_failure(&response, error.as_ref().ok())
2413                        {
2414                            sleep(d).await;
2415                            continue;
2416                        }
2417
2418                        dlg.finished(false);
2419
2420                        return Err(match error {
2421                            Ok(value) => common::Error::BadRequest(value),
2422                            _ => common::Error::Failure(response),
2423                        });
2424                    }
2425                    let response = {
2426                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2427                        let encoded = common::to_string(&bytes);
2428                        match serde_json::from_str(&encoded) {
2429                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2430                            Err(error) => {
2431                                dlg.response_json_decode_error(&encoded, &error);
2432                                return Err(common::Error::JsonDecodeError(
2433                                    encoded.to_string(),
2434                                    error,
2435                                ));
2436                            }
2437                        }
2438                    };
2439
2440                    dlg.finished(true);
2441                    return Ok(response);
2442                }
2443            }
2444        }
2445    }
2446
2447    /// The parent resource. This may be "projects/{project_id}",
2448    /// "folders/{folder_id}", or "organizations/{organization_id}".
2449    ///
2450    /// Sets the *parent* path property to the given value.
2451    ///
2452    /// Even though the property as already been set when instantiating this call,
2453    /// we provide this method for API completeness.
2454    pub fn parent(mut self, new_value: &str) -> FolderApprovalRequestListCall<'a, C> {
2455        self._parent = new_value.to_string();
2456        self
2457    }
2458    /// A token identifying the page of results to return.
2459    ///
2460    /// Sets the *page token* query property to the given value.
2461    pub fn page_token(mut self, new_value: &str) -> FolderApprovalRequestListCall<'a, C> {
2462        self._page_token = Some(new_value.to_string());
2463        self
2464    }
2465    /// Requested page size.
2466    ///
2467    /// Sets the *page size* query property to the given value.
2468    pub fn page_size(mut self, new_value: i32) -> FolderApprovalRequestListCall<'a, C> {
2469        self._page_size = Some(new_value);
2470        self
2471    }
2472    /// A filter on the type of approval requests to retrieve. Must be one of the
2473    /// following values:
2474    /// <ol>
2475    ///   <li>[not set]: Requests that are pending or have active approvals.</li>
2476    ///   <li>ALL: All requests.</li>
2477    ///   <li>PENDING: Only pending requests.</li>
2478    ///   <li>ACTIVE: Only active (i.e. currently approved) requests.</li>
2479    ///   <li>DISMISSED: Only dismissed (including expired) requests.</li>
2480    ///   <li>HISTORY: Active and dismissed (including expired) requests.</li>
2481    /// </ol>
2482    ///
2483    /// Sets the *filter* query property to the given value.
2484    pub fn filter(mut self, new_value: &str) -> FolderApprovalRequestListCall<'a, C> {
2485        self._filter = Some(new_value.to_string());
2486        self
2487    }
2488    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2489    /// while executing the actual API request.
2490    ///
2491    /// ````text
2492    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2493    /// ````
2494    ///
2495    /// Sets the *delegate* property to the given value.
2496    pub fn delegate(
2497        mut self,
2498        new_value: &'a mut dyn common::Delegate,
2499    ) -> FolderApprovalRequestListCall<'a, C> {
2500        self._delegate = Some(new_value);
2501        self
2502    }
2503
2504    /// Set any additional parameter of the query string used in the request.
2505    /// It should be used to set parameters which are not yet available through their own
2506    /// setters.
2507    ///
2508    /// Please note that this method must not be used to set any of the known parameters
2509    /// which have their own setter method. If done anyway, the request will fail.
2510    ///
2511    /// # Additional Parameters
2512    ///
2513    /// * *$.xgafv* (query-string) - V1 error format.
2514    /// * *access_token* (query-string) - OAuth access token.
2515    /// * *alt* (query-string) - Data format for response.
2516    /// * *callback* (query-string) - JSONP
2517    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2518    /// * *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.
2519    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2520    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2521    /// * *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.
2522    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2523    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2524    pub fn param<T>(mut self, name: T, value: T) -> FolderApprovalRequestListCall<'a, C>
2525    where
2526        T: AsRef<str>,
2527    {
2528        self._additional_params
2529            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2530        self
2531    }
2532
2533    /// Identifies the authorization scope for the method you are building.
2534    ///
2535    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2536    /// [`Scope::CloudPlatform`].
2537    ///
2538    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2539    /// tokens for more than one scope.
2540    ///
2541    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2542    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2543    /// sufficient, a read-write scope will do as well.
2544    pub fn add_scope<St>(mut self, scope: St) -> FolderApprovalRequestListCall<'a, C>
2545    where
2546        St: AsRef<str>,
2547    {
2548        self._scopes.insert(String::from(scope.as_ref()));
2549        self
2550    }
2551    /// Identifies the authorization scope(s) for the method you are building.
2552    ///
2553    /// See [`Self::add_scope()`] for details.
2554    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderApprovalRequestListCall<'a, C>
2555    where
2556        I: IntoIterator<Item = St>,
2557        St: AsRef<str>,
2558    {
2559        self._scopes
2560            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2561        self
2562    }
2563
2564    /// Removes all scopes, and no default scope will be used either.
2565    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2566    /// for details).
2567    pub fn clear_scopes(mut self) -> FolderApprovalRequestListCall<'a, C> {
2568        self._scopes.clear();
2569        self
2570    }
2571}
2572
2573/// Deletes the settings associated with a project, folder, or organization.
2574/// This will have the effect of disabling Access Approval for the project,
2575/// folder, or organization, but only if all ancestors also have Access
2576/// Approval disabled. If Access Approval is enabled at a higher level of the
2577/// hierarchy, then Access Approval will still be enabled at this level as
2578/// the settings are inherited.
2579///
2580/// A builder for the *deleteAccessApprovalSettings* method supported by a *folder* resource.
2581/// It is not used directly, but through a [`FolderMethods`] instance.
2582///
2583/// # Example
2584///
2585/// Instantiate a resource method builder
2586///
2587/// ```test_harness,no_run
2588/// # extern crate hyper;
2589/// # extern crate hyper_rustls;
2590/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
2591/// # async fn dox() {
2592/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2593///
2594/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2595/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2596/// #     .with_native_roots()
2597/// #     .unwrap()
2598/// #     .https_only()
2599/// #     .enable_http2()
2600/// #     .build();
2601///
2602/// # let executor = hyper_util::rt::TokioExecutor::new();
2603/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2604/// #     secret,
2605/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2606/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2607/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2608/// #     ),
2609/// # ).build().await.unwrap();
2610///
2611/// # let client = hyper_util::client::legacy::Client::builder(
2612/// #     hyper_util::rt::TokioExecutor::new()
2613/// # )
2614/// # .build(
2615/// #     hyper_rustls::HttpsConnectorBuilder::new()
2616/// #         .with_native_roots()
2617/// #         .unwrap()
2618/// #         .https_or_http()
2619/// #         .enable_http2()
2620/// #         .build()
2621/// # );
2622/// # let mut hub = AccessApproval::new(client, auth);
2623/// // You can configure optional parameters by calling the respective setters at will, and
2624/// // execute the final call using `doit()`.
2625/// // Values shown here are possibly random and not representative !
2626/// let result = hub.folders().delete_access_approval_settings("name")
2627///              .doit().await;
2628/// # }
2629/// ```
2630pub struct FolderDeleteAccessApprovalSettingCall<'a, C>
2631where
2632    C: 'a,
2633{
2634    hub: &'a AccessApproval<C>,
2635    _name: String,
2636    _delegate: Option<&'a mut dyn common::Delegate>,
2637    _additional_params: HashMap<String, String>,
2638    _scopes: BTreeSet<String>,
2639}
2640
2641impl<'a, C> common::CallBuilder for FolderDeleteAccessApprovalSettingCall<'a, C> {}
2642
2643impl<'a, C> FolderDeleteAccessApprovalSettingCall<'a, C>
2644where
2645    C: common::Connector,
2646{
2647    /// Perform the operation you have build so far.
2648    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2649        use std::borrow::Cow;
2650        use std::io::{Read, Seek};
2651
2652        use common::{url::Params, ToParts};
2653        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2654
2655        let mut dd = common::DefaultDelegate;
2656        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2657        dlg.begin(common::MethodInfo {
2658            id: "accessapproval.folders.deleteAccessApprovalSettings",
2659            http_method: hyper::Method::DELETE,
2660        });
2661
2662        for &field in ["alt", "name"].iter() {
2663            if self._additional_params.contains_key(field) {
2664                dlg.finished(false);
2665                return Err(common::Error::FieldClash(field));
2666            }
2667        }
2668
2669        let mut params = Params::with_capacity(3 + self._additional_params.len());
2670        params.push("name", self._name);
2671
2672        params.extend(self._additional_params.iter());
2673
2674        params.push("alt", "json");
2675        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2676        if self._scopes.is_empty() {
2677            self._scopes
2678                .insert(Scope::CloudPlatform.as_ref().to_string());
2679        }
2680
2681        #[allow(clippy::single_element_loop)]
2682        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2683            url = params.uri_replacement(url, param_name, find_this, true);
2684        }
2685        {
2686            let to_remove = ["name"];
2687            params.remove_params(&to_remove);
2688        }
2689
2690        let url = params.parse_with_url(&url);
2691
2692        loop {
2693            let token = match self
2694                .hub
2695                .auth
2696                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2697                .await
2698            {
2699                Ok(token) => token,
2700                Err(e) => match dlg.token(e) {
2701                    Ok(token) => token,
2702                    Err(e) => {
2703                        dlg.finished(false);
2704                        return Err(common::Error::MissingToken(e));
2705                    }
2706                },
2707            };
2708            let mut req_result = {
2709                let client = &self.hub.client;
2710                dlg.pre_request();
2711                let mut req_builder = hyper::Request::builder()
2712                    .method(hyper::Method::DELETE)
2713                    .uri(url.as_str())
2714                    .header(USER_AGENT, self.hub._user_agent.clone());
2715
2716                if let Some(token) = token.as_ref() {
2717                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2718                }
2719
2720                let request = req_builder
2721                    .header(CONTENT_LENGTH, 0_u64)
2722                    .body(common::to_body::<String>(None));
2723
2724                client.request(request.unwrap()).await
2725            };
2726
2727            match req_result {
2728                Err(err) => {
2729                    if let common::Retry::After(d) = dlg.http_error(&err) {
2730                        sleep(d).await;
2731                        continue;
2732                    }
2733                    dlg.finished(false);
2734                    return Err(common::Error::HttpError(err));
2735                }
2736                Ok(res) => {
2737                    let (mut parts, body) = res.into_parts();
2738                    let mut body = common::Body::new(body);
2739                    if !parts.status.is_success() {
2740                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2741                        let error = serde_json::from_str(&common::to_string(&bytes));
2742                        let response = common::to_response(parts, bytes.into());
2743
2744                        if let common::Retry::After(d) =
2745                            dlg.http_failure(&response, error.as_ref().ok())
2746                        {
2747                            sleep(d).await;
2748                            continue;
2749                        }
2750
2751                        dlg.finished(false);
2752
2753                        return Err(match error {
2754                            Ok(value) => common::Error::BadRequest(value),
2755                            _ => common::Error::Failure(response),
2756                        });
2757                    }
2758                    let response = {
2759                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2760                        let encoded = common::to_string(&bytes);
2761                        match serde_json::from_str(&encoded) {
2762                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2763                            Err(error) => {
2764                                dlg.response_json_decode_error(&encoded, &error);
2765                                return Err(common::Error::JsonDecodeError(
2766                                    encoded.to_string(),
2767                                    error,
2768                                ));
2769                            }
2770                        }
2771                    };
2772
2773                    dlg.finished(true);
2774                    return Ok(response);
2775                }
2776            }
2777        }
2778    }
2779
2780    /// Name of the AccessApprovalSettings to delete.
2781    ///
2782    /// Sets the *name* path property to the given value.
2783    ///
2784    /// Even though the property as already been set when instantiating this call,
2785    /// we provide this method for API completeness.
2786    pub fn name(mut self, new_value: &str) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
2787        self._name = new_value.to_string();
2788        self
2789    }
2790    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2791    /// while executing the actual API request.
2792    ///
2793    /// ````text
2794    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2795    /// ````
2796    ///
2797    /// Sets the *delegate* property to the given value.
2798    pub fn delegate(
2799        mut self,
2800        new_value: &'a mut dyn common::Delegate,
2801    ) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
2802        self._delegate = Some(new_value);
2803        self
2804    }
2805
2806    /// Set any additional parameter of the query string used in the request.
2807    /// It should be used to set parameters which are not yet available through their own
2808    /// setters.
2809    ///
2810    /// Please note that this method must not be used to set any of the known parameters
2811    /// which have their own setter method. If done anyway, the request will fail.
2812    ///
2813    /// # Additional Parameters
2814    ///
2815    /// * *$.xgafv* (query-string) - V1 error format.
2816    /// * *access_token* (query-string) - OAuth access token.
2817    /// * *alt* (query-string) - Data format for response.
2818    /// * *callback* (query-string) - JSONP
2819    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2820    /// * *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.
2821    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2822    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2823    /// * *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.
2824    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2825    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2826    pub fn param<T>(mut self, name: T, value: T) -> FolderDeleteAccessApprovalSettingCall<'a, C>
2827    where
2828        T: AsRef<str>,
2829    {
2830        self._additional_params
2831            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2832        self
2833    }
2834
2835    /// Identifies the authorization scope for the method you are building.
2836    ///
2837    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2838    /// [`Scope::CloudPlatform`].
2839    ///
2840    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2841    /// tokens for more than one scope.
2842    ///
2843    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2844    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2845    /// sufficient, a read-write scope will do as well.
2846    pub fn add_scope<St>(mut self, scope: St) -> FolderDeleteAccessApprovalSettingCall<'a, C>
2847    where
2848        St: AsRef<str>,
2849    {
2850        self._scopes.insert(String::from(scope.as_ref()));
2851        self
2852    }
2853    /// Identifies the authorization scope(s) for the method you are building.
2854    ///
2855    /// See [`Self::add_scope()`] for details.
2856    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderDeleteAccessApprovalSettingCall<'a, C>
2857    where
2858        I: IntoIterator<Item = St>,
2859        St: AsRef<str>,
2860    {
2861        self._scopes
2862            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2863        self
2864    }
2865
2866    /// Removes all scopes, and no default scope will be used either.
2867    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2868    /// for details).
2869    pub fn clear_scopes(mut self) -> FolderDeleteAccessApprovalSettingCall<'a, C> {
2870        self._scopes.clear();
2871        self
2872    }
2873}
2874
2875/// Gets the settings associated with a project, folder, or organization.
2876///
2877/// A builder for the *getAccessApprovalSettings* method supported by a *folder* resource.
2878/// It is not used directly, but through a [`FolderMethods`] instance.
2879///
2880/// # Example
2881///
2882/// Instantiate a resource method builder
2883///
2884/// ```test_harness,no_run
2885/// # extern crate hyper;
2886/// # extern crate hyper_rustls;
2887/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
2888/// # async fn dox() {
2889/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2890///
2891/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2892/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2893/// #     .with_native_roots()
2894/// #     .unwrap()
2895/// #     .https_only()
2896/// #     .enable_http2()
2897/// #     .build();
2898///
2899/// # let executor = hyper_util::rt::TokioExecutor::new();
2900/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2901/// #     secret,
2902/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2903/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2904/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2905/// #     ),
2906/// # ).build().await.unwrap();
2907///
2908/// # let client = hyper_util::client::legacy::Client::builder(
2909/// #     hyper_util::rt::TokioExecutor::new()
2910/// # )
2911/// # .build(
2912/// #     hyper_rustls::HttpsConnectorBuilder::new()
2913/// #         .with_native_roots()
2914/// #         .unwrap()
2915/// #         .https_or_http()
2916/// #         .enable_http2()
2917/// #         .build()
2918/// # );
2919/// # let mut hub = AccessApproval::new(client, auth);
2920/// // You can configure optional parameters by calling the respective setters at will, and
2921/// // execute the final call using `doit()`.
2922/// // Values shown here are possibly random and not representative !
2923/// let result = hub.folders().get_access_approval_settings("name")
2924///              .doit().await;
2925/// # }
2926/// ```
2927pub struct FolderGetAccessApprovalSettingCall<'a, C>
2928where
2929    C: 'a,
2930{
2931    hub: &'a AccessApproval<C>,
2932    _name: String,
2933    _delegate: Option<&'a mut dyn common::Delegate>,
2934    _additional_params: HashMap<String, String>,
2935    _scopes: BTreeSet<String>,
2936}
2937
2938impl<'a, C> common::CallBuilder for FolderGetAccessApprovalSettingCall<'a, C> {}
2939
2940impl<'a, C> FolderGetAccessApprovalSettingCall<'a, C>
2941where
2942    C: common::Connector,
2943{
2944    /// Perform the operation you have build so far.
2945    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
2946        use std::borrow::Cow;
2947        use std::io::{Read, Seek};
2948
2949        use common::{url::Params, ToParts};
2950        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2951
2952        let mut dd = common::DefaultDelegate;
2953        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2954        dlg.begin(common::MethodInfo {
2955            id: "accessapproval.folders.getAccessApprovalSettings",
2956            http_method: hyper::Method::GET,
2957        });
2958
2959        for &field in ["alt", "name"].iter() {
2960            if self._additional_params.contains_key(field) {
2961                dlg.finished(false);
2962                return Err(common::Error::FieldClash(field));
2963            }
2964        }
2965
2966        let mut params = Params::with_capacity(3 + self._additional_params.len());
2967        params.push("name", self._name);
2968
2969        params.extend(self._additional_params.iter());
2970
2971        params.push("alt", "json");
2972        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2973        if self._scopes.is_empty() {
2974            self._scopes
2975                .insert(Scope::CloudPlatform.as_ref().to_string());
2976        }
2977
2978        #[allow(clippy::single_element_loop)]
2979        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2980            url = params.uri_replacement(url, param_name, find_this, true);
2981        }
2982        {
2983            let to_remove = ["name"];
2984            params.remove_params(&to_remove);
2985        }
2986
2987        let url = params.parse_with_url(&url);
2988
2989        loop {
2990            let token = match self
2991                .hub
2992                .auth
2993                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2994                .await
2995            {
2996                Ok(token) => token,
2997                Err(e) => match dlg.token(e) {
2998                    Ok(token) => token,
2999                    Err(e) => {
3000                        dlg.finished(false);
3001                        return Err(common::Error::MissingToken(e));
3002                    }
3003                },
3004            };
3005            let mut req_result = {
3006                let client = &self.hub.client;
3007                dlg.pre_request();
3008                let mut req_builder = hyper::Request::builder()
3009                    .method(hyper::Method::GET)
3010                    .uri(url.as_str())
3011                    .header(USER_AGENT, self.hub._user_agent.clone());
3012
3013                if let Some(token) = token.as_ref() {
3014                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3015                }
3016
3017                let request = req_builder
3018                    .header(CONTENT_LENGTH, 0_u64)
3019                    .body(common::to_body::<String>(None));
3020
3021                client.request(request.unwrap()).await
3022            };
3023
3024            match req_result {
3025                Err(err) => {
3026                    if let common::Retry::After(d) = dlg.http_error(&err) {
3027                        sleep(d).await;
3028                        continue;
3029                    }
3030                    dlg.finished(false);
3031                    return Err(common::Error::HttpError(err));
3032                }
3033                Ok(res) => {
3034                    let (mut parts, body) = res.into_parts();
3035                    let mut body = common::Body::new(body);
3036                    if !parts.status.is_success() {
3037                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3038                        let error = serde_json::from_str(&common::to_string(&bytes));
3039                        let response = common::to_response(parts, bytes.into());
3040
3041                        if let common::Retry::After(d) =
3042                            dlg.http_failure(&response, error.as_ref().ok())
3043                        {
3044                            sleep(d).await;
3045                            continue;
3046                        }
3047
3048                        dlg.finished(false);
3049
3050                        return Err(match error {
3051                            Ok(value) => common::Error::BadRequest(value),
3052                            _ => common::Error::Failure(response),
3053                        });
3054                    }
3055                    let response = {
3056                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3057                        let encoded = common::to_string(&bytes);
3058                        match serde_json::from_str(&encoded) {
3059                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3060                            Err(error) => {
3061                                dlg.response_json_decode_error(&encoded, &error);
3062                                return Err(common::Error::JsonDecodeError(
3063                                    encoded.to_string(),
3064                                    error,
3065                                ));
3066                            }
3067                        }
3068                    };
3069
3070                    dlg.finished(true);
3071                    return Ok(response);
3072                }
3073            }
3074        }
3075    }
3076
3077    /// Name of the AccessApprovalSettings to retrieve.
3078    ///
3079    /// Sets the *name* path property to the given value.
3080    ///
3081    /// Even though the property as already been set when instantiating this call,
3082    /// we provide this method for API completeness.
3083    pub fn name(mut self, new_value: &str) -> FolderGetAccessApprovalSettingCall<'a, C> {
3084        self._name = new_value.to_string();
3085        self
3086    }
3087    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3088    /// while executing the actual API request.
3089    ///
3090    /// ````text
3091    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3092    /// ````
3093    ///
3094    /// Sets the *delegate* property to the given value.
3095    pub fn delegate(
3096        mut self,
3097        new_value: &'a mut dyn common::Delegate,
3098    ) -> FolderGetAccessApprovalSettingCall<'a, C> {
3099        self._delegate = Some(new_value);
3100        self
3101    }
3102
3103    /// Set any additional parameter of the query string used in the request.
3104    /// It should be used to set parameters which are not yet available through their own
3105    /// setters.
3106    ///
3107    /// Please note that this method must not be used to set any of the known parameters
3108    /// which have their own setter method. If done anyway, the request will fail.
3109    ///
3110    /// # Additional Parameters
3111    ///
3112    /// * *$.xgafv* (query-string) - V1 error format.
3113    /// * *access_token* (query-string) - OAuth access token.
3114    /// * *alt* (query-string) - Data format for response.
3115    /// * *callback* (query-string) - JSONP
3116    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3117    /// * *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.
3118    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3119    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3120    /// * *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.
3121    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3122    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3123    pub fn param<T>(mut self, name: T, value: T) -> FolderGetAccessApprovalSettingCall<'a, C>
3124    where
3125        T: AsRef<str>,
3126    {
3127        self._additional_params
3128            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3129        self
3130    }
3131
3132    /// Identifies the authorization scope for the method you are building.
3133    ///
3134    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3135    /// [`Scope::CloudPlatform`].
3136    ///
3137    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3138    /// tokens for more than one scope.
3139    ///
3140    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3141    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3142    /// sufficient, a read-write scope will do as well.
3143    pub fn add_scope<St>(mut self, scope: St) -> FolderGetAccessApprovalSettingCall<'a, C>
3144    where
3145        St: AsRef<str>,
3146    {
3147        self._scopes.insert(String::from(scope.as_ref()));
3148        self
3149    }
3150    /// Identifies the authorization scope(s) for the method you are building.
3151    ///
3152    /// See [`Self::add_scope()`] for details.
3153    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetAccessApprovalSettingCall<'a, C>
3154    where
3155        I: IntoIterator<Item = St>,
3156        St: AsRef<str>,
3157    {
3158        self._scopes
3159            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3160        self
3161    }
3162
3163    /// Removes all scopes, and no default scope will be used either.
3164    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3165    /// for details).
3166    pub fn clear_scopes(mut self) -> FolderGetAccessApprovalSettingCall<'a, C> {
3167        self._scopes.clear();
3168        self
3169    }
3170}
3171
3172/// Updates the settings associated with a project, folder, or organization.
3173/// Settings to update are determined by the value of field_mask.
3174///
3175/// A builder for the *updateAccessApprovalSettings* method supported by a *folder* resource.
3176/// It is not used directly, but through a [`FolderMethods`] instance.
3177///
3178/// # Example
3179///
3180/// Instantiate a resource method builder
3181///
3182/// ```test_harness,no_run
3183/// # extern crate hyper;
3184/// # extern crate hyper_rustls;
3185/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
3186/// use accessapproval1_beta1::api::AccessApprovalSettings;
3187/// # async fn dox() {
3188/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3189///
3190/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3191/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3192/// #     .with_native_roots()
3193/// #     .unwrap()
3194/// #     .https_only()
3195/// #     .enable_http2()
3196/// #     .build();
3197///
3198/// # let executor = hyper_util::rt::TokioExecutor::new();
3199/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3200/// #     secret,
3201/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3202/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3203/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3204/// #     ),
3205/// # ).build().await.unwrap();
3206///
3207/// # let client = hyper_util::client::legacy::Client::builder(
3208/// #     hyper_util::rt::TokioExecutor::new()
3209/// # )
3210/// # .build(
3211/// #     hyper_rustls::HttpsConnectorBuilder::new()
3212/// #         .with_native_roots()
3213/// #         .unwrap()
3214/// #         .https_or_http()
3215/// #         .enable_http2()
3216/// #         .build()
3217/// # );
3218/// # let mut hub = AccessApproval::new(client, auth);
3219/// // As the method needs a request, you would usually fill it with the desired information
3220/// // into the respective structure. Some of the parts shown here might not be applicable !
3221/// // Values shown here are possibly random and not representative !
3222/// let mut req = AccessApprovalSettings::default();
3223///
3224/// // You can configure optional parameters by calling the respective setters at will, and
3225/// // execute the final call using `doit()`.
3226/// // Values shown here are possibly random and not representative !
3227/// let result = hub.folders().update_access_approval_settings(req, "name")
3228///              .update_mask(FieldMask::new::<&str>(&[]))
3229///              .doit().await;
3230/// # }
3231/// ```
3232pub struct FolderUpdateAccessApprovalSettingCall<'a, C>
3233where
3234    C: 'a,
3235{
3236    hub: &'a AccessApproval<C>,
3237    _request: AccessApprovalSettings,
3238    _name: String,
3239    _update_mask: Option<common::FieldMask>,
3240    _delegate: Option<&'a mut dyn common::Delegate>,
3241    _additional_params: HashMap<String, String>,
3242    _scopes: BTreeSet<String>,
3243}
3244
3245impl<'a, C> common::CallBuilder for FolderUpdateAccessApprovalSettingCall<'a, C> {}
3246
3247impl<'a, C> FolderUpdateAccessApprovalSettingCall<'a, C>
3248where
3249    C: common::Connector,
3250{
3251    /// Perform the operation you have build so far.
3252    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
3253        use std::borrow::Cow;
3254        use std::io::{Read, Seek};
3255
3256        use common::{url::Params, ToParts};
3257        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3258
3259        let mut dd = common::DefaultDelegate;
3260        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3261        dlg.begin(common::MethodInfo {
3262            id: "accessapproval.folders.updateAccessApprovalSettings",
3263            http_method: hyper::Method::PATCH,
3264        });
3265
3266        for &field in ["alt", "name", "updateMask"].iter() {
3267            if self._additional_params.contains_key(field) {
3268                dlg.finished(false);
3269                return Err(common::Error::FieldClash(field));
3270            }
3271        }
3272
3273        let mut params = Params::with_capacity(5 + self._additional_params.len());
3274        params.push("name", self._name);
3275        if let Some(value) = self._update_mask.as_ref() {
3276            params.push("updateMask", value.to_string());
3277        }
3278
3279        params.extend(self._additional_params.iter());
3280
3281        params.push("alt", "json");
3282        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3283        if self._scopes.is_empty() {
3284            self._scopes
3285                .insert(Scope::CloudPlatform.as_ref().to_string());
3286        }
3287
3288        #[allow(clippy::single_element_loop)]
3289        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3290            url = params.uri_replacement(url, param_name, find_this, true);
3291        }
3292        {
3293            let to_remove = ["name"];
3294            params.remove_params(&to_remove);
3295        }
3296
3297        let url = params.parse_with_url(&url);
3298
3299        let mut json_mime_type = mime::APPLICATION_JSON;
3300        let mut request_value_reader = {
3301            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3302            common::remove_json_null_values(&mut value);
3303            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3304            serde_json::to_writer(&mut dst, &value).unwrap();
3305            dst
3306        };
3307        let request_size = request_value_reader
3308            .seek(std::io::SeekFrom::End(0))
3309            .unwrap();
3310        request_value_reader
3311            .seek(std::io::SeekFrom::Start(0))
3312            .unwrap();
3313
3314        loop {
3315            let token = match self
3316                .hub
3317                .auth
3318                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3319                .await
3320            {
3321                Ok(token) => token,
3322                Err(e) => match dlg.token(e) {
3323                    Ok(token) => token,
3324                    Err(e) => {
3325                        dlg.finished(false);
3326                        return Err(common::Error::MissingToken(e));
3327                    }
3328                },
3329            };
3330            request_value_reader
3331                .seek(std::io::SeekFrom::Start(0))
3332                .unwrap();
3333            let mut req_result = {
3334                let client = &self.hub.client;
3335                dlg.pre_request();
3336                let mut req_builder = hyper::Request::builder()
3337                    .method(hyper::Method::PATCH)
3338                    .uri(url.as_str())
3339                    .header(USER_AGENT, self.hub._user_agent.clone());
3340
3341                if let Some(token) = token.as_ref() {
3342                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3343                }
3344
3345                let request = req_builder
3346                    .header(CONTENT_TYPE, json_mime_type.to_string())
3347                    .header(CONTENT_LENGTH, request_size as u64)
3348                    .body(common::to_body(
3349                        request_value_reader.get_ref().clone().into(),
3350                    ));
3351
3352                client.request(request.unwrap()).await
3353            };
3354
3355            match req_result {
3356                Err(err) => {
3357                    if let common::Retry::After(d) = dlg.http_error(&err) {
3358                        sleep(d).await;
3359                        continue;
3360                    }
3361                    dlg.finished(false);
3362                    return Err(common::Error::HttpError(err));
3363                }
3364                Ok(res) => {
3365                    let (mut parts, body) = res.into_parts();
3366                    let mut body = common::Body::new(body);
3367                    if !parts.status.is_success() {
3368                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3369                        let error = serde_json::from_str(&common::to_string(&bytes));
3370                        let response = common::to_response(parts, bytes.into());
3371
3372                        if let common::Retry::After(d) =
3373                            dlg.http_failure(&response, error.as_ref().ok())
3374                        {
3375                            sleep(d).await;
3376                            continue;
3377                        }
3378
3379                        dlg.finished(false);
3380
3381                        return Err(match error {
3382                            Ok(value) => common::Error::BadRequest(value),
3383                            _ => common::Error::Failure(response),
3384                        });
3385                    }
3386                    let response = {
3387                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3388                        let encoded = common::to_string(&bytes);
3389                        match serde_json::from_str(&encoded) {
3390                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3391                            Err(error) => {
3392                                dlg.response_json_decode_error(&encoded, &error);
3393                                return Err(common::Error::JsonDecodeError(
3394                                    encoded.to_string(),
3395                                    error,
3396                                ));
3397                            }
3398                        }
3399                    };
3400
3401                    dlg.finished(true);
3402                    return Ok(response);
3403                }
3404            }
3405        }
3406    }
3407
3408    ///
3409    /// Sets the *request* property to the given value.
3410    ///
3411    /// Even though the property as already been set when instantiating this call,
3412    /// we provide this method for API completeness.
3413    pub fn request(
3414        mut self,
3415        new_value: AccessApprovalSettings,
3416    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
3417        self._request = new_value;
3418        self
3419    }
3420    /// The resource name of the settings. Format is one of:
3421    /// <ol>
3422    ///   <li>"projects/{project_id}/accessApprovalSettings"</li>
3423    ///   <li>"folders/{folder_id}/accessApprovalSettings"</li>
3424    ///   <li>"organizations/{organization_id}/accessApprovalSettings"</li>
3425    /// <ol>
3426    ///
3427    /// Sets the *name* path property to the given value.
3428    ///
3429    /// Even though the property as already been set when instantiating this call,
3430    /// we provide this method for API completeness.
3431    pub fn name(mut self, new_value: &str) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
3432        self._name = new_value.to_string();
3433        self
3434    }
3435    /// For the `FieldMask` definition, see
3436    /// https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
3437    /// If this field is left unset, only the notification_emails field will be
3438    /// updated.
3439    ///
3440    /// Sets the *update mask* query property to the given value.
3441    pub fn update_mask(
3442        mut self,
3443        new_value: common::FieldMask,
3444    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
3445        self._update_mask = Some(new_value);
3446        self
3447    }
3448    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3449    /// while executing the actual API request.
3450    ///
3451    /// ````text
3452    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3453    /// ````
3454    ///
3455    /// Sets the *delegate* property to the given value.
3456    pub fn delegate(
3457        mut self,
3458        new_value: &'a mut dyn common::Delegate,
3459    ) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
3460        self._delegate = Some(new_value);
3461        self
3462    }
3463
3464    /// Set any additional parameter of the query string used in the request.
3465    /// It should be used to set parameters which are not yet available through their own
3466    /// setters.
3467    ///
3468    /// Please note that this method must not be used to set any of the known parameters
3469    /// which have their own setter method. If done anyway, the request will fail.
3470    ///
3471    /// # Additional Parameters
3472    ///
3473    /// * *$.xgafv* (query-string) - V1 error format.
3474    /// * *access_token* (query-string) - OAuth access token.
3475    /// * *alt* (query-string) - Data format for response.
3476    /// * *callback* (query-string) - JSONP
3477    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3478    /// * *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.
3479    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3480    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3481    /// * *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.
3482    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3483    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3484    pub fn param<T>(mut self, name: T, value: T) -> FolderUpdateAccessApprovalSettingCall<'a, C>
3485    where
3486        T: AsRef<str>,
3487    {
3488        self._additional_params
3489            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3490        self
3491    }
3492
3493    /// Identifies the authorization scope for the method you are building.
3494    ///
3495    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3496    /// [`Scope::CloudPlatform`].
3497    ///
3498    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3499    /// tokens for more than one scope.
3500    ///
3501    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3502    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3503    /// sufficient, a read-write scope will do as well.
3504    pub fn add_scope<St>(mut self, scope: St) -> FolderUpdateAccessApprovalSettingCall<'a, C>
3505    where
3506        St: AsRef<str>,
3507    {
3508        self._scopes.insert(String::from(scope.as_ref()));
3509        self
3510    }
3511    /// Identifies the authorization scope(s) for the method you are building.
3512    ///
3513    /// See [`Self::add_scope()`] for details.
3514    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderUpdateAccessApprovalSettingCall<'a, C>
3515    where
3516        I: IntoIterator<Item = St>,
3517        St: AsRef<str>,
3518    {
3519        self._scopes
3520            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3521        self
3522    }
3523
3524    /// Removes all scopes, and no default scope will be used either.
3525    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3526    /// for details).
3527    pub fn clear_scopes(mut self) -> FolderUpdateAccessApprovalSettingCall<'a, C> {
3528        self._scopes.clear();
3529        self
3530    }
3531}
3532
3533/// Approves a request and returns the updated ApprovalRequest.
3534///
3535/// Returns NOT_FOUND if the request does not exist. Returns
3536/// FAILED_PRECONDITION if the request exists but is not in a pending state.
3537///
3538/// A builder for the *approvalRequests.approve* method supported by a *organization* resource.
3539/// It is not used directly, but through a [`OrganizationMethods`] instance.
3540///
3541/// # Example
3542///
3543/// Instantiate a resource method builder
3544///
3545/// ```test_harness,no_run
3546/// # extern crate hyper;
3547/// # extern crate hyper_rustls;
3548/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
3549/// use accessapproval1_beta1::api::ApproveApprovalRequestMessage;
3550/// # async fn dox() {
3551/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3552///
3553/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3554/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3555/// #     .with_native_roots()
3556/// #     .unwrap()
3557/// #     .https_only()
3558/// #     .enable_http2()
3559/// #     .build();
3560///
3561/// # let executor = hyper_util::rt::TokioExecutor::new();
3562/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3563/// #     secret,
3564/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3565/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3566/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3567/// #     ),
3568/// # ).build().await.unwrap();
3569///
3570/// # let client = hyper_util::client::legacy::Client::builder(
3571/// #     hyper_util::rt::TokioExecutor::new()
3572/// # )
3573/// # .build(
3574/// #     hyper_rustls::HttpsConnectorBuilder::new()
3575/// #         .with_native_roots()
3576/// #         .unwrap()
3577/// #         .https_or_http()
3578/// #         .enable_http2()
3579/// #         .build()
3580/// # );
3581/// # let mut hub = AccessApproval::new(client, auth);
3582/// // As the method needs a request, you would usually fill it with the desired information
3583/// // into the respective structure. Some of the parts shown here might not be applicable !
3584/// // Values shown here are possibly random and not representative !
3585/// let mut req = ApproveApprovalRequestMessage::default();
3586///
3587/// // You can configure optional parameters by calling the respective setters at will, and
3588/// // execute the final call using `doit()`.
3589/// // Values shown here are possibly random and not representative !
3590/// let result = hub.organizations().approval_requests_approve(req, "name")
3591///              .doit().await;
3592/// # }
3593/// ```
3594pub struct OrganizationApprovalRequestApproveCall<'a, C>
3595where
3596    C: 'a,
3597{
3598    hub: &'a AccessApproval<C>,
3599    _request: ApproveApprovalRequestMessage,
3600    _name: String,
3601    _delegate: Option<&'a mut dyn common::Delegate>,
3602    _additional_params: HashMap<String, String>,
3603    _scopes: BTreeSet<String>,
3604}
3605
3606impl<'a, C> common::CallBuilder for OrganizationApprovalRequestApproveCall<'a, C> {}
3607
3608impl<'a, C> OrganizationApprovalRequestApproveCall<'a, C>
3609where
3610    C: common::Connector,
3611{
3612    /// Perform the operation you have build so far.
3613    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
3614        use std::borrow::Cow;
3615        use std::io::{Read, Seek};
3616
3617        use common::{url::Params, ToParts};
3618        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3619
3620        let mut dd = common::DefaultDelegate;
3621        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3622        dlg.begin(common::MethodInfo {
3623            id: "accessapproval.organizations.approvalRequests.approve",
3624            http_method: hyper::Method::POST,
3625        });
3626
3627        for &field in ["alt", "name"].iter() {
3628            if self._additional_params.contains_key(field) {
3629                dlg.finished(false);
3630                return Err(common::Error::FieldClash(field));
3631            }
3632        }
3633
3634        let mut params = Params::with_capacity(4 + self._additional_params.len());
3635        params.push("name", self._name);
3636
3637        params.extend(self._additional_params.iter());
3638
3639        params.push("alt", "json");
3640        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:approve";
3641        if self._scopes.is_empty() {
3642            self._scopes
3643                .insert(Scope::CloudPlatform.as_ref().to_string());
3644        }
3645
3646        #[allow(clippy::single_element_loop)]
3647        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3648            url = params.uri_replacement(url, param_name, find_this, true);
3649        }
3650        {
3651            let to_remove = ["name"];
3652            params.remove_params(&to_remove);
3653        }
3654
3655        let url = params.parse_with_url(&url);
3656
3657        let mut json_mime_type = mime::APPLICATION_JSON;
3658        let mut request_value_reader = {
3659            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3660            common::remove_json_null_values(&mut value);
3661            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3662            serde_json::to_writer(&mut dst, &value).unwrap();
3663            dst
3664        };
3665        let request_size = request_value_reader
3666            .seek(std::io::SeekFrom::End(0))
3667            .unwrap();
3668        request_value_reader
3669            .seek(std::io::SeekFrom::Start(0))
3670            .unwrap();
3671
3672        loop {
3673            let token = match self
3674                .hub
3675                .auth
3676                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3677                .await
3678            {
3679                Ok(token) => token,
3680                Err(e) => match dlg.token(e) {
3681                    Ok(token) => token,
3682                    Err(e) => {
3683                        dlg.finished(false);
3684                        return Err(common::Error::MissingToken(e));
3685                    }
3686                },
3687            };
3688            request_value_reader
3689                .seek(std::io::SeekFrom::Start(0))
3690                .unwrap();
3691            let mut req_result = {
3692                let client = &self.hub.client;
3693                dlg.pre_request();
3694                let mut req_builder = hyper::Request::builder()
3695                    .method(hyper::Method::POST)
3696                    .uri(url.as_str())
3697                    .header(USER_AGENT, self.hub._user_agent.clone());
3698
3699                if let Some(token) = token.as_ref() {
3700                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3701                }
3702
3703                let request = req_builder
3704                    .header(CONTENT_TYPE, json_mime_type.to_string())
3705                    .header(CONTENT_LENGTH, request_size as u64)
3706                    .body(common::to_body(
3707                        request_value_reader.get_ref().clone().into(),
3708                    ));
3709
3710                client.request(request.unwrap()).await
3711            };
3712
3713            match req_result {
3714                Err(err) => {
3715                    if let common::Retry::After(d) = dlg.http_error(&err) {
3716                        sleep(d).await;
3717                        continue;
3718                    }
3719                    dlg.finished(false);
3720                    return Err(common::Error::HttpError(err));
3721                }
3722                Ok(res) => {
3723                    let (mut parts, body) = res.into_parts();
3724                    let mut body = common::Body::new(body);
3725                    if !parts.status.is_success() {
3726                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3727                        let error = serde_json::from_str(&common::to_string(&bytes));
3728                        let response = common::to_response(parts, bytes.into());
3729
3730                        if let common::Retry::After(d) =
3731                            dlg.http_failure(&response, error.as_ref().ok())
3732                        {
3733                            sleep(d).await;
3734                            continue;
3735                        }
3736
3737                        dlg.finished(false);
3738
3739                        return Err(match error {
3740                            Ok(value) => common::Error::BadRequest(value),
3741                            _ => common::Error::Failure(response),
3742                        });
3743                    }
3744                    let response = {
3745                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3746                        let encoded = common::to_string(&bytes);
3747                        match serde_json::from_str(&encoded) {
3748                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3749                            Err(error) => {
3750                                dlg.response_json_decode_error(&encoded, &error);
3751                                return Err(common::Error::JsonDecodeError(
3752                                    encoded.to_string(),
3753                                    error,
3754                                ));
3755                            }
3756                        }
3757                    };
3758
3759                    dlg.finished(true);
3760                    return Ok(response);
3761                }
3762            }
3763        }
3764    }
3765
3766    ///
3767    /// Sets the *request* property to the given value.
3768    ///
3769    /// Even though the property as already been set when instantiating this call,
3770    /// we provide this method for API completeness.
3771    pub fn request(
3772        mut self,
3773        new_value: ApproveApprovalRequestMessage,
3774    ) -> OrganizationApprovalRequestApproveCall<'a, C> {
3775        self._request = new_value;
3776        self
3777    }
3778    /// Name of the approval request to approve.
3779    ///
3780    /// Sets the *name* path property to the given value.
3781    ///
3782    /// Even though the property as already been set when instantiating this call,
3783    /// we provide this method for API completeness.
3784    pub fn name(mut self, new_value: &str) -> OrganizationApprovalRequestApproveCall<'a, C> {
3785        self._name = new_value.to_string();
3786        self
3787    }
3788    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3789    /// while executing the actual API request.
3790    ///
3791    /// ````text
3792    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3793    /// ````
3794    ///
3795    /// Sets the *delegate* property to the given value.
3796    pub fn delegate(
3797        mut self,
3798        new_value: &'a mut dyn common::Delegate,
3799    ) -> OrganizationApprovalRequestApproveCall<'a, C> {
3800        self._delegate = Some(new_value);
3801        self
3802    }
3803
3804    /// Set any additional parameter of the query string used in the request.
3805    /// It should be used to set parameters which are not yet available through their own
3806    /// setters.
3807    ///
3808    /// Please note that this method must not be used to set any of the known parameters
3809    /// which have their own setter method. If done anyway, the request will fail.
3810    ///
3811    /// # Additional Parameters
3812    ///
3813    /// * *$.xgafv* (query-string) - V1 error format.
3814    /// * *access_token* (query-string) - OAuth access token.
3815    /// * *alt* (query-string) - Data format for response.
3816    /// * *callback* (query-string) - JSONP
3817    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3818    /// * *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.
3819    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3820    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3821    /// * *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.
3822    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3823    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3824    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestApproveCall<'a, C>
3825    where
3826        T: AsRef<str>,
3827    {
3828        self._additional_params
3829            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3830        self
3831    }
3832
3833    /// Identifies the authorization scope for the method you are building.
3834    ///
3835    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3836    /// [`Scope::CloudPlatform`].
3837    ///
3838    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3839    /// tokens for more than one scope.
3840    ///
3841    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3842    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3843    /// sufficient, a read-write scope will do as well.
3844    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestApproveCall<'a, C>
3845    where
3846        St: AsRef<str>,
3847    {
3848        self._scopes.insert(String::from(scope.as_ref()));
3849        self
3850    }
3851    /// Identifies the authorization scope(s) for the method you are building.
3852    ///
3853    /// See [`Self::add_scope()`] for details.
3854    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestApproveCall<'a, C>
3855    where
3856        I: IntoIterator<Item = St>,
3857        St: AsRef<str>,
3858    {
3859        self._scopes
3860            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3861        self
3862    }
3863
3864    /// Removes all scopes, and no default scope will be used either.
3865    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3866    /// for details).
3867    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestApproveCall<'a, C> {
3868        self._scopes.clear();
3869        self
3870    }
3871}
3872
3873/// Dismisses a request. Returns the updated ApprovalRequest.
3874///
3875/// NOTE: This does not deny access to the resource if another request has been
3876/// made and approved. It is equivalent in effect to ignoring the request
3877/// altogether.
3878///
3879/// Returns NOT_FOUND if the request does not exist.
3880///
3881/// Returns FAILED_PRECONDITION if the request exists but is not in a pending
3882/// state.
3883///
3884/// A builder for the *approvalRequests.dismiss* method supported by a *organization* resource.
3885/// It is not used directly, but through a [`OrganizationMethods`] instance.
3886///
3887/// # Example
3888///
3889/// Instantiate a resource method builder
3890///
3891/// ```test_harness,no_run
3892/// # extern crate hyper;
3893/// # extern crate hyper_rustls;
3894/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
3895/// use accessapproval1_beta1::api::DismissApprovalRequestMessage;
3896/// # async fn dox() {
3897/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3898///
3899/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3900/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3901/// #     .with_native_roots()
3902/// #     .unwrap()
3903/// #     .https_only()
3904/// #     .enable_http2()
3905/// #     .build();
3906///
3907/// # let executor = hyper_util::rt::TokioExecutor::new();
3908/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3909/// #     secret,
3910/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3911/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3912/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3913/// #     ),
3914/// # ).build().await.unwrap();
3915///
3916/// # let client = hyper_util::client::legacy::Client::builder(
3917/// #     hyper_util::rt::TokioExecutor::new()
3918/// # )
3919/// # .build(
3920/// #     hyper_rustls::HttpsConnectorBuilder::new()
3921/// #         .with_native_roots()
3922/// #         .unwrap()
3923/// #         .https_or_http()
3924/// #         .enable_http2()
3925/// #         .build()
3926/// # );
3927/// # let mut hub = AccessApproval::new(client, auth);
3928/// // As the method needs a request, you would usually fill it with the desired information
3929/// // into the respective structure. Some of the parts shown here might not be applicable !
3930/// // Values shown here are possibly random and not representative !
3931/// let mut req = DismissApprovalRequestMessage::default();
3932///
3933/// // You can configure optional parameters by calling the respective setters at will, and
3934/// // execute the final call using `doit()`.
3935/// // Values shown here are possibly random and not representative !
3936/// let result = hub.organizations().approval_requests_dismiss(req, "name")
3937///              .doit().await;
3938/// # }
3939/// ```
3940pub struct OrganizationApprovalRequestDismisCall<'a, C>
3941where
3942    C: 'a,
3943{
3944    hub: &'a AccessApproval<C>,
3945    _request: DismissApprovalRequestMessage,
3946    _name: String,
3947    _delegate: Option<&'a mut dyn common::Delegate>,
3948    _additional_params: HashMap<String, String>,
3949    _scopes: BTreeSet<String>,
3950}
3951
3952impl<'a, C> common::CallBuilder for OrganizationApprovalRequestDismisCall<'a, C> {}
3953
3954impl<'a, C> OrganizationApprovalRequestDismisCall<'a, C>
3955where
3956    C: common::Connector,
3957{
3958    /// Perform the operation you have build so far.
3959    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
3960        use std::borrow::Cow;
3961        use std::io::{Read, Seek};
3962
3963        use common::{url::Params, ToParts};
3964        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3965
3966        let mut dd = common::DefaultDelegate;
3967        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3968        dlg.begin(common::MethodInfo {
3969            id: "accessapproval.organizations.approvalRequests.dismiss",
3970            http_method: hyper::Method::POST,
3971        });
3972
3973        for &field in ["alt", "name"].iter() {
3974            if self._additional_params.contains_key(field) {
3975                dlg.finished(false);
3976                return Err(common::Error::FieldClash(field));
3977            }
3978        }
3979
3980        let mut params = Params::with_capacity(4 + self._additional_params.len());
3981        params.push("name", self._name);
3982
3983        params.extend(self._additional_params.iter());
3984
3985        params.push("alt", "json");
3986        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:dismiss";
3987        if self._scopes.is_empty() {
3988            self._scopes
3989                .insert(Scope::CloudPlatform.as_ref().to_string());
3990        }
3991
3992        #[allow(clippy::single_element_loop)]
3993        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3994            url = params.uri_replacement(url, param_name, find_this, true);
3995        }
3996        {
3997            let to_remove = ["name"];
3998            params.remove_params(&to_remove);
3999        }
4000
4001        let url = params.parse_with_url(&url);
4002
4003        let mut json_mime_type = mime::APPLICATION_JSON;
4004        let mut request_value_reader = {
4005            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4006            common::remove_json_null_values(&mut value);
4007            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4008            serde_json::to_writer(&mut dst, &value).unwrap();
4009            dst
4010        };
4011        let request_size = request_value_reader
4012            .seek(std::io::SeekFrom::End(0))
4013            .unwrap();
4014        request_value_reader
4015            .seek(std::io::SeekFrom::Start(0))
4016            .unwrap();
4017
4018        loop {
4019            let token = match self
4020                .hub
4021                .auth
4022                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4023                .await
4024            {
4025                Ok(token) => token,
4026                Err(e) => match dlg.token(e) {
4027                    Ok(token) => token,
4028                    Err(e) => {
4029                        dlg.finished(false);
4030                        return Err(common::Error::MissingToken(e));
4031                    }
4032                },
4033            };
4034            request_value_reader
4035                .seek(std::io::SeekFrom::Start(0))
4036                .unwrap();
4037            let mut req_result = {
4038                let client = &self.hub.client;
4039                dlg.pre_request();
4040                let mut req_builder = hyper::Request::builder()
4041                    .method(hyper::Method::POST)
4042                    .uri(url.as_str())
4043                    .header(USER_AGENT, self.hub._user_agent.clone());
4044
4045                if let Some(token) = token.as_ref() {
4046                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4047                }
4048
4049                let request = req_builder
4050                    .header(CONTENT_TYPE, json_mime_type.to_string())
4051                    .header(CONTENT_LENGTH, request_size as u64)
4052                    .body(common::to_body(
4053                        request_value_reader.get_ref().clone().into(),
4054                    ));
4055
4056                client.request(request.unwrap()).await
4057            };
4058
4059            match req_result {
4060                Err(err) => {
4061                    if let common::Retry::After(d) = dlg.http_error(&err) {
4062                        sleep(d).await;
4063                        continue;
4064                    }
4065                    dlg.finished(false);
4066                    return Err(common::Error::HttpError(err));
4067                }
4068                Ok(res) => {
4069                    let (mut parts, body) = res.into_parts();
4070                    let mut body = common::Body::new(body);
4071                    if !parts.status.is_success() {
4072                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4073                        let error = serde_json::from_str(&common::to_string(&bytes));
4074                        let response = common::to_response(parts, bytes.into());
4075
4076                        if let common::Retry::After(d) =
4077                            dlg.http_failure(&response, error.as_ref().ok())
4078                        {
4079                            sleep(d).await;
4080                            continue;
4081                        }
4082
4083                        dlg.finished(false);
4084
4085                        return Err(match error {
4086                            Ok(value) => common::Error::BadRequest(value),
4087                            _ => common::Error::Failure(response),
4088                        });
4089                    }
4090                    let response = {
4091                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4092                        let encoded = common::to_string(&bytes);
4093                        match serde_json::from_str(&encoded) {
4094                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4095                            Err(error) => {
4096                                dlg.response_json_decode_error(&encoded, &error);
4097                                return Err(common::Error::JsonDecodeError(
4098                                    encoded.to_string(),
4099                                    error,
4100                                ));
4101                            }
4102                        }
4103                    };
4104
4105                    dlg.finished(true);
4106                    return Ok(response);
4107                }
4108            }
4109        }
4110    }
4111
4112    ///
4113    /// Sets the *request* property to the given value.
4114    ///
4115    /// Even though the property as already been set when instantiating this call,
4116    /// we provide this method for API completeness.
4117    pub fn request(
4118        mut self,
4119        new_value: DismissApprovalRequestMessage,
4120    ) -> OrganizationApprovalRequestDismisCall<'a, C> {
4121        self._request = new_value;
4122        self
4123    }
4124    /// Name of the ApprovalRequest to dismiss.
4125    ///
4126    /// Sets the *name* path property to the given value.
4127    ///
4128    /// Even though the property as already been set when instantiating this call,
4129    /// we provide this method for API completeness.
4130    pub fn name(mut self, new_value: &str) -> OrganizationApprovalRequestDismisCall<'a, C> {
4131        self._name = new_value.to_string();
4132        self
4133    }
4134    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4135    /// while executing the actual API request.
4136    ///
4137    /// ````text
4138    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4139    /// ````
4140    ///
4141    /// Sets the *delegate* property to the given value.
4142    pub fn delegate(
4143        mut self,
4144        new_value: &'a mut dyn common::Delegate,
4145    ) -> OrganizationApprovalRequestDismisCall<'a, C> {
4146        self._delegate = Some(new_value);
4147        self
4148    }
4149
4150    /// Set any additional parameter of the query string used in the request.
4151    /// It should be used to set parameters which are not yet available through their own
4152    /// setters.
4153    ///
4154    /// Please note that this method must not be used to set any of the known parameters
4155    /// which have their own setter method. If done anyway, the request will fail.
4156    ///
4157    /// # Additional Parameters
4158    ///
4159    /// * *$.xgafv* (query-string) - V1 error format.
4160    /// * *access_token* (query-string) - OAuth access token.
4161    /// * *alt* (query-string) - Data format for response.
4162    /// * *callback* (query-string) - JSONP
4163    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4164    /// * *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.
4165    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4166    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4167    /// * *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.
4168    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4169    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4170    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestDismisCall<'a, C>
4171    where
4172        T: AsRef<str>,
4173    {
4174        self._additional_params
4175            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4176        self
4177    }
4178
4179    /// Identifies the authorization scope for the method you are building.
4180    ///
4181    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4182    /// [`Scope::CloudPlatform`].
4183    ///
4184    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4185    /// tokens for more than one scope.
4186    ///
4187    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4188    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4189    /// sufficient, a read-write scope will do as well.
4190    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestDismisCall<'a, C>
4191    where
4192        St: AsRef<str>,
4193    {
4194        self._scopes.insert(String::from(scope.as_ref()));
4195        self
4196    }
4197    /// Identifies the authorization scope(s) for the method you are building.
4198    ///
4199    /// See [`Self::add_scope()`] for details.
4200    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestDismisCall<'a, C>
4201    where
4202        I: IntoIterator<Item = St>,
4203        St: AsRef<str>,
4204    {
4205        self._scopes
4206            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4207        self
4208    }
4209
4210    /// Removes all scopes, and no default scope will be used either.
4211    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4212    /// for details).
4213    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestDismisCall<'a, C> {
4214        self._scopes.clear();
4215        self
4216    }
4217}
4218
4219/// Gets an approval request. Returns NOT_FOUND if the request does not exist.
4220///
4221/// A builder for the *approvalRequests.get* method supported by a *organization* resource.
4222/// It is not used directly, but through a [`OrganizationMethods`] instance.
4223///
4224/// # Example
4225///
4226/// Instantiate a resource method builder
4227///
4228/// ```test_harness,no_run
4229/// # extern crate hyper;
4230/// # extern crate hyper_rustls;
4231/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
4232/// # async fn dox() {
4233/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4234///
4235/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4236/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4237/// #     .with_native_roots()
4238/// #     .unwrap()
4239/// #     .https_only()
4240/// #     .enable_http2()
4241/// #     .build();
4242///
4243/// # let executor = hyper_util::rt::TokioExecutor::new();
4244/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4245/// #     secret,
4246/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4247/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4248/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4249/// #     ),
4250/// # ).build().await.unwrap();
4251///
4252/// # let client = hyper_util::client::legacy::Client::builder(
4253/// #     hyper_util::rt::TokioExecutor::new()
4254/// # )
4255/// # .build(
4256/// #     hyper_rustls::HttpsConnectorBuilder::new()
4257/// #         .with_native_roots()
4258/// #         .unwrap()
4259/// #         .https_or_http()
4260/// #         .enable_http2()
4261/// #         .build()
4262/// # );
4263/// # let mut hub = AccessApproval::new(client, auth);
4264/// // You can configure optional parameters by calling the respective setters at will, and
4265/// // execute the final call using `doit()`.
4266/// // Values shown here are possibly random and not representative !
4267/// let result = hub.organizations().approval_requests_get("name")
4268///              .doit().await;
4269/// # }
4270/// ```
4271pub struct OrganizationApprovalRequestGetCall<'a, C>
4272where
4273    C: 'a,
4274{
4275    hub: &'a AccessApproval<C>,
4276    _name: String,
4277    _delegate: Option<&'a mut dyn common::Delegate>,
4278    _additional_params: HashMap<String, String>,
4279    _scopes: BTreeSet<String>,
4280}
4281
4282impl<'a, C> common::CallBuilder for OrganizationApprovalRequestGetCall<'a, C> {}
4283
4284impl<'a, C> OrganizationApprovalRequestGetCall<'a, C>
4285where
4286    C: common::Connector,
4287{
4288    /// Perform the operation you have build so far.
4289    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
4290        use std::borrow::Cow;
4291        use std::io::{Read, Seek};
4292
4293        use common::{url::Params, ToParts};
4294        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4295
4296        let mut dd = common::DefaultDelegate;
4297        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4298        dlg.begin(common::MethodInfo {
4299            id: "accessapproval.organizations.approvalRequests.get",
4300            http_method: hyper::Method::GET,
4301        });
4302
4303        for &field in ["alt", "name"].iter() {
4304            if self._additional_params.contains_key(field) {
4305                dlg.finished(false);
4306                return Err(common::Error::FieldClash(field));
4307            }
4308        }
4309
4310        let mut params = Params::with_capacity(3 + self._additional_params.len());
4311        params.push("name", self._name);
4312
4313        params.extend(self._additional_params.iter());
4314
4315        params.push("alt", "json");
4316        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4317        if self._scopes.is_empty() {
4318            self._scopes
4319                .insert(Scope::CloudPlatform.as_ref().to_string());
4320        }
4321
4322        #[allow(clippy::single_element_loop)]
4323        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4324            url = params.uri_replacement(url, param_name, find_this, true);
4325        }
4326        {
4327            let to_remove = ["name"];
4328            params.remove_params(&to_remove);
4329        }
4330
4331        let url = params.parse_with_url(&url);
4332
4333        loop {
4334            let token = match self
4335                .hub
4336                .auth
4337                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4338                .await
4339            {
4340                Ok(token) => token,
4341                Err(e) => match dlg.token(e) {
4342                    Ok(token) => token,
4343                    Err(e) => {
4344                        dlg.finished(false);
4345                        return Err(common::Error::MissingToken(e));
4346                    }
4347                },
4348            };
4349            let mut req_result = {
4350                let client = &self.hub.client;
4351                dlg.pre_request();
4352                let mut req_builder = hyper::Request::builder()
4353                    .method(hyper::Method::GET)
4354                    .uri(url.as_str())
4355                    .header(USER_AGENT, self.hub._user_agent.clone());
4356
4357                if let Some(token) = token.as_ref() {
4358                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4359                }
4360
4361                let request = req_builder
4362                    .header(CONTENT_LENGTH, 0_u64)
4363                    .body(common::to_body::<String>(None));
4364
4365                client.request(request.unwrap()).await
4366            };
4367
4368            match req_result {
4369                Err(err) => {
4370                    if let common::Retry::After(d) = dlg.http_error(&err) {
4371                        sleep(d).await;
4372                        continue;
4373                    }
4374                    dlg.finished(false);
4375                    return Err(common::Error::HttpError(err));
4376                }
4377                Ok(res) => {
4378                    let (mut parts, body) = res.into_parts();
4379                    let mut body = common::Body::new(body);
4380                    if !parts.status.is_success() {
4381                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4382                        let error = serde_json::from_str(&common::to_string(&bytes));
4383                        let response = common::to_response(parts, bytes.into());
4384
4385                        if let common::Retry::After(d) =
4386                            dlg.http_failure(&response, error.as_ref().ok())
4387                        {
4388                            sleep(d).await;
4389                            continue;
4390                        }
4391
4392                        dlg.finished(false);
4393
4394                        return Err(match error {
4395                            Ok(value) => common::Error::BadRequest(value),
4396                            _ => common::Error::Failure(response),
4397                        });
4398                    }
4399                    let response = {
4400                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4401                        let encoded = common::to_string(&bytes);
4402                        match serde_json::from_str(&encoded) {
4403                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4404                            Err(error) => {
4405                                dlg.response_json_decode_error(&encoded, &error);
4406                                return Err(common::Error::JsonDecodeError(
4407                                    encoded.to_string(),
4408                                    error,
4409                                ));
4410                            }
4411                        }
4412                    };
4413
4414                    dlg.finished(true);
4415                    return Ok(response);
4416                }
4417            }
4418        }
4419    }
4420
4421    /// Name of the approval request to retrieve.
4422    ///
4423    /// Sets the *name* path property to the given value.
4424    ///
4425    /// Even though the property as already been set when instantiating this call,
4426    /// we provide this method for API completeness.
4427    pub fn name(mut self, new_value: &str) -> OrganizationApprovalRequestGetCall<'a, C> {
4428        self._name = new_value.to_string();
4429        self
4430    }
4431    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4432    /// while executing the actual API request.
4433    ///
4434    /// ````text
4435    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4436    /// ````
4437    ///
4438    /// Sets the *delegate* property to the given value.
4439    pub fn delegate(
4440        mut self,
4441        new_value: &'a mut dyn common::Delegate,
4442    ) -> OrganizationApprovalRequestGetCall<'a, C> {
4443        self._delegate = Some(new_value);
4444        self
4445    }
4446
4447    /// Set any additional parameter of the query string used in the request.
4448    /// It should be used to set parameters which are not yet available through their own
4449    /// setters.
4450    ///
4451    /// Please note that this method must not be used to set any of the known parameters
4452    /// which have their own setter method. If done anyway, the request will fail.
4453    ///
4454    /// # Additional Parameters
4455    ///
4456    /// * *$.xgafv* (query-string) - V1 error format.
4457    /// * *access_token* (query-string) - OAuth access token.
4458    /// * *alt* (query-string) - Data format for response.
4459    /// * *callback* (query-string) - JSONP
4460    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4461    /// * *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.
4462    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4463    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4464    /// * *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.
4465    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4466    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4467    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestGetCall<'a, C>
4468    where
4469        T: AsRef<str>,
4470    {
4471        self._additional_params
4472            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4473        self
4474    }
4475
4476    /// Identifies the authorization scope for the method you are building.
4477    ///
4478    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4479    /// [`Scope::CloudPlatform`].
4480    ///
4481    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4482    /// tokens for more than one scope.
4483    ///
4484    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4485    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4486    /// sufficient, a read-write scope will do as well.
4487    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestGetCall<'a, C>
4488    where
4489        St: AsRef<str>,
4490    {
4491        self._scopes.insert(String::from(scope.as_ref()));
4492        self
4493    }
4494    /// Identifies the authorization scope(s) for the method you are building.
4495    ///
4496    /// See [`Self::add_scope()`] for details.
4497    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestGetCall<'a, C>
4498    where
4499        I: IntoIterator<Item = St>,
4500        St: AsRef<str>,
4501    {
4502        self._scopes
4503            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4504        self
4505    }
4506
4507    /// Removes all scopes, and no default scope will be used either.
4508    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4509    /// for details).
4510    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestGetCall<'a, C> {
4511        self._scopes.clear();
4512        self
4513    }
4514}
4515
4516/// Lists approval requests associated with a project, folder, or organization.
4517/// Approval requests can be filtered by state (pending, active, dismissed).
4518/// The order is reverse chronological.
4519///
4520/// A builder for the *approvalRequests.list* method supported by a *organization* resource.
4521/// It is not used directly, but through a [`OrganizationMethods`] instance.
4522///
4523/// # Example
4524///
4525/// Instantiate a resource method builder
4526///
4527/// ```test_harness,no_run
4528/// # extern crate hyper;
4529/// # extern crate hyper_rustls;
4530/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
4531/// # async fn dox() {
4532/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4533///
4534/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4535/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4536/// #     .with_native_roots()
4537/// #     .unwrap()
4538/// #     .https_only()
4539/// #     .enable_http2()
4540/// #     .build();
4541///
4542/// # let executor = hyper_util::rt::TokioExecutor::new();
4543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4544/// #     secret,
4545/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4546/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4547/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4548/// #     ),
4549/// # ).build().await.unwrap();
4550///
4551/// # let client = hyper_util::client::legacy::Client::builder(
4552/// #     hyper_util::rt::TokioExecutor::new()
4553/// # )
4554/// # .build(
4555/// #     hyper_rustls::HttpsConnectorBuilder::new()
4556/// #         .with_native_roots()
4557/// #         .unwrap()
4558/// #         .https_or_http()
4559/// #         .enable_http2()
4560/// #         .build()
4561/// # );
4562/// # let mut hub = AccessApproval::new(client, auth);
4563/// // You can configure optional parameters by calling the respective setters at will, and
4564/// // execute the final call using `doit()`.
4565/// // Values shown here are possibly random and not representative !
4566/// let result = hub.organizations().approval_requests_list("parent")
4567///              .page_token("dolor")
4568///              .page_size(-17)
4569///              .filter("ipsum")
4570///              .doit().await;
4571/// # }
4572/// ```
4573pub struct OrganizationApprovalRequestListCall<'a, C>
4574where
4575    C: 'a,
4576{
4577    hub: &'a AccessApproval<C>,
4578    _parent: String,
4579    _page_token: Option<String>,
4580    _page_size: Option<i32>,
4581    _filter: Option<String>,
4582    _delegate: Option<&'a mut dyn common::Delegate>,
4583    _additional_params: HashMap<String, String>,
4584    _scopes: BTreeSet<String>,
4585}
4586
4587impl<'a, C> common::CallBuilder for OrganizationApprovalRequestListCall<'a, C> {}
4588
4589impl<'a, C> OrganizationApprovalRequestListCall<'a, C>
4590where
4591    C: common::Connector,
4592{
4593    /// Perform the operation you have build so far.
4594    pub async fn doit(
4595        mut self,
4596    ) -> common::Result<(common::Response, ListApprovalRequestsResponse)> {
4597        use std::borrow::Cow;
4598        use std::io::{Read, Seek};
4599
4600        use common::{url::Params, ToParts};
4601        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4602
4603        let mut dd = common::DefaultDelegate;
4604        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4605        dlg.begin(common::MethodInfo {
4606            id: "accessapproval.organizations.approvalRequests.list",
4607            http_method: hyper::Method::GET,
4608        });
4609
4610        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
4611            if self._additional_params.contains_key(field) {
4612                dlg.finished(false);
4613                return Err(common::Error::FieldClash(field));
4614            }
4615        }
4616
4617        let mut params = Params::with_capacity(6 + self._additional_params.len());
4618        params.push("parent", self._parent);
4619        if let Some(value) = self._page_token.as_ref() {
4620            params.push("pageToken", value);
4621        }
4622        if let Some(value) = self._page_size.as_ref() {
4623            params.push("pageSize", value.to_string());
4624        }
4625        if let Some(value) = self._filter.as_ref() {
4626            params.push("filter", value);
4627        }
4628
4629        params.extend(self._additional_params.iter());
4630
4631        params.push("alt", "json");
4632        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/approvalRequests";
4633        if self._scopes.is_empty() {
4634            self._scopes
4635                .insert(Scope::CloudPlatform.as_ref().to_string());
4636        }
4637
4638        #[allow(clippy::single_element_loop)]
4639        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4640            url = params.uri_replacement(url, param_name, find_this, true);
4641        }
4642        {
4643            let to_remove = ["parent"];
4644            params.remove_params(&to_remove);
4645        }
4646
4647        let url = params.parse_with_url(&url);
4648
4649        loop {
4650            let token = match self
4651                .hub
4652                .auth
4653                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4654                .await
4655            {
4656                Ok(token) => token,
4657                Err(e) => match dlg.token(e) {
4658                    Ok(token) => token,
4659                    Err(e) => {
4660                        dlg.finished(false);
4661                        return Err(common::Error::MissingToken(e));
4662                    }
4663                },
4664            };
4665            let mut req_result = {
4666                let client = &self.hub.client;
4667                dlg.pre_request();
4668                let mut req_builder = hyper::Request::builder()
4669                    .method(hyper::Method::GET)
4670                    .uri(url.as_str())
4671                    .header(USER_AGENT, self.hub._user_agent.clone());
4672
4673                if let Some(token) = token.as_ref() {
4674                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4675                }
4676
4677                let request = req_builder
4678                    .header(CONTENT_LENGTH, 0_u64)
4679                    .body(common::to_body::<String>(None));
4680
4681                client.request(request.unwrap()).await
4682            };
4683
4684            match req_result {
4685                Err(err) => {
4686                    if let common::Retry::After(d) = dlg.http_error(&err) {
4687                        sleep(d).await;
4688                        continue;
4689                    }
4690                    dlg.finished(false);
4691                    return Err(common::Error::HttpError(err));
4692                }
4693                Ok(res) => {
4694                    let (mut parts, body) = res.into_parts();
4695                    let mut body = common::Body::new(body);
4696                    if !parts.status.is_success() {
4697                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4698                        let error = serde_json::from_str(&common::to_string(&bytes));
4699                        let response = common::to_response(parts, bytes.into());
4700
4701                        if let common::Retry::After(d) =
4702                            dlg.http_failure(&response, error.as_ref().ok())
4703                        {
4704                            sleep(d).await;
4705                            continue;
4706                        }
4707
4708                        dlg.finished(false);
4709
4710                        return Err(match error {
4711                            Ok(value) => common::Error::BadRequest(value),
4712                            _ => common::Error::Failure(response),
4713                        });
4714                    }
4715                    let response = {
4716                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4717                        let encoded = common::to_string(&bytes);
4718                        match serde_json::from_str(&encoded) {
4719                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4720                            Err(error) => {
4721                                dlg.response_json_decode_error(&encoded, &error);
4722                                return Err(common::Error::JsonDecodeError(
4723                                    encoded.to_string(),
4724                                    error,
4725                                ));
4726                            }
4727                        }
4728                    };
4729
4730                    dlg.finished(true);
4731                    return Ok(response);
4732                }
4733            }
4734        }
4735    }
4736
4737    /// The parent resource. This may be "projects/{project_id}",
4738    /// "folders/{folder_id}", or "organizations/{organization_id}".
4739    ///
4740    /// Sets the *parent* path property to the given value.
4741    ///
4742    /// Even though the property as already been set when instantiating this call,
4743    /// we provide this method for API completeness.
4744    pub fn parent(mut self, new_value: &str) -> OrganizationApprovalRequestListCall<'a, C> {
4745        self._parent = new_value.to_string();
4746        self
4747    }
4748    /// A token identifying the page of results to return.
4749    ///
4750    /// Sets the *page token* query property to the given value.
4751    pub fn page_token(mut self, new_value: &str) -> OrganizationApprovalRequestListCall<'a, C> {
4752        self._page_token = Some(new_value.to_string());
4753        self
4754    }
4755    /// Requested page size.
4756    ///
4757    /// Sets the *page size* query property to the given value.
4758    pub fn page_size(mut self, new_value: i32) -> OrganizationApprovalRequestListCall<'a, C> {
4759        self._page_size = Some(new_value);
4760        self
4761    }
4762    /// A filter on the type of approval requests to retrieve. Must be one of the
4763    /// following values:
4764    /// <ol>
4765    ///   <li>[not set]: Requests that are pending or have active approvals.</li>
4766    ///   <li>ALL: All requests.</li>
4767    ///   <li>PENDING: Only pending requests.</li>
4768    ///   <li>ACTIVE: Only active (i.e. currently approved) requests.</li>
4769    ///   <li>DISMISSED: Only dismissed (including expired) requests.</li>
4770    ///   <li>HISTORY: Active and dismissed (including expired) requests.</li>
4771    /// </ol>
4772    ///
4773    /// Sets the *filter* query property to the given value.
4774    pub fn filter(mut self, new_value: &str) -> OrganizationApprovalRequestListCall<'a, C> {
4775        self._filter = Some(new_value.to_string());
4776        self
4777    }
4778    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4779    /// while executing the actual API request.
4780    ///
4781    /// ````text
4782    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4783    /// ````
4784    ///
4785    /// Sets the *delegate* property to the given value.
4786    pub fn delegate(
4787        mut self,
4788        new_value: &'a mut dyn common::Delegate,
4789    ) -> OrganizationApprovalRequestListCall<'a, C> {
4790        self._delegate = Some(new_value);
4791        self
4792    }
4793
4794    /// Set any additional parameter of the query string used in the request.
4795    /// It should be used to set parameters which are not yet available through their own
4796    /// setters.
4797    ///
4798    /// Please note that this method must not be used to set any of the known parameters
4799    /// which have their own setter method. If done anyway, the request will fail.
4800    ///
4801    /// # Additional Parameters
4802    ///
4803    /// * *$.xgafv* (query-string) - V1 error format.
4804    /// * *access_token* (query-string) - OAuth access token.
4805    /// * *alt* (query-string) - Data format for response.
4806    /// * *callback* (query-string) - JSONP
4807    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4808    /// * *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.
4809    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4810    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4811    /// * *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.
4812    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4813    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4814    pub fn param<T>(mut self, name: T, value: T) -> OrganizationApprovalRequestListCall<'a, C>
4815    where
4816        T: AsRef<str>,
4817    {
4818        self._additional_params
4819            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4820        self
4821    }
4822
4823    /// Identifies the authorization scope for the method you are building.
4824    ///
4825    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4826    /// [`Scope::CloudPlatform`].
4827    ///
4828    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4829    /// tokens for more than one scope.
4830    ///
4831    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4832    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4833    /// sufficient, a read-write scope will do as well.
4834    pub fn add_scope<St>(mut self, scope: St) -> OrganizationApprovalRequestListCall<'a, C>
4835    where
4836        St: AsRef<str>,
4837    {
4838        self._scopes.insert(String::from(scope.as_ref()));
4839        self
4840    }
4841    /// Identifies the authorization scope(s) for the method you are building.
4842    ///
4843    /// See [`Self::add_scope()`] for details.
4844    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationApprovalRequestListCall<'a, C>
4845    where
4846        I: IntoIterator<Item = St>,
4847        St: AsRef<str>,
4848    {
4849        self._scopes
4850            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4851        self
4852    }
4853
4854    /// Removes all scopes, and no default scope will be used either.
4855    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4856    /// for details).
4857    pub fn clear_scopes(mut self) -> OrganizationApprovalRequestListCall<'a, C> {
4858        self._scopes.clear();
4859        self
4860    }
4861}
4862
4863/// Deletes the settings associated with a project, folder, or organization.
4864/// This will have the effect of disabling Access Approval for the project,
4865/// folder, or organization, but only if all ancestors also have Access
4866/// Approval disabled. If Access Approval is enabled at a higher level of the
4867/// hierarchy, then Access Approval will still be enabled at this level as
4868/// the settings are inherited.
4869///
4870/// A builder for the *deleteAccessApprovalSettings* method supported by a *organization* resource.
4871/// It is not used directly, but through a [`OrganizationMethods`] instance.
4872///
4873/// # Example
4874///
4875/// Instantiate a resource method builder
4876///
4877/// ```test_harness,no_run
4878/// # extern crate hyper;
4879/// # extern crate hyper_rustls;
4880/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
4881/// # async fn dox() {
4882/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4883///
4884/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4885/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4886/// #     .with_native_roots()
4887/// #     .unwrap()
4888/// #     .https_only()
4889/// #     .enable_http2()
4890/// #     .build();
4891///
4892/// # let executor = hyper_util::rt::TokioExecutor::new();
4893/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4894/// #     secret,
4895/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4896/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4897/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4898/// #     ),
4899/// # ).build().await.unwrap();
4900///
4901/// # let client = hyper_util::client::legacy::Client::builder(
4902/// #     hyper_util::rt::TokioExecutor::new()
4903/// # )
4904/// # .build(
4905/// #     hyper_rustls::HttpsConnectorBuilder::new()
4906/// #         .with_native_roots()
4907/// #         .unwrap()
4908/// #         .https_or_http()
4909/// #         .enable_http2()
4910/// #         .build()
4911/// # );
4912/// # let mut hub = AccessApproval::new(client, auth);
4913/// // You can configure optional parameters by calling the respective setters at will, and
4914/// // execute the final call using `doit()`.
4915/// // Values shown here are possibly random and not representative !
4916/// let result = hub.organizations().delete_access_approval_settings("name")
4917///              .doit().await;
4918/// # }
4919/// ```
4920pub struct OrganizationDeleteAccessApprovalSettingCall<'a, C>
4921where
4922    C: 'a,
4923{
4924    hub: &'a AccessApproval<C>,
4925    _name: String,
4926    _delegate: Option<&'a mut dyn common::Delegate>,
4927    _additional_params: HashMap<String, String>,
4928    _scopes: BTreeSet<String>,
4929}
4930
4931impl<'a, C> common::CallBuilder for OrganizationDeleteAccessApprovalSettingCall<'a, C> {}
4932
4933impl<'a, C> OrganizationDeleteAccessApprovalSettingCall<'a, C>
4934where
4935    C: common::Connector,
4936{
4937    /// Perform the operation you have build so far.
4938    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4939        use std::borrow::Cow;
4940        use std::io::{Read, Seek};
4941
4942        use common::{url::Params, ToParts};
4943        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4944
4945        let mut dd = common::DefaultDelegate;
4946        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4947        dlg.begin(common::MethodInfo {
4948            id: "accessapproval.organizations.deleteAccessApprovalSettings",
4949            http_method: hyper::Method::DELETE,
4950        });
4951
4952        for &field in ["alt", "name"].iter() {
4953            if self._additional_params.contains_key(field) {
4954                dlg.finished(false);
4955                return Err(common::Error::FieldClash(field));
4956            }
4957        }
4958
4959        let mut params = Params::with_capacity(3 + self._additional_params.len());
4960        params.push("name", self._name);
4961
4962        params.extend(self._additional_params.iter());
4963
4964        params.push("alt", "json");
4965        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
4966        if self._scopes.is_empty() {
4967            self._scopes
4968                .insert(Scope::CloudPlatform.as_ref().to_string());
4969        }
4970
4971        #[allow(clippy::single_element_loop)]
4972        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4973            url = params.uri_replacement(url, param_name, find_this, true);
4974        }
4975        {
4976            let to_remove = ["name"];
4977            params.remove_params(&to_remove);
4978        }
4979
4980        let url = params.parse_with_url(&url);
4981
4982        loop {
4983            let token = match self
4984                .hub
4985                .auth
4986                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4987                .await
4988            {
4989                Ok(token) => token,
4990                Err(e) => match dlg.token(e) {
4991                    Ok(token) => token,
4992                    Err(e) => {
4993                        dlg.finished(false);
4994                        return Err(common::Error::MissingToken(e));
4995                    }
4996                },
4997            };
4998            let mut req_result = {
4999                let client = &self.hub.client;
5000                dlg.pre_request();
5001                let mut req_builder = hyper::Request::builder()
5002                    .method(hyper::Method::DELETE)
5003                    .uri(url.as_str())
5004                    .header(USER_AGENT, self.hub._user_agent.clone());
5005
5006                if let Some(token) = token.as_ref() {
5007                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5008                }
5009
5010                let request = req_builder
5011                    .header(CONTENT_LENGTH, 0_u64)
5012                    .body(common::to_body::<String>(None));
5013
5014                client.request(request.unwrap()).await
5015            };
5016
5017            match req_result {
5018                Err(err) => {
5019                    if let common::Retry::After(d) = dlg.http_error(&err) {
5020                        sleep(d).await;
5021                        continue;
5022                    }
5023                    dlg.finished(false);
5024                    return Err(common::Error::HttpError(err));
5025                }
5026                Ok(res) => {
5027                    let (mut parts, body) = res.into_parts();
5028                    let mut body = common::Body::new(body);
5029                    if !parts.status.is_success() {
5030                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5031                        let error = serde_json::from_str(&common::to_string(&bytes));
5032                        let response = common::to_response(parts, bytes.into());
5033
5034                        if let common::Retry::After(d) =
5035                            dlg.http_failure(&response, error.as_ref().ok())
5036                        {
5037                            sleep(d).await;
5038                            continue;
5039                        }
5040
5041                        dlg.finished(false);
5042
5043                        return Err(match error {
5044                            Ok(value) => common::Error::BadRequest(value),
5045                            _ => common::Error::Failure(response),
5046                        });
5047                    }
5048                    let response = {
5049                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5050                        let encoded = common::to_string(&bytes);
5051                        match serde_json::from_str(&encoded) {
5052                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5053                            Err(error) => {
5054                                dlg.response_json_decode_error(&encoded, &error);
5055                                return Err(common::Error::JsonDecodeError(
5056                                    encoded.to_string(),
5057                                    error,
5058                                ));
5059                            }
5060                        }
5061                    };
5062
5063                    dlg.finished(true);
5064                    return Ok(response);
5065                }
5066            }
5067        }
5068    }
5069
5070    /// Name of the AccessApprovalSettings to delete.
5071    ///
5072    /// Sets the *name* path property to the given value.
5073    ///
5074    /// Even though the property as already been set when instantiating this call,
5075    /// we provide this method for API completeness.
5076    pub fn name(mut self, new_value: &str) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
5077        self._name = new_value.to_string();
5078        self
5079    }
5080    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5081    /// while executing the actual API request.
5082    ///
5083    /// ````text
5084    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5085    /// ````
5086    ///
5087    /// Sets the *delegate* property to the given value.
5088    pub fn delegate(
5089        mut self,
5090        new_value: &'a mut dyn common::Delegate,
5091    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
5092        self._delegate = Some(new_value);
5093        self
5094    }
5095
5096    /// Set any additional parameter of the query string used in the request.
5097    /// It should be used to set parameters which are not yet available through their own
5098    /// setters.
5099    ///
5100    /// Please note that this method must not be used to set any of the known parameters
5101    /// which have their own setter method. If done anyway, the request will fail.
5102    ///
5103    /// # Additional Parameters
5104    ///
5105    /// * *$.xgafv* (query-string) - V1 error format.
5106    /// * *access_token* (query-string) - OAuth access token.
5107    /// * *alt* (query-string) - Data format for response.
5108    /// * *callback* (query-string) - JSONP
5109    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5110    /// * *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.
5111    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5112    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5113    /// * *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.
5114    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5115    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5116    pub fn param<T>(
5117        mut self,
5118        name: T,
5119        value: T,
5120    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C>
5121    where
5122        T: AsRef<str>,
5123    {
5124        self._additional_params
5125            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5126        self
5127    }
5128
5129    /// Identifies the authorization scope for the method you are building.
5130    ///
5131    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5132    /// [`Scope::CloudPlatform`].
5133    ///
5134    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5135    /// tokens for more than one scope.
5136    ///
5137    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5138    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5139    /// sufficient, a read-write scope will do as well.
5140    pub fn add_scope<St>(mut self, scope: St) -> OrganizationDeleteAccessApprovalSettingCall<'a, C>
5141    where
5142        St: AsRef<str>,
5143    {
5144        self._scopes.insert(String::from(scope.as_ref()));
5145        self
5146    }
5147    /// Identifies the authorization scope(s) for the method you are building.
5148    ///
5149    /// See [`Self::add_scope()`] for details.
5150    pub fn add_scopes<I, St>(
5151        mut self,
5152        scopes: I,
5153    ) -> OrganizationDeleteAccessApprovalSettingCall<'a, C>
5154    where
5155        I: IntoIterator<Item = St>,
5156        St: AsRef<str>,
5157    {
5158        self._scopes
5159            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5160        self
5161    }
5162
5163    /// Removes all scopes, and no default scope will be used either.
5164    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5165    /// for details).
5166    pub fn clear_scopes(mut self) -> OrganizationDeleteAccessApprovalSettingCall<'a, C> {
5167        self._scopes.clear();
5168        self
5169    }
5170}
5171
5172/// Gets the settings associated with a project, folder, or organization.
5173///
5174/// A builder for the *getAccessApprovalSettings* method supported by a *organization* resource.
5175/// It is not used directly, but through a [`OrganizationMethods`] instance.
5176///
5177/// # Example
5178///
5179/// Instantiate a resource method builder
5180///
5181/// ```test_harness,no_run
5182/// # extern crate hyper;
5183/// # extern crate hyper_rustls;
5184/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
5185/// # async fn dox() {
5186/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5187///
5188/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5189/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5190/// #     .with_native_roots()
5191/// #     .unwrap()
5192/// #     .https_only()
5193/// #     .enable_http2()
5194/// #     .build();
5195///
5196/// # let executor = hyper_util::rt::TokioExecutor::new();
5197/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5198/// #     secret,
5199/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5200/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5201/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5202/// #     ),
5203/// # ).build().await.unwrap();
5204///
5205/// # let client = hyper_util::client::legacy::Client::builder(
5206/// #     hyper_util::rt::TokioExecutor::new()
5207/// # )
5208/// # .build(
5209/// #     hyper_rustls::HttpsConnectorBuilder::new()
5210/// #         .with_native_roots()
5211/// #         .unwrap()
5212/// #         .https_or_http()
5213/// #         .enable_http2()
5214/// #         .build()
5215/// # );
5216/// # let mut hub = AccessApproval::new(client, auth);
5217/// // You can configure optional parameters by calling the respective setters at will, and
5218/// // execute the final call using `doit()`.
5219/// // Values shown here are possibly random and not representative !
5220/// let result = hub.organizations().get_access_approval_settings("name")
5221///              .doit().await;
5222/// # }
5223/// ```
5224pub struct OrganizationGetAccessApprovalSettingCall<'a, C>
5225where
5226    C: 'a,
5227{
5228    hub: &'a AccessApproval<C>,
5229    _name: String,
5230    _delegate: Option<&'a mut dyn common::Delegate>,
5231    _additional_params: HashMap<String, String>,
5232    _scopes: BTreeSet<String>,
5233}
5234
5235impl<'a, C> common::CallBuilder for OrganizationGetAccessApprovalSettingCall<'a, C> {}
5236
5237impl<'a, C> OrganizationGetAccessApprovalSettingCall<'a, C>
5238where
5239    C: common::Connector,
5240{
5241    /// Perform the operation you have build so far.
5242    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
5243        use std::borrow::Cow;
5244        use std::io::{Read, Seek};
5245
5246        use common::{url::Params, ToParts};
5247        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5248
5249        let mut dd = common::DefaultDelegate;
5250        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5251        dlg.begin(common::MethodInfo {
5252            id: "accessapproval.organizations.getAccessApprovalSettings",
5253            http_method: hyper::Method::GET,
5254        });
5255
5256        for &field in ["alt", "name"].iter() {
5257            if self._additional_params.contains_key(field) {
5258                dlg.finished(false);
5259                return Err(common::Error::FieldClash(field));
5260            }
5261        }
5262
5263        let mut params = Params::with_capacity(3 + self._additional_params.len());
5264        params.push("name", self._name);
5265
5266        params.extend(self._additional_params.iter());
5267
5268        params.push("alt", "json");
5269        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
5270        if self._scopes.is_empty() {
5271            self._scopes
5272                .insert(Scope::CloudPlatform.as_ref().to_string());
5273        }
5274
5275        #[allow(clippy::single_element_loop)]
5276        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5277            url = params.uri_replacement(url, param_name, find_this, true);
5278        }
5279        {
5280            let to_remove = ["name"];
5281            params.remove_params(&to_remove);
5282        }
5283
5284        let url = params.parse_with_url(&url);
5285
5286        loop {
5287            let token = match self
5288                .hub
5289                .auth
5290                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5291                .await
5292            {
5293                Ok(token) => token,
5294                Err(e) => match dlg.token(e) {
5295                    Ok(token) => token,
5296                    Err(e) => {
5297                        dlg.finished(false);
5298                        return Err(common::Error::MissingToken(e));
5299                    }
5300                },
5301            };
5302            let mut req_result = {
5303                let client = &self.hub.client;
5304                dlg.pre_request();
5305                let mut req_builder = hyper::Request::builder()
5306                    .method(hyper::Method::GET)
5307                    .uri(url.as_str())
5308                    .header(USER_AGENT, self.hub._user_agent.clone());
5309
5310                if let Some(token) = token.as_ref() {
5311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5312                }
5313
5314                let request = req_builder
5315                    .header(CONTENT_LENGTH, 0_u64)
5316                    .body(common::to_body::<String>(None));
5317
5318                client.request(request.unwrap()).await
5319            };
5320
5321            match req_result {
5322                Err(err) => {
5323                    if let common::Retry::After(d) = dlg.http_error(&err) {
5324                        sleep(d).await;
5325                        continue;
5326                    }
5327                    dlg.finished(false);
5328                    return Err(common::Error::HttpError(err));
5329                }
5330                Ok(res) => {
5331                    let (mut parts, body) = res.into_parts();
5332                    let mut body = common::Body::new(body);
5333                    if !parts.status.is_success() {
5334                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5335                        let error = serde_json::from_str(&common::to_string(&bytes));
5336                        let response = common::to_response(parts, bytes.into());
5337
5338                        if let common::Retry::After(d) =
5339                            dlg.http_failure(&response, error.as_ref().ok())
5340                        {
5341                            sleep(d).await;
5342                            continue;
5343                        }
5344
5345                        dlg.finished(false);
5346
5347                        return Err(match error {
5348                            Ok(value) => common::Error::BadRequest(value),
5349                            _ => common::Error::Failure(response),
5350                        });
5351                    }
5352                    let response = {
5353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5354                        let encoded = common::to_string(&bytes);
5355                        match serde_json::from_str(&encoded) {
5356                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5357                            Err(error) => {
5358                                dlg.response_json_decode_error(&encoded, &error);
5359                                return Err(common::Error::JsonDecodeError(
5360                                    encoded.to_string(),
5361                                    error,
5362                                ));
5363                            }
5364                        }
5365                    };
5366
5367                    dlg.finished(true);
5368                    return Ok(response);
5369                }
5370            }
5371        }
5372    }
5373
5374    /// Name of the AccessApprovalSettings to retrieve.
5375    ///
5376    /// Sets the *name* path property to the given value.
5377    ///
5378    /// Even though the property as already been set when instantiating this call,
5379    /// we provide this method for API completeness.
5380    pub fn name(mut self, new_value: &str) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
5381        self._name = new_value.to_string();
5382        self
5383    }
5384    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5385    /// while executing the actual API request.
5386    ///
5387    /// ````text
5388    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5389    /// ````
5390    ///
5391    /// Sets the *delegate* property to the given value.
5392    pub fn delegate(
5393        mut self,
5394        new_value: &'a mut dyn common::Delegate,
5395    ) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
5396        self._delegate = Some(new_value);
5397        self
5398    }
5399
5400    /// Set any additional parameter of the query string used in the request.
5401    /// It should be used to set parameters which are not yet available through their own
5402    /// setters.
5403    ///
5404    /// Please note that this method must not be used to set any of the known parameters
5405    /// which have their own setter method. If done anyway, the request will fail.
5406    ///
5407    /// # Additional Parameters
5408    ///
5409    /// * *$.xgafv* (query-string) - V1 error format.
5410    /// * *access_token* (query-string) - OAuth access token.
5411    /// * *alt* (query-string) - Data format for response.
5412    /// * *callback* (query-string) - JSONP
5413    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5414    /// * *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.
5415    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5416    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5417    /// * *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.
5418    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5419    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5420    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetAccessApprovalSettingCall<'a, C>
5421    where
5422        T: AsRef<str>,
5423    {
5424        self._additional_params
5425            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5426        self
5427    }
5428
5429    /// Identifies the authorization scope for the method you are building.
5430    ///
5431    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5432    /// [`Scope::CloudPlatform`].
5433    ///
5434    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5435    /// tokens for more than one scope.
5436    ///
5437    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5438    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5439    /// sufficient, a read-write scope will do as well.
5440    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetAccessApprovalSettingCall<'a, C>
5441    where
5442        St: AsRef<str>,
5443    {
5444        self._scopes.insert(String::from(scope.as_ref()));
5445        self
5446    }
5447    /// Identifies the authorization scope(s) for the method you are building.
5448    ///
5449    /// See [`Self::add_scope()`] for details.
5450    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetAccessApprovalSettingCall<'a, C>
5451    where
5452        I: IntoIterator<Item = St>,
5453        St: AsRef<str>,
5454    {
5455        self._scopes
5456            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5457        self
5458    }
5459
5460    /// Removes all scopes, and no default scope will be used either.
5461    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5462    /// for details).
5463    pub fn clear_scopes(mut self) -> OrganizationGetAccessApprovalSettingCall<'a, C> {
5464        self._scopes.clear();
5465        self
5466    }
5467}
5468
5469/// Updates the settings associated with a project, folder, or organization.
5470/// Settings to update are determined by the value of field_mask.
5471///
5472/// A builder for the *updateAccessApprovalSettings* method supported by a *organization* resource.
5473/// It is not used directly, but through a [`OrganizationMethods`] instance.
5474///
5475/// # Example
5476///
5477/// Instantiate a resource method builder
5478///
5479/// ```test_harness,no_run
5480/// # extern crate hyper;
5481/// # extern crate hyper_rustls;
5482/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
5483/// use accessapproval1_beta1::api::AccessApprovalSettings;
5484/// # async fn dox() {
5485/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5486///
5487/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5488/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5489/// #     .with_native_roots()
5490/// #     .unwrap()
5491/// #     .https_only()
5492/// #     .enable_http2()
5493/// #     .build();
5494///
5495/// # let executor = hyper_util::rt::TokioExecutor::new();
5496/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5497/// #     secret,
5498/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5499/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5500/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5501/// #     ),
5502/// # ).build().await.unwrap();
5503///
5504/// # let client = hyper_util::client::legacy::Client::builder(
5505/// #     hyper_util::rt::TokioExecutor::new()
5506/// # )
5507/// # .build(
5508/// #     hyper_rustls::HttpsConnectorBuilder::new()
5509/// #         .with_native_roots()
5510/// #         .unwrap()
5511/// #         .https_or_http()
5512/// #         .enable_http2()
5513/// #         .build()
5514/// # );
5515/// # let mut hub = AccessApproval::new(client, auth);
5516/// // As the method needs a request, you would usually fill it with the desired information
5517/// // into the respective structure. Some of the parts shown here might not be applicable !
5518/// // Values shown here are possibly random and not representative !
5519/// let mut req = AccessApprovalSettings::default();
5520///
5521/// // You can configure optional parameters by calling the respective setters at will, and
5522/// // execute the final call using `doit()`.
5523/// // Values shown here are possibly random and not representative !
5524/// let result = hub.organizations().update_access_approval_settings(req, "name")
5525///              .update_mask(FieldMask::new::<&str>(&[]))
5526///              .doit().await;
5527/// # }
5528/// ```
5529pub struct OrganizationUpdateAccessApprovalSettingCall<'a, C>
5530where
5531    C: 'a,
5532{
5533    hub: &'a AccessApproval<C>,
5534    _request: AccessApprovalSettings,
5535    _name: String,
5536    _update_mask: Option<common::FieldMask>,
5537    _delegate: Option<&'a mut dyn common::Delegate>,
5538    _additional_params: HashMap<String, String>,
5539    _scopes: BTreeSet<String>,
5540}
5541
5542impl<'a, C> common::CallBuilder for OrganizationUpdateAccessApprovalSettingCall<'a, C> {}
5543
5544impl<'a, C> OrganizationUpdateAccessApprovalSettingCall<'a, C>
5545where
5546    C: common::Connector,
5547{
5548    /// Perform the operation you have build so far.
5549    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
5550        use std::borrow::Cow;
5551        use std::io::{Read, Seek};
5552
5553        use common::{url::Params, ToParts};
5554        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5555
5556        let mut dd = common::DefaultDelegate;
5557        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5558        dlg.begin(common::MethodInfo {
5559            id: "accessapproval.organizations.updateAccessApprovalSettings",
5560            http_method: hyper::Method::PATCH,
5561        });
5562
5563        for &field in ["alt", "name", "updateMask"].iter() {
5564            if self._additional_params.contains_key(field) {
5565                dlg.finished(false);
5566                return Err(common::Error::FieldClash(field));
5567            }
5568        }
5569
5570        let mut params = Params::with_capacity(5 + self._additional_params.len());
5571        params.push("name", self._name);
5572        if let Some(value) = self._update_mask.as_ref() {
5573            params.push("updateMask", value.to_string());
5574        }
5575
5576        params.extend(self._additional_params.iter());
5577
5578        params.push("alt", "json");
5579        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
5580        if self._scopes.is_empty() {
5581            self._scopes
5582                .insert(Scope::CloudPlatform.as_ref().to_string());
5583        }
5584
5585        #[allow(clippy::single_element_loop)]
5586        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5587            url = params.uri_replacement(url, param_name, find_this, true);
5588        }
5589        {
5590            let to_remove = ["name"];
5591            params.remove_params(&to_remove);
5592        }
5593
5594        let url = params.parse_with_url(&url);
5595
5596        let mut json_mime_type = mime::APPLICATION_JSON;
5597        let mut request_value_reader = {
5598            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5599            common::remove_json_null_values(&mut value);
5600            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5601            serde_json::to_writer(&mut dst, &value).unwrap();
5602            dst
5603        };
5604        let request_size = request_value_reader
5605            .seek(std::io::SeekFrom::End(0))
5606            .unwrap();
5607        request_value_reader
5608            .seek(std::io::SeekFrom::Start(0))
5609            .unwrap();
5610
5611        loop {
5612            let token = match self
5613                .hub
5614                .auth
5615                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5616                .await
5617            {
5618                Ok(token) => token,
5619                Err(e) => match dlg.token(e) {
5620                    Ok(token) => token,
5621                    Err(e) => {
5622                        dlg.finished(false);
5623                        return Err(common::Error::MissingToken(e));
5624                    }
5625                },
5626            };
5627            request_value_reader
5628                .seek(std::io::SeekFrom::Start(0))
5629                .unwrap();
5630            let mut req_result = {
5631                let client = &self.hub.client;
5632                dlg.pre_request();
5633                let mut req_builder = hyper::Request::builder()
5634                    .method(hyper::Method::PATCH)
5635                    .uri(url.as_str())
5636                    .header(USER_AGENT, self.hub._user_agent.clone());
5637
5638                if let Some(token) = token.as_ref() {
5639                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5640                }
5641
5642                let request = req_builder
5643                    .header(CONTENT_TYPE, json_mime_type.to_string())
5644                    .header(CONTENT_LENGTH, request_size as u64)
5645                    .body(common::to_body(
5646                        request_value_reader.get_ref().clone().into(),
5647                    ));
5648
5649                client.request(request.unwrap()).await
5650            };
5651
5652            match req_result {
5653                Err(err) => {
5654                    if let common::Retry::After(d) = dlg.http_error(&err) {
5655                        sleep(d).await;
5656                        continue;
5657                    }
5658                    dlg.finished(false);
5659                    return Err(common::Error::HttpError(err));
5660                }
5661                Ok(res) => {
5662                    let (mut parts, body) = res.into_parts();
5663                    let mut body = common::Body::new(body);
5664                    if !parts.status.is_success() {
5665                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5666                        let error = serde_json::from_str(&common::to_string(&bytes));
5667                        let response = common::to_response(parts, bytes.into());
5668
5669                        if let common::Retry::After(d) =
5670                            dlg.http_failure(&response, error.as_ref().ok())
5671                        {
5672                            sleep(d).await;
5673                            continue;
5674                        }
5675
5676                        dlg.finished(false);
5677
5678                        return Err(match error {
5679                            Ok(value) => common::Error::BadRequest(value),
5680                            _ => common::Error::Failure(response),
5681                        });
5682                    }
5683                    let response = {
5684                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5685                        let encoded = common::to_string(&bytes);
5686                        match serde_json::from_str(&encoded) {
5687                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5688                            Err(error) => {
5689                                dlg.response_json_decode_error(&encoded, &error);
5690                                return Err(common::Error::JsonDecodeError(
5691                                    encoded.to_string(),
5692                                    error,
5693                                ));
5694                            }
5695                        }
5696                    };
5697
5698                    dlg.finished(true);
5699                    return Ok(response);
5700                }
5701            }
5702        }
5703    }
5704
5705    ///
5706    /// Sets the *request* property to the given value.
5707    ///
5708    /// Even though the property as already been set when instantiating this call,
5709    /// we provide this method for API completeness.
5710    pub fn request(
5711        mut self,
5712        new_value: AccessApprovalSettings,
5713    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
5714        self._request = new_value;
5715        self
5716    }
5717    /// The resource name of the settings. Format is one of:
5718    /// <ol>
5719    ///   <li>"projects/{project_id}/accessApprovalSettings"</li>
5720    ///   <li>"folders/{folder_id}/accessApprovalSettings"</li>
5721    ///   <li>"organizations/{organization_id}/accessApprovalSettings"</li>
5722    /// <ol>
5723    ///
5724    /// Sets the *name* path property to the given value.
5725    ///
5726    /// Even though the property as already been set when instantiating this call,
5727    /// we provide this method for API completeness.
5728    pub fn name(mut self, new_value: &str) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
5729        self._name = new_value.to_string();
5730        self
5731    }
5732    /// For the `FieldMask` definition, see
5733    /// https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
5734    /// If this field is left unset, only the notification_emails field will be
5735    /// updated.
5736    ///
5737    /// Sets the *update mask* query property to the given value.
5738    pub fn update_mask(
5739        mut self,
5740        new_value: common::FieldMask,
5741    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
5742        self._update_mask = Some(new_value);
5743        self
5744    }
5745    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5746    /// while executing the actual API request.
5747    ///
5748    /// ````text
5749    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5750    /// ````
5751    ///
5752    /// Sets the *delegate* property to the given value.
5753    pub fn delegate(
5754        mut self,
5755        new_value: &'a mut dyn common::Delegate,
5756    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
5757        self._delegate = Some(new_value);
5758        self
5759    }
5760
5761    /// Set any additional parameter of the query string used in the request.
5762    /// It should be used to set parameters which are not yet available through their own
5763    /// setters.
5764    ///
5765    /// Please note that this method must not be used to set any of the known parameters
5766    /// which have their own setter method. If done anyway, the request will fail.
5767    ///
5768    /// # Additional Parameters
5769    ///
5770    /// * *$.xgafv* (query-string) - V1 error format.
5771    /// * *access_token* (query-string) - OAuth access token.
5772    /// * *alt* (query-string) - Data format for response.
5773    /// * *callback* (query-string) - JSONP
5774    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5775    /// * *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.
5776    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5777    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5778    /// * *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.
5779    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5780    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5781    pub fn param<T>(
5782        mut self,
5783        name: T,
5784        value: T,
5785    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C>
5786    where
5787        T: AsRef<str>,
5788    {
5789        self._additional_params
5790            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5791        self
5792    }
5793
5794    /// Identifies the authorization scope for the method you are building.
5795    ///
5796    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5797    /// [`Scope::CloudPlatform`].
5798    ///
5799    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5800    /// tokens for more than one scope.
5801    ///
5802    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5803    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5804    /// sufficient, a read-write scope will do as well.
5805    pub fn add_scope<St>(mut self, scope: St) -> OrganizationUpdateAccessApprovalSettingCall<'a, C>
5806    where
5807        St: AsRef<str>,
5808    {
5809        self._scopes.insert(String::from(scope.as_ref()));
5810        self
5811    }
5812    /// Identifies the authorization scope(s) for the method you are building.
5813    ///
5814    /// See [`Self::add_scope()`] for details.
5815    pub fn add_scopes<I, St>(
5816        mut self,
5817        scopes: I,
5818    ) -> OrganizationUpdateAccessApprovalSettingCall<'a, C>
5819    where
5820        I: IntoIterator<Item = St>,
5821        St: AsRef<str>,
5822    {
5823        self._scopes
5824            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5825        self
5826    }
5827
5828    /// Removes all scopes, and no default scope will be used either.
5829    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5830    /// for details).
5831    pub fn clear_scopes(mut self) -> OrganizationUpdateAccessApprovalSettingCall<'a, C> {
5832        self._scopes.clear();
5833        self
5834    }
5835}
5836
5837/// Approves a request and returns the updated ApprovalRequest.
5838///
5839/// Returns NOT_FOUND if the request does not exist. Returns
5840/// FAILED_PRECONDITION if the request exists but is not in a pending state.
5841///
5842/// A builder for the *approvalRequests.approve* method supported by a *project* resource.
5843/// It is not used directly, but through a [`ProjectMethods`] instance.
5844///
5845/// # Example
5846///
5847/// Instantiate a resource method builder
5848///
5849/// ```test_harness,no_run
5850/// # extern crate hyper;
5851/// # extern crate hyper_rustls;
5852/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
5853/// use accessapproval1_beta1::api::ApproveApprovalRequestMessage;
5854/// # async fn dox() {
5855/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5856///
5857/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5858/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5859/// #     .with_native_roots()
5860/// #     .unwrap()
5861/// #     .https_only()
5862/// #     .enable_http2()
5863/// #     .build();
5864///
5865/// # let executor = hyper_util::rt::TokioExecutor::new();
5866/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5867/// #     secret,
5868/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5869/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5870/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5871/// #     ),
5872/// # ).build().await.unwrap();
5873///
5874/// # let client = hyper_util::client::legacy::Client::builder(
5875/// #     hyper_util::rt::TokioExecutor::new()
5876/// # )
5877/// # .build(
5878/// #     hyper_rustls::HttpsConnectorBuilder::new()
5879/// #         .with_native_roots()
5880/// #         .unwrap()
5881/// #         .https_or_http()
5882/// #         .enable_http2()
5883/// #         .build()
5884/// # );
5885/// # let mut hub = AccessApproval::new(client, auth);
5886/// // As the method needs a request, you would usually fill it with the desired information
5887/// // into the respective structure. Some of the parts shown here might not be applicable !
5888/// // Values shown here are possibly random and not representative !
5889/// let mut req = ApproveApprovalRequestMessage::default();
5890///
5891/// // You can configure optional parameters by calling the respective setters at will, and
5892/// // execute the final call using `doit()`.
5893/// // Values shown here are possibly random and not representative !
5894/// let result = hub.projects().approval_requests_approve(req, "name")
5895///              .doit().await;
5896/// # }
5897/// ```
5898pub struct ProjectApprovalRequestApproveCall<'a, C>
5899where
5900    C: 'a,
5901{
5902    hub: &'a AccessApproval<C>,
5903    _request: ApproveApprovalRequestMessage,
5904    _name: String,
5905    _delegate: Option<&'a mut dyn common::Delegate>,
5906    _additional_params: HashMap<String, String>,
5907    _scopes: BTreeSet<String>,
5908}
5909
5910impl<'a, C> common::CallBuilder for ProjectApprovalRequestApproveCall<'a, C> {}
5911
5912impl<'a, C> ProjectApprovalRequestApproveCall<'a, C>
5913where
5914    C: common::Connector,
5915{
5916    /// Perform the operation you have build so far.
5917    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
5918        use std::borrow::Cow;
5919        use std::io::{Read, Seek};
5920
5921        use common::{url::Params, ToParts};
5922        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5923
5924        let mut dd = common::DefaultDelegate;
5925        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5926        dlg.begin(common::MethodInfo {
5927            id: "accessapproval.projects.approvalRequests.approve",
5928            http_method: hyper::Method::POST,
5929        });
5930
5931        for &field in ["alt", "name"].iter() {
5932            if self._additional_params.contains_key(field) {
5933                dlg.finished(false);
5934                return Err(common::Error::FieldClash(field));
5935            }
5936        }
5937
5938        let mut params = Params::with_capacity(4 + self._additional_params.len());
5939        params.push("name", self._name);
5940
5941        params.extend(self._additional_params.iter());
5942
5943        params.push("alt", "json");
5944        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:approve";
5945        if self._scopes.is_empty() {
5946            self._scopes
5947                .insert(Scope::CloudPlatform.as_ref().to_string());
5948        }
5949
5950        #[allow(clippy::single_element_loop)]
5951        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5952            url = params.uri_replacement(url, param_name, find_this, true);
5953        }
5954        {
5955            let to_remove = ["name"];
5956            params.remove_params(&to_remove);
5957        }
5958
5959        let url = params.parse_with_url(&url);
5960
5961        let mut json_mime_type = mime::APPLICATION_JSON;
5962        let mut request_value_reader = {
5963            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5964            common::remove_json_null_values(&mut value);
5965            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5966            serde_json::to_writer(&mut dst, &value).unwrap();
5967            dst
5968        };
5969        let request_size = request_value_reader
5970            .seek(std::io::SeekFrom::End(0))
5971            .unwrap();
5972        request_value_reader
5973            .seek(std::io::SeekFrom::Start(0))
5974            .unwrap();
5975
5976        loop {
5977            let token = match self
5978                .hub
5979                .auth
5980                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5981                .await
5982            {
5983                Ok(token) => token,
5984                Err(e) => match dlg.token(e) {
5985                    Ok(token) => token,
5986                    Err(e) => {
5987                        dlg.finished(false);
5988                        return Err(common::Error::MissingToken(e));
5989                    }
5990                },
5991            };
5992            request_value_reader
5993                .seek(std::io::SeekFrom::Start(0))
5994                .unwrap();
5995            let mut req_result = {
5996                let client = &self.hub.client;
5997                dlg.pre_request();
5998                let mut req_builder = hyper::Request::builder()
5999                    .method(hyper::Method::POST)
6000                    .uri(url.as_str())
6001                    .header(USER_AGENT, self.hub._user_agent.clone());
6002
6003                if let Some(token) = token.as_ref() {
6004                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6005                }
6006
6007                let request = req_builder
6008                    .header(CONTENT_TYPE, json_mime_type.to_string())
6009                    .header(CONTENT_LENGTH, request_size as u64)
6010                    .body(common::to_body(
6011                        request_value_reader.get_ref().clone().into(),
6012                    ));
6013
6014                client.request(request.unwrap()).await
6015            };
6016
6017            match req_result {
6018                Err(err) => {
6019                    if let common::Retry::After(d) = dlg.http_error(&err) {
6020                        sleep(d).await;
6021                        continue;
6022                    }
6023                    dlg.finished(false);
6024                    return Err(common::Error::HttpError(err));
6025                }
6026                Ok(res) => {
6027                    let (mut parts, body) = res.into_parts();
6028                    let mut body = common::Body::new(body);
6029                    if !parts.status.is_success() {
6030                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6031                        let error = serde_json::from_str(&common::to_string(&bytes));
6032                        let response = common::to_response(parts, bytes.into());
6033
6034                        if let common::Retry::After(d) =
6035                            dlg.http_failure(&response, error.as_ref().ok())
6036                        {
6037                            sleep(d).await;
6038                            continue;
6039                        }
6040
6041                        dlg.finished(false);
6042
6043                        return Err(match error {
6044                            Ok(value) => common::Error::BadRequest(value),
6045                            _ => common::Error::Failure(response),
6046                        });
6047                    }
6048                    let response = {
6049                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6050                        let encoded = common::to_string(&bytes);
6051                        match serde_json::from_str(&encoded) {
6052                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6053                            Err(error) => {
6054                                dlg.response_json_decode_error(&encoded, &error);
6055                                return Err(common::Error::JsonDecodeError(
6056                                    encoded.to_string(),
6057                                    error,
6058                                ));
6059                            }
6060                        }
6061                    };
6062
6063                    dlg.finished(true);
6064                    return Ok(response);
6065                }
6066            }
6067        }
6068    }
6069
6070    ///
6071    /// Sets the *request* property to the given value.
6072    ///
6073    /// Even though the property as already been set when instantiating this call,
6074    /// we provide this method for API completeness.
6075    pub fn request(
6076        mut self,
6077        new_value: ApproveApprovalRequestMessage,
6078    ) -> ProjectApprovalRequestApproveCall<'a, C> {
6079        self._request = new_value;
6080        self
6081    }
6082    /// Name of the approval request to approve.
6083    ///
6084    /// Sets the *name* path property to the given value.
6085    ///
6086    /// Even though the property as already been set when instantiating this call,
6087    /// we provide this method for API completeness.
6088    pub fn name(mut self, new_value: &str) -> ProjectApprovalRequestApproveCall<'a, C> {
6089        self._name = new_value.to_string();
6090        self
6091    }
6092    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6093    /// while executing the actual API request.
6094    ///
6095    /// ````text
6096    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6097    /// ````
6098    ///
6099    /// Sets the *delegate* property to the given value.
6100    pub fn delegate(
6101        mut self,
6102        new_value: &'a mut dyn common::Delegate,
6103    ) -> ProjectApprovalRequestApproveCall<'a, C> {
6104        self._delegate = Some(new_value);
6105        self
6106    }
6107
6108    /// Set any additional parameter of the query string used in the request.
6109    /// It should be used to set parameters which are not yet available through their own
6110    /// setters.
6111    ///
6112    /// Please note that this method must not be used to set any of the known parameters
6113    /// which have their own setter method. If done anyway, the request will fail.
6114    ///
6115    /// # Additional Parameters
6116    ///
6117    /// * *$.xgafv* (query-string) - V1 error format.
6118    /// * *access_token* (query-string) - OAuth access token.
6119    /// * *alt* (query-string) - Data format for response.
6120    /// * *callback* (query-string) - JSONP
6121    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6122    /// * *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.
6123    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6124    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6125    /// * *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.
6126    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6127    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6128    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestApproveCall<'a, C>
6129    where
6130        T: AsRef<str>,
6131    {
6132        self._additional_params
6133            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6134        self
6135    }
6136
6137    /// Identifies the authorization scope for the method you are building.
6138    ///
6139    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6140    /// [`Scope::CloudPlatform`].
6141    ///
6142    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6143    /// tokens for more than one scope.
6144    ///
6145    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6146    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6147    /// sufficient, a read-write scope will do as well.
6148    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestApproveCall<'a, C>
6149    where
6150        St: AsRef<str>,
6151    {
6152        self._scopes.insert(String::from(scope.as_ref()));
6153        self
6154    }
6155    /// Identifies the authorization scope(s) for the method you are building.
6156    ///
6157    /// See [`Self::add_scope()`] for details.
6158    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestApproveCall<'a, C>
6159    where
6160        I: IntoIterator<Item = St>,
6161        St: AsRef<str>,
6162    {
6163        self._scopes
6164            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6165        self
6166    }
6167
6168    /// Removes all scopes, and no default scope will be used either.
6169    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6170    /// for details).
6171    pub fn clear_scopes(mut self) -> ProjectApprovalRequestApproveCall<'a, C> {
6172        self._scopes.clear();
6173        self
6174    }
6175}
6176
6177/// Dismisses a request. Returns the updated ApprovalRequest.
6178///
6179/// NOTE: This does not deny access to the resource if another request has been
6180/// made and approved. It is equivalent in effect to ignoring the request
6181/// altogether.
6182///
6183/// Returns NOT_FOUND if the request does not exist.
6184///
6185/// Returns FAILED_PRECONDITION if the request exists but is not in a pending
6186/// state.
6187///
6188/// A builder for the *approvalRequests.dismiss* method supported by a *project* resource.
6189/// It is not used directly, but through a [`ProjectMethods`] instance.
6190///
6191/// # Example
6192///
6193/// Instantiate a resource method builder
6194///
6195/// ```test_harness,no_run
6196/// # extern crate hyper;
6197/// # extern crate hyper_rustls;
6198/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
6199/// use accessapproval1_beta1::api::DismissApprovalRequestMessage;
6200/// # async fn dox() {
6201/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6202///
6203/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6204/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6205/// #     .with_native_roots()
6206/// #     .unwrap()
6207/// #     .https_only()
6208/// #     .enable_http2()
6209/// #     .build();
6210///
6211/// # let executor = hyper_util::rt::TokioExecutor::new();
6212/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6213/// #     secret,
6214/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6215/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6216/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6217/// #     ),
6218/// # ).build().await.unwrap();
6219///
6220/// # let client = hyper_util::client::legacy::Client::builder(
6221/// #     hyper_util::rt::TokioExecutor::new()
6222/// # )
6223/// # .build(
6224/// #     hyper_rustls::HttpsConnectorBuilder::new()
6225/// #         .with_native_roots()
6226/// #         .unwrap()
6227/// #         .https_or_http()
6228/// #         .enable_http2()
6229/// #         .build()
6230/// # );
6231/// # let mut hub = AccessApproval::new(client, auth);
6232/// // As the method needs a request, you would usually fill it with the desired information
6233/// // into the respective structure. Some of the parts shown here might not be applicable !
6234/// // Values shown here are possibly random and not representative !
6235/// let mut req = DismissApprovalRequestMessage::default();
6236///
6237/// // You can configure optional parameters by calling the respective setters at will, and
6238/// // execute the final call using `doit()`.
6239/// // Values shown here are possibly random and not representative !
6240/// let result = hub.projects().approval_requests_dismiss(req, "name")
6241///              .doit().await;
6242/// # }
6243/// ```
6244pub struct ProjectApprovalRequestDismisCall<'a, C>
6245where
6246    C: 'a,
6247{
6248    hub: &'a AccessApproval<C>,
6249    _request: DismissApprovalRequestMessage,
6250    _name: String,
6251    _delegate: Option<&'a mut dyn common::Delegate>,
6252    _additional_params: HashMap<String, String>,
6253    _scopes: BTreeSet<String>,
6254}
6255
6256impl<'a, C> common::CallBuilder for ProjectApprovalRequestDismisCall<'a, C> {}
6257
6258impl<'a, C> ProjectApprovalRequestDismisCall<'a, C>
6259where
6260    C: common::Connector,
6261{
6262    /// Perform the operation you have build so far.
6263    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
6264        use std::borrow::Cow;
6265        use std::io::{Read, Seek};
6266
6267        use common::{url::Params, ToParts};
6268        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6269
6270        let mut dd = common::DefaultDelegate;
6271        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6272        dlg.begin(common::MethodInfo {
6273            id: "accessapproval.projects.approvalRequests.dismiss",
6274            http_method: hyper::Method::POST,
6275        });
6276
6277        for &field in ["alt", "name"].iter() {
6278            if self._additional_params.contains_key(field) {
6279                dlg.finished(false);
6280                return Err(common::Error::FieldClash(field));
6281            }
6282        }
6283
6284        let mut params = Params::with_capacity(4 + self._additional_params.len());
6285        params.push("name", self._name);
6286
6287        params.extend(self._additional_params.iter());
6288
6289        params.push("alt", "json");
6290        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}:dismiss";
6291        if self._scopes.is_empty() {
6292            self._scopes
6293                .insert(Scope::CloudPlatform.as_ref().to_string());
6294        }
6295
6296        #[allow(clippy::single_element_loop)]
6297        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6298            url = params.uri_replacement(url, param_name, find_this, true);
6299        }
6300        {
6301            let to_remove = ["name"];
6302            params.remove_params(&to_remove);
6303        }
6304
6305        let url = params.parse_with_url(&url);
6306
6307        let mut json_mime_type = mime::APPLICATION_JSON;
6308        let mut request_value_reader = {
6309            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6310            common::remove_json_null_values(&mut value);
6311            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6312            serde_json::to_writer(&mut dst, &value).unwrap();
6313            dst
6314        };
6315        let request_size = request_value_reader
6316            .seek(std::io::SeekFrom::End(0))
6317            .unwrap();
6318        request_value_reader
6319            .seek(std::io::SeekFrom::Start(0))
6320            .unwrap();
6321
6322        loop {
6323            let token = match self
6324                .hub
6325                .auth
6326                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6327                .await
6328            {
6329                Ok(token) => token,
6330                Err(e) => match dlg.token(e) {
6331                    Ok(token) => token,
6332                    Err(e) => {
6333                        dlg.finished(false);
6334                        return Err(common::Error::MissingToken(e));
6335                    }
6336                },
6337            };
6338            request_value_reader
6339                .seek(std::io::SeekFrom::Start(0))
6340                .unwrap();
6341            let mut req_result = {
6342                let client = &self.hub.client;
6343                dlg.pre_request();
6344                let mut req_builder = hyper::Request::builder()
6345                    .method(hyper::Method::POST)
6346                    .uri(url.as_str())
6347                    .header(USER_AGENT, self.hub._user_agent.clone());
6348
6349                if let Some(token) = token.as_ref() {
6350                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6351                }
6352
6353                let request = req_builder
6354                    .header(CONTENT_TYPE, json_mime_type.to_string())
6355                    .header(CONTENT_LENGTH, request_size as u64)
6356                    .body(common::to_body(
6357                        request_value_reader.get_ref().clone().into(),
6358                    ));
6359
6360                client.request(request.unwrap()).await
6361            };
6362
6363            match req_result {
6364                Err(err) => {
6365                    if let common::Retry::After(d) = dlg.http_error(&err) {
6366                        sleep(d).await;
6367                        continue;
6368                    }
6369                    dlg.finished(false);
6370                    return Err(common::Error::HttpError(err));
6371                }
6372                Ok(res) => {
6373                    let (mut parts, body) = res.into_parts();
6374                    let mut body = common::Body::new(body);
6375                    if !parts.status.is_success() {
6376                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6377                        let error = serde_json::from_str(&common::to_string(&bytes));
6378                        let response = common::to_response(parts, bytes.into());
6379
6380                        if let common::Retry::After(d) =
6381                            dlg.http_failure(&response, error.as_ref().ok())
6382                        {
6383                            sleep(d).await;
6384                            continue;
6385                        }
6386
6387                        dlg.finished(false);
6388
6389                        return Err(match error {
6390                            Ok(value) => common::Error::BadRequest(value),
6391                            _ => common::Error::Failure(response),
6392                        });
6393                    }
6394                    let response = {
6395                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6396                        let encoded = common::to_string(&bytes);
6397                        match serde_json::from_str(&encoded) {
6398                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6399                            Err(error) => {
6400                                dlg.response_json_decode_error(&encoded, &error);
6401                                return Err(common::Error::JsonDecodeError(
6402                                    encoded.to_string(),
6403                                    error,
6404                                ));
6405                            }
6406                        }
6407                    };
6408
6409                    dlg.finished(true);
6410                    return Ok(response);
6411                }
6412            }
6413        }
6414    }
6415
6416    ///
6417    /// Sets the *request* property to the given value.
6418    ///
6419    /// Even though the property as already been set when instantiating this call,
6420    /// we provide this method for API completeness.
6421    pub fn request(
6422        mut self,
6423        new_value: DismissApprovalRequestMessage,
6424    ) -> ProjectApprovalRequestDismisCall<'a, C> {
6425        self._request = new_value;
6426        self
6427    }
6428    /// Name of the ApprovalRequest to dismiss.
6429    ///
6430    /// Sets the *name* path property to the given value.
6431    ///
6432    /// Even though the property as already been set when instantiating this call,
6433    /// we provide this method for API completeness.
6434    pub fn name(mut self, new_value: &str) -> ProjectApprovalRequestDismisCall<'a, C> {
6435        self._name = new_value.to_string();
6436        self
6437    }
6438    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6439    /// while executing the actual API request.
6440    ///
6441    /// ````text
6442    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6443    /// ````
6444    ///
6445    /// Sets the *delegate* property to the given value.
6446    pub fn delegate(
6447        mut self,
6448        new_value: &'a mut dyn common::Delegate,
6449    ) -> ProjectApprovalRequestDismisCall<'a, C> {
6450        self._delegate = Some(new_value);
6451        self
6452    }
6453
6454    /// Set any additional parameter of the query string used in the request.
6455    /// It should be used to set parameters which are not yet available through their own
6456    /// setters.
6457    ///
6458    /// Please note that this method must not be used to set any of the known parameters
6459    /// which have their own setter method. If done anyway, the request will fail.
6460    ///
6461    /// # Additional Parameters
6462    ///
6463    /// * *$.xgafv* (query-string) - V1 error format.
6464    /// * *access_token* (query-string) - OAuth access token.
6465    /// * *alt* (query-string) - Data format for response.
6466    /// * *callback* (query-string) - JSONP
6467    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6468    /// * *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.
6469    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6470    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6471    /// * *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.
6472    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6473    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6474    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestDismisCall<'a, C>
6475    where
6476        T: AsRef<str>,
6477    {
6478        self._additional_params
6479            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6480        self
6481    }
6482
6483    /// Identifies the authorization scope for the method you are building.
6484    ///
6485    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6486    /// [`Scope::CloudPlatform`].
6487    ///
6488    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6489    /// tokens for more than one scope.
6490    ///
6491    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6492    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6493    /// sufficient, a read-write scope will do as well.
6494    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestDismisCall<'a, C>
6495    where
6496        St: AsRef<str>,
6497    {
6498        self._scopes.insert(String::from(scope.as_ref()));
6499        self
6500    }
6501    /// Identifies the authorization scope(s) for the method you are building.
6502    ///
6503    /// See [`Self::add_scope()`] for details.
6504    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestDismisCall<'a, C>
6505    where
6506        I: IntoIterator<Item = St>,
6507        St: AsRef<str>,
6508    {
6509        self._scopes
6510            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6511        self
6512    }
6513
6514    /// Removes all scopes, and no default scope will be used either.
6515    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6516    /// for details).
6517    pub fn clear_scopes(mut self) -> ProjectApprovalRequestDismisCall<'a, C> {
6518        self._scopes.clear();
6519        self
6520    }
6521}
6522
6523/// Gets an approval request. Returns NOT_FOUND if the request does not exist.
6524///
6525/// A builder for the *approvalRequests.get* method supported by a *project* resource.
6526/// It is not used directly, but through a [`ProjectMethods`] instance.
6527///
6528/// # Example
6529///
6530/// Instantiate a resource method builder
6531///
6532/// ```test_harness,no_run
6533/// # extern crate hyper;
6534/// # extern crate hyper_rustls;
6535/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
6536/// # async fn dox() {
6537/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6538///
6539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6540/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6541/// #     .with_native_roots()
6542/// #     .unwrap()
6543/// #     .https_only()
6544/// #     .enable_http2()
6545/// #     .build();
6546///
6547/// # let executor = hyper_util::rt::TokioExecutor::new();
6548/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6549/// #     secret,
6550/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6551/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6552/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6553/// #     ),
6554/// # ).build().await.unwrap();
6555///
6556/// # let client = hyper_util::client::legacy::Client::builder(
6557/// #     hyper_util::rt::TokioExecutor::new()
6558/// # )
6559/// # .build(
6560/// #     hyper_rustls::HttpsConnectorBuilder::new()
6561/// #         .with_native_roots()
6562/// #         .unwrap()
6563/// #         .https_or_http()
6564/// #         .enable_http2()
6565/// #         .build()
6566/// # );
6567/// # let mut hub = AccessApproval::new(client, auth);
6568/// // You can configure optional parameters by calling the respective setters at will, and
6569/// // execute the final call using `doit()`.
6570/// // Values shown here are possibly random and not representative !
6571/// let result = hub.projects().approval_requests_get("name")
6572///              .doit().await;
6573/// # }
6574/// ```
6575pub struct ProjectApprovalRequestGetCall<'a, C>
6576where
6577    C: 'a,
6578{
6579    hub: &'a AccessApproval<C>,
6580    _name: String,
6581    _delegate: Option<&'a mut dyn common::Delegate>,
6582    _additional_params: HashMap<String, String>,
6583    _scopes: BTreeSet<String>,
6584}
6585
6586impl<'a, C> common::CallBuilder for ProjectApprovalRequestGetCall<'a, C> {}
6587
6588impl<'a, C> ProjectApprovalRequestGetCall<'a, C>
6589where
6590    C: common::Connector,
6591{
6592    /// Perform the operation you have build so far.
6593    pub async fn doit(mut self) -> common::Result<(common::Response, ApprovalRequest)> {
6594        use std::borrow::Cow;
6595        use std::io::{Read, Seek};
6596
6597        use common::{url::Params, ToParts};
6598        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6599
6600        let mut dd = common::DefaultDelegate;
6601        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6602        dlg.begin(common::MethodInfo {
6603            id: "accessapproval.projects.approvalRequests.get",
6604            http_method: hyper::Method::GET,
6605        });
6606
6607        for &field in ["alt", "name"].iter() {
6608            if self._additional_params.contains_key(field) {
6609                dlg.finished(false);
6610                return Err(common::Error::FieldClash(field));
6611            }
6612        }
6613
6614        let mut params = Params::with_capacity(3 + self._additional_params.len());
6615        params.push("name", self._name);
6616
6617        params.extend(self._additional_params.iter());
6618
6619        params.push("alt", "json");
6620        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
6621        if self._scopes.is_empty() {
6622            self._scopes
6623                .insert(Scope::CloudPlatform.as_ref().to_string());
6624        }
6625
6626        #[allow(clippy::single_element_loop)]
6627        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6628            url = params.uri_replacement(url, param_name, find_this, true);
6629        }
6630        {
6631            let to_remove = ["name"];
6632            params.remove_params(&to_remove);
6633        }
6634
6635        let url = params.parse_with_url(&url);
6636
6637        loop {
6638            let token = match self
6639                .hub
6640                .auth
6641                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6642                .await
6643            {
6644                Ok(token) => token,
6645                Err(e) => match dlg.token(e) {
6646                    Ok(token) => token,
6647                    Err(e) => {
6648                        dlg.finished(false);
6649                        return Err(common::Error::MissingToken(e));
6650                    }
6651                },
6652            };
6653            let mut req_result = {
6654                let client = &self.hub.client;
6655                dlg.pre_request();
6656                let mut req_builder = hyper::Request::builder()
6657                    .method(hyper::Method::GET)
6658                    .uri(url.as_str())
6659                    .header(USER_AGENT, self.hub._user_agent.clone());
6660
6661                if let Some(token) = token.as_ref() {
6662                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6663                }
6664
6665                let request = req_builder
6666                    .header(CONTENT_LENGTH, 0_u64)
6667                    .body(common::to_body::<String>(None));
6668
6669                client.request(request.unwrap()).await
6670            };
6671
6672            match req_result {
6673                Err(err) => {
6674                    if let common::Retry::After(d) = dlg.http_error(&err) {
6675                        sleep(d).await;
6676                        continue;
6677                    }
6678                    dlg.finished(false);
6679                    return Err(common::Error::HttpError(err));
6680                }
6681                Ok(res) => {
6682                    let (mut parts, body) = res.into_parts();
6683                    let mut body = common::Body::new(body);
6684                    if !parts.status.is_success() {
6685                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6686                        let error = serde_json::from_str(&common::to_string(&bytes));
6687                        let response = common::to_response(parts, bytes.into());
6688
6689                        if let common::Retry::After(d) =
6690                            dlg.http_failure(&response, error.as_ref().ok())
6691                        {
6692                            sleep(d).await;
6693                            continue;
6694                        }
6695
6696                        dlg.finished(false);
6697
6698                        return Err(match error {
6699                            Ok(value) => common::Error::BadRequest(value),
6700                            _ => common::Error::Failure(response),
6701                        });
6702                    }
6703                    let response = {
6704                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6705                        let encoded = common::to_string(&bytes);
6706                        match serde_json::from_str(&encoded) {
6707                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6708                            Err(error) => {
6709                                dlg.response_json_decode_error(&encoded, &error);
6710                                return Err(common::Error::JsonDecodeError(
6711                                    encoded.to_string(),
6712                                    error,
6713                                ));
6714                            }
6715                        }
6716                    };
6717
6718                    dlg.finished(true);
6719                    return Ok(response);
6720                }
6721            }
6722        }
6723    }
6724
6725    /// Name of the approval request to retrieve.
6726    ///
6727    /// Sets the *name* path property to the given value.
6728    ///
6729    /// Even though the property as already been set when instantiating this call,
6730    /// we provide this method for API completeness.
6731    pub fn name(mut self, new_value: &str) -> ProjectApprovalRequestGetCall<'a, C> {
6732        self._name = new_value.to_string();
6733        self
6734    }
6735    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6736    /// while executing the actual API request.
6737    ///
6738    /// ````text
6739    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6740    /// ````
6741    ///
6742    /// Sets the *delegate* property to the given value.
6743    pub fn delegate(
6744        mut self,
6745        new_value: &'a mut dyn common::Delegate,
6746    ) -> ProjectApprovalRequestGetCall<'a, C> {
6747        self._delegate = Some(new_value);
6748        self
6749    }
6750
6751    /// Set any additional parameter of the query string used in the request.
6752    /// It should be used to set parameters which are not yet available through their own
6753    /// setters.
6754    ///
6755    /// Please note that this method must not be used to set any of the known parameters
6756    /// which have their own setter method. If done anyway, the request will fail.
6757    ///
6758    /// # Additional Parameters
6759    ///
6760    /// * *$.xgafv* (query-string) - V1 error format.
6761    /// * *access_token* (query-string) - OAuth access token.
6762    /// * *alt* (query-string) - Data format for response.
6763    /// * *callback* (query-string) - JSONP
6764    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6765    /// * *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.
6766    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6767    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6768    /// * *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.
6769    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6770    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6771    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestGetCall<'a, C>
6772    where
6773        T: AsRef<str>,
6774    {
6775        self._additional_params
6776            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6777        self
6778    }
6779
6780    /// Identifies the authorization scope for the method you are building.
6781    ///
6782    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6783    /// [`Scope::CloudPlatform`].
6784    ///
6785    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6786    /// tokens for more than one scope.
6787    ///
6788    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6789    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6790    /// sufficient, a read-write scope will do as well.
6791    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestGetCall<'a, C>
6792    where
6793        St: AsRef<str>,
6794    {
6795        self._scopes.insert(String::from(scope.as_ref()));
6796        self
6797    }
6798    /// Identifies the authorization scope(s) for the method you are building.
6799    ///
6800    /// See [`Self::add_scope()`] for details.
6801    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestGetCall<'a, C>
6802    where
6803        I: IntoIterator<Item = St>,
6804        St: AsRef<str>,
6805    {
6806        self._scopes
6807            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6808        self
6809    }
6810
6811    /// Removes all scopes, and no default scope will be used either.
6812    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6813    /// for details).
6814    pub fn clear_scopes(mut self) -> ProjectApprovalRequestGetCall<'a, C> {
6815        self._scopes.clear();
6816        self
6817    }
6818}
6819
6820/// Lists approval requests associated with a project, folder, or organization.
6821/// Approval requests can be filtered by state (pending, active, dismissed).
6822/// The order is reverse chronological.
6823///
6824/// A builder for the *approvalRequests.list* method supported by a *project* resource.
6825/// It is not used directly, but through a [`ProjectMethods`] instance.
6826///
6827/// # Example
6828///
6829/// Instantiate a resource method builder
6830///
6831/// ```test_harness,no_run
6832/// # extern crate hyper;
6833/// # extern crate hyper_rustls;
6834/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
6835/// # async fn dox() {
6836/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6837///
6838/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6839/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6840/// #     .with_native_roots()
6841/// #     .unwrap()
6842/// #     .https_only()
6843/// #     .enable_http2()
6844/// #     .build();
6845///
6846/// # let executor = hyper_util::rt::TokioExecutor::new();
6847/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6848/// #     secret,
6849/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6850/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6851/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6852/// #     ),
6853/// # ).build().await.unwrap();
6854///
6855/// # let client = hyper_util::client::legacy::Client::builder(
6856/// #     hyper_util::rt::TokioExecutor::new()
6857/// # )
6858/// # .build(
6859/// #     hyper_rustls::HttpsConnectorBuilder::new()
6860/// #         .with_native_roots()
6861/// #         .unwrap()
6862/// #         .https_or_http()
6863/// #         .enable_http2()
6864/// #         .build()
6865/// # );
6866/// # let mut hub = AccessApproval::new(client, auth);
6867/// // You can configure optional parameters by calling the respective setters at will, and
6868/// // execute the final call using `doit()`.
6869/// // Values shown here are possibly random and not representative !
6870/// let result = hub.projects().approval_requests_list("parent")
6871///              .page_token("rebum.")
6872///              .page_size(-57)
6873///              .filter("ipsum")
6874///              .doit().await;
6875/// # }
6876/// ```
6877pub struct ProjectApprovalRequestListCall<'a, C>
6878where
6879    C: 'a,
6880{
6881    hub: &'a AccessApproval<C>,
6882    _parent: String,
6883    _page_token: Option<String>,
6884    _page_size: Option<i32>,
6885    _filter: Option<String>,
6886    _delegate: Option<&'a mut dyn common::Delegate>,
6887    _additional_params: HashMap<String, String>,
6888    _scopes: BTreeSet<String>,
6889}
6890
6891impl<'a, C> common::CallBuilder for ProjectApprovalRequestListCall<'a, C> {}
6892
6893impl<'a, C> ProjectApprovalRequestListCall<'a, C>
6894where
6895    C: common::Connector,
6896{
6897    /// Perform the operation you have build so far.
6898    pub async fn doit(
6899        mut self,
6900    ) -> common::Result<(common::Response, ListApprovalRequestsResponse)> {
6901        use std::borrow::Cow;
6902        use std::io::{Read, Seek};
6903
6904        use common::{url::Params, ToParts};
6905        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6906
6907        let mut dd = common::DefaultDelegate;
6908        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6909        dlg.begin(common::MethodInfo {
6910            id: "accessapproval.projects.approvalRequests.list",
6911            http_method: hyper::Method::GET,
6912        });
6913
6914        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
6915            if self._additional_params.contains_key(field) {
6916                dlg.finished(false);
6917                return Err(common::Error::FieldClash(field));
6918            }
6919        }
6920
6921        let mut params = Params::with_capacity(6 + self._additional_params.len());
6922        params.push("parent", self._parent);
6923        if let Some(value) = self._page_token.as_ref() {
6924            params.push("pageToken", value);
6925        }
6926        if let Some(value) = self._page_size.as_ref() {
6927            params.push("pageSize", value.to_string());
6928        }
6929        if let Some(value) = self._filter.as_ref() {
6930            params.push("filter", value);
6931        }
6932
6933        params.extend(self._additional_params.iter());
6934
6935        params.push("alt", "json");
6936        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/approvalRequests";
6937        if self._scopes.is_empty() {
6938            self._scopes
6939                .insert(Scope::CloudPlatform.as_ref().to_string());
6940        }
6941
6942        #[allow(clippy::single_element_loop)]
6943        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6944            url = params.uri_replacement(url, param_name, find_this, true);
6945        }
6946        {
6947            let to_remove = ["parent"];
6948            params.remove_params(&to_remove);
6949        }
6950
6951        let url = params.parse_with_url(&url);
6952
6953        loop {
6954            let token = match self
6955                .hub
6956                .auth
6957                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6958                .await
6959            {
6960                Ok(token) => token,
6961                Err(e) => match dlg.token(e) {
6962                    Ok(token) => token,
6963                    Err(e) => {
6964                        dlg.finished(false);
6965                        return Err(common::Error::MissingToken(e));
6966                    }
6967                },
6968            };
6969            let mut req_result = {
6970                let client = &self.hub.client;
6971                dlg.pre_request();
6972                let mut req_builder = hyper::Request::builder()
6973                    .method(hyper::Method::GET)
6974                    .uri(url.as_str())
6975                    .header(USER_AGENT, self.hub._user_agent.clone());
6976
6977                if let Some(token) = token.as_ref() {
6978                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6979                }
6980
6981                let request = req_builder
6982                    .header(CONTENT_LENGTH, 0_u64)
6983                    .body(common::to_body::<String>(None));
6984
6985                client.request(request.unwrap()).await
6986            };
6987
6988            match req_result {
6989                Err(err) => {
6990                    if let common::Retry::After(d) = dlg.http_error(&err) {
6991                        sleep(d).await;
6992                        continue;
6993                    }
6994                    dlg.finished(false);
6995                    return Err(common::Error::HttpError(err));
6996                }
6997                Ok(res) => {
6998                    let (mut parts, body) = res.into_parts();
6999                    let mut body = common::Body::new(body);
7000                    if !parts.status.is_success() {
7001                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7002                        let error = serde_json::from_str(&common::to_string(&bytes));
7003                        let response = common::to_response(parts, bytes.into());
7004
7005                        if let common::Retry::After(d) =
7006                            dlg.http_failure(&response, error.as_ref().ok())
7007                        {
7008                            sleep(d).await;
7009                            continue;
7010                        }
7011
7012                        dlg.finished(false);
7013
7014                        return Err(match error {
7015                            Ok(value) => common::Error::BadRequest(value),
7016                            _ => common::Error::Failure(response),
7017                        });
7018                    }
7019                    let response = {
7020                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7021                        let encoded = common::to_string(&bytes);
7022                        match serde_json::from_str(&encoded) {
7023                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7024                            Err(error) => {
7025                                dlg.response_json_decode_error(&encoded, &error);
7026                                return Err(common::Error::JsonDecodeError(
7027                                    encoded.to_string(),
7028                                    error,
7029                                ));
7030                            }
7031                        }
7032                    };
7033
7034                    dlg.finished(true);
7035                    return Ok(response);
7036                }
7037            }
7038        }
7039    }
7040
7041    /// The parent resource. This may be "projects/{project_id}",
7042    /// "folders/{folder_id}", or "organizations/{organization_id}".
7043    ///
7044    /// Sets the *parent* path property to the given value.
7045    ///
7046    /// Even though the property as already been set when instantiating this call,
7047    /// we provide this method for API completeness.
7048    pub fn parent(mut self, new_value: &str) -> ProjectApprovalRequestListCall<'a, C> {
7049        self._parent = new_value.to_string();
7050        self
7051    }
7052    /// A token identifying the page of results to return.
7053    ///
7054    /// Sets the *page token* query property to the given value.
7055    pub fn page_token(mut self, new_value: &str) -> ProjectApprovalRequestListCall<'a, C> {
7056        self._page_token = Some(new_value.to_string());
7057        self
7058    }
7059    /// Requested page size.
7060    ///
7061    /// Sets the *page size* query property to the given value.
7062    pub fn page_size(mut self, new_value: i32) -> ProjectApprovalRequestListCall<'a, C> {
7063        self._page_size = Some(new_value);
7064        self
7065    }
7066    /// A filter on the type of approval requests to retrieve. Must be one of the
7067    /// following values:
7068    /// <ol>
7069    ///   <li>[not set]: Requests that are pending or have active approvals.</li>
7070    ///   <li>ALL: All requests.</li>
7071    ///   <li>PENDING: Only pending requests.</li>
7072    ///   <li>ACTIVE: Only active (i.e. currently approved) requests.</li>
7073    ///   <li>DISMISSED: Only dismissed (including expired) requests.</li>
7074    ///   <li>HISTORY: Active and dismissed (including expired) requests.</li>
7075    /// </ol>
7076    ///
7077    /// Sets the *filter* query property to the given value.
7078    pub fn filter(mut self, new_value: &str) -> ProjectApprovalRequestListCall<'a, C> {
7079        self._filter = Some(new_value.to_string());
7080        self
7081    }
7082    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7083    /// while executing the actual API request.
7084    ///
7085    /// ````text
7086    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7087    /// ````
7088    ///
7089    /// Sets the *delegate* property to the given value.
7090    pub fn delegate(
7091        mut self,
7092        new_value: &'a mut dyn common::Delegate,
7093    ) -> ProjectApprovalRequestListCall<'a, C> {
7094        self._delegate = Some(new_value);
7095        self
7096    }
7097
7098    /// Set any additional parameter of the query string used in the request.
7099    /// It should be used to set parameters which are not yet available through their own
7100    /// setters.
7101    ///
7102    /// Please note that this method must not be used to set any of the known parameters
7103    /// which have their own setter method. If done anyway, the request will fail.
7104    ///
7105    /// # Additional Parameters
7106    ///
7107    /// * *$.xgafv* (query-string) - V1 error format.
7108    /// * *access_token* (query-string) - OAuth access token.
7109    /// * *alt* (query-string) - Data format for response.
7110    /// * *callback* (query-string) - JSONP
7111    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7112    /// * *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.
7113    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7114    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7115    /// * *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.
7116    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7117    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7118    pub fn param<T>(mut self, name: T, value: T) -> ProjectApprovalRequestListCall<'a, C>
7119    where
7120        T: AsRef<str>,
7121    {
7122        self._additional_params
7123            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7124        self
7125    }
7126
7127    /// Identifies the authorization scope for the method you are building.
7128    ///
7129    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7130    /// [`Scope::CloudPlatform`].
7131    ///
7132    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7133    /// tokens for more than one scope.
7134    ///
7135    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7136    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7137    /// sufficient, a read-write scope will do as well.
7138    pub fn add_scope<St>(mut self, scope: St) -> ProjectApprovalRequestListCall<'a, C>
7139    where
7140        St: AsRef<str>,
7141    {
7142        self._scopes.insert(String::from(scope.as_ref()));
7143        self
7144    }
7145    /// Identifies the authorization scope(s) for the method you are building.
7146    ///
7147    /// See [`Self::add_scope()`] for details.
7148    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectApprovalRequestListCall<'a, C>
7149    where
7150        I: IntoIterator<Item = St>,
7151        St: AsRef<str>,
7152    {
7153        self._scopes
7154            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7155        self
7156    }
7157
7158    /// Removes all scopes, and no default scope will be used either.
7159    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7160    /// for details).
7161    pub fn clear_scopes(mut self) -> ProjectApprovalRequestListCall<'a, C> {
7162        self._scopes.clear();
7163        self
7164    }
7165}
7166
7167/// Deletes the settings associated with a project, folder, or organization.
7168/// This will have the effect of disabling Access Approval for the project,
7169/// folder, or organization, but only if all ancestors also have Access
7170/// Approval disabled. If Access Approval is enabled at a higher level of the
7171/// hierarchy, then Access Approval will still be enabled at this level as
7172/// the settings are inherited.
7173///
7174/// A builder for the *deleteAccessApprovalSettings* method supported by a *project* resource.
7175/// It is not used directly, but through a [`ProjectMethods`] instance.
7176///
7177/// # Example
7178///
7179/// Instantiate a resource method builder
7180///
7181/// ```test_harness,no_run
7182/// # extern crate hyper;
7183/// # extern crate hyper_rustls;
7184/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
7185/// # async fn dox() {
7186/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7187///
7188/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7189/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7190/// #     .with_native_roots()
7191/// #     .unwrap()
7192/// #     .https_only()
7193/// #     .enable_http2()
7194/// #     .build();
7195///
7196/// # let executor = hyper_util::rt::TokioExecutor::new();
7197/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7198/// #     secret,
7199/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7200/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7201/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7202/// #     ),
7203/// # ).build().await.unwrap();
7204///
7205/// # let client = hyper_util::client::legacy::Client::builder(
7206/// #     hyper_util::rt::TokioExecutor::new()
7207/// # )
7208/// # .build(
7209/// #     hyper_rustls::HttpsConnectorBuilder::new()
7210/// #         .with_native_roots()
7211/// #         .unwrap()
7212/// #         .https_or_http()
7213/// #         .enable_http2()
7214/// #         .build()
7215/// # );
7216/// # let mut hub = AccessApproval::new(client, auth);
7217/// // You can configure optional parameters by calling the respective setters at will, and
7218/// // execute the final call using `doit()`.
7219/// // Values shown here are possibly random and not representative !
7220/// let result = hub.projects().delete_access_approval_settings("name")
7221///              .doit().await;
7222/// # }
7223/// ```
7224pub struct ProjectDeleteAccessApprovalSettingCall<'a, C>
7225where
7226    C: 'a,
7227{
7228    hub: &'a AccessApproval<C>,
7229    _name: String,
7230    _delegate: Option<&'a mut dyn common::Delegate>,
7231    _additional_params: HashMap<String, String>,
7232    _scopes: BTreeSet<String>,
7233}
7234
7235impl<'a, C> common::CallBuilder for ProjectDeleteAccessApprovalSettingCall<'a, C> {}
7236
7237impl<'a, C> ProjectDeleteAccessApprovalSettingCall<'a, C>
7238where
7239    C: common::Connector,
7240{
7241    /// Perform the operation you have build so far.
7242    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7243        use std::borrow::Cow;
7244        use std::io::{Read, Seek};
7245
7246        use common::{url::Params, ToParts};
7247        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7248
7249        let mut dd = common::DefaultDelegate;
7250        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7251        dlg.begin(common::MethodInfo {
7252            id: "accessapproval.projects.deleteAccessApprovalSettings",
7253            http_method: hyper::Method::DELETE,
7254        });
7255
7256        for &field in ["alt", "name"].iter() {
7257            if self._additional_params.contains_key(field) {
7258                dlg.finished(false);
7259                return Err(common::Error::FieldClash(field));
7260            }
7261        }
7262
7263        let mut params = Params::with_capacity(3 + self._additional_params.len());
7264        params.push("name", self._name);
7265
7266        params.extend(self._additional_params.iter());
7267
7268        params.push("alt", "json");
7269        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7270        if self._scopes.is_empty() {
7271            self._scopes
7272                .insert(Scope::CloudPlatform.as_ref().to_string());
7273        }
7274
7275        #[allow(clippy::single_element_loop)]
7276        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7277            url = params.uri_replacement(url, param_name, find_this, true);
7278        }
7279        {
7280            let to_remove = ["name"];
7281            params.remove_params(&to_remove);
7282        }
7283
7284        let url = params.parse_with_url(&url);
7285
7286        loop {
7287            let token = match self
7288                .hub
7289                .auth
7290                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7291                .await
7292            {
7293                Ok(token) => token,
7294                Err(e) => match dlg.token(e) {
7295                    Ok(token) => token,
7296                    Err(e) => {
7297                        dlg.finished(false);
7298                        return Err(common::Error::MissingToken(e));
7299                    }
7300                },
7301            };
7302            let mut req_result = {
7303                let client = &self.hub.client;
7304                dlg.pre_request();
7305                let mut req_builder = hyper::Request::builder()
7306                    .method(hyper::Method::DELETE)
7307                    .uri(url.as_str())
7308                    .header(USER_AGENT, self.hub._user_agent.clone());
7309
7310                if let Some(token) = token.as_ref() {
7311                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7312                }
7313
7314                let request = req_builder
7315                    .header(CONTENT_LENGTH, 0_u64)
7316                    .body(common::to_body::<String>(None));
7317
7318                client.request(request.unwrap()).await
7319            };
7320
7321            match req_result {
7322                Err(err) => {
7323                    if let common::Retry::After(d) = dlg.http_error(&err) {
7324                        sleep(d).await;
7325                        continue;
7326                    }
7327                    dlg.finished(false);
7328                    return Err(common::Error::HttpError(err));
7329                }
7330                Ok(res) => {
7331                    let (mut parts, body) = res.into_parts();
7332                    let mut body = common::Body::new(body);
7333                    if !parts.status.is_success() {
7334                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7335                        let error = serde_json::from_str(&common::to_string(&bytes));
7336                        let response = common::to_response(parts, bytes.into());
7337
7338                        if let common::Retry::After(d) =
7339                            dlg.http_failure(&response, error.as_ref().ok())
7340                        {
7341                            sleep(d).await;
7342                            continue;
7343                        }
7344
7345                        dlg.finished(false);
7346
7347                        return Err(match error {
7348                            Ok(value) => common::Error::BadRequest(value),
7349                            _ => common::Error::Failure(response),
7350                        });
7351                    }
7352                    let response = {
7353                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7354                        let encoded = common::to_string(&bytes);
7355                        match serde_json::from_str(&encoded) {
7356                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7357                            Err(error) => {
7358                                dlg.response_json_decode_error(&encoded, &error);
7359                                return Err(common::Error::JsonDecodeError(
7360                                    encoded.to_string(),
7361                                    error,
7362                                ));
7363                            }
7364                        }
7365                    };
7366
7367                    dlg.finished(true);
7368                    return Ok(response);
7369                }
7370            }
7371        }
7372    }
7373
7374    /// Name of the AccessApprovalSettings to delete.
7375    ///
7376    /// Sets the *name* path property to the given value.
7377    ///
7378    /// Even though the property as already been set when instantiating this call,
7379    /// we provide this method for API completeness.
7380    pub fn name(mut self, new_value: &str) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
7381        self._name = new_value.to_string();
7382        self
7383    }
7384    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7385    /// while executing the actual API request.
7386    ///
7387    /// ````text
7388    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7389    /// ````
7390    ///
7391    /// Sets the *delegate* property to the given value.
7392    pub fn delegate(
7393        mut self,
7394        new_value: &'a mut dyn common::Delegate,
7395    ) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
7396        self._delegate = Some(new_value);
7397        self
7398    }
7399
7400    /// Set any additional parameter of the query string used in the request.
7401    /// It should be used to set parameters which are not yet available through their own
7402    /// setters.
7403    ///
7404    /// Please note that this method must not be used to set any of the known parameters
7405    /// which have their own setter method. If done anyway, the request will fail.
7406    ///
7407    /// # Additional Parameters
7408    ///
7409    /// * *$.xgafv* (query-string) - V1 error format.
7410    /// * *access_token* (query-string) - OAuth access token.
7411    /// * *alt* (query-string) - Data format for response.
7412    /// * *callback* (query-string) - JSONP
7413    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7414    /// * *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.
7415    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7416    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7417    /// * *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.
7418    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7419    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7420    pub fn param<T>(mut self, name: T, value: T) -> ProjectDeleteAccessApprovalSettingCall<'a, C>
7421    where
7422        T: AsRef<str>,
7423    {
7424        self._additional_params
7425            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7426        self
7427    }
7428
7429    /// Identifies the authorization scope for the method you are building.
7430    ///
7431    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7432    /// [`Scope::CloudPlatform`].
7433    ///
7434    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7435    /// tokens for more than one scope.
7436    ///
7437    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7438    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7439    /// sufficient, a read-write scope will do as well.
7440    pub fn add_scope<St>(mut self, scope: St) -> ProjectDeleteAccessApprovalSettingCall<'a, C>
7441    where
7442        St: AsRef<str>,
7443    {
7444        self._scopes.insert(String::from(scope.as_ref()));
7445        self
7446    }
7447    /// Identifies the authorization scope(s) for the method you are building.
7448    ///
7449    /// See [`Self::add_scope()`] for details.
7450    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDeleteAccessApprovalSettingCall<'a, C>
7451    where
7452        I: IntoIterator<Item = St>,
7453        St: AsRef<str>,
7454    {
7455        self._scopes
7456            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7457        self
7458    }
7459
7460    /// Removes all scopes, and no default scope will be used either.
7461    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7462    /// for details).
7463    pub fn clear_scopes(mut self) -> ProjectDeleteAccessApprovalSettingCall<'a, C> {
7464        self._scopes.clear();
7465        self
7466    }
7467}
7468
7469/// Gets the settings associated with a project, folder, or organization.
7470///
7471/// A builder for the *getAccessApprovalSettings* method supported by a *project* resource.
7472/// It is not used directly, but through a [`ProjectMethods`] instance.
7473///
7474/// # Example
7475///
7476/// Instantiate a resource method builder
7477///
7478/// ```test_harness,no_run
7479/// # extern crate hyper;
7480/// # extern crate hyper_rustls;
7481/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
7482/// # async fn dox() {
7483/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7484///
7485/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7486/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7487/// #     .with_native_roots()
7488/// #     .unwrap()
7489/// #     .https_only()
7490/// #     .enable_http2()
7491/// #     .build();
7492///
7493/// # let executor = hyper_util::rt::TokioExecutor::new();
7494/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7495/// #     secret,
7496/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7497/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7498/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7499/// #     ),
7500/// # ).build().await.unwrap();
7501///
7502/// # let client = hyper_util::client::legacy::Client::builder(
7503/// #     hyper_util::rt::TokioExecutor::new()
7504/// # )
7505/// # .build(
7506/// #     hyper_rustls::HttpsConnectorBuilder::new()
7507/// #         .with_native_roots()
7508/// #         .unwrap()
7509/// #         .https_or_http()
7510/// #         .enable_http2()
7511/// #         .build()
7512/// # );
7513/// # let mut hub = AccessApproval::new(client, auth);
7514/// // You can configure optional parameters by calling the respective setters at will, and
7515/// // execute the final call using `doit()`.
7516/// // Values shown here are possibly random and not representative !
7517/// let result = hub.projects().get_access_approval_settings("name")
7518///              .doit().await;
7519/// # }
7520/// ```
7521pub struct ProjectGetAccessApprovalSettingCall<'a, C>
7522where
7523    C: 'a,
7524{
7525    hub: &'a AccessApproval<C>,
7526    _name: String,
7527    _delegate: Option<&'a mut dyn common::Delegate>,
7528    _additional_params: HashMap<String, String>,
7529    _scopes: BTreeSet<String>,
7530}
7531
7532impl<'a, C> common::CallBuilder for ProjectGetAccessApprovalSettingCall<'a, C> {}
7533
7534impl<'a, C> ProjectGetAccessApprovalSettingCall<'a, C>
7535where
7536    C: common::Connector,
7537{
7538    /// Perform the operation you have build so far.
7539    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
7540        use std::borrow::Cow;
7541        use std::io::{Read, Seek};
7542
7543        use common::{url::Params, ToParts};
7544        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7545
7546        let mut dd = common::DefaultDelegate;
7547        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7548        dlg.begin(common::MethodInfo {
7549            id: "accessapproval.projects.getAccessApprovalSettings",
7550            http_method: hyper::Method::GET,
7551        });
7552
7553        for &field in ["alt", "name"].iter() {
7554            if self._additional_params.contains_key(field) {
7555                dlg.finished(false);
7556                return Err(common::Error::FieldClash(field));
7557            }
7558        }
7559
7560        let mut params = Params::with_capacity(3 + self._additional_params.len());
7561        params.push("name", self._name);
7562
7563        params.extend(self._additional_params.iter());
7564
7565        params.push("alt", "json");
7566        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7567        if self._scopes.is_empty() {
7568            self._scopes
7569                .insert(Scope::CloudPlatform.as_ref().to_string());
7570        }
7571
7572        #[allow(clippy::single_element_loop)]
7573        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7574            url = params.uri_replacement(url, param_name, find_this, true);
7575        }
7576        {
7577            let to_remove = ["name"];
7578            params.remove_params(&to_remove);
7579        }
7580
7581        let url = params.parse_with_url(&url);
7582
7583        loop {
7584            let token = match self
7585                .hub
7586                .auth
7587                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7588                .await
7589            {
7590                Ok(token) => token,
7591                Err(e) => match dlg.token(e) {
7592                    Ok(token) => token,
7593                    Err(e) => {
7594                        dlg.finished(false);
7595                        return Err(common::Error::MissingToken(e));
7596                    }
7597                },
7598            };
7599            let mut req_result = {
7600                let client = &self.hub.client;
7601                dlg.pre_request();
7602                let mut req_builder = hyper::Request::builder()
7603                    .method(hyper::Method::GET)
7604                    .uri(url.as_str())
7605                    .header(USER_AGENT, self.hub._user_agent.clone());
7606
7607                if let Some(token) = token.as_ref() {
7608                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7609                }
7610
7611                let request = req_builder
7612                    .header(CONTENT_LENGTH, 0_u64)
7613                    .body(common::to_body::<String>(None));
7614
7615                client.request(request.unwrap()).await
7616            };
7617
7618            match req_result {
7619                Err(err) => {
7620                    if let common::Retry::After(d) = dlg.http_error(&err) {
7621                        sleep(d).await;
7622                        continue;
7623                    }
7624                    dlg.finished(false);
7625                    return Err(common::Error::HttpError(err));
7626                }
7627                Ok(res) => {
7628                    let (mut parts, body) = res.into_parts();
7629                    let mut body = common::Body::new(body);
7630                    if !parts.status.is_success() {
7631                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7632                        let error = serde_json::from_str(&common::to_string(&bytes));
7633                        let response = common::to_response(parts, bytes.into());
7634
7635                        if let common::Retry::After(d) =
7636                            dlg.http_failure(&response, error.as_ref().ok())
7637                        {
7638                            sleep(d).await;
7639                            continue;
7640                        }
7641
7642                        dlg.finished(false);
7643
7644                        return Err(match error {
7645                            Ok(value) => common::Error::BadRequest(value),
7646                            _ => common::Error::Failure(response),
7647                        });
7648                    }
7649                    let response = {
7650                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7651                        let encoded = common::to_string(&bytes);
7652                        match serde_json::from_str(&encoded) {
7653                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7654                            Err(error) => {
7655                                dlg.response_json_decode_error(&encoded, &error);
7656                                return Err(common::Error::JsonDecodeError(
7657                                    encoded.to_string(),
7658                                    error,
7659                                ));
7660                            }
7661                        }
7662                    };
7663
7664                    dlg.finished(true);
7665                    return Ok(response);
7666                }
7667            }
7668        }
7669    }
7670
7671    /// Name of the AccessApprovalSettings to retrieve.
7672    ///
7673    /// Sets the *name* path property to the given value.
7674    ///
7675    /// Even though the property as already been set when instantiating this call,
7676    /// we provide this method for API completeness.
7677    pub fn name(mut self, new_value: &str) -> ProjectGetAccessApprovalSettingCall<'a, C> {
7678        self._name = new_value.to_string();
7679        self
7680    }
7681    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7682    /// while executing the actual API request.
7683    ///
7684    /// ````text
7685    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7686    /// ````
7687    ///
7688    /// Sets the *delegate* property to the given value.
7689    pub fn delegate(
7690        mut self,
7691        new_value: &'a mut dyn common::Delegate,
7692    ) -> ProjectGetAccessApprovalSettingCall<'a, C> {
7693        self._delegate = Some(new_value);
7694        self
7695    }
7696
7697    /// Set any additional parameter of the query string used in the request.
7698    /// It should be used to set parameters which are not yet available through their own
7699    /// setters.
7700    ///
7701    /// Please note that this method must not be used to set any of the known parameters
7702    /// which have their own setter method. If done anyway, the request will fail.
7703    ///
7704    /// # Additional Parameters
7705    ///
7706    /// * *$.xgafv* (query-string) - V1 error format.
7707    /// * *access_token* (query-string) - OAuth access token.
7708    /// * *alt* (query-string) - Data format for response.
7709    /// * *callback* (query-string) - JSONP
7710    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7711    /// * *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.
7712    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7713    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7714    /// * *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.
7715    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7716    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7717    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetAccessApprovalSettingCall<'a, C>
7718    where
7719        T: AsRef<str>,
7720    {
7721        self._additional_params
7722            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7723        self
7724    }
7725
7726    /// Identifies the authorization scope for the method you are building.
7727    ///
7728    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7729    /// [`Scope::CloudPlatform`].
7730    ///
7731    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7732    /// tokens for more than one scope.
7733    ///
7734    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7735    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7736    /// sufficient, a read-write scope will do as well.
7737    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetAccessApprovalSettingCall<'a, C>
7738    where
7739        St: AsRef<str>,
7740    {
7741        self._scopes.insert(String::from(scope.as_ref()));
7742        self
7743    }
7744    /// Identifies the authorization scope(s) for the method you are building.
7745    ///
7746    /// See [`Self::add_scope()`] for details.
7747    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetAccessApprovalSettingCall<'a, C>
7748    where
7749        I: IntoIterator<Item = St>,
7750        St: AsRef<str>,
7751    {
7752        self._scopes
7753            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7754        self
7755    }
7756
7757    /// Removes all scopes, and no default scope will be used either.
7758    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7759    /// for details).
7760    pub fn clear_scopes(mut self) -> ProjectGetAccessApprovalSettingCall<'a, C> {
7761        self._scopes.clear();
7762        self
7763    }
7764}
7765
7766/// Updates the settings associated with a project, folder, or organization.
7767/// Settings to update are determined by the value of field_mask.
7768///
7769/// A builder for the *updateAccessApprovalSettings* method supported by a *project* resource.
7770/// It is not used directly, but through a [`ProjectMethods`] instance.
7771///
7772/// # Example
7773///
7774/// Instantiate a resource method builder
7775///
7776/// ```test_harness,no_run
7777/// # extern crate hyper;
7778/// # extern crate hyper_rustls;
7779/// # extern crate google_accessapproval1_beta1 as accessapproval1_beta1;
7780/// use accessapproval1_beta1::api::AccessApprovalSettings;
7781/// # async fn dox() {
7782/// # use accessapproval1_beta1::{AccessApproval, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7783///
7784/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7785/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7786/// #     .with_native_roots()
7787/// #     .unwrap()
7788/// #     .https_only()
7789/// #     .enable_http2()
7790/// #     .build();
7791///
7792/// # let executor = hyper_util::rt::TokioExecutor::new();
7793/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7794/// #     secret,
7795/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7796/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7797/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7798/// #     ),
7799/// # ).build().await.unwrap();
7800///
7801/// # let client = hyper_util::client::legacy::Client::builder(
7802/// #     hyper_util::rt::TokioExecutor::new()
7803/// # )
7804/// # .build(
7805/// #     hyper_rustls::HttpsConnectorBuilder::new()
7806/// #         .with_native_roots()
7807/// #         .unwrap()
7808/// #         .https_or_http()
7809/// #         .enable_http2()
7810/// #         .build()
7811/// # );
7812/// # let mut hub = AccessApproval::new(client, auth);
7813/// // As the method needs a request, you would usually fill it with the desired information
7814/// // into the respective structure. Some of the parts shown here might not be applicable !
7815/// // Values shown here are possibly random and not representative !
7816/// let mut req = AccessApprovalSettings::default();
7817///
7818/// // You can configure optional parameters by calling the respective setters at will, and
7819/// // execute the final call using `doit()`.
7820/// // Values shown here are possibly random and not representative !
7821/// let result = hub.projects().update_access_approval_settings(req, "name")
7822///              .update_mask(FieldMask::new::<&str>(&[]))
7823///              .doit().await;
7824/// # }
7825/// ```
7826pub struct ProjectUpdateAccessApprovalSettingCall<'a, C>
7827where
7828    C: 'a,
7829{
7830    hub: &'a AccessApproval<C>,
7831    _request: AccessApprovalSettings,
7832    _name: String,
7833    _update_mask: Option<common::FieldMask>,
7834    _delegate: Option<&'a mut dyn common::Delegate>,
7835    _additional_params: HashMap<String, String>,
7836    _scopes: BTreeSet<String>,
7837}
7838
7839impl<'a, C> common::CallBuilder for ProjectUpdateAccessApprovalSettingCall<'a, C> {}
7840
7841impl<'a, C> ProjectUpdateAccessApprovalSettingCall<'a, C>
7842where
7843    C: common::Connector,
7844{
7845    /// Perform the operation you have build so far.
7846    pub async fn doit(mut self) -> common::Result<(common::Response, AccessApprovalSettings)> {
7847        use std::borrow::Cow;
7848        use std::io::{Read, Seek};
7849
7850        use common::{url::Params, ToParts};
7851        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7852
7853        let mut dd = common::DefaultDelegate;
7854        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7855        dlg.begin(common::MethodInfo {
7856            id: "accessapproval.projects.updateAccessApprovalSettings",
7857            http_method: hyper::Method::PATCH,
7858        });
7859
7860        for &field in ["alt", "name", "updateMask"].iter() {
7861            if self._additional_params.contains_key(field) {
7862                dlg.finished(false);
7863                return Err(common::Error::FieldClash(field));
7864            }
7865        }
7866
7867        let mut params = Params::with_capacity(5 + self._additional_params.len());
7868        params.push("name", self._name);
7869        if let Some(value) = self._update_mask.as_ref() {
7870            params.push("updateMask", value.to_string());
7871        }
7872
7873        params.extend(self._additional_params.iter());
7874
7875        params.push("alt", "json");
7876        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
7877        if self._scopes.is_empty() {
7878            self._scopes
7879                .insert(Scope::CloudPlatform.as_ref().to_string());
7880        }
7881
7882        #[allow(clippy::single_element_loop)]
7883        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7884            url = params.uri_replacement(url, param_name, find_this, true);
7885        }
7886        {
7887            let to_remove = ["name"];
7888            params.remove_params(&to_remove);
7889        }
7890
7891        let url = params.parse_with_url(&url);
7892
7893        let mut json_mime_type = mime::APPLICATION_JSON;
7894        let mut request_value_reader = {
7895            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7896            common::remove_json_null_values(&mut value);
7897            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7898            serde_json::to_writer(&mut dst, &value).unwrap();
7899            dst
7900        };
7901        let request_size = request_value_reader
7902            .seek(std::io::SeekFrom::End(0))
7903            .unwrap();
7904        request_value_reader
7905            .seek(std::io::SeekFrom::Start(0))
7906            .unwrap();
7907
7908        loop {
7909            let token = match self
7910                .hub
7911                .auth
7912                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7913                .await
7914            {
7915                Ok(token) => token,
7916                Err(e) => match dlg.token(e) {
7917                    Ok(token) => token,
7918                    Err(e) => {
7919                        dlg.finished(false);
7920                        return Err(common::Error::MissingToken(e));
7921                    }
7922                },
7923            };
7924            request_value_reader
7925                .seek(std::io::SeekFrom::Start(0))
7926                .unwrap();
7927            let mut req_result = {
7928                let client = &self.hub.client;
7929                dlg.pre_request();
7930                let mut req_builder = hyper::Request::builder()
7931                    .method(hyper::Method::PATCH)
7932                    .uri(url.as_str())
7933                    .header(USER_AGENT, self.hub._user_agent.clone());
7934
7935                if let Some(token) = token.as_ref() {
7936                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7937                }
7938
7939                let request = req_builder
7940                    .header(CONTENT_TYPE, json_mime_type.to_string())
7941                    .header(CONTENT_LENGTH, request_size as u64)
7942                    .body(common::to_body(
7943                        request_value_reader.get_ref().clone().into(),
7944                    ));
7945
7946                client.request(request.unwrap()).await
7947            };
7948
7949            match req_result {
7950                Err(err) => {
7951                    if let common::Retry::After(d) = dlg.http_error(&err) {
7952                        sleep(d).await;
7953                        continue;
7954                    }
7955                    dlg.finished(false);
7956                    return Err(common::Error::HttpError(err));
7957                }
7958                Ok(res) => {
7959                    let (mut parts, body) = res.into_parts();
7960                    let mut body = common::Body::new(body);
7961                    if !parts.status.is_success() {
7962                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7963                        let error = serde_json::from_str(&common::to_string(&bytes));
7964                        let response = common::to_response(parts, bytes.into());
7965
7966                        if let common::Retry::After(d) =
7967                            dlg.http_failure(&response, error.as_ref().ok())
7968                        {
7969                            sleep(d).await;
7970                            continue;
7971                        }
7972
7973                        dlg.finished(false);
7974
7975                        return Err(match error {
7976                            Ok(value) => common::Error::BadRequest(value),
7977                            _ => common::Error::Failure(response),
7978                        });
7979                    }
7980                    let response = {
7981                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7982                        let encoded = common::to_string(&bytes);
7983                        match serde_json::from_str(&encoded) {
7984                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7985                            Err(error) => {
7986                                dlg.response_json_decode_error(&encoded, &error);
7987                                return Err(common::Error::JsonDecodeError(
7988                                    encoded.to_string(),
7989                                    error,
7990                                ));
7991                            }
7992                        }
7993                    };
7994
7995                    dlg.finished(true);
7996                    return Ok(response);
7997                }
7998            }
7999        }
8000    }
8001
8002    ///
8003    /// Sets the *request* property to the given value.
8004    ///
8005    /// Even though the property as already been set when instantiating this call,
8006    /// we provide this method for API completeness.
8007    pub fn request(
8008        mut self,
8009        new_value: AccessApprovalSettings,
8010    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
8011        self._request = new_value;
8012        self
8013    }
8014    /// The resource name of the settings. Format is one of:
8015    /// <ol>
8016    ///   <li>"projects/{project_id}/accessApprovalSettings"</li>
8017    ///   <li>"folders/{folder_id}/accessApprovalSettings"</li>
8018    ///   <li>"organizations/{organization_id}/accessApprovalSettings"</li>
8019    /// <ol>
8020    ///
8021    /// Sets the *name* path property to the given value.
8022    ///
8023    /// Even though the property as already been set when instantiating this call,
8024    /// we provide this method for API completeness.
8025    pub fn name(mut self, new_value: &str) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
8026        self._name = new_value.to_string();
8027        self
8028    }
8029    /// For the `FieldMask` definition, see
8030    /// https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
8031    /// If this field is left unset, only the notification_emails field will be
8032    /// updated.
8033    ///
8034    /// Sets the *update mask* query property to the given value.
8035    pub fn update_mask(
8036        mut self,
8037        new_value: common::FieldMask,
8038    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
8039        self._update_mask = Some(new_value);
8040        self
8041    }
8042    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8043    /// while executing the actual API request.
8044    ///
8045    /// ````text
8046    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8047    /// ````
8048    ///
8049    /// Sets the *delegate* property to the given value.
8050    pub fn delegate(
8051        mut self,
8052        new_value: &'a mut dyn common::Delegate,
8053    ) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
8054        self._delegate = Some(new_value);
8055        self
8056    }
8057
8058    /// Set any additional parameter of the query string used in the request.
8059    /// It should be used to set parameters which are not yet available through their own
8060    /// setters.
8061    ///
8062    /// Please note that this method must not be used to set any of the known parameters
8063    /// which have their own setter method. If done anyway, the request will fail.
8064    ///
8065    /// # Additional Parameters
8066    ///
8067    /// * *$.xgafv* (query-string) - V1 error format.
8068    /// * *access_token* (query-string) - OAuth access token.
8069    /// * *alt* (query-string) - Data format for response.
8070    /// * *callback* (query-string) - JSONP
8071    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8072    /// * *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.
8073    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8074    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8075    /// * *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.
8076    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8077    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8078    pub fn param<T>(mut self, name: T, value: T) -> ProjectUpdateAccessApprovalSettingCall<'a, C>
8079    where
8080        T: AsRef<str>,
8081    {
8082        self._additional_params
8083            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8084        self
8085    }
8086
8087    /// Identifies the authorization scope for the method you are building.
8088    ///
8089    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8090    /// [`Scope::CloudPlatform`].
8091    ///
8092    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8093    /// tokens for more than one scope.
8094    ///
8095    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8096    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8097    /// sufficient, a read-write scope will do as well.
8098    pub fn add_scope<St>(mut self, scope: St) -> ProjectUpdateAccessApprovalSettingCall<'a, C>
8099    where
8100        St: AsRef<str>,
8101    {
8102        self._scopes.insert(String::from(scope.as_ref()));
8103        self
8104    }
8105    /// Identifies the authorization scope(s) for the method you are building.
8106    ///
8107    /// See [`Self::add_scope()`] for details.
8108    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUpdateAccessApprovalSettingCall<'a, C>
8109    where
8110        I: IntoIterator<Item = St>,
8111        St: AsRef<str>,
8112    {
8113        self._scopes
8114            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8115        self
8116    }
8117
8118    /// Removes all scopes, and no default scope will be used either.
8119    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8120    /// for details).
8121    pub fn clear_scopes(mut self) -> ProjectUpdateAccessApprovalSettingCall<'a, C> {
8122        self._scopes.clear();
8123        self
8124    }
8125}