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