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