google_cloudresourcemanager1/
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    /// View your data across Google Cloud services and see the email address of your Google Account
20    CloudPlatformReadOnly,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27            Scope::CloudPlatformReadOnly => {
28                "https://www.googleapis.com/auth/cloud-platform.read-only"
29            }
30        }
31    }
32}
33
34#[allow(clippy::derivable_impls)]
35impl Default for Scope {
36    fn default() -> Scope {
37        Scope::CloudPlatform
38    }
39}
40
41// ########
42// HUB ###
43// ######
44
45/// Central instance to access all CloudResourceManager related resource activities
46///
47/// # Examples
48///
49/// Instantiate a new hub
50///
51/// ```test_harness,no_run
52/// extern crate hyper;
53/// extern crate hyper_rustls;
54/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
55/// use cloudresourcemanager1::{Result, Error};
56/// # async fn dox() {
57/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
58///
59/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
60/// // `client_secret`, among other things.
61/// let secret: yup_oauth2::ApplicationSecret = Default::default();
62/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
63/// // unless you replace  `None` with the desired Flow.
64/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
65/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
66/// // retrieve them from storage.
67/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
68///     secret,
69///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
70/// ).build().await.unwrap();
71///
72/// let client = hyper_util::client::legacy::Client::builder(
73///     hyper_util::rt::TokioExecutor::new()
74/// )
75/// .build(
76///     hyper_rustls::HttpsConnectorBuilder::new()
77///         .with_native_roots()
78///         .unwrap()
79///         .https_or_http()
80///         .enable_http1()
81///         .build()
82/// );
83/// let mut hub = CloudResourceManager::new(client, auth);
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.projects().list()
88///              .page_token("sanctus")
89///              .page_size(-80)
90///              .filter("amet.")
91///              .doit().await;
92///
93/// match result {
94///     Err(e) => match e {
95///         // The Error enum provides details about what exactly happened.
96///         // You can also just use its `Debug`, `Display` or `Error` traits
97///          Error::HttpError(_)
98///         |Error::Io(_)
99///         |Error::MissingAPIKey
100///         |Error::MissingToken(_)
101///         |Error::Cancelled
102///         |Error::UploadSizeLimitExceeded(_, _)
103///         |Error::Failure(_)
104///         |Error::BadRequest(_)
105///         |Error::FieldClash(_)
106///         |Error::JsonDecodeError(_, _) => println!("{}", e),
107///     },
108///     Ok(res) => println!("Success: {:?}", res),
109/// }
110/// # }
111/// ```
112#[derive(Clone)]
113pub struct CloudResourceManager<C> {
114    pub client: common::Client<C>,
115    pub auth: Box<dyn common::GetToken>,
116    _user_agent: String,
117    _base_url: String,
118    _root_url: String,
119}
120
121impl<C> common::Hub for CloudResourceManager<C> {}
122
123impl<'a, C> CloudResourceManager<C> {
124    pub fn new<A: 'static + common::GetToken>(
125        client: common::Client<C>,
126        auth: A,
127    ) -> CloudResourceManager<C> {
128        CloudResourceManager {
129            client,
130            auth: Box::new(auth),
131            _user_agent: "google-api-rust-client/6.0.0".to_string(),
132            _base_url: "https://cloudresourcemanager.googleapis.com/".to_string(),
133            _root_url: "https://cloudresourcemanager.googleapis.com/".to_string(),
134        }
135    }
136
137    pub fn folders(&'a self) -> FolderMethods<'a, C> {
138        FolderMethods { hub: self }
139    }
140    pub fn liens(&'a self) -> LienMethods<'a, C> {
141        LienMethods { hub: self }
142    }
143    pub fn operations(&'a self) -> OperationMethods<'a, C> {
144        OperationMethods { hub: self }
145    }
146    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
147        OrganizationMethods { hub: self }
148    }
149    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
150        ProjectMethods { hub: self }
151    }
152
153    /// Set the user-agent header field to use in all requests to the server.
154    /// It defaults to `google-api-rust-client/6.0.0`.
155    ///
156    /// Returns the previously set user-agent.
157    pub fn user_agent(&mut self, agent_name: String) -> String {
158        std::mem::replace(&mut self._user_agent, agent_name)
159    }
160
161    /// Set the base url to use in all requests to the server.
162    /// It defaults to `https://cloudresourcemanager.googleapis.com/`.
163    ///
164    /// Returns the previously set base url.
165    pub fn base_url(&mut self, new_base_url: String) -> String {
166        std::mem::replace(&mut self._base_url, new_base_url)
167    }
168
169    /// Set the root url to use in all requests to the server.
170    /// It defaults to `https://cloudresourcemanager.googleapis.com/`.
171    ///
172    /// Returns the previously set root url.
173    pub fn root_url(&mut self, new_root_url: String) -> String {
174        std::mem::replace(&mut self._root_url, new_root_url)
175    }
176}
177
178// ############
179// SCHEMAS ###
180// ##########
181/// Identifying information for a single ancestor of a project.
182///
183/// This type is not used in any activity, and only used as *part* of another schema.
184///
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct Ancestor {
189    /// Resource id of the ancestor.
190    #[serde(rename = "resourceId")]
191    pub resource_id: Option<ResourceId>,
192}
193
194impl common::Part for Ancestor {}
195
196/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
197///
198/// This type is not used in any activity, and only used as *part* of another schema.
199///
200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
201#[serde_with::serde_as]
202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
203pub struct AuditConfig {
204    /// The configuration for logging of each type of permission.
205    #[serde(rename = "auditLogConfigs")]
206    pub audit_log_configs: Option<Vec<AuditLogConfig>>,
207    /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
208    pub service: Option<String>,
209}
210
211impl common::Part for AuditConfig {}
212
213/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
214///
215/// This type is not used in any activity, and only used as *part* of another schema.
216///
217#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
218#[serde_with::serde_as]
219#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
220pub struct AuditLogConfig {
221    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
222    #[serde(rename = "exemptedMembers")]
223    pub exempted_members: Option<Vec<String>>,
224    /// The log type that this config enables.
225    #[serde(rename = "logType")]
226    pub log_type: Option<String>,
227}
228
229impl common::Part for AuditLogConfig {}
230
231/// Associates `members`, or principals, with a `role`.
232///
233/// This type is not used in any activity, and only used as *part* of another schema.
234///
235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
236#[serde_with::serde_as]
237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
238pub struct Binding {
239    /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
240    pub condition: Option<Expr>,
241    /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
242    pub members: Option<Vec<String>>,
243    /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
244    pub role: Option<String>,
245}
246
247impl common::Part for Binding {}
248
249/// A `Constraint` that is either enforced or not. For example a constraint `constraints/compute.disableSerialPortAccess`. If it is enforced on a VM instance, serial port connections will not be opened to that instance.
250///
251/// This type is not used in any activity, and only used as *part* of another schema.
252///
253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
254#[serde_with::serde_as]
255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
256pub struct BooleanConstraint {
257    _never_set: Option<bool>,
258}
259
260impl common::Part for BooleanConstraint {}
261
262/// Used in `policy_type` to specify how `boolean_policy` will behave at this resource.
263///
264/// This type is not used in any activity, and only used as *part* of another schema.
265///
266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
267#[serde_with::serde_as]
268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
269pub struct BooleanPolicy {
270    /// If `true`, then the `Policy` is enforced. If `false`, then any configuration is acceptable. Suppose you have a `Constraint` `constraints/compute.disableSerialPortAccess` with `constraint_default` set to `ALLOW`. A `Policy` for that `Constraint` exhibits the following behavior: - If the `Policy` at this resource has enforced set to `false`, serial port connection attempts will be allowed. - If the `Policy` at this resource has enforced set to `true`, serial port connection attempts will be refused. - If the `Policy` at this resource is `RestoreDefault`, serial port connection attempts will be allowed. - If no `Policy` is set at this resource or anywhere higher in the resource hierarchy, serial port connection attempts will be allowed. - If no `Policy` is set at this resource, but one exists higher in the resource hierarchy, the behavior is as if the`Policy` were set at this resource. The following examples demonstrate the different possible layerings: Example 1 (nearest `Constraint` wins): `organizations/foo` has a `Policy` with: {enforced: false} `projects/bar` has no `Policy` set. The constraint at `projects/bar` and `organizations/foo` will not be enforced. Example 2 (enforcement gets replaced): `organizations/foo` has a `Policy` with: {enforced: false} `projects/bar` has a `Policy` with: {enforced: true} The constraint at `organizations/foo` is not enforced. The constraint at `projects/bar` is enforced. Example 3 (RestoreDefault): `organizations/foo` has a `Policy` with: {enforced: true} `projects/bar` has a `Policy` with: {RestoreDefault: {}} The constraint at `organizations/foo` is enforced. The constraint at `projects/bar` is not enforced, because `constraint_default` for the `Constraint` is `ALLOW`.
271    pub enforced: Option<bool>,
272}
273
274impl common::Part for BooleanPolicy {}
275
276/// The request sent to the ClearOrgPolicy method.
277///
278/// # Activities
279///
280/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
281/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
282///
283/// * [clear org policy folders](FolderClearOrgPolicyCall) (request)
284/// * [clear org policy organizations](OrganizationClearOrgPolicyCall) (request)
285/// * [clear org policy projects](ProjectClearOrgPolicyCall) (request)
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct ClearOrgPolicyRequest {
290    /// Name of the `Constraint` of the `Policy` to clear.
291    pub constraint: Option<String>,
292    /// The current version, for concurrency control. Not sending an `etag` will cause the `Policy` to be cleared blindly.
293    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
294    pub etag: Option<Vec<u8>>,
295}
296
297impl common::RequestValue for ClearOrgPolicyRequest {}
298
299/// A `Constraint` describes a way in which a resource’s configuration can be restricted. For example, it controls which cloud services can be activated across an organization, or whether a Compute Engine instance can have serial port connections established. `Constraints` can be configured by the organization’s policy administrator to fit the needs of the organzation by setting Policies for `Constraints` at different locations in the organization’s resource hierarchy. Policies are inherited down the resource hierarchy from higher levels, but can also be overridden. For details about the inheritance rules please read about [Policies](https://cloud.google.com/resource-manager/reference/rest/v1/Policy). `Constraints` have a default behavior determined by the `constraint_default` field, which is the enforcement behavior that is used in the absence of a `Policy` being defined or inherited for the resource in question.
300///
301/// This type is not used in any activity, and only used as *part* of another schema.
302#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
303#[serde_with::serde_as]
304#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
305pub struct Constraint {
306    /// Defines this constraint as being a BooleanConstraint.
307    #[serde(rename = "booleanConstraint")]
308    pub boolean_constraint: Option<BooleanConstraint>,
309    /// The evaluation behavior of this constraint in the absence of 'Policy'.
310    #[serde(rename = "constraintDefault")]
311    pub constraint_default: Option<String>,
312    /// Detailed description of what this `Constraint` controls as well as how and where it is enforced. Mutable.
313    pub description: Option<String>,
314    /// The human readable name. Mutable.
315    #[serde(rename = "displayName")]
316    pub display_name: Option<String>,
317    /// Defines this constraint as being a ListConstraint.
318    #[serde(rename = "listConstraint")]
319    pub list_constraint: Option<ListConstraint>,
320    /// Immutable value, required to globally be unique. For example, `constraints/serviceuser.services`
321    pub name: Option<String>,
322    /// Version of the `Constraint`. Default version is 0;
323    pub version: Option<i32>,
324}
325
326impl common::Part for Constraint {}
327
328/// 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); }
329///
330/// # Activities
331///
332/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
333/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
334///
335/// * [clear org policy folders](FolderClearOrgPolicyCall) (response)
336/// * [delete liens](LienDeleteCall) (response)
337/// * [clear org policy organizations](OrganizationClearOrgPolicyCall) (response)
338/// * [clear org policy projects](ProjectClearOrgPolicyCall) (response)
339/// * [delete projects](ProjectDeleteCall) (response)
340/// * [undelete projects](ProjectUndeleteCall) (response)
341#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
342#[serde_with::serde_as]
343#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
344pub struct Empty {
345    _never_set: Option<bool>,
346}
347
348impl common::ResponseResult for Empty {}
349
350/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
351///
352/// This type is not used in any activity, and only used as *part* of another schema.
353///
354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
355#[serde_with::serde_as]
356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
357pub struct Expr {
358    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
359    pub description: Option<String>,
360    /// Textual representation of an expression in Common Expression Language syntax.
361    pub expression: Option<String>,
362    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
363    pub location: Option<String>,
364    /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
365    pub title: Option<String>,
366}
367
368impl common::Part for Expr {}
369
370/// The request sent to the GetAncestry method.
371///
372/// # Activities
373///
374/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
375/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
376///
377/// * [get ancestry projects](ProjectGetAncestryCall) (request)
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct GetAncestryRequest {
382    _never_set: Option<bool>,
383}
384
385impl common::RequestValue for GetAncestryRequest {}
386
387/// Response from the projects.getAncestry method.
388///
389/// # Activities
390///
391/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
392/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
393///
394/// * [get ancestry projects](ProjectGetAncestryCall) (response)
395#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
396#[serde_with::serde_as]
397#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
398pub struct GetAncestryResponse {
399    /// Ancestors are ordered from bottom to top of the resource hierarchy. The first ancestor is the project itself, followed by the project's parent, etc..
400    pub ancestor: Option<Vec<Ancestor>>,
401}
402
403impl common::ResponseResult for GetAncestryResponse {}
404
405/// The request sent to the GetEffectiveOrgPolicy method.
406///
407/// # Activities
408///
409/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
410/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
411///
412/// * [get effective org policy folders](FolderGetEffectiveOrgPolicyCall) (request)
413/// * [get effective org policy organizations](OrganizationGetEffectiveOrgPolicyCall) (request)
414/// * [get effective org policy projects](ProjectGetEffectiveOrgPolicyCall) (request)
415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
416#[serde_with::serde_as]
417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
418pub struct GetEffectiveOrgPolicyRequest {
419    /// The name of the `Constraint` to compute the effective `Policy`.
420    pub constraint: Option<String>,
421}
422
423impl common::RequestValue for GetEffectiveOrgPolicyRequest {}
424
425/// Request message for `GetIamPolicy` method.
426///
427/// # Activities
428///
429/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
430/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
431///
432/// * [get iam policy organizations](OrganizationGetIamPolicyCall) (request)
433/// * [get iam policy projects](ProjectGetIamPolicyCall) (request)
434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
435#[serde_with::serde_as]
436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
437pub struct GetIamPolicyRequest {
438    /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
439    pub options: Option<GetPolicyOptions>,
440}
441
442impl common::RequestValue for GetIamPolicyRequest {}
443
444/// The request sent to the GetOrgPolicy method.
445///
446/// # Activities
447///
448/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
449/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
450///
451/// * [get org policy folders](FolderGetOrgPolicyCall) (request)
452/// * [get org policy organizations](OrganizationGetOrgPolicyCall) (request)
453/// * [get org policy projects](ProjectGetOrgPolicyCall) (request)
454#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
455#[serde_with::serde_as]
456#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
457pub struct GetOrgPolicyRequest {
458    /// Name of the `Constraint` to get the `Policy`.
459    pub constraint: Option<String>,
460}
461
462impl common::RequestValue for GetOrgPolicyRequest {}
463
464/// Encapsulates settings provided to GetIamPolicy.
465///
466/// This type is not used in any activity, and only used as *part* of another schema.
467///
468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
469#[serde_with::serde_as]
470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
471pub struct GetPolicyOptions {
472    /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
473    #[serde(rename = "requestedPolicyVersion")]
474    pub requested_policy_version: Option<i32>,
475}
476
477impl common::Part for GetPolicyOptions {}
478
479/// A Lien represents an encumbrance on the actions that can be performed on a resource.
480///
481/// # Activities
482///
483/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
484/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
485///
486/// * [create liens](LienCreateCall) (request|response)
487/// * [delete liens](LienDeleteCall) (none)
488/// * [get liens](LienGetCall) (response)
489/// * [list liens](LienListCall) (none)
490#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
491#[serde_with::serde_as]
492#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
493pub struct Lien {
494    /// The creation time of this Lien.
495    #[serde(rename = "createTime")]
496    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
497    /// A system-generated unique identifier for this Lien. Example: `liens/1234abcd`
498    pub name: Option<String>,
499    /// A stable, user-visible/meaningful string identifying the origin of the Lien, intended to be inspected programmatically. Maximum length of 200 characters. Example: 'compute.googleapis.com'
500    pub origin: Option<String>,
501    /// A reference to the resource this Lien is attached to. The server will validate the parent against those for which Liens are supported. Example: `projects/1234`
502    pub parent: Option<String>,
503    /// Concise user-visible strings indicating why an action cannot be performed on a resource. Maximum length of 200 characters. Example: 'Holds production API key'
504    pub reason: Option<String>,
505    /// The types of operations which should be blocked as a result of this Lien. Each value should correspond to an IAM permission. The server will validate the permissions against those for which Liens are supported. An empty list is meaningless and will be rejected. Example: ['resourcemanager.projects.delete']
506    pub restrictions: Option<Vec<String>>,
507}
508
509impl common::RequestValue for Lien {}
510impl common::Resource for Lien {}
511impl common::ResponseResult for Lien {}
512
513/// The request sent to the `ListAvailableOrgPolicyConstraints` method on the project, folder, or organization.
514///
515/// # Activities
516///
517/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
518/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
519///
520/// * [list available org policy constraints folders](FolderListAvailableOrgPolicyConstraintCall) (request)
521/// * [list available org policy constraints organizations](OrganizationListAvailableOrgPolicyConstraintCall) (request)
522/// * [list available org policy constraints projects](ProjectListAvailableOrgPolicyConstraintCall) (request)
523#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
524#[serde_with::serde_as]
525#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
526pub struct ListAvailableOrgPolicyConstraintsRequest {
527    /// Size of the pages to be returned. This is currently unsupported and will be ignored. The server may at any point start using this field to limit page size.
528    #[serde(rename = "pageSize")]
529    pub page_size: Option<i32>,
530    /// Page token used to retrieve the next page. This is currently unsupported and will be ignored. The server may at any point start using this field.
531    #[serde(rename = "pageToken")]
532    pub page_token: Option<String>,
533}
534
535impl common::RequestValue for ListAvailableOrgPolicyConstraintsRequest {}
536
537/// The response returned from the `ListAvailableOrgPolicyConstraints` method. Returns all `Constraints` that could be set at this level of the hierarchy (contrast with the response from `ListPolicies`, which returns all policies which are set).
538///
539/// # Activities
540///
541/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
542/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
543///
544/// * [list available org policy constraints folders](FolderListAvailableOrgPolicyConstraintCall) (response)
545/// * [list available org policy constraints organizations](OrganizationListAvailableOrgPolicyConstraintCall) (response)
546/// * [list available org policy constraints projects](ProjectListAvailableOrgPolicyConstraintCall) (response)
547#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
548#[serde_with::serde_as]
549#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
550pub struct ListAvailableOrgPolicyConstraintsResponse {
551    /// The collection of constraints that are settable on the request resource.
552    pub constraints: Option<Vec<Constraint>>,
553    /// Page token used to retrieve the next page. This is currently not used.
554    #[serde(rename = "nextPageToken")]
555    pub next_page_token: Option<String>,
556}
557
558impl common::ResponseResult for ListAvailableOrgPolicyConstraintsResponse {}
559
560/// A `Constraint` that allows or disallows a list of string values, which are configured by an Organization's policy administrator with a `Policy`.
561///
562/// This type is not used in any activity, and only used as *part* of another schema.
563///
564#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
565#[serde_with::serde_as]
566#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
567pub struct ListConstraint {
568    /// Optional. The Google Cloud Console will try to default to a configuration that matches the value specified in this `Constraint`.
569    #[serde(rename = "suggestedValue")]
570    pub suggested_value: Option<String>,
571    /// Indicates whether subtrees of Cloud Resource Manager resource hierarchy can be used in `Policy.allowed_values` and `Policy.denied_values`. For example, `"under:folders/123"` would match any resource under the 'folders/123' folder.
572    #[serde(rename = "supportsUnder")]
573    pub supports_under: Option<bool>,
574}
575
576impl common::Part for ListConstraint {}
577
578/// The response message for Liens.ListLiens.
579///
580/// # Activities
581///
582/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
583/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
584///
585/// * [list liens](LienListCall) (response)
586#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
587#[serde_with::serde_as]
588#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
589pub struct ListLiensResponse {
590    /// A list of Liens.
591    pub liens: Option<Vec<Lien>>,
592    /// Token to retrieve the next page of results, or empty if there are no more results in the list.
593    #[serde(rename = "nextPageToken")]
594    pub next_page_token: Option<String>,
595}
596
597impl common::ResponseResult for ListLiensResponse {}
598
599/// The request sent to the ListOrgPolicies method.
600///
601/// # Activities
602///
603/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
604/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
605///
606/// * [list org policies folders](FolderListOrgPolicyCall) (request)
607/// * [list org policies organizations](OrganizationListOrgPolicyCall) (request)
608/// * [list org policies projects](ProjectListOrgPolicyCall) (request)
609#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
610#[serde_with::serde_as]
611#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
612pub struct ListOrgPoliciesRequest {
613    /// Size of the pages to be returned. This is currently unsupported and will be ignored. The server may at any point start using this field to limit page size.
614    #[serde(rename = "pageSize")]
615    pub page_size: Option<i32>,
616    /// Page token used to retrieve the next page. This is currently unsupported and will be ignored. The server may at any point start using this field.
617    #[serde(rename = "pageToken")]
618    pub page_token: Option<String>,
619}
620
621impl common::RequestValue for ListOrgPoliciesRequest {}
622
623/// The response returned from the `ListOrgPolicies` method. It will be empty if no `Policies` are set on the resource.
624///
625/// # Activities
626///
627/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
628/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
629///
630/// * [list org policies folders](FolderListOrgPolicyCall) (response)
631/// * [list org policies organizations](OrganizationListOrgPolicyCall) (response)
632/// * [list org policies projects](ProjectListOrgPolicyCall) (response)
633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
634#[serde_with::serde_as]
635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
636pub struct ListOrgPoliciesResponse {
637    /// Page token used to retrieve the next page. This is currently not used, but the server may at any point start supplying a valid token.
638    #[serde(rename = "nextPageToken")]
639    pub next_page_token: Option<String>,
640    /// The `Policies` that are set on the resource. It will be empty if no `Policies` are set.
641    pub policies: Option<Vec<OrgPolicy>>,
642}
643
644impl common::ResponseResult for ListOrgPoliciesResponse {}
645
646/// Used in `policy_type` to specify how `list_policy` behaves at this resource. `ListPolicy` can define specific values and subtrees of Cloud Resource Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that are allowed or denied by setting the `allowed_values` and `denied_values` fields. This is achieved by using the `under:` and optional `is:` prefixes. The `under:` prefix is used to denote resource subtree values. The `is:` prefix is used to denote specific values, and is required only if the value contains a ":". Values prefixed with "is:" are treated the same as values with no prefix. Ancestry subtrees must be in one of the following formats: - "projects/", e.g. "projects/tokyo-rain-123" - "folders/", e.g. "folders/1234" - "organizations/", e.g. "organizations/1234" The `supports_under` field of the associated `Constraint` defines whether ancestry prefixes can be used. You can set `allowed_values` and `denied_values` in the same `Policy` if `all_values` is `ALL_VALUES_UNSPECIFIED`. `ALLOW` or `DENY` are used to allow or deny all values. If `all_values` is set to either `ALLOW` or `DENY`, `allowed_values` and `denied_values` must be unset.
647///
648/// This type is not used in any activity, and only used as *part* of another schema.
649///
650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
651#[serde_with::serde_as]
652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
653pub struct ListPolicy {
654    /// The policy all_values state.
655    #[serde(rename = "allValues")]
656    pub all_values: Option<String>,
657    /// List of values allowed at this resource. Can only be set if `all_values` is set to `ALL_VALUES_UNSPECIFIED`.
658    #[serde(rename = "allowedValues")]
659    pub allowed_values: Option<Vec<String>>,
660    /// List of values denied at this resource. Can only be set if `all_values` is set to `ALL_VALUES_UNSPECIFIED`.
661    #[serde(rename = "deniedValues")]
662    pub denied_values: Option<Vec<String>>,
663    /// Determines the inheritance behavior for this `Policy`. By default, a `ListPolicy` set at a resource supersedes any `Policy` set anywhere up the resource hierarchy. However, if `inherit_from_parent` is set to `true`, then the values from the effective `Policy` of the parent resource are inherited, meaning the values set in this `Policy` are added to the values inherited up the hierarchy. Setting `Policy` hierarchies that inherit both allowed values and denied values isn't recommended in most circumstances to keep the configuration simple and understandable. However, it is possible to set a `Policy` with `allowed_values` set that inherits a `Policy` with `denied_values` set. In this case, the values that are allowed must be in `allowed_values` and not present in `denied_values`. For example, suppose you have a `Constraint` `constraints/serviceuser.services`, which has a `constraint_type` of `list_constraint`, and with `constraint_default` set to `ALLOW`. Suppose that at the Organization level, a `Policy` is applied that restricts the allowed API activations to {`E1`, `E2`}. Then, if a `Policy` is applied to a project below the Organization that has `inherit_from_parent` set to `false` and field all_values set to DENY, then an attempt to activate any API will be denied. The following examples demonstrate different possible layerings for `projects/bar` parented by `organizations/foo`: Example 1 (no inherited values): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values:"E2"} `projects/bar` has `inherit_from_parent` `false` and values: {allowed_values: "E3" allowed_values: "E4"} The accepted values at `organizations/foo` are `E1`, `E2`. The accepted values at `projects/bar` are `E3`, and `E4`. Example 2 (inherited values): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values:"E2"} `projects/bar` has a `Policy` with values: {value: "E3" value: "E4" inherit_from_parent: true} The accepted values at `organizations/foo` are `E1`, `E2`. The accepted values at `projects/bar` are `E1`, `E2`, `E3`, and `E4`. Example 3 (inheriting both allowed and denied values): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values: "E2"} `projects/bar` has a `Policy` with: {denied_values: "E1"} The accepted values at `organizations/foo` are `E1`, `E2`. The value accepted at `projects/bar` is `E2`. Example 4 (RestoreDefault): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values:"E2"} `projects/bar` has a `Policy` with values: {RestoreDefault: {}} The accepted values at `organizations/foo` are `E1`, `E2`. The accepted values at `projects/bar` are either all or none depending on the value of `constraint_default` (if `ALLOW`, all; if `DENY`, none). Example 5 (no policy inherits parent policy): `organizations/foo` has no `Policy` set. `projects/bar` has no `Policy` set. The accepted values at both levels are either all or none depending on the value of `constraint_default` (if `ALLOW`, all; if `DENY`, none). Example 6 (ListConstraint allowing all): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values: "E2"} `projects/bar` has a `Policy` with: {all: ALLOW} The accepted values at `organizations/foo` are `E1`, E2`. Any value is accepted at `projects/bar`. Example 7 (ListConstraint allowing none): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values: "E2"} `projects/bar` has a `Policy` with: {all: DENY} The accepted values at `organizations/foo` are `E1`, E2`. No value is accepted at `projects/bar`. Example 10 (allowed and denied subtrees of Resource Manager hierarchy): Given the following resource hierarchy O1->{F1, F2}; F1->{P1}; F2->{P2, P3}, `organizations/foo` has a `Policy` with values: {allowed_values: "under:organizations/O1"} `projects/bar` has a `Policy` with: {allowed_values: "under:projects/P3"} {denied_values: "under:folders/F2"} The accepted values at `organizations/foo` are `organizations/O1`, `folders/F1`, `folders/F2`, `projects/P1`, `projects/P2`, `projects/P3`. The accepted values at `projects/bar` are `organizations/O1`, `folders/F1`, `projects/P1`.
664    #[serde(rename = "inheritFromParent")]
665    pub inherit_from_parent: Option<bool>,
666    /// Optional. The Google Cloud Console will try to default to a configuration that matches the value specified in this `Policy`. If `suggested_value` is not set, it will inherit the value specified higher in the hierarchy, unless `inherit_from_parent` is `false`.
667    #[serde(rename = "suggestedValue")]
668    pub suggested_value: Option<String>,
669}
670
671impl common::Part for ListPolicy {}
672
673/// A page of the response received from the ListProjects method. A paginated response where more pages are available has `next_page_token` set. This token can be used in a subsequent request to retrieve the next request page.
674///
675/// # Activities
676///
677/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
678/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
679///
680/// * [list projects](ProjectListCall) (response)
681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
682#[serde_with::serde_as]
683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
684pub struct ListProjectsResponse {
685    /// Pagination token. If the result set is too large to fit in a single response, this token is returned. It encodes the position of the current result cursor. Feeding this value into a new list request with the `page_token` parameter gives the next page of the results. When `next_page_token` is not filled in, there is no next page and the list returned is the last page in the result set. Pagination tokens have a limited lifetime.
686    #[serde(rename = "nextPageToken")]
687    pub next_page_token: Option<String>,
688    /// The list of Projects that matched the list filter. This list can be paginated.
689    pub projects: Option<Vec<Project>>,
690}
691
692impl common::ResponseResult for ListProjectsResponse {}
693
694/// This resource represents a long-running operation that is the result of a network API call.
695///
696/// # Activities
697///
698/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
699/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
700///
701/// * [get operations](OperationGetCall) (response)
702/// * [create projects](ProjectCreateCall) (response)
703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
704#[serde_with::serde_as]
705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
706pub struct Operation {
707    /// If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available.
708    pub done: Option<bool>,
709    /// The error result of the operation in case of failure or cancellation.
710    pub error: Option<Status>,
711    /// Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
712    pub metadata: Option<HashMap<String, serde_json::Value>>,
713    /// The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`.
714    pub name: Option<String>,
715    /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
716    pub response: Option<HashMap<String, serde_json::Value>>,
717}
718
719impl common::Resource for Operation {}
720impl common::ResponseResult for Operation {}
721
722/// Defines a Cloud Organization `Policy` which is used to specify `Constraints` for configurations of Cloud Platform resources.
723///
724/// # Activities
725///
726/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
727/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
728///
729/// * [get effective org policy folders](FolderGetEffectiveOrgPolicyCall) (response)
730/// * [get org policy folders](FolderGetOrgPolicyCall) (response)
731/// * [set org policy folders](FolderSetOrgPolicyCall) (response)
732/// * [get effective org policy organizations](OrganizationGetEffectiveOrgPolicyCall) (response)
733/// * [get org policy organizations](OrganizationGetOrgPolicyCall) (response)
734/// * [set org policy organizations](OrganizationSetOrgPolicyCall) (response)
735/// * [get effective org policy projects](ProjectGetEffectiveOrgPolicyCall) (response)
736/// * [get org policy projects](ProjectGetOrgPolicyCall) (response)
737/// * [set org policy projects](ProjectSetOrgPolicyCall) (response)
738#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
739#[serde_with::serde_as]
740#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
741pub struct OrgPolicy {
742    /// For boolean `Constraints`, whether to enforce the `Constraint` or not.
743    #[serde(rename = "booleanPolicy")]
744    pub boolean_policy: Option<BooleanPolicy>,
745    /// The name of the `Constraint` the `Policy` is configuring, for example, `constraints/serviceuser.services`. A [list of available constraints](https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints) is available. Immutable after creation.
746    pub constraint: Option<String>,
747    /// An opaque tag indicating the current version of the `Policy`, used for concurrency control. When the `Policy` is returned from either a `GetPolicy` or a `ListOrgPolicy` request, this `etag` indicates the version of the current `Policy` to use when executing a read-modify-write loop. When the `Policy` is returned from a `GetEffectivePolicy` request, the `etag` will be unset. When the `Policy` is used in a `SetOrgPolicy` method, use the `etag` value that was returned from a `GetOrgPolicy` request as part of a read-modify-write loop for concurrency control. Not setting the `etag`in a `SetOrgPolicy` request will result in an unconditional write of the `Policy`.
748    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
749    pub etag: Option<Vec<u8>>,
750    /// List of values either allowed or disallowed.
751    #[serde(rename = "listPolicy")]
752    pub list_policy: Option<ListPolicy>,
753    /// Restores the default behavior of the constraint; independent of `Constraint` type.
754    #[serde(rename = "restoreDefault")]
755    pub restore_default: Option<RestoreDefault>,
756    /// The time stamp the `Policy` was previously updated. This is set by the server, not specified by the caller, and represents the last time a call to `SetOrgPolicy` was made for that `Policy`. Any value set by the client will be ignored.
757    #[serde(rename = "updateTime")]
758    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
759    /// Version of the `Policy`. Default version is 0;
760    pub version: Option<i32>,
761}
762
763impl common::ResponseResult for OrgPolicy {}
764
765/// The root node in the resource hierarchy to which a particular entity’s (e.g., company) resources belong.
766///
767/// # Activities
768///
769/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
770/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
771///
772/// * [clear org policy organizations](OrganizationClearOrgPolicyCall) (none)
773/// * [get organizations](OrganizationGetCall) (response)
774/// * [get effective org policy organizations](OrganizationGetEffectiveOrgPolicyCall) (none)
775/// * [get iam policy organizations](OrganizationGetIamPolicyCall) (none)
776/// * [get org policy organizations](OrganizationGetOrgPolicyCall) (none)
777/// * [list available org policy constraints organizations](OrganizationListAvailableOrgPolicyConstraintCall) (none)
778/// * [list org policies organizations](OrganizationListOrgPolicyCall) (none)
779/// * [search organizations](OrganizationSearchCall) (none)
780/// * [set iam policy organizations](OrganizationSetIamPolicyCall) (none)
781/// * [set org policy organizations](OrganizationSetOrgPolicyCall) (none)
782/// * [test iam permissions organizations](OrganizationTestIamPermissionCall) (none)
783#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
784#[serde_with::serde_as]
785#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
786pub struct Organization {
787    /// Timestamp when the Organization was created. Assigned by the server.
788    #[serde(rename = "creationTime")]
789    pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
790    /// A human-readable string that refers to the Organization in the Google Cloud console. This string is set by the server and cannot be changed. The string will be set to the primary domain (for example, "google.com") of the G Suite customer that owns the organization.
791    #[serde(rename = "displayName")]
792    pub display_name: Option<String>,
793    /// The organization's current lifecycle state. Assigned by the server.
794    #[serde(rename = "lifecycleState")]
795    pub lifecycle_state: Option<String>,
796    /// Output only. The resource name of the organization. This is the organization's relative path in the API. Its format is "organizations/[organization_id]". For example, "organizations/1234".
797    pub name: Option<String>,
798    /// The owner of this Organization. The owner should be specified on creation. Once set, it cannot be changed. This field is required.
799    pub owner: Option<OrganizationOwner>,
800}
801
802impl common::Resource for Organization {}
803impl common::ResponseResult for Organization {}
804
805/// The entity that owns an Organization. The lifetime of the Organization and all of its descendants are bound to the `OrganizationOwner`. If the `OrganizationOwner` is deleted, the Organization and all its descendants will be deleted.
806///
807/// This type is not used in any activity, and only used as *part* of another schema.
808///
809#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
810#[serde_with::serde_as]
811#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
812pub struct OrganizationOwner {
813    /// The G Suite customer id used in the Directory API.
814    #[serde(rename = "directoryCustomerId")]
815    pub directory_customer_id: Option<String>,
816}
817
818impl common::Part for OrganizationOwner {}
819
820/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
821///
822/// # Activities
823///
824/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
825/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
826///
827/// * [get iam policy organizations](OrganizationGetIamPolicyCall) (response)
828/// * [set iam policy organizations](OrganizationSetIamPolicyCall) (response)
829/// * [get iam policy projects](ProjectGetIamPolicyCall) (response)
830/// * [set iam policy projects](ProjectSetIamPolicyCall) (response)
831#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
832#[serde_with::serde_as]
833#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
834pub struct Policy {
835    /// Specifies cloud audit logging configuration for this policy.
836    #[serde(rename = "auditConfigs")]
837    pub audit_configs: Option<Vec<AuditConfig>>,
838    /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
839    pub bindings: Option<Vec<Binding>>,
840    /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
841    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
842    pub etag: Option<Vec<u8>>,
843    /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
844    pub version: Option<i32>,
845}
846
847impl common::ResponseResult for Policy {}
848
849/// A Project is a high-level Google Cloud Platform entity. It is a container for ACLs, APIs, App Engine Apps, VMs, and other Google Cloud Platform resources.
850///
851/// # Activities
852///
853/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
854/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
855///
856/// * [clear org policy projects](ProjectClearOrgPolicyCall) (none)
857/// * [create projects](ProjectCreateCall) (request)
858/// * [delete projects](ProjectDeleteCall) (none)
859/// * [get projects](ProjectGetCall) (response)
860/// * [get ancestry projects](ProjectGetAncestryCall) (none)
861/// * [get effective org policy projects](ProjectGetEffectiveOrgPolicyCall) (none)
862/// * [get iam policy projects](ProjectGetIamPolicyCall) (none)
863/// * [get org policy projects](ProjectGetOrgPolicyCall) (none)
864/// * [list projects](ProjectListCall) (none)
865/// * [list available org policy constraints projects](ProjectListAvailableOrgPolicyConstraintCall) (none)
866/// * [list org policies projects](ProjectListOrgPolicyCall) (none)
867/// * [set iam policy projects](ProjectSetIamPolicyCall) (none)
868/// * [set org policy projects](ProjectSetOrgPolicyCall) (none)
869/// * [test iam permissions projects](ProjectTestIamPermissionCall) (none)
870/// * [undelete projects](ProjectUndeleteCall) (none)
871/// * [update projects](ProjectUpdateCall) (request|response)
872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
873#[serde_with::serde_as]
874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
875pub struct Project {
876    /// Creation time. Read-only.
877    #[serde(rename = "createTime")]
878    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
879    /// The labels associated with this Project. Label keys must be between 1 and 63 characters long and must conform to the following regular expression: a-z{0,62}. Label values must be between 0 and 63 characters long and must conform to the regular expression [a-z0-9_-]{0,63}. A label value can be empty. No more than 256 labels can be associated with a given resource. Clients should store labels in a representation such as JSON that does not depend on specific characters being disallowed. Example: "environment" : "dev" Read-write.
880    pub labels: Option<HashMap<String, String>>,
881    /// The Project lifecycle state. Read-only.
882    #[serde(rename = "lifecycleState")]
883    pub lifecycle_state: Option<String>,
884    /// The optional user-assigned display name of the Project. When present it must be between 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. Example: `My Project` Read-write.
885    pub name: Option<String>,
886    /// An optional reference to a parent Resource. Supported parent types include "organization" and "folder". Once set, the parent cannot be cleared. The `parent` can be set on creation or using the `UpdateProject` method; the end user must have the `resourcemanager.projects.create` permission on the parent.
887    pub parent: Option<ResourceId>,
888    /// The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited. Example: `tokyo-rain-123` Read-only after creation.
889    #[serde(rename = "projectId")]
890    pub project_id: Option<String>,
891    /// The number uniquely identifying the project. Example: `415104041262` Read-only.
892    #[serde(rename = "projectNumber")]
893    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
894    pub project_number: Option<i64>,
895    /// Optional. Input only. Immutable. Tag keys/values directly bound to this project. Each item in the map must be expressed as " : ". For example: "123/environment" : "production", "123/costCenter" : "marketing" Note: Currently this field is in Preview.
896    pub tags: Option<HashMap<String, String>>,
897}
898
899impl common::RequestValue for Project {}
900impl common::Resource for Project {}
901impl common::ResponseResult for Project {}
902
903/// A container to reference an id for any resource type. A `resource` in Google Cloud Platform is a generic term for something you (a developer) may want to interact with through one of our API's. Some examples are an App Engine app, a Compute Engine instance, a Cloud SQL database, and so on.
904///
905/// This type is not used in any activity, and only used as *part* of another schema.
906///
907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
908#[serde_with::serde_as]
909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
910pub struct ResourceId {
911    /// The type-specific id. This should correspond to the id used in the type-specific API's.
912    pub id: Option<String>,
913    /// The resource type this id is for. At present, the valid types are: "organization", "folder", and "project".
914    #[serde(rename = "type")]
915    pub type_: Option<String>,
916}
917
918impl common::Part for ResourceId {}
919
920/// Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific `Constraint` at this resource. Suppose that `constraint_default` is set to `ALLOW` for the `Constraint` `constraints/serviceuser.services`. Suppose that organization foo.com sets a `Policy` at their Organization resource node that restricts the allowed service activations to deny all service activations. They could then set a `Policy` with the `policy_type` `restore_default` on several experimental projects, restoring the `constraint_default` enforcement of the `Constraint` for only those projects, allowing those projects to have all services activated.
921///
922/// This type is not used in any activity, and only used as *part* of another schema.
923///
924#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
925#[serde_with::serde_as]
926#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
927pub struct RestoreDefault {
928    _never_set: Option<bool>,
929}
930
931impl common::Part for RestoreDefault {}
932
933/// The request sent to the `SearchOrganizations` method.
934///
935/// # Activities
936///
937/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
938/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
939///
940/// * [search organizations](OrganizationSearchCall) (request)
941#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
942#[serde_with::serde_as]
943#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
944pub struct SearchOrganizationsRequest {
945    /// An optional query string used to filter the Organizations to return in the response. Filter rules are case-insensitive. Organizations may be filtered by `owner.directoryCustomerId` or by `domain`, where the domain is a G Suite domain, for example: * Filter `owner.directorycustomerid:123456789` returns Organization resources with `owner.directory_customer_id` equal to `123456789`. * Filter `domain:google.com` returns Organization resources corresponding to the domain `google.com`. This field is optional.
946    pub filter: Option<String>,
947    /// The maximum number of Organizations to return in the response. The server can return fewer organizations than requested. If unspecified, server picks an appropriate default.
948    #[serde(rename = "pageSize")]
949    pub page_size: Option<i32>,
950    /// A pagination token returned from a previous call to `SearchOrganizations` that indicates from where listing should continue. This field is optional.
951    #[serde(rename = "pageToken")]
952    pub page_token: Option<String>,
953}
954
955impl common::RequestValue for SearchOrganizationsRequest {}
956
957/// The response returned from the `SearchOrganizations` method.
958///
959/// # Activities
960///
961/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
962/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
963///
964/// * [search organizations](OrganizationSearchCall) (response)
965#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
966#[serde_with::serde_as]
967#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
968pub struct SearchOrganizationsResponse {
969    /// A pagination token to be used to retrieve the next page of results. If the result is too large to fit within the page size specified in the request, this field will be set with a token that can be used to fetch the next page of results. If this field is empty, it indicates that this response contains the last page of results.
970    #[serde(rename = "nextPageToken")]
971    pub next_page_token: Option<String>,
972    /// The list of Organizations that matched the search query, possibly paginated.
973    pub organizations: Option<Vec<Organization>>,
974}
975
976impl common::ResponseResult for SearchOrganizationsResponse {}
977
978/// Request message for `SetIamPolicy` method.
979///
980/// # Activities
981///
982/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
983/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
984///
985/// * [set iam policy organizations](OrganizationSetIamPolicyCall) (request)
986/// * [set iam policy projects](ProjectSetIamPolicyCall) (request)
987#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
988#[serde_with::serde_as]
989#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
990pub struct SetIamPolicyRequest {
991    /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
992    pub policy: Option<Policy>,
993    /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
994    #[serde(rename = "updateMask")]
995    pub update_mask: Option<common::FieldMask>,
996}
997
998impl common::RequestValue for SetIamPolicyRequest {}
999
1000/// The request sent to the SetOrgPolicyRequest method.
1001///
1002/// # Activities
1003///
1004/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1005/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1006///
1007/// * [set org policy folders](FolderSetOrgPolicyCall) (request)
1008/// * [set org policy organizations](OrganizationSetOrgPolicyCall) (request)
1009/// * [set org policy projects](ProjectSetOrgPolicyCall) (request)
1010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1011#[serde_with::serde_as]
1012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1013pub struct SetOrgPolicyRequest {
1014    /// `Policy` to set on the resource.
1015    pub policy: Option<OrgPolicy>,
1016}
1017
1018impl common::RequestValue for SetOrgPolicyRequest {}
1019
1020/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
1021///
1022/// This type is not used in any activity, and only used as *part* of another schema.
1023///
1024#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1025#[serde_with::serde_as]
1026#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1027pub struct Status {
1028    /// The status code, which should be an enum value of google.rpc.Code.
1029    pub code: Option<i32>,
1030    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1031    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1032    /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
1033    pub message: Option<String>,
1034}
1035
1036impl common::Part for Status {}
1037
1038/// Request message for `TestIamPermissions` method.
1039///
1040/// # Activities
1041///
1042/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1043/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1044///
1045/// * [test iam permissions organizations](OrganizationTestIamPermissionCall) (request)
1046/// * [test iam permissions projects](ProjectTestIamPermissionCall) (request)
1047#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1048#[serde_with::serde_as]
1049#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1050pub struct TestIamPermissionsRequest {
1051    /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1052    pub permissions: Option<Vec<String>>,
1053}
1054
1055impl common::RequestValue for TestIamPermissionsRequest {}
1056
1057/// Response message for `TestIamPermissions` method.
1058///
1059/// # Activities
1060///
1061/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1062/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1063///
1064/// * [test iam permissions organizations](OrganizationTestIamPermissionCall) (response)
1065/// * [test iam permissions projects](ProjectTestIamPermissionCall) (response)
1066#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1067#[serde_with::serde_as]
1068#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1069pub struct TestIamPermissionsResponse {
1070    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1071    pub permissions: Option<Vec<String>>,
1072}
1073
1074impl common::ResponseResult for TestIamPermissionsResponse {}
1075
1076/// The request sent to the UndeleteProject method.
1077///
1078/// # Activities
1079///
1080/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1081/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1082///
1083/// * [undelete projects](ProjectUndeleteCall) (request)
1084#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1085#[serde_with::serde_as]
1086#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1087pub struct UndeleteProjectRequest {
1088    _never_set: Option<bool>,
1089}
1090
1091impl common::RequestValue for UndeleteProjectRequest {}
1092
1093// ###################
1094// MethodBuilders ###
1095// #################
1096
1097/// A builder providing access to all methods supported on *folder* resources.
1098/// It is not used directly, but through the [`CloudResourceManager`] hub.
1099///
1100/// # Example
1101///
1102/// Instantiate a resource builder
1103///
1104/// ```test_harness,no_run
1105/// extern crate hyper;
1106/// extern crate hyper_rustls;
1107/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1108///
1109/// # async fn dox() {
1110/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1111///
1112/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1113/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1114///     secret,
1115///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1116/// ).build().await.unwrap();
1117///
1118/// let client = hyper_util::client::legacy::Client::builder(
1119///     hyper_util::rt::TokioExecutor::new()
1120/// )
1121/// .build(
1122///     hyper_rustls::HttpsConnectorBuilder::new()
1123///         .with_native_roots()
1124///         .unwrap()
1125///         .https_or_http()
1126///         .enable_http1()
1127///         .build()
1128/// );
1129/// let mut hub = CloudResourceManager::new(client, auth);
1130/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1131/// // like `clear_org_policy(...)`, `get_effective_org_policy(...)`, `get_org_policy(...)`, `list_available_org_policy_constraints(...)`, `list_org_policies(...)` and `set_org_policy(...)`
1132/// // to build up your call.
1133/// let rb = hub.folders();
1134/// # }
1135/// ```
1136pub struct FolderMethods<'a, C>
1137where
1138    C: 'a,
1139{
1140    hub: &'a CloudResourceManager<C>,
1141}
1142
1143impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
1144
1145impl<'a, C> FolderMethods<'a, C> {
1146    /// Create a builder to help you perform the following task:
1147    ///
1148    /// Clears a `Policy` from a resource.
1149    ///
1150    /// # Arguments
1151    ///
1152    /// * `request` - No description provided.
1153    /// * `resource` - Name of the resource for the `Policy` to clear.
1154    pub fn clear_org_policy(
1155        &self,
1156        request: ClearOrgPolicyRequest,
1157        resource: &str,
1158    ) -> FolderClearOrgPolicyCall<'a, C> {
1159        FolderClearOrgPolicyCall {
1160            hub: self.hub,
1161            _request: request,
1162            _resource: resource.to_string(),
1163            _delegate: Default::default(),
1164            _additional_params: Default::default(),
1165            _scopes: Default::default(),
1166        }
1167    }
1168
1169    /// Create a builder to help you perform the following task:
1170    ///
1171    /// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
1172    ///
1173    /// # Arguments
1174    ///
1175    /// * `request` - No description provided.
1176    /// * `resource` - The name of the resource to start computing the effective `Policy`.
1177    pub fn get_effective_org_policy(
1178        &self,
1179        request: GetEffectiveOrgPolicyRequest,
1180        resource: &str,
1181    ) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
1182        FolderGetEffectiveOrgPolicyCall {
1183            hub: self.hub,
1184            _request: request,
1185            _resource: resource.to_string(),
1186            _delegate: Default::default(),
1187            _additional_params: Default::default(),
1188            _scopes: Default::default(),
1189        }
1190    }
1191
1192    /// Create a builder to help you perform the following task:
1193    ///
1194    /// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
1195    ///
1196    /// # Arguments
1197    ///
1198    /// * `request` - No description provided.
1199    /// * `resource` - Name of the resource the `Policy` is set on.
1200    pub fn get_org_policy(
1201        &self,
1202        request: GetOrgPolicyRequest,
1203        resource: &str,
1204    ) -> FolderGetOrgPolicyCall<'a, C> {
1205        FolderGetOrgPolicyCall {
1206            hub: self.hub,
1207            _request: request,
1208            _resource: resource.to_string(),
1209            _delegate: Default::default(),
1210            _additional_params: Default::default(),
1211            _scopes: Default::default(),
1212        }
1213    }
1214
1215    /// Create a builder to help you perform the following task:
1216    ///
1217    /// Lists `Constraints` that could be applied on the specified resource.
1218    ///
1219    /// # Arguments
1220    ///
1221    /// * `request` - No description provided.
1222    /// * `resource` - Name of the resource to list `Constraints` for.
1223    pub fn list_available_org_policy_constraints(
1224        &self,
1225        request: ListAvailableOrgPolicyConstraintsRequest,
1226        resource: &str,
1227    ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
1228        FolderListAvailableOrgPolicyConstraintCall {
1229            hub: self.hub,
1230            _request: request,
1231            _resource: resource.to_string(),
1232            _delegate: Default::default(),
1233            _additional_params: Default::default(),
1234            _scopes: Default::default(),
1235        }
1236    }
1237
1238    /// Create a builder to help you perform the following task:
1239    ///
1240    /// Lists all the `Policies` set for a particular resource.
1241    ///
1242    /// # Arguments
1243    ///
1244    /// * `request` - No description provided.
1245    /// * `resource` - Name of the resource to list Policies for.
1246    pub fn list_org_policies(
1247        &self,
1248        request: ListOrgPoliciesRequest,
1249        resource: &str,
1250    ) -> FolderListOrgPolicyCall<'a, C> {
1251        FolderListOrgPolicyCall {
1252            hub: self.hub,
1253            _request: request,
1254            _resource: resource.to_string(),
1255            _delegate: Default::default(),
1256            _additional_params: Default::default(),
1257            _scopes: Default::default(),
1258        }
1259    }
1260
1261    /// Create a builder to help you perform the following task:
1262    ///
1263    /// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
1264    ///
1265    /// # Arguments
1266    ///
1267    /// * `request` - No description provided.
1268    /// * `resource` - Resource name of the resource to attach the `Policy`.
1269    pub fn set_org_policy(
1270        &self,
1271        request: SetOrgPolicyRequest,
1272        resource: &str,
1273    ) -> FolderSetOrgPolicyCall<'a, C> {
1274        FolderSetOrgPolicyCall {
1275            hub: self.hub,
1276            _request: request,
1277            _resource: resource.to_string(),
1278            _delegate: Default::default(),
1279            _additional_params: Default::default(),
1280            _scopes: Default::default(),
1281        }
1282    }
1283}
1284
1285/// A builder providing access to all methods supported on *lien* resources.
1286/// It is not used directly, but through the [`CloudResourceManager`] hub.
1287///
1288/// # Example
1289///
1290/// Instantiate a resource builder
1291///
1292/// ```test_harness,no_run
1293/// extern crate hyper;
1294/// extern crate hyper_rustls;
1295/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1296///
1297/// # async fn dox() {
1298/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1299///
1300/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1301/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1302///     secret,
1303///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1304/// ).build().await.unwrap();
1305///
1306/// let client = hyper_util::client::legacy::Client::builder(
1307///     hyper_util::rt::TokioExecutor::new()
1308/// )
1309/// .build(
1310///     hyper_rustls::HttpsConnectorBuilder::new()
1311///         .with_native_roots()
1312///         .unwrap()
1313///         .https_or_http()
1314///         .enable_http1()
1315///         .build()
1316/// );
1317/// let mut hub = CloudResourceManager::new(client, auth);
1318/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1319/// // like `create(...)`, `delete(...)`, `get(...)` and `list(...)`
1320/// // to build up your call.
1321/// let rb = hub.liens();
1322/// # }
1323/// ```
1324pub struct LienMethods<'a, C>
1325where
1326    C: 'a,
1327{
1328    hub: &'a CloudResourceManager<C>,
1329}
1330
1331impl<'a, C> common::MethodsBuilder for LienMethods<'a, C> {}
1332
1333impl<'a, C> LienMethods<'a, C> {
1334    /// Create a builder to help you perform the following task:
1335    ///
1336    /// Create a Lien which applies to the resource denoted by the `parent` field. Callers of this method will require permission on the `parent` resource. For example, applying to `projects/1234` requires permission `resourcemanager.projects.updateLiens`. NOTE: Some resources may limit the number of Liens which may be applied.
1337    ///
1338    /// # Arguments
1339    ///
1340    /// * `request` - No description provided.
1341    pub fn create(&self, request: Lien) -> LienCreateCall<'a, C> {
1342        LienCreateCall {
1343            hub: self.hub,
1344            _request: request,
1345            _delegate: Default::default(),
1346            _additional_params: Default::default(),
1347            _scopes: Default::default(),
1348        }
1349    }
1350
1351    /// Create a builder to help you perform the following task:
1352    ///
1353    /// Delete a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.updateLiens`.
1354    ///
1355    /// # Arguments
1356    ///
1357    /// * `name` - Required. The name/identifier of the Lien to delete.
1358    pub fn delete(&self, name: &str) -> LienDeleteCall<'a, C> {
1359        LienDeleteCall {
1360            hub: self.hub,
1361            _name: name.to_string(),
1362            _delegate: Default::default(),
1363            _additional_params: Default::default(),
1364            _scopes: Default::default(),
1365        }
1366    }
1367
1368    /// Create a builder to help you perform the following task:
1369    ///
1370    /// Retrieve a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`
1371    ///
1372    /// # Arguments
1373    ///
1374    /// * `name` - Required. The name/identifier of the Lien.
1375    pub fn get(&self, name: &str) -> LienGetCall<'a, C> {
1376        LienGetCall {
1377            hub: self.hub,
1378            _name: name.to_string(),
1379            _delegate: Default::default(),
1380            _additional_params: Default::default(),
1381            _scopes: Default::default(),
1382        }
1383    }
1384
1385    /// Create a builder to help you perform the following task:
1386    ///
1387    /// List all Liens applied to the `parent` resource. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`.
1388    pub fn list(&self) -> LienListCall<'a, C> {
1389        LienListCall {
1390            hub: self.hub,
1391            _parent: Default::default(),
1392            _page_token: Default::default(),
1393            _page_size: Default::default(),
1394            _delegate: Default::default(),
1395            _additional_params: Default::default(),
1396            _scopes: Default::default(),
1397        }
1398    }
1399}
1400
1401/// A builder providing access to all methods supported on *operation* resources.
1402/// It is not used directly, but through the [`CloudResourceManager`] hub.
1403///
1404/// # Example
1405///
1406/// Instantiate a resource builder
1407///
1408/// ```test_harness,no_run
1409/// extern crate hyper;
1410/// extern crate hyper_rustls;
1411/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1412///
1413/// # async fn dox() {
1414/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1415///
1416/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1417/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1418///     secret,
1419///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1420/// ).build().await.unwrap();
1421///
1422/// let client = hyper_util::client::legacy::Client::builder(
1423///     hyper_util::rt::TokioExecutor::new()
1424/// )
1425/// .build(
1426///     hyper_rustls::HttpsConnectorBuilder::new()
1427///         .with_native_roots()
1428///         .unwrap()
1429///         .https_or_http()
1430///         .enable_http1()
1431///         .build()
1432/// );
1433/// let mut hub = CloudResourceManager::new(client, auth);
1434/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1435/// // like `get(...)`
1436/// // to build up your call.
1437/// let rb = hub.operations();
1438/// # }
1439/// ```
1440pub struct OperationMethods<'a, C>
1441where
1442    C: 'a,
1443{
1444    hub: &'a CloudResourceManager<C>,
1445}
1446
1447impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
1448
1449impl<'a, C> OperationMethods<'a, C> {
1450    /// Create a builder to help you perform the following task:
1451    ///
1452    /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
1453    ///
1454    /// # Arguments
1455    ///
1456    /// * `name` - The name of the operation resource.
1457    pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
1458        OperationGetCall {
1459            hub: self.hub,
1460            _name: name.to_string(),
1461            _delegate: Default::default(),
1462            _additional_params: Default::default(),
1463            _scopes: Default::default(),
1464        }
1465    }
1466}
1467
1468/// A builder providing access to all methods supported on *organization* resources.
1469/// It is not used directly, but through the [`CloudResourceManager`] hub.
1470///
1471/// # Example
1472///
1473/// Instantiate a resource builder
1474///
1475/// ```test_harness,no_run
1476/// extern crate hyper;
1477/// extern crate hyper_rustls;
1478/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1479///
1480/// # async fn dox() {
1481/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1482///
1483/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1484/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1485///     secret,
1486///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1487/// ).build().await.unwrap();
1488///
1489/// let client = hyper_util::client::legacy::Client::builder(
1490///     hyper_util::rt::TokioExecutor::new()
1491/// )
1492/// .build(
1493///     hyper_rustls::HttpsConnectorBuilder::new()
1494///         .with_native_roots()
1495///         .unwrap()
1496///         .https_or_http()
1497///         .enable_http1()
1498///         .build()
1499/// );
1500/// let mut hub = CloudResourceManager::new(client, auth);
1501/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1502/// // like `clear_org_policy(...)`, `get(...)`, `get_effective_org_policy(...)`, `get_iam_policy(...)`, `get_org_policy(...)`, `list_available_org_policy_constraints(...)`, `list_org_policies(...)`, `search(...)`, `set_iam_policy(...)`, `set_org_policy(...)` and `test_iam_permissions(...)`
1503/// // to build up your call.
1504/// let rb = hub.organizations();
1505/// # }
1506/// ```
1507pub struct OrganizationMethods<'a, C>
1508where
1509    C: 'a,
1510{
1511    hub: &'a CloudResourceManager<C>,
1512}
1513
1514impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
1515
1516impl<'a, C> OrganizationMethods<'a, C> {
1517    /// Create a builder to help you perform the following task:
1518    ///
1519    /// Clears a `Policy` from a resource.
1520    ///
1521    /// # Arguments
1522    ///
1523    /// * `request` - No description provided.
1524    /// * `resource` - Name of the resource for the `Policy` to clear.
1525    pub fn clear_org_policy(
1526        &self,
1527        request: ClearOrgPolicyRequest,
1528        resource: &str,
1529    ) -> OrganizationClearOrgPolicyCall<'a, C> {
1530        OrganizationClearOrgPolicyCall {
1531            hub: self.hub,
1532            _request: request,
1533            _resource: resource.to_string(),
1534            _delegate: Default::default(),
1535            _additional_params: Default::default(),
1536            _scopes: Default::default(),
1537        }
1538    }
1539
1540    /// Create a builder to help you perform the following task:
1541    ///
1542    /// Fetches an Organization resource identified by the specified resource name.
1543    ///
1544    /// # Arguments
1545    ///
1546    /// * `name` - The resource name of the Organization to fetch. This is the organization's relative path in the API, formatted as "organizations/[organizationId]". For example, "organizations/1234".
1547    pub fn get(&self, name: &str) -> OrganizationGetCall<'a, C> {
1548        OrganizationGetCall {
1549            hub: self.hub,
1550            _name: name.to_string(),
1551            _delegate: Default::default(),
1552            _additional_params: Default::default(),
1553            _scopes: Default::default(),
1554        }
1555    }
1556
1557    /// Create a builder to help you perform the following task:
1558    ///
1559    /// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
1560    ///
1561    /// # Arguments
1562    ///
1563    /// * `request` - No description provided.
1564    /// * `resource` - The name of the resource to start computing the effective `Policy`.
1565    pub fn get_effective_org_policy(
1566        &self,
1567        request: GetEffectiveOrgPolicyRequest,
1568        resource: &str,
1569    ) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
1570        OrganizationGetEffectiveOrgPolicyCall {
1571            hub: self.hub,
1572            _request: request,
1573            _resource: resource.to_string(),
1574            _delegate: Default::default(),
1575            _additional_params: Default::default(),
1576            _scopes: Default::default(),
1577        }
1578    }
1579
1580    /// Create a builder to help you perform the following task:
1581    ///
1582    /// Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization
1583    ///
1584    /// # Arguments
1585    ///
1586    /// * `request` - No description provided.
1587    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1588    pub fn get_iam_policy(
1589        &self,
1590        request: GetIamPolicyRequest,
1591        resource: &str,
1592    ) -> OrganizationGetIamPolicyCall<'a, C> {
1593        OrganizationGetIamPolicyCall {
1594            hub: self.hub,
1595            _request: request,
1596            _resource: resource.to_string(),
1597            _delegate: Default::default(),
1598            _additional_params: Default::default(),
1599            _scopes: Default::default(),
1600        }
1601    }
1602
1603    /// Create a builder to help you perform the following task:
1604    ///
1605    /// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
1606    ///
1607    /// # Arguments
1608    ///
1609    /// * `request` - No description provided.
1610    /// * `resource` - Name of the resource the `Policy` is set on.
1611    pub fn get_org_policy(
1612        &self,
1613        request: GetOrgPolicyRequest,
1614        resource: &str,
1615    ) -> OrganizationGetOrgPolicyCall<'a, C> {
1616        OrganizationGetOrgPolicyCall {
1617            hub: self.hub,
1618            _request: request,
1619            _resource: resource.to_string(),
1620            _delegate: Default::default(),
1621            _additional_params: Default::default(),
1622            _scopes: Default::default(),
1623        }
1624    }
1625
1626    /// Create a builder to help you perform the following task:
1627    ///
1628    /// Lists `Constraints` that could be applied on the specified resource.
1629    ///
1630    /// # Arguments
1631    ///
1632    /// * `request` - No description provided.
1633    /// * `resource` - Name of the resource to list `Constraints` for.
1634    pub fn list_available_org_policy_constraints(
1635        &self,
1636        request: ListAvailableOrgPolicyConstraintsRequest,
1637        resource: &str,
1638    ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
1639        OrganizationListAvailableOrgPolicyConstraintCall {
1640            hub: self.hub,
1641            _request: request,
1642            _resource: resource.to_string(),
1643            _delegate: Default::default(),
1644            _additional_params: Default::default(),
1645            _scopes: Default::default(),
1646        }
1647    }
1648
1649    /// Create a builder to help you perform the following task:
1650    ///
1651    /// Lists all the `Policies` set for a particular resource.
1652    ///
1653    /// # Arguments
1654    ///
1655    /// * `request` - No description provided.
1656    /// * `resource` - Name of the resource to list Policies for.
1657    pub fn list_org_policies(
1658        &self,
1659        request: ListOrgPoliciesRequest,
1660        resource: &str,
1661    ) -> OrganizationListOrgPolicyCall<'a, C> {
1662        OrganizationListOrgPolicyCall {
1663            hub: self.hub,
1664            _request: request,
1665            _resource: resource.to_string(),
1666            _delegate: Default::default(),
1667            _additional_params: Default::default(),
1668            _scopes: Default::default(),
1669        }
1670    }
1671
1672    /// Create a builder to help you perform the following task:
1673    ///
1674    /// Searches Organization resources that are visible to the user and satisfy the specified filter. This method returns Organizations in an unspecified order. New Organizations do not necessarily appear at the end of the results. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get` or has super admin privileges.
1675    ///
1676    /// # Arguments
1677    ///
1678    /// * `request` - No description provided.
1679    pub fn search(&self, request: SearchOrganizationsRequest) -> OrganizationSearchCall<'a, C> {
1680        OrganizationSearchCall {
1681            hub: self.hub,
1682            _request: request,
1683            _delegate: Default::default(),
1684            _additional_params: Default::default(),
1685            _scopes: Default::default(),
1686        }
1687    }
1688
1689    /// Create a builder to help you perform the following task:
1690    ///
1691    /// Sets the access control policy on an Organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization
1692    ///
1693    /// # Arguments
1694    ///
1695    /// * `request` - No description provided.
1696    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1697    pub fn set_iam_policy(
1698        &self,
1699        request: SetIamPolicyRequest,
1700        resource: &str,
1701    ) -> OrganizationSetIamPolicyCall<'a, C> {
1702        OrganizationSetIamPolicyCall {
1703            hub: self.hub,
1704            _request: request,
1705            _resource: resource.to_string(),
1706            _delegate: Default::default(),
1707            _additional_params: Default::default(),
1708            _scopes: Default::default(),
1709        }
1710    }
1711
1712    /// Create a builder to help you perform the following task:
1713    ///
1714    /// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
1715    ///
1716    /// # Arguments
1717    ///
1718    /// * `request` - No description provided.
1719    /// * `resource` - Resource name of the resource to attach the `Policy`.
1720    pub fn set_org_policy(
1721        &self,
1722        request: SetOrgPolicyRequest,
1723        resource: &str,
1724    ) -> OrganizationSetOrgPolicyCall<'a, C> {
1725        OrganizationSetOrgPolicyCall {
1726            hub: self.hub,
1727            _request: request,
1728            _resource: resource.to_string(),
1729            _delegate: Default::default(),
1730            _additional_params: Default::default(),
1731            _scopes: Default::default(),
1732        }
1733    }
1734
1735    /// Create a builder to help you perform the following task:
1736    ///
1737    /// Returns permissions that a caller has on the specified Organization. The `resource` field should be the organization's resource name, e.g. "organizations/123". There are no permissions required for making this API call.
1738    ///
1739    /// # Arguments
1740    ///
1741    /// * `request` - No description provided.
1742    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1743    pub fn test_iam_permissions(
1744        &self,
1745        request: TestIamPermissionsRequest,
1746        resource: &str,
1747    ) -> OrganizationTestIamPermissionCall<'a, C> {
1748        OrganizationTestIamPermissionCall {
1749            hub: self.hub,
1750            _request: request,
1751            _resource: resource.to_string(),
1752            _delegate: Default::default(),
1753            _additional_params: Default::default(),
1754            _scopes: Default::default(),
1755        }
1756    }
1757}
1758
1759/// A builder providing access to all methods supported on *project* resources.
1760/// It is not used directly, but through the [`CloudResourceManager`] hub.
1761///
1762/// # Example
1763///
1764/// Instantiate a resource builder
1765///
1766/// ```test_harness,no_run
1767/// extern crate hyper;
1768/// extern crate hyper_rustls;
1769/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1770///
1771/// # async fn dox() {
1772/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1773///
1774/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1775/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1776///     secret,
1777///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1778/// ).build().await.unwrap();
1779///
1780/// let client = hyper_util::client::legacy::Client::builder(
1781///     hyper_util::rt::TokioExecutor::new()
1782/// )
1783/// .build(
1784///     hyper_rustls::HttpsConnectorBuilder::new()
1785///         .with_native_roots()
1786///         .unwrap()
1787///         .https_or_http()
1788///         .enable_http1()
1789///         .build()
1790/// );
1791/// let mut hub = CloudResourceManager::new(client, auth);
1792/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1793/// // like `clear_org_policy(...)`, `create(...)`, `delete(...)`, `get(...)`, `get_ancestry(...)`, `get_effective_org_policy(...)`, `get_iam_policy(...)`, `get_org_policy(...)`, `list(...)`, `list_available_org_policy_constraints(...)`, `list_org_policies(...)`, `set_iam_policy(...)`, `set_org_policy(...)`, `test_iam_permissions(...)`, `undelete(...)` and `update(...)`
1794/// // to build up your call.
1795/// let rb = hub.projects();
1796/// # }
1797/// ```
1798pub struct ProjectMethods<'a, C>
1799where
1800    C: 'a,
1801{
1802    hub: &'a CloudResourceManager<C>,
1803}
1804
1805impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1806
1807impl<'a, C> ProjectMethods<'a, C> {
1808    /// Create a builder to help you perform the following task:
1809    ///
1810    /// Clears a `Policy` from a resource.
1811    ///
1812    /// # Arguments
1813    ///
1814    /// * `request` - No description provided.
1815    /// * `resource` - Name of the resource for the `Policy` to clear.
1816    pub fn clear_org_policy(
1817        &self,
1818        request: ClearOrgPolicyRequest,
1819        resource: &str,
1820    ) -> ProjectClearOrgPolicyCall<'a, C> {
1821        ProjectClearOrgPolicyCall {
1822            hub: self.hub,
1823            _request: request,
1824            _resource: resource.to_string(),
1825            _delegate: Default::default(),
1826            _additional_params: Default::default(),
1827            _scopes: Default::default(),
1828        }
1829    }
1830
1831    /// Create a builder to help you perform the following task:
1832    ///
1833    /// Request that a new Project be created. The result is an Operation which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking Operation is automatically deleted after a few hours, so there is no need to call DeleteOperation. Authorization requires the Google IAM permission `resourcemanager.projects.create` on the specified parent for the new project. The parent is identified by a specified ResourceId, which must include both an ID and a type, such as organization. This method does not associate the new project with a billing account. You can set or update the billing account associated with a project using the \[`projects.updateBillingInfo`\] (/billing/reference/rest/v1/projects/updateBillingInfo) method.
1834    ///
1835    /// # Arguments
1836    ///
1837    /// * `request` - No description provided.
1838    pub fn create(&self, request: Project) -> ProjectCreateCall<'a, C> {
1839        ProjectCreateCall {
1840            hub: self.hub,
1841            _request: request,
1842            _delegate: Default::default(),
1843            _additional_params: Default::default(),
1844            _scopes: Default::default(),
1845        }
1846    }
1847
1848    /// Create a builder to help you perform the following task:
1849    ///
1850    /// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if it has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have delete permissions for this Project.
1851    ///
1852    /// # Arguments
1853    ///
1854    /// * `projectId` - The Project ID (for example, `foo-bar-123`). Required.
1855    pub fn delete(&self, project_id: &str) -> ProjectDeleteCall<'a, C> {
1856        ProjectDeleteCall {
1857            hub: self.hub,
1858            _project_id: project_id.to_string(),
1859            _delegate: Default::default(),
1860            _additional_params: Default::default(),
1861            _scopes: Default::default(),
1862        }
1863    }
1864
1865    /// Create a builder to help you perform the following task:
1866    ///
1867    /// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
1868    ///
1869    /// # Arguments
1870    ///
1871    /// * `projectId` - Required. The Project ID (for example, `my-project-123`).
1872    pub fn get(&self, project_id: &str) -> ProjectGetCall<'a, C> {
1873        ProjectGetCall {
1874            hub: self.hub,
1875            _project_id: project_id.to_string(),
1876            _delegate: Default::default(),
1877            _additional_params: Default::default(),
1878            _scopes: Default::default(),
1879        }
1880    }
1881
1882    /// Create a builder to help you perform the following task:
1883    ///
1884    /// Gets a list of ancestors in the resource hierarchy for the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
1885    ///
1886    /// # Arguments
1887    ///
1888    /// * `request` - No description provided.
1889    /// * `projectId` - Required. The Project ID (for example, `my-project-123`).
1890    pub fn get_ancestry(
1891        &self,
1892        request: GetAncestryRequest,
1893        project_id: &str,
1894    ) -> ProjectGetAncestryCall<'a, C> {
1895        ProjectGetAncestryCall {
1896            hub: self.hub,
1897            _request: request,
1898            _project_id: project_id.to_string(),
1899            _delegate: Default::default(),
1900            _additional_params: Default::default(),
1901            _scopes: Default::default(),
1902        }
1903    }
1904
1905    /// Create a builder to help you perform the following task:
1906    ///
1907    /// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
1908    ///
1909    /// # Arguments
1910    ///
1911    /// * `request` - No description provided.
1912    /// * `resource` - The name of the resource to start computing the effective `Policy`.
1913    pub fn get_effective_org_policy(
1914        &self,
1915        request: GetEffectiveOrgPolicyRequest,
1916        resource: &str,
1917    ) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
1918        ProjectGetEffectiveOrgPolicyCall {
1919            hub: self.hub,
1920            _request: request,
1921            _resource: resource.to_string(),
1922            _delegate: Default::default(),
1923            _additional_params: Default::default(),
1924            _scopes: Default::default(),
1925        }
1926    }
1927
1928    /// Create a builder to help you perform the following task:
1929    ///
1930    /// Returns the IAM access control policy for the specified Project. Permission is denied if the policy or the resource does not exist. Authorization requires the Google IAM permission `resourcemanager.projects.getIamPolicy` on the project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names).
1931    ///
1932    /// # Arguments
1933    ///
1934    /// * `request` - No description provided.
1935    /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1936    pub fn get_iam_policy(
1937        &self,
1938        request: GetIamPolicyRequest,
1939        resource: &str,
1940    ) -> ProjectGetIamPolicyCall<'a, C> {
1941        ProjectGetIamPolicyCall {
1942            hub: self.hub,
1943            _request: request,
1944            _resource: resource.to_string(),
1945            _delegate: Default::default(),
1946            _additional_params: Default::default(),
1947            _scopes: Default::default(),
1948        }
1949    }
1950
1951    /// Create a builder to help you perform the following task:
1952    ///
1953    /// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
1954    ///
1955    /// # Arguments
1956    ///
1957    /// * `request` - No description provided.
1958    /// * `resource` - Name of the resource the `Policy` is set on.
1959    pub fn get_org_policy(
1960        &self,
1961        request: GetOrgPolicyRequest,
1962        resource: &str,
1963    ) -> ProjectGetOrgPolicyCall<'a, C> {
1964        ProjectGetOrgPolicyCall {
1965            hub: self.hub,
1966            _request: request,
1967            _resource: resource.to_string(),
1968            _delegate: Default::default(),
1969            _additional_params: Default::default(),
1970            _scopes: Default::default(),
1971        }
1972    }
1973
1974    /// Create a builder to help you perform the following task:
1975    ///
1976    /// Lists Projects that the caller has the `resourcemanager.projects.get` permission on and satisfy the specified filter. This method returns Projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the GetProject method. NOTE: If the request filter contains a `parent.type` and `parent.id` and the caller has the `resourcemanager.projects.list` permission on the parent, the results will be drawn from an alternate index which provides more consistent results. In future versions of this API, this List method will be split into List and Search to properly capture the behavioral difference.
1977    pub fn list(&self) -> ProjectListCall<'a, C> {
1978        ProjectListCall {
1979            hub: self.hub,
1980            _page_token: Default::default(),
1981            _page_size: Default::default(),
1982            _filter: Default::default(),
1983            _delegate: Default::default(),
1984            _additional_params: Default::default(),
1985            _scopes: Default::default(),
1986        }
1987    }
1988
1989    /// Create a builder to help you perform the following task:
1990    ///
1991    /// Lists `Constraints` that could be applied on the specified resource.
1992    ///
1993    /// # Arguments
1994    ///
1995    /// * `request` - No description provided.
1996    /// * `resource` - Name of the resource to list `Constraints` for.
1997    pub fn list_available_org_policy_constraints(
1998        &self,
1999        request: ListAvailableOrgPolicyConstraintsRequest,
2000        resource: &str,
2001    ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
2002        ProjectListAvailableOrgPolicyConstraintCall {
2003            hub: self.hub,
2004            _request: request,
2005            _resource: resource.to_string(),
2006            _delegate: Default::default(),
2007            _additional_params: Default::default(),
2008            _scopes: Default::default(),
2009        }
2010    }
2011
2012    /// Create a builder to help you perform the following task:
2013    ///
2014    /// Lists all the `Policies` set for a particular resource.
2015    ///
2016    /// # Arguments
2017    ///
2018    /// * `request` - No description provided.
2019    /// * `resource` - Name of the resource to list Policies for.
2020    pub fn list_org_policies(
2021        &self,
2022        request: ListOrgPoliciesRequest,
2023        resource: &str,
2024    ) -> ProjectListOrgPolicyCall<'a, C> {
2025        ProjectListOrgPolicyCall {
2026            hub: self.hub,
2027            _request: request,
2028            _resource: resource.to_string(),
2029            _delegate: Default::default(),
2030            _additional_params: Default::default(),
2031            _scopes: Default::default(),
2032        }
2033    }
2034
2035    /// Create a builder to help you perform the following task:
2036    ///
2037    /// Sets the IAM access control policy for the specified Project. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. NOTE: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + You can only grant ownership of a project to a member by using the Google Cloud console. Inviting a member will deliver an invitation email that they must accept. An invitation email is not generated if you are granting a role other than owner, or if both the member you are inviting and the project are part of your organization. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible. Authorization requires the Google IAM permission `resourcemanager.projects.setIamPolicy` on the project
2038    ///
2039    /// # Arguments
2040    ///
2041    /// * `request` - No description provided.
2042    /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2043    pub fn set_iam_policy(
2044        &self,
2045        request: SetIamPolicyRequest,
2046        resource: &str,
2047    ) -> ProjectSetIamPolicyCall<'a, C> {
2048        ProjectSetIamPolicyCall {
2049            hub: self.hub,
2050            _request: request,
2051            _resource: resource.to_string(),
2052            _delegate: Default::default(),
2053            _additional_params: Default::default(),
2054            _scopes: Default::default(),
2055        }
2056    }
2057
2058    /// Create a builder to help you perform the following task:
2059    ///
2060    /// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
2061    ///
2062    /// # Arguments
2063    ///
2064    /// * `request` - No description provided.
2065    /// * `resource` - Resource name of the resource to attach the `Policy`.
2066    pub fn set_org_policy(
2067        &self,
2068        request: SetOrgPolicyRequest,
2069        resource: &str,
2070    ) -> ProjectSetOrgPolicyCall<'a, C> {
2071        ProjectSetOrgPolicyCall {
2072            hub: self.hub,
2073            _request: request,
2074            _resource: resource.to_string(),
2075            _delegate: Default::default(),
2076            _additional_params: Default::default(),
2077            _scopes: Default::default(),
2078        }
2079    }
2080
2081    /// Create a builder to help you perform the following task:
2082    ///
2083    /// Returns permissions that a caller has on the specified Project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). There are no permissions required for making this API call.
2084    ///
2085    /// # Arguments
2086    ///
2087    /// * `request` - No description provided.
2088    /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
2089    pub fn test_iam_permissions(
2090        &self,
2091        request: TestIamPermissionsRequest,
2092        resource: &str,
2093    ) -> ProjectTestIamPermissionCall<'a, C> {
2094        ProjectTestIamPermissionCall {
2095            hub: self.hub,
2096            _request: request,
2097            _resource: resource.to_string(),
2098            _delegate: Default::default(),
2099            _additional_params: Default::default(),
2100            _scopes: Default::default(),
2101        }
2102    }
2103
2104    /// Create a builder to help you perform the following task:
2105    ///
2106    /// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have undelete permissions for this Project.
2107    ///
2108    /// # Arguments
2109    ///
2110    /// * `request` - No description provided.
2111    /// * `projectId` - Required. The project ID (for example, `foo-bar-123`).
2112    pub fn undelete(
2113        &self,
2114        request: UndeleteProjectRequest,
2115        project_id: &str,
2116    ) -> ProjectUndeleteCall<'a, C> {
2117        ProjectUndeleteCall {
2118            hub: self.hub,
2119            _request: request,
2120            _project_id: project_id.to_string(),
2121            _delegate: Default::default(),
2122            _additional_params: Default::default(),
2123            _scopes: Default::default(),
2124        }
2125    }
2126
2127    /// Create a builder to help you perform the following task:
2128    ///
2129    /// Updates the attributes of the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have modify permissions for this Project.
2130    ///
2131    /// # Arguments
2132    ///
2133    /// * `request` - No description provided.
2134    /// * `projectId` - The project ID (for example, `my-project-123`). Required.
2135    pub fn update(&self, request: Project, project_id: &str) -> ProjectUpdateCall<'a, C> {
2136        ProjectUpdateCall {
2137            hub: self.hub,
2138            _request: request,
2139            _project_id: project_id.to_string(),
2140            _delegate: Default::default(),
2141            _additional_params: Default::default(),
2142            _scopes: Default::default(),
2143        }
2144    }
2145}
2146
2147// ###################
2148// CallBuilders   ###
2149// #################
2150
2151/// Clears a `Policy` from a resource.
2152///
2153/// A builder for the *clearOrgPolicy* method supported by a *folder* resource.
2154/// It is not used directly, but through a [`FolderMethods`] instance.
2155///
2156/// # Example
2157///
2158/// Instantiate a resource method builder
2159///
2160/// ```test_harness,no_run
2161/// # extern crate hyper;
2162/// # extern crate hyper_rustls;
2163/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
2164/// use cloudresourcemanager1::api::ClearOrgPolicyRequest;
2165/// # async fn dox() {
2166/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2167///
2168/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2169/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2170/// #     secret,
2171/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2172/// # ).build().await.unwrap();
2173///
2174/// # let client = hyper_util::client::legacy::Client::builder(
2175/// #     hyper_util::rt::TokioExecutor::new()
2176/// # )
2177/// # .build(
2178/// #     hyper_rustls::HttpsConnectorBuilder::new()
2179/// #         .with_native_roots()
2180/// #         .unwrap()
2181/// #         .https_or_http()
2182/// #         .enable_http1()
2183/// #         .build()
2184/// # );
2185/// # let mut hub = CloudResourceManager::new(client, auth);
2186/// // As the method needs a request, you would usually fill it with the desired information
2187/// // into the respective structure. Some of the parts shown here might not be applicable !
2188/// // Values shown here are possibly random and not representative !
2189/// let mut req = ClearOrgPolicyRequest::default();
2190///
2191/// // You can configure optional parameters by calling the respective setters at will, and
2192/// // execute the final call using `doit()`.
2193/// // Values shown here are possibly random and not representative !
2194/// let result = hub.folders().clear_org_policy(req, "resource")
2195///              .doit().await;
2196/// # }
2197/// ```
2198pub struct FolderClearOrgPolicyCall<'a, C>
2199where
2200    C: 'a,
2201{
2202    hub: &'a CloudResourceManager<C>,
2203    _request: ClearOrgPolicyRequest,
2204    _resource: String,
2205    _delegate: Option<&'a mut dyn common::Delegate>,
2206    _additional_params: HashMap<String, String>,
2207    _scopes: BTreeSet<String>,
2208}
2209
2210impl<'a, C> common::CallBuilder for FolderClearOrgPolicyCall<'a, C> {}
2211
2212impl<'a, C> FolderClearOrgPolicyCall<'a, C>
2213where
2214    C: common::Connector,
2215{
2216    /// Perform the operation you have build so far.
2217    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2218        use std::borrow::Cow;
2219        use std::io::{Read, Seek};
2220
2221        use common::{url::Params, ToParts};
2222        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2223
2224        let mut dd = common::DefaultDelegate;
2225        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2226        dlg.begin(common::MethodInfo {
2227            id: "cloudresourcemanager.folders.clearOrgPolicy",
2228            http_method: hyper::Method::POST,
2229        });
2230
2231        for &field in ["alt", "resource"].iter() {
2232            if self._additional_params.contains_key(field) {
2233                dlg.finished(false);
2234                return Err(common::Error::FieldClash(field));
2235            }
2236        }
2237
2238        let mut params = Params::with_capacity(4 + self._additional_params.len());
2239        params.push("resource", self._resource);
2240
2241        params.extend(self._additional_params.iter());
2242
2243        params.push("alt", "json");
2244        let mut url = self.hub._base_url.clone() + "v1/{+resource}:clearOrgPolicy";
2245        if self._scopes.is_empty() {
2246            self._scopes
2247                .insert(Scope::CloudPlatform.as_ref().to_string());
2248        }
2249
2250        #[allow(clippy::single_element_loop)]
2251        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2252            url = params.uri_replacement(url, param_name, find_this, true);
2253        }
2254        {
2255            let to_remove = ["resource"];
2256            params.remove_params(&to_remove);
2257        }
2258
2259        let url = params.parse_with_url(&url);
2260
2261        let mut json_mime_type = mime::APPLICATION_JSON;
2262        let mut request_value_reader = {
2263            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2264            common::remove_json_null_values(&mut value);
2265            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2266            serde_json::to_writer(&mut dst, &value).unwrap();
2267            dst
2268        };
2269        let request_size = request_value_reader
2270            .seek(std::io::SeekFrom::End(0))
2271            .unwrap();
2272        request_value_reader
2273            .seek(std::io::SeekFrom::Start(0))
2274            .unwrap();
2275
2276        loop {
2277            let token = match self
2278                .hub
2279                .auth
2280                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2281                .await
2282            {
2283                Ok(token) => token,
2284                Err(e) => match dlg.token(e) {
2285                    Ok(token) => token,
2286                    Err(e) => {
2287                        dlg.finished(false);
2288                        return Err(common::Error::MissingToken(e));
2289                    }
2290                },
2291            };
2292            request_value_reader
2293                .seek(std::io::SeekFrom::Start(0))
2294                .unwrap();
2295            let mut req_result = {
2296                let client = &self.hub.client;
2297                dlg.pre_request();
2298                let mut req_builder = hyper::Request::builder()
2299                    .method(hyper::Method::POST)
2300                    .uri(url.as_str())
2301                    .header(USER_AGENT, self.hub._user_agent.clone());
2302
2303                if let Some(token) = token.as_ref() {
2304                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2305                }
2306
2307                let request = req_builder
2308                    .header(CONTENT_TYPE, json_mime_type.to_string())
2309                    .header(CONTENT_LENGTH, request_size as u64)
2310                    .body(common::to_body(
2311                        request_value_reader.get_ref().clone().into(),
2312                    ));
2313
2314                client.request(request.unwrap()).await
2315            };
2316
2317            match req_result {
2318                Err(err) => {
2319                    if let common::Retry::After(d) = dlg.http_error(&err) {
2320                        sleep(d).await;
2321                        continue;
2322                    }
2323                    dlg.finished(false);
2324                    return Err(common::Error::HttpError(err));
2325                }
2326                Ok(res) => {
2327                    let (mut parts, body) = res.into_parts();
2328                    let mut body = common::Body::new(body);
2329                    if !parts.status.is_success() {
2330                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2331                        let error = serde_json::from_str(&common::to_string(&bytes));
2332                        let response = common::to_response(parts, bytes.into());
2333
2334                        if let common::Retry::After(d) =
2335                            dlg.http_failure(&response, error.as_ref().ok())
2336                        {
2337                            sleep(d).await;
2338                            continue;
2339                        }
2340
2341                        dlg.finished(false);
2342
2343                        return Err(match error {
2344                            Ok(value) => common::Error::BadRequest(value),
2345                            _ => common::Error::Failure(response),
2346                        });
2347                    }
2348                    let response = {
2349                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2350                        let encoded = common::to_string(&bytes);
2351                        match serde_json::from_str(&encoded) {
2352                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2353                            Err(error) => {
2354                                dlg.response_json_decode_error(&encoded, &error);
2355                                return Err(common::Error::JsonDecodeError(
2356                                    encoded.to_string(),
2357                                    error,
2358                                ));
2359                            }
2360                        }
2361                    };
2362
2363                    dlg.finished(true);
2364                    return Ok(response);
2365                }
2366            }
2367        }
2368    }
2369
2370    ///
2371    /// Sets the *request* property to the given value.
2372    ///
2373    /// Even though the property as already been set when instantiating this call,
2374    /// we provide this method for API completeness.
2375    pub fn request(mut self, new_value: ClearOrgPolicyRequest) -> FolderClearOrgPolicyCall<'a, C> {
2376        self._request = new_value;
2377        self
2378    }
2379    /// Name of the resource for the `Policy` to clear.
2380    ///
2381    /// Sets the *resource* path property to the given value.
2382    ///
2383    /// Even though the property as already been set when instantiating this call,
2384    /// we provide this method for API completeness.
2385    pub fn resource(mut self, new_value: &str) -> FolderClearOrgPolicyCall<'a, C> {
2386        self._resource = new_value.to_string();
2387        self
2388    }
2389    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2390    /// while executing the actual API request.
2391    ///
2392    /// ````text
2393    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2394    /// ````
2395    ///
2396    /// Sets the *delegate* property to the given value.
2397    pub fn delegate(
2398        mut self,
2399        new_value: &'a mut dyn common::Delegate,
2400    ) -> FolderClearOrgPolicyCall<'a, C> {
2401        self._delegate = Some(new_value);
2402        self
2403    }
2404
2405    /// Set any additional parameter of the query string used in the request.
2406    /// It should be used to set parameters which are not yet available through their own
2407    /// setters.
2408    ///
2409    /// Please note that this method must not be used to set any of the known parameters
2410    /// which have their own setter method. If done anyway, the request will fail.
2411    ///
2412    /// # Additional Parameters
2413    ///
2414    /// * *$.xgafv* (query-string) - V1 error format.
2415    /// * *access_token* (query-string) - OAuth access token.
2416    /// * *alt* (query-string) - Data format for response.
2417    /// * *callback* (query-string) - JSONP
2418    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2419    /// * *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.
2420    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2421    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2422    /// * *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.
2423    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2424    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2425    pub fn param<T>(mut self, name: T, value: T) -> FolderClearOrgPolicyCall<'a, C>
2426    where
2427        T: AsRef<str>,
2428    {
2429        self._additional_params
2430            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2431        self
2432    }
2433
2434    /// Identifies the authorization scope for the method you are building.
2435    ///
2436    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2437    /// [`Scope::CloudPlatform`].
2438    ///
2439    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2440    /// tokens for more than one scope.
2441    ///
2442    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2443    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2444    /// sufficient, a read-write scope will do as well.
2445    pub fn add_scope<St>(mut self, scope: St) -> FolderClearOrgPolicyCall<'a, C>
2446    where
2447        St: AsRef<str>,
2448    {
2449        self._scopes.insert(String::from(scope.as_ref()));
2450        self
2451    }
2452    /// Identifies the authorization scope(s) for the method you are building.
2453    ///
2454    /// See [`Self::add_scope()`] for details.
2455    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderClearOrgPolicyCall<'a, C>
2456    where
2457        I: IntoIterator<Item = St>,
2458        St: AsRef<str>,
2459    {
2460        self._scopes
2461            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2462        self
2463    }
2464
2465    /// Removes all scopes, and no default scope will be used either.
2466    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2467    /// for details).
2468    pub fn clear_scopes(mut self) -> FolderClearOrgPolicyCall<'a, C> {
2469        self._scopes.clear();
2470        self
2471    }
2472}
2473
2474/// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
2475///
2476/// A builder for the *getEffectiveOrgPolicy* method supported by a *folder* resource.
2477/// It is not used directly, but through a [`FolderMethods`] instance.
2478///
2479/// # Example
2480///
2481/// Instantiate a resource method builder
2482///
2483/// ```test_harness,no_run
2484/// # extern crate hyper;
2485/// # extern crate hyper_rustls;
2486/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
2487/// use cloudresourcemanager1::api::GetEffectiveOrgPolicyRequest;
2488/// # async fn dox() {
2489/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2490///
2491/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2492/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2493/// #     secret,
2494/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2495/// # ).build().await.unwrap();
2496///
2497/// # let client = hyper_util::client::legacy::Client::builder(
2498/// #     hyper_util::rt::TokioExecutor::new()
2499/// # )
2500/// # .build(
2501/// #     hyper_rustls::HttpsConnectorBuilder::new()
2502/// #         .with_native_roots()
2503/// #         .unwrap()
2504/// #         .https_or_http()
2505/// #         .enable_http1()
2506/// #         .build()
2507/// # );
2508/// # let mut hub = CloudResourceManager::new(client, auth);
2509/// // As the method needs a request, you would usually fill it with the desired information
2510/// // into the respective structure. Some of the parts shown here might not be applicable !
2511/// // Values shown here are possibly random and not representative !
2512/// let mut req = GetEffectiveOrgPolicyRequest::default();
2513///
2514/// // You can configure optional parameters by calling the respective setters at will, and
2515/// // execute the final call using `doit()`.
2516/// // Values shown here are possibly random and not representative !
2517/// let result = hub.folders().get_effective_org_policy(req, "resource")
2518///              .doit().await;
2519/// # }
2520/// ```
2521pub struct FolderGetEffectiveOrgPolicyCall<'a, C>
2522where
2523    C: 'a,
2524{
2525    hub: &'a CloudResourceManager<C>,
2526    _request: GetEffectiveOrgPolicyRequest,
2527    _resource: String,
2528    _delegate: Option<&'a mut dyn common::Delegate>,
2529    _additional_params: HashMap<String, String>,
2530    _scopes: BTreeSet<String>,
2531}
2532
2533impl<'a, C> common::CallBuilder for FolderGetEffectiveOrgPolicyCall<'a, C> {}
2534
2535impl<'a, C> FolderGetEffectiveOrgPolicyCall<'a, C>
2536where
2537    C: common::Connector,
2538{
2539    /// Perform the operation you have build so far.
2540    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
2541        use std::borrow::Cow;
2542        use std::io::{Read, Seek};
2543
2544        use common::{url::Params, ToParts};
2545        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2546
2547        let mut dd = common::DefaultDelegate;
2548        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2549        dlg.begin(common::MethodInfo {
2550            id: "cloudresourcemanager.folders.getEffectiveOrgPolicy",
2551            http_method: hyper::Method::POST,
2552        });
2553
2554        for &field in ["alt", "resource"].iter() {
2555            if self._additional_params.contains_key(field) {
2556                dlg.finished(false);
2557                return Err(common::Error::FieldClash(field));
2558            }
2559        }
2560
2561        let mut params = Params::with_capacity(4 + self._additional_params.len());
2562        params.push("resource", self._resource);
2563
2564        params.extend(self._additional_params.iter());
2565
2566        params.push("alt", "json");
2567        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getEffectiveOrgPolicy";
2568        if self._scopes.is_empty() {
2569            self._scopes
2570                .insert(Scope::CloudPlatform.as_ref().to_string());
2571        }
2572
2573        #[allow(clippy::single_element_loop)]
2574        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2575            url = params.uri_replacement(url, param_name, find_this, true);
2576        }
2577        {
2578            let to_remove = ["resource"];
2579            params.remove_params(&to_remove);
2580        }
2581
2582        let url = params.parse_with_url(&url);
2583
2584        let mut json_mime_type = mime::APPLICATION_JSON;
2585        let mut request_value_reader = {
2586            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2587            common::remove_json_null_values(&mut value);
2588            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2589            serde_json::to_writer(&mut dst, &value).unwrap();
2590            dst
2591        };
2592        let request_size = request_value_reader
2593            .seek(std::io::SeekFrom::End(0))
2594            .unwrap();
2595        request_value_reader
2596            .seek(std::io::SeekFrom::Start(0))
2597            .unwrap();
2598
2599        loop {
2600            let token = match self
2601                .hub
2602                .auth
2603                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2604                .await
2605            {
2606                Ok(token) => token,
2607                Err(e) => match dlg.token(e) {
2608                    Ok(token) => token,
2609                    Err(e) => {
2610                        dlg.finished(false);
2611                        return Err(common::Error::MissingToken(e));
2612                    }
2613                },
2614            };
2615            request_value_reader
2616                .seek(std::io::SeekFrom::Start(0))
2617                .unwrap();
2618            let mut req_result = {
2619                let client = &self.hub.client;
2620                dlg.pre_request();
2621                let mut req_builder = hyper::Request::builder()
2622                    .method(hyper::Method::POST)
2623                    .uri(url.as_str())
2624                    .header(USER_AGENT, self.hub._user_agent.clone());
2625
2626                if let Some(token) = token.as_ref() {
2627                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2628                }
2629
2630                let request = req_builder
2631                    .header(CONTENT_TYPE, json_mime_type.to_string())
2632                    .header(CONTENT_LENGTH, request_size as u64)
2633                    .body(common::to_body(
2634                        request_value_reader.get_ref().clone().into(),
2635                    ));
2636
2637                client.request(request.unwrap()).await
2638            };
2639
2640            match req_result {
2641                Err(err) => {
2642                    if let common::Retry::After(d) = dlg.http_error(&err) {
2643                        sleep(d).await;
2644                        continue;
2645                    }
2646                    dlg.finished(false);
2647                    return Err(common::Error::HttpError(err));
2648                }
2649                Ok(res) => {
2650                    let (mut parts, body) = res.into_parts();
2651                    let mut body = common::Body::new(body);
2652                    if !parts.status.is_success() {
2653                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2654                        let error = serde_json::from_str(&common::to_string(&bytes));
2655                        let response = common::to_response(parts, bytes.into());
2656
2657                        if let common::Retry::After(d) =
2658                            dlg.http_failure(&response, error.as_ref().ok())
2659                        {
2660                            sleep(d).await;
2661                            continue;
2662                        }
2663
2664                        dlg.finished(false);
2665
2666                        return Err(match error {
2667                            Ok(value) => common::Error::BadRequest(value),
2668                            _ => common::Error::Failure(response),
2669                        });
2670                    }
2671                    let response = {
2672                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2673                        let encoded = common::to_string(&bytes);
2674                        match serde_json::from_str(&encoded) {
2675                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2676                            Err(error) => {
2677                                dlg.response_json_decode_error(&encoded, &error);
2678                                return Err(common::Error::JsonDecodeError(
2679                                    encoded.to_string(),
2680                                    error,
2681                                ));
2682                            }
2683                        }
2684                    };
2685
2686                    dlg.finished(true);
2687                    return Ok(response);
2688                }
2689            }
2690        }
2691    }
2692
2693    ///
2694    /// Sets the *request* property to the given value.
2695    ///
2696    /// Even though the property as already been set when instantiating this call,
2697    /// we provide this method for API completeness.
2698    pub fn request(
2699        mut self,
2700        new_value: GetEffectiveOrgPolicyRequest,
2701    ) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2702        self._request = new_value;
2703        self
2704    }
2705    /// The name of the resource to start computing the effective `Policy`.
2706    ///
2707    /// Sets the *resource* path property to the given value.
2708    ///
2709    /// Even though the property as already been set when instantiating this call,
2710    /// we provide this method for API completeness.
2711    pub fn resource(mut self, new_value: &str) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2712        self._resource = new_value.to_string();
2713        self
2714    }
2715    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2716    /// while executing the actual API request.
2717    ///
2718    /// ````text
2719    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2720    /// ````
2721    ///
2722    /// Sets the *delegate* property to the given value.
2723    pub fn delegate(
2724        mut self,
2725        new_value: &'a mut dyn common::Delegate,
2726    ) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2727        self._delegate = Some(new_value);
2728        self
2729    }
2730
2731    /// Set any additional parameter of the query string used in the request.
2732    /// It should be used to set parameters which are not yet available through their own
2733    /// setters.
2734    ///
2735    /// Please note that this method must not be used to set any of the known parameters
2736    /// which have their own setter method. If done anyway, the request will fail.
2737    ///
2738    /// # Additional Parameters
2739    ///
2740    /// * *$.xgafv* (query-string) - V1 error format.
2741    /// * *access_token* (query-string) - OAuth access token.
2742    /// * *alt* (query-string) - Data format for response.
2743    /// * *callback* (query-string) - JSONP
2744    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2745    /// * *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.
2746    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2747    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2748    /// * *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.
2749    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2750    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2751    pub fn param<T>(mut self, name: T, value: T) -> FolderGetEffectiveOrgPolicyCall<'a, C>
2752    where
2753        T: AsRef<str>,
2754    {
2755        self._additional_params
2756            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2757        self
2758    }
2759
2760    /// Identifies the authorization scope for the method you are building.
2761    ///
2762    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2763    /// [`Scope::CloudPlatform`].
2764    ///
2765    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2766    /// tokens for more than one scope.
2767    ///
2768    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2769    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2770    /// sufficient, a read-write scope will do as well.
2771    pub fn add_scope<St>(mut self, scope: St) -> FolderGetEffectiveOrgPolicyCall<'a, C>
2772    where
2773        St: AsRef<str>,
2774    {
2775        self._scopes.insert(String::from(scope.as_ref()));
2776        self
2777    }
2778    /// Identifies the authorization scope(s) for the method you are building.
2779    ///
2780    /// See [`Self::add_scope()`] for details.
2781    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetEffectiveOrgPolicyCall<'a, C>
2782    where
2783        I: IntoIterator<Item = St>,
2784        St: AsRef<str>,
2785    {
2786        self._scopes
2787            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2788        self
2789    }
2790
2791    /// Removes all scopes, and no default scope will be used either.
2792    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2793    /// for details).
2794    pub fn clear_scopes(mut self) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2795        self._scopes.clear();
2796        self
2797    }
2798}
2799
2800/// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
2801///
2802/// A builder for the *getOrgPolicy* method supported by a *folder* resource.
2803/// It is not used directly, but through a [`FolderMethods`] instance.
2804///
2805/// # Example
2806///
2807/// Instantiate a resource method builder
2808///
2809/// ```test_harness,no_run
2810/// # extern crate hyper;
2811/// # extern crate hyper_rustls;
2812/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
2813/// use cloudresourcemanager1::api::GetOrgPolicyRequest;
2814/// # async fn dox() {
2815/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2816///
2817/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2818/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2819/// #     secret,
2820/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2821/// # ).build().await.unwrap();
2822///
2823/// # let client = hyper_util::client::legacy::Client::builder(
2824/// #     hyper_util::rt::TokioExecutor::new()
2825/// # )
2826/// # .build(
2827/// #     hyper_rustls::HttpsConnectorBuilder::new()
2828/// #         .with_native_roots()
2829/// #         .unwrap()
2830/// #         .https_or_http()
2831/// #         .enable_http1()
2832/// #         .build()
2833/// # );
2834/// # let mut hub = CloudResourceManager::new(client, auth);
2835/// // As the method needs a request, you would usually fill it with the desired information
2836/// // into the respective structure. Some of the parts shown here might not be applicable !
2837/// // Values shown here are possibly random and not representative !
2838/// let mut req = GetOrgPolicyRequest::default();
2839///
2840/// // You can configure optional parameters by calling the respective setters at will, and
2841/// // execute the final call using `doit()`.
2842/// // Values shown here are possibly random and not representative !
2843/// let result = hub.folders().get_org_policy(req, "resource")
2844///              .doit().await;
2845/// # }
2846/// ```
2847pub struct FolderGetOrgPolicyCall<'a, C>
2848where
2849    C: 'a,
2850{
2851    hub: &'a CloudResourceManager<C>,
2852    _request: GetOrgPolicyRequest,
2853    _resource: String,
2854    _delegate: Option<&'a mut dyn common::Delegate>,
2855    _additional_params: HashMap<String, String>,
2856    _scopes: BTreeSet<String>,
2857}
2858
2859impl<'a, C> common::CallBuilder for FolderGetOrgPolicyCall<'a, C> {}
2860
2861impl<'a, C> FolderGetOrgPolicyCall<'a, C>
2862where
2863    C: common::Connector,
2864{
2865    /// Perform the operation you have build so far.
2866    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
2867        use std::borrow::Cow;
2868        use std::io::{Read, Seek};
2869
2870        use common::{url::Params, ToParts};
2871        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2872
2873        let mut dd = common::DefaultDelegate;
2874        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2875        dlg.begin(common::MethodInfo {
2876            id: "cloudresourcemanager.folders.getOrgPolicy",
2877            http_method: hyper::Method::POST,
2878        });
2879
2880        for &field in ["alt", "resource"].iter() {
2881            if self._additional_params.contains_key(field) {
2882                dlg.finished(false);
2883                return Err(common::Error::FieldClash(field));
2884            }
2885        }
2886
2887        let mut params = Params::with_capacity(4 + self._additional_params.len());
2888        params.push("resource", self._resource);
2889
2890        params.extend(self._additional_params.iter());
2891
2892        params.push("alt", "json");
2893        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getOrgPolicy";
2894        if self._scopes.is_empty() {
2895            self._scopes
2896                .insert(Scope::CloudPlatform.as_ref().to_string());
2897        }
2898
2899        #[allow(clippy::single_element_loop)]
2900        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2901            url = params.uri_replacement(url, param_name, find_this, true);
2902        }
2903        {
2904            let to_remove = ["resource"];
2905            params.remove_params(&to_remove);
2906        }
2907
2908        let url = params.parse_with_url(&url);
2909
2910        let mut json_mime_type = mime::APPLICATION_JSON;
2911        let mut request_value_reader = {
2912            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2913            common::remove_json_null_values(&mut value);
2914            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2915            serde_json::to_writer(&mut dst, &value).unwrap();
2916            dst
2917        };
2918        let request_size = request_value_reader
2919            .seek(std::io::SeekFrom::End(0))
2920            .unwrap();
2921        request_value_reader
2922            .seek(std::io::SeekFrom::Start(0))
2923            .unwrap();
2924
2925        loop {
2926            let token = match self
2927                .hub
2928                .auth
2929                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2930                .await
2931            {
2932                Ok(token) => token,
2933                Err(e) => match dlg.token(e) {
2934                    Ok(token) => token,
2935                    Err(e) => {
2936                        dlg.finished(false);
2937                        return Err(common::Error::MissingToken(e));
2938                    }
2939                },
2940            };
2941            request_value_reader
2942                .seek(std::io::SeekFrom::Start(0))
2943                .unwrap();
2944            let mut req_result = {
2945                let client = &self.hub.client;
2946                dlg.pre_request();
2947                let mut req_builder = hyper::Request::builder()
2948                    .method(hyper::Method::POST)
2949                    .uri(url.as_str())
2950                    .header(USER_AGENT, self.hub._user_agent.clone());
2951
2952                if let Some(token) = token.as_ref() {
2953                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2954                }
2955
2956                let request = req_builder
2957                    .header(CONTENT_TYPE, json_mime_type.to_string())
2958                    .header(CONTENT_LENGTH, request_size as u64)
2959                    .body(common::to_body(
2960                        request_value_reader.get_ref().clone().into(),
2961                    ));
2962
2963                client.request(request.unwrap()).await
2964            };
2965
2966            match req_result {
2967                Err(err) => {
2968                    if let common::Retry::After(d) = dlg.http_error(&err) {
2969                        sleep(d).await;
2970                        continue;
2971                    }
2972                    dlg.finished(false);
2973                    return Err(common::Error::HttpError(err));
2974                }
2975                Ok(res) => {
2976                    let (mut parts, body) = res.into_parts();
2977                    let mut body = common::Body::new(body);
2978                    if !parts.status.is_success() {
2979                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2980                        let error = serde_json::from_str(&common::to_string(&bytes));
2981                        let response = common::to_response(parts, bytes.into());
2982
2983                        if let common::Retry::After(d) =
2984                            dlg.http_failure(&response, error.as_ref().ok())
2985                        {
2986                            sleep(d).await;
2987                            continue;
2988                        }
2989
2990                        dlg.finished(false);
2991
2992                        return Err(match error {
2993                            Ok(value) => common::Error::BadRequest(value),
2994                            _ => common::Error::Failure(response),
2995                        });
2996                    }
2997                    let response = {
2998                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2999                        let encoded = common::to_string(&bytes);
3000                        match serde_json::from_str(&encoded) {
3001                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3002                            Err(error) => {
3003                                dlg.response_json_decode_error(&encoded, &error);
3004                                return Err(common::Error::JsonDecodeError(
3005                                    encoded.to_string(),
3006                                    error,
3007                                ));
3008                            }
3009                        }
3010                    };
3011
3012                    dlg.finished(true);
3013                    return Ok(response);
3014                }
3015            }
3016        }
3017    }
3018
3019    ///
3020    /// Sets the *request* property to the given value.
3021    ///
3022    /// Even though the property as already been set when instantiating this call,
3023    /// we provide this method for API completeness.
3024    pub fn request(mut self, new_value: GetOrgPolicyRequest) -> FolderGetOrgPolicyCall<'a, C> {
3025        self._request = new_value;
3026        self
3027    }
3028    /// Name of the resource the `Policy` is set on.
3029    ///
3030    /// Sets the *resource* path property to the given value.
3031    ///
3032    /// Even though the property as already been set when instantiating this call,
3033    /// we provide this method for API completeness.
3034    pub fn resource(mut self, new_value: &str) -> FolderGetOrgPolicyCall<'a, C> {
3035        self._resource = new_value.to_string();
3036        self
3037    }
3038    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3039    /// while executing the actual API request.
3040    ///
3041    /// ````text
3042    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3043    /// ````
3044    ///
3045    /// Sets the *delegate* property to the given value.
3046    pub fn delegate(
3047        mut self,
3048        new_value: &'a mut dyn common::Delegate,
3049    ) -> FolderGetOrgPolicyCall<'a, C> {
3050        self._delegate = Some(new_value);
3051        self
3052    }
3053
3054    /// Set any additional parameter of the query string used in the request.
3055    /// It should be used to set parameters which are not yet available through their own
3056    /// setters.
3057    ///
3058    /// Please note that this method must not be used to set any of the known parameters
3059    /// which have their own setter method. If done anyway, the request will fail.
3060    ///
3061    /// # Additional Parameters
3062    ///
3063    /// * *$.xgafv* (query-string) - V1 error format.
3064    /// * *access_token* (query-string) - OAuth access token.
3065    /// * *alt* (query-string) - Data format for response.
3066    /// * *callback* (query-string) - JSONP
3067    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3068    /// * *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.
3069    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3070    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3071    /// * *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.
3072    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3073    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3074    pub fn param<T>(mut self, name: T, value: T) -> FolderGetOrgPolicyCall<'a, C>
3075    where
3076        T: AsRef<str>,
3077    {
3078        self._additional_params
3079            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3080        self
3081    }
3082
3083    /// Identifies the authorization scope for the method you are building.
3084    ///
3085    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3086    /// [`Scope::CloudPlatform`].
3087    ///
3088    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3089    /// tokens for more than one scope.
3090    ///
3091    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3092    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3093    /// sufficient, a read-write scope will do as well.
3094    pub fn add_scope<St>(mut self, scope: St) -> FolderGetOrgPolicyCall<'a, C>
3095    where
3096        St: AsRef<str>,
3097    {
3098        self._scopes.insert(String::from(scope.as_ref()));
3099        self
3100    }
3101    /// Identifies the authorization scope(s) for the method you are building.
3102    ///
3103    /// See [`Self::add_scope()`] for details.
3104    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetOrgPolicyCall<'a, C>
3105    where
3106        I: IntoIterator<Item = St>,
3107        St: AsRef<str>,
3108    {
3109        self._scopes
3110            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3111        self
3112    }
3113
3114    /// Removes all scopes, and no default scope will be used either.
3115    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3116    /// for details).
3117    pub fn clear_scopes(mut self) -> FolderGetOrgPolicyCall<'a, C> {
3118        self._scopes.clear();
3119        self
3120    }
3121}
3122
3123/// Lists `Constraints` that could be applied on the specified resource.
3124///
3125/// A builder for the *listAvailableOrgPolicyConstraints* method supported by a *folder* resource.
3126/// It is not used directly, but through a [`FolderMethods`] instance.
3127///
3128/// # Example
3129///
3130/// Instantiate a resource method builder
3131///
3132/// ```test_harness,no_run
3133/// # extern crate hyper;
3134/// # extern crate hyper_rustls;
3135/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
3136/// use cloudresourcemanager1::api::ListAvailableOrgPolicyConstraintsRequest;
3137/// # async fn dox() {
3138/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3139///
3140/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3141/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3142/// #     secret,
3143/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3144/// # ).build().await.unwrap();
3145///
3146/// # let client = hyper_util::client::legacy::Client::builder(
3147/// #     hyper_util::rt::TokioExecutor::new()
3148/// # )
3149/// # .build(
3150/// #     hyper_rustls::HttpsConnectorBuilder::new()
3151/// #         .with_native_roots()
3152/// #         .unwrap()
3153/// #         .https_or_http()
3154/// #         .enable_http1()
3155/// #         .build()
3156/// # );
3157/// # let mut hub = CloudResourceManager::new(client, auth);
3158/// // As the method needs a request, you would usually fill it with the desired information
3159/// // into the respective structure. Some of the parts shown here might not be applicable !
3160/// // Values shown here are possibly random and not representative !
3161/// let mut req = ListAvailableOrgPolicyConstraintsRequest::default();
3162///
3163/// // You can configure optional parameters by calling the respective setters at will, and
3164/// // execute the final call using `doit()`.
3165/// // Values shown here are possibly random and not representative !
3166/// let result = hub.folders().list_available_org_policy_constraints(req, "resource")
3167///              .doit().await;
3168/// # }
3169/// ```
3170pub struct FolderListAvailableOrgPolicyConstraintCall<'a, C>
3171where
3172    C: 'a,
3173{
3174    hub: &'a CloudResourceManager<C>,
3175    _request: ListAvailableOrgPolicyConstraintsRequest,
3176    _resource: String,
3177    _delegate: Option<&'a mut dyn common::Delegate>,
3178    _additional_params: HashMap<String, String>,
3179    _scopes: BTreeSet<String>,
3180}
3181
3182impl<'a, C> common::CallBuilder for FolderListAvailableOrgPolicyConstraintCall<'a, C> {}
3183
3184impl<'a, C> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3185where
3186    C: common::Connector,
3187{
3188    /// Perform the operation you have build so far.
3189    pub async fn doit(
3190        mut self,
3191    ) -> common::Result<(common::Response, ListAvailableOrgPolicyConstraintsResponse)> {
3192        use std::borrow::Cow;
3193        use std::io::{Read, Seek};
3194
3195        use common::{url::Params, ToParts};
3196        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3197
3198        let mut dd = common::DefaultDelegate;
3199        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3200        dlg.begin(common::MethodInfo {
3201            id: "cloudresourcemanager.folders.listAvailableOrgPolicyConstraints",
3202            http_method: hyper::Method::POST,
3203        });
3204
3205        for &field in ["alt", "resource"].iter() {
3206            if self._additional_params.contains_key(field) {
3207                dlg.finished(false);
3208                return Err(common::Error::FieldClash(field));
3209            }
3210        }
3211
3212        let mut params = Params::with_capacity(4 + self._additional_params.len());
3213        params.push("resource", self._resource);
3214
3215        params.extend(self._additional_params.iter());
3216
3217        params.push("alt", "json");
3218        let mut url =
3219            self.hub._base_url.clone() + "v1/{+resource}:listAvailableOrgPolicyConstraints";
3220        if self._scopes.is_empty() {
3221            self._scopes
3222                .insert(Scope::CloudPlatform.as_ref().to_string());
3223        }
3224
3225        #[allow(clippy::single_element_loop)]
3226        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3227            url = params.uri_replacement(url, param_name, find_this, true);
3228        }
3229        {
3230            let to_remove = ["resource"];
3231            params.remove_params(&to_remove);
3232        }
3233
3234        let url = params.parse_with_url(&url);
3235
3236        let mut json_mime_type = mime::APPLICATION_JSON;
3237        let mut request_value_reader = {
3238            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3239            common::remove_json_null_values(&mut value);
3240            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3241            serde_json::to_writer(&mut dst, &value).unwrap();
3242            dst
3243        };
3244        let request_size = request_value_reader
3245            .seek(std::io::SeekFrom::End(0))
3246            .unwrap();
3247        request_value_reader
3248            .seek(std::io::SeekFrom::Start(0))
3249            .unwrap();
3250
3251        loop {
3252            let token = match self
3253                .hub
3254                .auth
3255                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3256                .await
3257            {
3258                Ok(token) => token,
3259                Err(e) => match dlg.token(e) {
3260                    Ok(token) => token,
3261                    Err(e) => {
3262                        dlg.finished(false);
3263                        return Err(common::Error::MissingToken(e));
3264                    }
3265                },
3266            };
3267            request_value_reader
3268                .seek(std::io::SeekFrom::Start(0))
3269                .unwrap();
3270            let mut req_result = {
3271                let client = &self.hub.client;
3272                dlg.pre_request();
3273                let mut req_builder = hyper::Request::builder()
3274                    .method(hyper::Method::POST)
3275                    .uri(url.as_str())
3276                    .header(USER_AGENT, self.hub._user_agent.clone());
3277
3278                if let Some(token) = token.as_ref() {
3279                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3280                }
3281
3282                let request = req_builder
3283                    .header(CONTENT_TYPE, json_mime_type.to_string())
3284                    .header(CONTENT_LENGTH, request_size as u64)
3285                    .body(common::to_body(
3286                        request_value_reader.get_ref().clone().into(),
3287                    ));
3288
3289                client.request(request.unwrap()).await
3290            };
3291
3292            match req_result {
3293                Err(err) => {
3294                    if let common::Retry::After(d) = dlg.http_error(&err) {
3295                        sleep(d).await;
3296                        continue;
3297                    }
3298                    dlg.finished(false);
3299                    return Err(common::Error::HttpError(err));
3300                }
3301                Ok(res) => {
3302                    let (mut parts, body) = res.into_parts();
3303                    let mut body = common::Body::new(body);
3304                    if !parts.status.is_success() {
3305                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3306                        let error = serde_json::from_str(&common::to_string(&bytes));
3307                        let response = common::to_response(parts, bytes.into());
3308
3309                        if let common::Retry::After(d) =
3310                            dlg.http_failure(&response, error.as_ref().ok())
3311                        {
3312                            sleep(d).await;
3313                            continue;
3314                        }
3315
3316                        dlg.finished(false);
3317
3318                        return Err(match error {
3319                            Ok(value) => common::Error::BadRequest(value),
3320                            _ => common::Error::Failure(response),
3321                        });
3322                    }
3323                    let response = {
3324                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3325                        let encoded = common::to_string(&bytes);
3326                        match serde_json::from_str(&encoded) {
3327                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3328                            Err(error) => {
3329                                dlg.response_json_decode_error(&encoded, &error);
3330                                return Err(common::Error::JsonDecodeError(
3331                                    encoded.to_string(),
3332                                    error,
3333                                ));
3334                            }
3335                        }
3336                    };
3337
3338                    dlg.finished(true);
3339                    return Ok(response);
3340                }
3341            }
3342        }
3343    }
3344
3345    ///
3346    /// Sets the *request* property to the given value.
3347    ///
3348    /// Even though the property as already been set when instantiating this call,
3349    /// we provide this method for API completeness.
3350    pub fn request(
3351        mut self,
3352        new_value: ListAvailableOrgPolicyConstraintsRequest,
3353    ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3354        self._request = new_value;
3355        self
3356    }
3357    /// Name of the resource to list `Constraints` for.
3358    ///
3359    /// Sets the *resource* path property to the given value.
3360    ///
3361    /// Even though the property as already been set when instantiating this call,
3362    /// we provide this method for API completeness.
3363    pub fn resource(
3364        mut self,
3365        new_value: &str,
3366    ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3367        self._resource = new_value.to_string();
3368        self
3369    }
3370    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3371    /// while executing the actual API request.
3372    ///
3373    /// ````text
3374    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3375    /// ````
3376    ///
3377    /// Sets the *delegate* property to the given value.
3378    pub fn delegate(
3379        mut self,
3380        new_value: &'a mut dyn common::Delegate,
3381    ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3382        self._delegate = Some(new_value);
3383        self
3384    }
3385
3386    /// Set any additional parameter of the query string used in the request.
3387    /// It should be used to set parameters which are not yet available through their own
3388    /// setters.
3389    ///
3390    /// Please note that this method must not be used to set any of the known parameters
3391    /// which have their own setter method. If done anyway, the request will fail.
3392    ///
3393    /// # Additional Parameters
3394    ///
3395    /// * *$.xgafv* (query-string) - V1 error format.
3396    /// * *access_token* (query-string) - OAuth access token.
3397    /// * *alt* (query-string) - Data format for response.
3398    /// * *callback* (query-string) - JSONP
3399    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3400    /// * *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.
3401    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3402    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3403    /// * *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.
3404    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3405    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3406    pub fn param<T>(
3407        mut self,
3408        name: T,
3409        value: T,
3410    ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3411    where
3412        T: AsRef<str>,
3413    {
3414        self._additional_params
3415            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3416        self
3417    }
3418
3419    /// Identifies the authorization scope for the method you are building.
3420    ///
3421    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3422    /// [`Scope::CloudPlatform`].
3423    ///
3424    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3425    /// tokens for more than one scope.
3426    ///
3427    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3428    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3429    /// sufficient, a read-write scope will do as well.
3430    pub fn add_scope<St>(mut self, scope: St) -> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3431    where
3432        St: AsRef<str>,
3433    {
3434        self._scopes.insert(String::from(scope.as_ref()));
3435        self
3436    }
3437    /// Identifies the authorization scope(s) for the method you are building.
3438    ///
3439    /// See [`Self::add_scope()`] for details.
3440    pub fn add_scopes<I, St>(
3441        mut self,
3442        scopes: I,
3443    ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3444    where
3445        I: IntoIterator<Item = St>,
3446        St: AsRef<str>,
3447    {
3448        self._scopes
3449            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3450        self
3451    }
3452
3453    /// Removes all scopes, and no default scope will be used either.
3454    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3455    /// for details).
3456    pub fn clear_scopes(mut self) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3457        self._scopes.clear();
3458        self
3459    }
3460}
3461
3462/// Lists all the `Policies` set for a particular resource.
3463///
3464/// A builder for the *listOrgPolicies* method supported by a *folder* resource.
3465/// It is not used directly, but through a [`FolderMethods`] instance.
3466///
3467/// # Example
3468///
3469/// Instantiate a resource method builder
3470///
3471/// ```test_harness,no_run
3472/// # extern crate hyper;
3473/// # extern crate hyper_rustls;
3474/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
3475/// use cloudresourcemanager1::api::ListOrgPoliciesRequest;
3476/// # async fn dox() {
3477/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3478///
3479/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3480/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3481/// #     secret,
3482/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3483/// # ).build().await.unwrap();
3484///
3485/// # let client = hyper_util::client::legacy::Client::builder(
3486/// #     hyper_util::rt::TokioExecutor::new()
3487/// # )
3488/// # .build(
3489/// #     hyper_rustls::HttpsConnectorBuilder::new()
3490/// #         .with_native_roots()
3491/// #         .unwrap()
3492/// #         .https_or_http()
3493/// #         .enable_http1()
3494/// #         .build()
3495/// # );
3496/// # let mut hub = CloudResourceManager::new(client, auth);
3497/// // As the method needs a request, you would usually fill it with the desired information
3498/// // into the respective structure. Some of the parts shown here might not be applicable !
3499/// // Values shown here are possibly random and not representative !
3500/// let mut req = ListOrgPoliciesRequest::default();
3501///
3502/// // You can configure optional parameters by calling the respective setters at will, and
3503/// // execute the final call using `doit()`.
3504/// // Values shown here are possibly random and not representative !
3505/// let result = hub.folders().list_org_policies(req, "resource")
3506///              .doit().await;
3507/// # }
3508/// ```
3509pub struct FolderListOrgPolicyCall<'a, C>
3510where
3511    C: 'a,
3512{
3513    hub: &'a CloudResourceManager<C>,
3514    _request: ListOrgPoliciesRequest,
3515    _resource: String,
3516    _delegate: Option<&'a mut dyn common::Delegate>,
3517    _additional_params: HashMap<String, String>,
3518    _scopes: BTreeSet<String>,
3519}
3520
3521impl<'a, C> common::CallBuilder for FolderListOrgPolicyCall<'a, C> {}
3522
3523impl<'a, C> FolderListOrgPolicyCall<'a, C>
3524where
3525    C: common::Connector,
3526{
3527    /// Perform the operation you have build so far.
3528    pub async fn doit(mut self) -> common::Result<(common::Response, ListOrgPoliciesResponse)> {
3529        use std::borrow::Cow;
3530        use std::io::{Read, Seek};
3531
3532        use common::{url::Params, ToParts};
3533        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3534
3535        let mut dd = common::DefaultDelegate;
3536        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3537        dlg.begin(common::MethodInfo {
3538            id: "cloudresourcemanager.folders.listOrgPolicies",
3539            http_method: hyper::Method::POST,
3540        });
3541
3542        for &field in ["alt", "resource"].iter() {
3543            if self._additional_params.contains_key(field) {
3544                dlg.finished(false);
3545                return Err(common::Error::FieldClash(field));
3546            }
3547        }
3548
3549        let mut params = Params::with_capacity(4 + self._additional_params.len());
3550        params.push("resource", self._resource);
3551
3552        params.extend(self._additional_params.iter());
3553
3554        params.push("alt", "json");
3555        let mut url = self.hub._base_url.clone() + "v1/{+resource}:listOrgPolicies";
3556        if self._scopes.is_empty() {
3557            self._scopes
3558                .insert(Scope::CloudPlatform.as_ref().to_string());
3559        }
3560
3561        #[allow(clippy::single_element_loop)]
3562        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3563            url = params.uri_replacement(url, param_name, find_this, true);
3564        }
3565        {
3566            let to_remove = ["resource"];
3567            params.remove_params(&to_remove);
3568        }
3569
3570        let url = params.parse_with_url(&url);
3571
3572        let mut json_mime_type = mime::APPLICATION_JSON;
3573        let mut request_value_reader = {
3574            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3575            common::remove_json_null_values(&mut value);
3576            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3577            serde_json::to_writer(&mut dst, &value).unwrap();
3578            dst
3579        };
3580        let request_size = request_value_reader
3581            .seek(std::io::SeekFrom::End(0))
3582            .unwrap();
3583        request_value_reader
3584            .seek(std::io::SeekFrom::Start(0))
3585            .unwrap();
3586
3587        loop {
3588            let token = match self
3589                .hub
3590                .auth
3591                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3592                .await
3593            {
3594                Ok(token) => token,
3595                Err(e) => match dlg.token(e) {
3596                    Ok(token) => token,
3597                    Err(e) => {
3598                        dlg.finished(false);
3599                        return Err(common::Error::MissingToken(e));
3600                    }
3601                },
3602            };
3603            request_value_reader
3604                .seek(std::io::SeekFrom::Start(0))
3605                .unwrap();
3606            let mut req_result = {
3607                let client = &self.hub.client;
3608                dlg.pre_request();
3609                let mut req_builder = hyper::Request::builder()
3610                    .method(hyper::Method::POST)
3611                    .uri(url.as_str())
3612                    .header(USER_AGENT, self.hub._user_agent.clone());
3613
3614                if let Some(token) = token.as_ref() {
3615                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3616                }
3617
3618                let request = req_builder
3619                    .header(CONTENT_TYPE, json_mime_type.to_string())
3620                    .header(CONTENT_LENGTH, request_size as u64)
3621                    .body(common::to_body(
3622                        request_value_reader.get_ref().clone().into(),
3623                    ));
3624
3625                client.request(request.unwrap()).await
3626            };
3627
3628            match req_result {
3629                Err(err) => {
3630                    if let common::Retry::After(d) = dlg.http_error(&err) {
3631                        sleep(d).await;
3632                        continue;
3633                    }
3634                    dlg.finished(false);
3635                    return Err(common::Error::HttpError(err));
3636                }
3637                Ok(res) => {
3638                    let (mut parts, body) = res.into_parts();
3639                    let mut body = common::Body::new(body);
3640                    if !parts.status.is_success() {
3641                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3642                        let error = serde_json::from_str(&common::to_string(&bytes));
3643                        let response = common::to_response(parts, bytes.into());
3644
3645                        if let common::Retry::After(d) =
3646                            dlg.http_failure(&response, error.as_ref().ok())
3647                        {
3648                            sleep(d).await;
3649                            continue;
3650                        }
3651
3652                        dlg.finished(false);
3653
3654                        return Err(match error {
3655                            Ok(value) => common::Error::BadRequest(value),
3656                            _ => common::Error::Failure(response),
3657                        });
3658                    }
3659                    let response = {
3660                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3661                        let encoded = common::to_string(&bytes);
3662                        match serde_json::from_str(&encoded) {
3663                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3664                            Err(error) => {
3665                                dlg.response_json_decode_error(&encoded, &error);
3666                                return Err(common::Error::JsonDecodeError(
3667                                    encoded.to_string(),
3668                                    error,
3669                                ));
3670                            }
3671                        }
3672                    };
3673
3674                    dlg.finished(true);
3675                    return Ok(response);
3676                }
3677            }
3678        }
3679    }
3680
3681    ///
3682    /// Sets the *request* property to the given value.
3683    ///
3684    /// Even though the property as already been set when instantiating this call,
3685    /// we provide this method for API completeness.
3686    pub fn request(mut self, new_value: ListOrgPoliciesRequest) -> FolderListOrgPolicyCall<'a, C> {
3687        self._request = new_value;
3688        self
3689    }
3690    /// Name of the resource to list Policies for.
3691    ///
3692    /// Sets the *resource* path property to the given value.
3693    ///
3694    /// Even though the property as already been set when instantiating this call,
3695    /// we provide this method for API completeness.
3696    pub fn resource(mut self, new_value: &str) -> FolderListOrgPolicyCall<'a, C> {
3697        self._resource = new_value.to_string();
3698        self
3699    }
3700    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3701    /// while executing the actual API request.
3702    ///
3703    /// ````text
3704    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3705    /// ````
3706    ///
3707    /// Sets the *delegate* property to the given value.
3708    pub fn delegate(
3709        mut self,
3710        new_value: &'a mut dyn common::Delegate,
3711    ) -> FolderListOrgPolicyCall<'a, C> {
3712        self._delegate = Some(new_value);
3713        self
3714    }
3715
3716    /// Set any additional parameter of the query string used in the request.
3717    /// It should be used to set parameters which are not yet available through their own
3718    /// setters.
3719    ///
3720    /// Please note that this method must not be used to set any of the known parameters
3721    /// which have their own setter method. If done anyway, the request will fail.
3722    ///
3723    /// # Additional Parameters
3724    ///
3725    /// * *$.xgafv* (query-string) - V1 error format.
3726    /// * *access_token* (query-string) - OAuth access token.
3727    /// * *alt* (query-string) - Data format for response.
3728    /// * *callback* (query-string) - JSONP
3729    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3730    /// * *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.
3731    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3732    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3733    /// * *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.
3734    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3735    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3736    pub fn param<T>(mut self, name: T, value: T) -> FolderListOrgPolicyCall<'a, C>
3737    where
3738        T: AsRef<str>,
3739    {
3740        self._additional_params
3741            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3742        self
3743    }
3744
3745    /// Identifies the authorization scope for the method you are building.
3746    ///
3747    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3748    /// [`Scope::CloudPlatform`].
3749    ///
3750    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3751    /// tokens for more than one scope.
3752    ///
3753    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3754    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3755    /// sufficient, a read-write scope will do as well.
3756    pub fn add_scope<St>(mut self, scope: St) -> FolderListOrgPolicyCall<'a, C>
3757    where
3758        St: AsRef<str>,
3759    {
3760        self._scopes.insert(String::from(scope.as_ref()));
3761        self
3762    }
3763    /// Identifies the authorization scope(s) for the method you are building.
3764    ///
3765    /// See [`Self::add_scope()`] for details.
3766    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderListOrgPolicyCall<'a, C>
3767    where
3768        I: IntoIterator<Item = St>,
3769        St: AsRef<str>,
3770    {
3771        self._scopes
3772            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3773        self
3774    }
3775
3776    /// Removes all scopes, and no default scope will be used either.
3777    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3778    /// for details).
3779    pub fn clear_scopes(mut self) -> FolderListOrgPolicyCall<'a, C> {
3780        self._scopes.clear();
3781        self
3782    }
3783}
3784
3785/// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
3786///
3787/// A builder for the *setOrgPolicy* method supported by a *folder* resource.
3788/// It is not used directly, but through a [`FolderMethods`] instance.
3789///
3790/// # Example
3791///
3792/// Instantiate a resource method builder
3793///
3794/// ```test_harness,no_run
3795/// # extern crate hyper;
3796/// # extern crate hyper_rustls;
3797/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
3798/// use cloudresourcemanager1::api::SetOrgPolicyRequest;
3799/// # async fn dox() {
3800/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3801///
3802/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3803/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3804/// #     secret,
3805/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3806/// # ).build().await.unwrap();
3807///
3808/// # let client = hyper_util::client::legacy::Client::builder(
3809/// #     hyper_util::rt::TokioExecutor::new()
3810/// # )
3811/// # .build(
3812/// #     hyper_rustls::HttpsConnectorBuilder::new()
3813/// #         .with_native_roots()
3814/// #         .unwrap()
3815/// #         .https_or_http()
3816/// #         .enable_http1()
3817/// #         .build()
3818/// # );
3819/// # let mut hub = CloudResourceManager::new(client, auth);
3820/// // As the method needs a request, you would usually fill it with the desired information
3821/// // into the respective structure. Some of the parts shown here might not be applicable !
3822/// // Values shown here are possibly random and not representative !
3823/// let mut req = SetOrgPolicyRequest::default();
3824///
3825/// // You can configure optional parameters by calling the respective setters at will, and
3826/// // execute the final call using `doit()`.
3827/// // Values shown here are possibly random and not representative !
3828/// let result = hub.folders().set_org_policy(req, "resource")
3829///              .doit().await;
3830/// # }
3831/// ```
3832pub struct FolderSetOrgPolicyCall<'a, C>
3833where
3834    C: 'a,
3835{
3836    hub: &'a CloudResourceManager<C>,
3837    _request: SetOrgPolicyRequest,
3838    _resource: String,
3839    _delegate: Option<&'a mut dyn common::Delegate>,
3840    _additional_params: HashMap<String, String>,
3841    _scopes: BTreeSet<String>,
3842}
3843
3844impl<'a, C> common::CallBuilder for FolderSetOrgPolicyCall<'a, C> {}
3845
3846impl<'a, C> FolderSetOrgPolicyCall<'a, C>
3847where
3848    C: common::Connector,
3849{
3850    /// Perform the operation you have build so far.
3851    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
3852        use std::borrow::Cow;
3853        use std::io::{Read, Seek};
3854
3855        use common::{url::Params, ToParts};
3856        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3857
3858        let mut dd = common::DefaultDelegate;
3859        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3860        dlg.begin(common::MethodInfo {
3861            id: "cloudresourcemanager.folders.setOrgPolicy",
3862            http_method: hyper::Method::POST,
3863        });
3864
3865        for &field in ["alt", "resource"].iter() {
3866            if self._additional_params.contains_key(field) {
3867                dlg.finished(false);
3868                return Err(common::Error::FieldClash(field));
3869            }
3870        }
3871
3872        let mut params = Params::with_capacity(4 + self._additional_params.len());
3873        params.push("resource", self._resource);
3874
3875        params.extend(self._additional_params.iter());
3876
3877        params.push("alt", "json");
3878        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setOrgPolicy";
3879        if self._scopes.is_empty() {
3880            self._scopes
3881                .insert(Scope::CloudPlatform.as_ref().to_string());
3882        }
3883
3884        #[allow(clippy::single_element_loop)]
3885        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3886            url = params.uri_replacement(url, param_name, find_this, true);
3887        }
3888        {
3889            let to_remove = ["resource"];
3890            params.remove_params(&to_remove);
3891        }
3892
3893        let url = params.parse_with_url(&url);
3894
3895        let mut json_mime_type = mime::APPLICATION_JSON;
3896        let mut request_value_reader = {
3897            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3898            common::remove_json_null_values(&mut value);
3899            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3900            serde_json::to_writer(&mut dst, &value).unwrap();
3901            dst
3902        };
3903        let request_size = request_value_reader
3904            .seek(std::io::SeekFrom::End(0))
3905            .unwrap();
3906        request_value_reader
3907            .seek(std::io::SeekFrom::Start(0))
3908            .unwrap();
3909
3910        loop {
3911            let token = match self
3912                .hub
3913                .auth
3914                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3915                .await
3916            {
3917                Ok(token) => token,
3918                Err(e) => match dlg.token(e) {
3919                    Ok(token) => token,
3920                    Err(e) => {
3921                        dlg.finished(false);
3922                        return Err(common::Error::MissingToken(e));
3923                    }
3924                },
3925            };
3926            request_value_reader
3927                .seek(std::io::SeekFrom::Start(0))
3928                .unwrap();
3929            let mut req_result = {
3930                let client = &self.hub.client;
3931                dlg.pre_request();
3932                let mut req_builder = hyper::Request::builder()
3933                    .method(hyper::Method::POST)
3934                    .uri(url.as_str())
3935                    .header(USER_AGENT, self.hub._user_agent.clone());
3936
3937                if let Some(token) = token.as_ref() {
3938                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3939                }
3940
3941                let request = req_builder
3942                    .header(CONTENT_TYPE, json_mime_type.to_string())
3943                    .header(CONTENT_LENGTH, request_size as u64)
3944                    .body(common::to_body(
3945                        request_value_reader.get_ref().clone().into(),
3946                    ));
3947
3948                client.request(request.unwrap()).await
3949            };
3950
3951            match req_result {
3952                Err(err) => {
3953                    if let common::Retry::After(d) = dlg.http_error(&err) {
3954                        sleep(d).await;
3955                        continue;
3956                    }
3957                    dlg.finished(false);
3958                    return Err(common::Error::HttpError(err));
3959                }
3960                Ok(res) => {
3961                    let (mut parts, body) = res.into_parts();
3962                    let mut body = common::Body::new(body);
3963                    if !parts.status.is_success() {
3964                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3965                        let error = serde_json::from_str(&common::to_string(&bytes));
3966                        let response = common::to_response(parts, bytes.into());
3967
3968                        if let common::Retry::After(d) =
3969                            dlg.http_failure(&response, error.as_ref().ok())
3970                        {
3971                            sleep(d).await;
3972                            continue;
3973                        }
3974
3975                        dlg.finished(false);
3976
3977                        return Err(match error {
3978                            Ok(value) => common::Error::BadRequest(value),
3979                            _ => common::Error::Failure(response),
3980                        });
3981                    }
3982                    let response = {
3983                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3984                        let encoded = common::to_string(&bytes);
3985                        match serde_json::from_str(&encoded) {
3986                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3987                            Err(error) => {
3988                                dlg.response_json_decode_error(&encoded, &error);
3989                                return Err(common::Error::JsonDecodeError(
3990                                    encoded.to_string(),
3991                                    error,
3992                                ));
3993                            }
3994                        }
3995                    };
3996
3997                    dlg.finished(true);
3998                    return Ok(response);
3999                }
4000            }
4001        }
4002    }
4003
4004    ///
4005    /// Sets the *request* property to the given value.
4006    ///
4007    /// Even though the property as already been set when instantiating this call,
4008    /// we provide this method for API completeness.
4009    pub fn request(mut self, new_value: SetOrgPolicyRequest) -> FolderSetOrgPolicyCall<'a, C> {
4010        self._request = new_value;
4011        self
4012    }
4013    /// Resource name of the resource to attach the `Policy`.
4014    ///
4015    /// Sets the *resource* path property to the given value.
4016    ///
4017    /// Even though the property as already been set when instantiating this call,
4018    /// we provide this method for API completeness.
4019    pub fn resource(mut self, new_value: &str) -> FolderSetOrgPolicyCall<'a, C> {
4020        self._resource = new_value.to_string();
4021        self
4022    }
4023    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4024    /// while executing the actual API request.
4025    ///
4026    /// ````text
4027    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4028    /// ````
4029    ///
4030    /// Sets the *delegate* property to the given value.
4031    pub fn delegate(
4032        mut self,
4033        new_value: &'a mut dyn common::Delegate,
4034    ) -> FolderSetOrgPolicyCall<'a, C> {
4035        self._delegate = Some(new_value);
4036        self
4037    }
4038
4039    /// Set any additional parameter of the query string used in the request.
4040    /// It should be used to set parameters which are not yet available through their own
4041    /// setters.
4042    ///
4043    /// Please note that this method must not be used to set any of the known parameters
4044    /// which have their own setter method. If done anyway, the request will fail.
4045    ///
4046    /// # Additional Parameters
4047    ///
4048    /// * *$.xgafv* (query-string) - V1 error format.
4049    /// * *access_token* (query-string) - OAuth access token.
4050    /// * *alt* (query-string) - Data format for response.
4051    /// * *callback* (query-string) - JSONP
4052    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4053    /// * *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.
4054    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4055    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4056    /// * *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.
4057    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4058    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4059    pub fn param<T>(mut self, name: T, value: T) -> FolderSetOrgPolicyCall<'a, C>
4060    where
4061        T: AsRef<str>,
4062    {
4063        self._additional_params
4064            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4065        self
4066    }
4067
4068    /// Identifies the authorization scope for the method you are building.
4069    ///
4070    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4071    /// [`Scope::CloudPlatform`].
4072    ///
4073    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4074    /// tokens for more than one scope.
4075    ///
4076    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4077    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4078    /// sufficient, a read-write scope will do as well.
4079    pub fn add_scope<St>(mut self, scope: St) -> FolderSetOrgPolicyCall<'a, C>
4080    where
4081        St: AsRef<str>,
4082    {
4083        self._scopes.insert(String::from(scope.as_ref()));
4084        self
4085    }
4086    /// Identifies the authorization scope(s) for the method you are building.
4087    ///
4088    /// See [`Self::add_scope()`] for details.
4089    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderSetOrgPolicyCall<'a, C>
4090    where
4091        I: IntoIterator<Item = St>,
4092        St: AsRef<str>,
4093    {
4094        self._scopes
4095            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4096        self
4097    }
4098
4099    /// Removes all scopes, and no default scope will be used either.
4100    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4101    /// for details).
4102    pub fn clear_scopes(mut self) -> FolderSetOrgPolicyCall<'a, C> {
4103        self._scopes.clear();
4104        self
4105    }
4106}
4107
4108/// Create a Lien which applies to the resource denoted by the `parent` field. Callers of this method will require permission on the `parent` resource. For example, applying to `projects/1234` requires permission `resourcemanager.projects.updateLiens`. NOTE: Some resources may limit the number of Liens which may be applied.
4109///
4110/// A builder for the *create* method supported by a *lien* resource.
4111/// It is not used directly, but through a [`LienMethods`] instance.
4112///
4113/// # Example
4114///
4115/// Instantiate a resource method builder
4116///
4117/// ```test_harness,no_run
4118/// # extern crate hyper;
4119/// # extern crate hyper_rustls;
4120/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
4121/// use cloudresourcemanager1::api::Lien;
4122/// # async fn dox() {
4123/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4124///
4125/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4126/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4127/// #     secret,
4128/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4129/// # ).build().await.unwrap();
4130///
4131/// # let client = hyper_util::client::legacy::Client::builder(
4132/// #     hyper_util::rt::TokioExecutor::new()
4133/// # )
4134/// # .build(
4135/// #     hyper_rustls::HttpsConnectorBuilder::new()
4136/// #         .with_native_roots()
4137/// #         .unwrap()
4138/// #         .https_or_http()
4139/// #         .enable_http1()
4140/// #         .build()
4141/// # );
4142/// # let mut hub = CloudResourceManager::new(client, auth);
4143/// // As the method needs a request, you would usually fill it with the desired information
4144/// // into the respective structure. Some of the parts shown here might not be applicable !
4145/// // Values shown here are possibly random and not representative !
4146/// let mut req = Lien::default();
4147///
4148/// // You can configure optional parameters by calling the respective setters at will, and
4149/// // execute the final call using `doit()`.
4150/// // Values shown here are possibly random and not representative !
4151/// let result = hub.liens().create(req)
4152///              .doit().await;
4153/// # }
4154/// ```
4155pub struct LienCreateCall<'a, C>
4156where
4157    C: 'a,
4158{
4159    hub: &'a CloudResourceManager<C>,
4160    _request: Lien,
4161    _delegate: Option<&'a mut dyn common::Delegate>,
4162    _additional_params: HashMap<String, String>,
4163    _scopes: BTreeSet<String>,
4164}
4165
4166impl<'a, C> common::CallBuilder for LienCreateCall<'a, C> {}
4167
4168impl<'a, C> LienCreateCall<'a, C>
4169where
4170    C: common::Connector,
4171{
4172    /// Perform the operation you have build so far.
4173    pub async fn doit(mut self) -> common::Result<(common::Response, Lien)> {
4174        use std::borrow::Cow;
4175        use std::io::{Read, Seek};
4176
4177        use common::{url::Params, ToParts};
4178        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4179
4180        let mut dd = common::DefaultDelegate;
4181        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4182        dlg.begin(common::MethodInfo {
4183            id: "cloudresourcemanager.liens.create",
4184            http_method: hyper::Method::POST,
4185        });
4186
4187        for &field in ["alt"].iter() {
4188            if self._additional_params.contains_key(field) {
4189                dlg.finished(false);
4190                return Err(common::Error::FieldClash(field));
4191            }
4192        }
4193
4194        let mut params = Params::with_capacity(3 + self._additional_params.len());
4195
4196        params.extend(self._additional_params.iter());
4197
4198        params.push("alt", "json");
4199        let mut url = self.hub._base_url.clone() + "v1/liens";
4200        if self._scopes.is_empty() {
4201            self._scopes
4202                .insert(Scope::CloudPlatform.as_ref().to_string());
4203        }
4204
4205        let url = params.parse_with_url(&url);
4206
4207        let mut json_mime_type = mime::APPLICATION_JSON;
4208        let mut request_value_reader = {
4209            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4210            common::remove_json_null_values(&mut value);
4211            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4212            serde_json::to_writer(&mut dst, &value).unwrap();
4213            dst
4214        };
4215        let request_size = request_value_reader
4216            .seek(std::io::SeekFrom::End(0))
4217            .unwrap();
4218        request_value_reader
4219            .seek(std::io::SeekFrom::Start(0))
4220            .unwrap();
4221
4222        loop {
4223            let token = match self
4224                .hub
4225                .auth
4226                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4227                .await
4228            {
4229                Ok(token) => token,
4230                Err(e) => match dlg.token(e) {
4231                    Ok(token) => token,
4232                    Err(e) => {
4233                        dlg.finished(false);
4234                        return Err(common::Error::MissingToken(e));
4235                    }
4236                },
4237            };
4238            request_value_reader
4239                .seek(std::io::SeekFrom::Start(0))
4240                .unwrap();
4241            let mut req_result = {
4242                let client = &self.hub.client;
4243                dlg.pre_request();
4244                let mut req_builder = hyper::Request::builder()
4245                    .method(hyper::Method::POST)
4246                    .uri(url.as_str())
4247                    .header(USER_AGENT, self.hub._user_agent.clone());
4248
4249                if let Some(token) = token.as_ref() {
4250                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4251                }
4252
4253                let request = req_builder
4254                    .header(CONTENT_TYPE, json_mime_type.to_string())
4255                    .header(CONTENT_LENGTH, request_size as u64)
4256                    .body(common::to_body(
4257                        request_value_reader.get_ref().clone().into(),
4258                    ));
4259
4260                client.request(request.unwrap()).await
4261            };
4262
4263            match req_result {
4264                Err(err) => {
4265                    if let common::Retry::After(d) = dlg.http_error(&err) {
4266                        sleep(d).await;
4267                        continue;
4268                    }
4269                    dlg.finished(false);
4270                    return Err(common::Error::HttpError(err));
4271                }
4272                Ok(res) => {
4273                    let (mut parts, body) = res.into_parts();
4274                    let mut body = common::Body::new(body);
4275                    if !parts.status.is_success() {
4276                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4277                        let error = serde_json::from_str(&common::to_string(&bytes));
4278                        let response = common::to_response(parts, bytes.into());
4279
4280                        if let common::Retry::After(d) =
4281                            dlg.http_failure(&response, error.as_ref().ok())
4282                        {
4283                            sleep(d).await;
4284                            continue;
4285                        }
4286
4287                        dlg.finished(false);
4288
4289                        return Err(match error {
4290                            Ok(value) => common::Error::BadRequest(value),
4291                            _ => common::Error::Failure(response),
4292                        });
4293                    }
4294                    let response = {
4295                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4296                        let encoded = common::to_string(&bytes);
4297                        match serde_json::from_str(&encoded) {
4298                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4299                            Err(error) => {
4300                                dlg.response_json_decode_error(&encoded, &error);
4301                                return Err(common::Error::JsonDecodeError(
4302                                    encoded.to_string(),
4303                                    error,
4304                                ));
4305                            }
4306                        }
4307                    };
4308
4309                    dlg.finished(true);
4310                    return Ok(response);
4311                }
4312            }
4313        }
4314    }
4315
4316    ///
4317    /// Sets the *request* property to the given value.
4318    ///
4319    /// Even though the property as already been set when instantiating this call,
4320    /// we provide this method for API completeness.
4321    pub fn request(mut self, new_value: Lien) -> LienCreateCall<'a, C> {
4322        self._request = new_value;
4323        self
4324    }
4325    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4326    /// while executing the actual API request.
4327    ///
4328    /// ````text
4329    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4330    /// ````
4331    ///
4332    /// Sets the *delegate* property to the given value.
4333    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienCreateCall<'a, C> {
4334        self._delegate = Some(new_value);
4335        self
4336    }
4337
4338    /// Set any additional parameter of the query string used in the request.
4339    /// It should be used to set parameters which are not yet available through their own
4340    /// setters.
4341    ///
4342    /// Please note that this method must not be used to set any of the known parameters
4343    /// which have their own setter method. If done anyway, the request will fail.
4344    ///
4345    /// # Additional Parameters
4346    ///
4347    /// * *$.xgafv* (query-string) - V1 error format.
4348    /// * *access_token* (query-string) - OAuth access token.
4349    /// * *alt* (query-string) - Data format for response.
4350    /// * *callback* (query-string) - JSONP
4351    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4352    /// * *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.
4353    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4354    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4355    /// * *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.
4356    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4357    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4358    pub fn param<T>(mut self, name: T, value: T) -> LienCreateCall<'a, C>
4359    where
4360        T: AsRef<str>,
4361    {
4362        self._additional_params
4363            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4364        self
4365    }
4366
4367    /// Identifies the authorization scope for the method you are building.
4368    ///
4369    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4370    /// [`Scope::CloudPlatform`].
4371    ///
4372    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4373    /// tokens for more than one scope.
4374    ///
4375    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4376    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4377    /// sufficient, a read-write scope will do as well.
4378    pub fn add_scope<St>(mut self, scope: St) -> LienCreateCall<'a, C>
4379    where
4380        St: AsRef<str>,
4381    {
4382        self._scopes.insert(String::from(scope.as_ref()));
4383        self
4384    }
4385    /// Identifies the authorization scope(s) for the method you are building.
4386    ///
4387    /// See [`Self::add_scope()`] for details.
4388    pub fn add_scopes<I, St>(mut self, scopes: I) -> LienCreateCall<'a, C>
4389    where
4390        I: IntoIterator<Item = St>,
4391        St: AsRef<str>,
4392    {
4393        self._scopes
4394            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4395        self
4396    }
4397
4398    /// Removes all scopes, and no default scope will be used either.
4399    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4400    /// for details).
4401    pub fn clear_scopes(mut self) -> LienCreateCall<'a, C> {
4402        self._scopes.clear();
4403        self
4404    }
4405}
4406
4407/// Delete a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.updateLiens`.
4408///
4409/// A builder for the *delete* method supported by a *lien* resource.
4410/// It is not used directly, but through a [`LienMethods`] instance.
4411///
4412/// # Example
4413///
4414/// Instantiate a resource method builder
4415///
4416/// ```test_harness,no_run
4417/// # extern crate hyper;
4418/// # extern crate hyper_rustls;
4419/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
4420/// # async fn dox() {
4421/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4422///
4423/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4424/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4425/// #     secret,
4426/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4427/// # ).build().await.unwrap();
4428///
4429/// # let client = hyper_util::client::legacy::Client::builder(
4430/// #     hyper_util::rt::TokioExecutor::new()
4431/// # )
4432/// # .build(
4433/// #     hyper_rustls::HttpsConnectorBuilder::new()
4434/// #         .with_native_roots()
4435/// #         .unwrap()
4436/// #         .https_or_http()
4437/// #         .enable_http1()
4438/// #         .build()
4439/// # );
4440/// # let mut hub = CloudResourceManager::new(client, auth);
4441/// // You can configure optional parameters by calling the respective setters at will, and
4442/// // execute the final call using `doit()`.
4443/// // Values shown here are possibly random and not representative !
4444/// let result = hub.liens().delete("name")
4445///              .doit().await;
4446/// # }
4447/// ```
4448pub struct LienDeleteCall<'a, C>
4449where
4450    C: 'a,
4451{
4452    hub: &'a CloudResourceManager<C>,
4453    _name: String,
4454    _delegate: Option<&'a mut dyn common::Delegate>,
4455    _additional_params: HashMap<String, String>,
4456    _scopes: BTreeSet<String>,
4457}
4458
4459impl<'a, C> common::CallBuilder for LienDeleteCall<'a, C> {}
4460
4461impl<'a, C> LienDeleteCall<'a, C>
4462where
4463    C: common::Connector,
4464{
4465    /// Perform the operation you have build so far.
4466    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4467        use std::borrow::Cow;
4468        use std::io::{Read, Seek};
4469
4470        use common::{url::Params, ToParts};
4471        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4472
4473        let mut dd = common::DefaultDelegate;
4474        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4475        dlg.begin(common::MethodInfo {
4476            id: "cloudresourcemanager.liens.delete",
4477            http_method: hyper::Method::DELETE,
4478        });
4479
4480        for &field in ["alt", "name"].iter() {
4481            if self._additional_params.contains_key(field) {
4482                dlg.finished(false);
4483                return Err(common::Error::FieldClash(field));
4484            }
4485        }
4486
4487        let mut params = Params::with_capacity(3 + self._additional_params.len());
4488        params.push("name", self._name);
4489
4490        params.extend(self._additional_params.iter());
4491
4492        params.push("alt", "json");
4493        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4494        if self._scopes.is_empty() {
4495            self._scopes
4496                .insert(Scope::CloudPlatform.as_ref().to_string());
4497        }
4498
4499        #[allow(clippy::single_element_loop)]
4500        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4501            url = params.uri_replacement(url, param_name, find_this, true);
4502        }
4503        {
4504            let to_remove = ["name"];
4505            params.remove_params(&to_remove);
4506        }
4507
4508        let url = params.parse_with_url(&url);
4509
4510        loop {
4511            let token = match self
4512                .hub
4513                .auth
4514                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4515                .await
4516            {
4517                Ok(token) => token,
4518                Err(e) => match dlg.token(e) {
4519                    Ok(token) => token,
4520                    Err(e) => {
4521                        dlg.finished(false);
4522                        return Err(common::Error::MissingToken(e));
4523                    }
4524                },
4525            };
4526            let mut req_result = {
4527                let client = &self.hub.client;
4528                dlg.pre_request();
4529                let mut req_builder = hyper::Request::builder()
4530                    .method(hyper::Method::DELETE)
4531                    .uri(url.as_str())
4532                    .header(USER_AGENT, self.hub._user_agent.clone());
4533
4534                if let Some(token) = token.as_ref() {
4535                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4536                }
4537
4538                let request = req_builder
4539                    .header(CONTENT_LENGTH, 0_u64)
4540                    .body(common::to_body::<String>(None));
4541
4542                client.request(request.unwrap()).await
4543            };
4544
4545            match req_result {
4546                Err(err) => {
4547                    if let common::Retry::After(d) = dlg.http_error(&err) {
4548                        sleep(d).await;
4549                        continue;
4550                    }
4551                    dlg.finished(false);
4552                    return Err(common::Error::HttpError(err));
4553                }
4554                Ok(res) => {
4555                    let (mut parts, body) = res.into_parts();
4556                    let mut body = common::Body::new(body);
4557                    if !parts.status.is_success() {
4558                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4559                        let error = serde_json::from_str(&common::to_string(&bytes));
4560                        let response = common::to_response(parts, bytes.into());
4561
4562                        if let common::Retry::After(d) =
4563                            dlg.http_failure(&response, error.as_ref().ok())
4564                        {
4565                            sleep(d).await;
4566                            continue;
4567                        }
4568
4569                        dlg.finished(false);
4570
4571                        return Err(match error {
4572                            Ok(value) => common::Error::BadRequest(value),
4573                            _ => common::Error::Failure(response),
4574                        });
4575                    }
4576                    let response = {
4577                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4578                        let encoded = common::to_string(&bytes);
4579                        match serde_json::from_str(&encoded) {
4580                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4581                            Err(error) => {
4582                                dlg.response_json_decode_error(&encoded, &error);
4583                                return Err(common::Error::JsonDecodeError(
4584                                    encoded.to_string(),
4585                                    error,
4586                                ));
4587                            }
4588                        }
4589                    };
4590
4591                    dlg.finished(true);
4592                    return Ok(response);
4593                }
4594            }
4595        }
4596    }
4597
4598    /// Required. The name/identifier of the Lien to delete.
4599    ///
4600    /// Sets the *name* path property to the given value.
4601    ///
4602    /// Even though the property as already been set when instantiating this call,
4603    /// we provide this method for API completeness.
4604    pub fn name(mut self, new_value: &str) -> LienDeleteCall<'a, C> {
4605        self._name = new_value.to_string();
4606        self
4607    }
4608    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4609    /// while executing the actual API request.
4610    ///
4611    /// ````text
4612    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4613    /// ````
4614    ///
4615    /// Sets the *delegate* property to the given value.
4616    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienDeleteCall<'a, C> {
4617        self._delegate = Some(new_value);
4618        self
4619    }
4620
4621    /// Set any additional parameter of the query string used in the request.
4622    /// It should be used to set parameters which are not yet available through their own
4623    /// setters.
4624    ///
4625    /// Please note that this method must not be used to set any of the known parameters
4626    /// which have their own setter method. If done anyway, the request will fail.
4627    ///
4628    /// # Additional Parameters
4629    ///
4630    /// * *$.xgafv* (query-string) - V1 error format.
4631    /// * *access_token* (query-string) - OAuth access token.
4632    /// * *alt* (query-string) - Data format for response.
4633    /// * *callback* (query-string) - JSONP
4634    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4635    /// * *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.
4636    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4637    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4638    /// * *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.
4639    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4640    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4641    pub fn param<T>(mut self, name: T, value: T) -> LienDeleteCall<'a, C>
4642    where
4643        T: AsRef<str>,
4644    {
4645        self._additional_params
4646            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4647        self
4648    }
4649
4650    /// Identifies the authorization scope for the method you are building.
4651    ///
4652    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4653    /// [`Scope::CloudPlatform`].
4654    ///
4655    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4656    /// tokens for more than one scope.
4657    ///
4658    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4659    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4660    /// sufficient, a read-write scope will do as well.
4661    pub fn add_scope<St>(mut self, scope: St) -> LienDeleteCall<'a, C>
4662    where
4663        St: AsRef<str>,
4664    {
4665        self._scopes.insert(String::from(scope.as_ref()));
4666        self
4667    }
4668    /// Identifies the authorization scope(s) for the method you are building.
4669    ///
4670    /// See [`Self::add_scope()`] for details.
4671    pub fn add_scopes<I, St>(mut self, scopes: I) -> LienDeleteCall<'a, C>
4672    where
4673        I: IntoIterator<Item = St>,
4674        St: AsRef<str>,
4675    {
4676        self._scopes
4677            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4678        self
4679    }
4680
4681    /// Removes all scopes, and no default scope will be used either.
4682    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4683    /// for details).
4684    pub fn clear_scopes(mut self) -> LienDeleteCall<'a, C> {
4685        self._scopes.clear();
4686        self
4687    }
4688}
4689
4690/// Retrieve a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`
4691///
4692/// A builder for the *get* method supported by a *lien* resource.
4693/// It is not used directly, but through a [`LienMethods`] instance.
4694///
4695/// # Example
4696///
4697/// Instantiate a resource method builder
4698///
4699/// ```test_harness,no_run
4700/// # extern crate hyper;
4701/// # extern crate hyper_rustls;
4702/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
4703/// # async fn dox() {
4704/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4705///
4706/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4707/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4708/// #     secret,
4709/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4710/// # ).build().await.unwrap();
4711///
4712/// # let client = hyper_util::client::legacy::Client::builder(
4713/// #     hyper_util::rt::TokioExecutor::new()
4714/// # )
4715/// # .build(
4716/// #     hyper_rustls::HttpsConnectorBuilder::new()
4717/// #         .with_native_roots()
4718/// #         .unwrap()
4719/// #         .https_or_http()
4720/// #         .enable_http1()
4721/// #         .build()
4722/// # );
4723/// # let mut hub = CloudResourceManager::new(client, auth);
4724/// // You can configure optional parameters by calling the respective setters at will, and
4725/// // execute the final call using `doit()`.
4726/// // Values shown here are possibly random and not representative !
4727/// let result = hub.liens().get("name")
4728///              .doit().await;
4729/// # }
4730/// ```
4731pub struct LienGetCall<'a, C>
4732where
4733    C: 'a,
4734{
4735    hub: &'a CloudResourceManager<C>,
4736    _name: String,
4737    _delegate: Option<&'a mut dyn common::Delegate>,
4738    _additional_params: HashMap<String, String>,
4739    _scopes: BTreeSet<String>,
4740}
4741
4742impl<'a, C> common::CallBuilder for LienGetCall<'a, C> {}
4743
4744impl<'a, C> LienGetCall<'a, C>
4745where
4746    C: common::Connector,
4747{
4748    /// Perform the operation you have build so far.
4749    pub async fn doit(mut self) -> common::Result<(common::Response, Lien)> {
4750        use std::borrow::Cow;
4751        use std::io::{Read, Seek};
4752
4753        use common::{url::Params, ToParts};
4754        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4755
4756        let mut dd = common::DefaultDelegate;
4757        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4758        dlg.begin(common::MethodInfo {
4759            id: "cloudresourcemanager.liens.get",
4760            http_method: hyper::Method::GET,
4761        });
4762
4763        for &field in ["alt", "name"].iter() {
4764            if self._additional_params.contains_key(field) {
4765                dlg.finished(false);
4766                return Err(common::Error::FieldClash(field));
4767            }
4768        }
4769
4770        let mut params = Params::with_capacity(3 + self._additional_params.len());
4771        params.push("name", self._name);
4772
4773        params.extend(self._additional_params.iter());
4774
4775        params.push("alt", "json");
4776        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4777        if self._scopes.is_empty() {
4778            self._scopes
4779                .insert(Scope::CloudPlatform.as_ref().to_string());
4780        }
4781
4782        #[allow(clippy::single_element_loop)]
4783        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4784            url = params.uri_replacement(url, param_name, find_this, true);
4785        }
4786        {
4787            let to_remove = ["name"];
4788            params.remove_params(&to_remove);
4789        }
4790
4791        let url = params.parse_with_url(&url);
4792
4793        loop {
4794            let token = match self
4795                .hub
4796                .auth
4797                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4798                .await
4799            {
4800                Ok(token) => token,
4801                Err(e) => match dlg.token(e) {
4802                    Ok(token) => token,
4803                    Err(e) => {
4804                        dlg.finished(false);
4805                        return Err(common::Error::MissingToken(e));
4806                    }
4807                },
4808            };
4809            let mut req_result = {
4810                let client = &self.hub.client;
4811                dlg.pre_request();
4812                let mut req_builder = hyper::Request::builder()
4813                    .method(hyper::Method::GET)
4814                    .uri(url.as_str())
4815                    .header(USER_AGENT, self.hub._user_agent.clone());
4816
4817                if let Some(token) = token.as_ref() {
4818                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4819                }
4820
4821                let request = req_builder
4822                    .header(CONTENT_LENGTH, 0_u64)
4823                    .body(common::to_body::<String>(None));
4824
4825                client.request(request.unwrap()).await
4826            };
4827
4828            match req_result {
4829                Err(err) => {
4830                    if let common::Retry::After(d) = dlg.http_error(&err) {
4831                        sleep(d).await;
4832                        continue;
4833                    }
4834                    dlg.finished(false);
4835                    return Err(common::Error::HttpError(err));
4836                }
4837                Ok(res) => {
4838                    let (mut parts, body) = res.into_parts();
4839                    let mut body = common::Body::new(body);
4840                    if !parts.status.is_success() {
4841                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4842                        let error = serde_json::from_str(&common::to_string(&bytes));
4843                        let response = common::to_response(parts, bytes.into());
4844
4845                        if let common::Retry::After(d) =
4846                            dlg.http_failure(&response, error.as_ref().ok())
4847                        {
4848                            sleep(d).await;
4849                            continue;
4850                        }
4851
4852                        dlg.finished(false);
4853
4854                        return Err(match error {
4855                            Ok(value) => common::Error::BadRequest(value),
4856                            _ => common::Error::Failure(response),
4857                        });
4858                    }
4859                    let response = {
4860                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4861                        let encoded = common::to_string(&bytes);
4862                        match serde_json::from_str(&encoded) {
4863                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4864                            Err(error) => {
4865                                dlg.response_json_decode_error(&encoded, &error);
4866                                return Err(common::Error::JsonDecodeError(
4867                                    encoded.to_string(),
4868                                    error,
4869                                ));
4870                            }
4871                        }
4872                    };
4873
4874                    dlg.finished(true);
4875                    return Ok(response);
4876                }
4877            }
4878        }
4879    }
4880
4881    /// Required. The name/identifier of the Lien.
4882    ///
4883    /// Sets the *name* path property to the given value.
4884    ///
4885    /// Even though the property as already been set when instantiating this call,
4886    /// we provide this method for API completeness.
4887    pub fn name(mut self, new_value: &str) -> LienGetCall<'a, C> {
4888        self._name = new_value.to_string();
4889        self
4890    }
4891    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4892    /// while executing the actual API request.
4893    ///
4894    /// ````text
4895    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4896    /// ````
4897    ///
4898    /// Sets the *delegate* property to the given value.
4899    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienGetCall<'a, C> {
4900        self._delegate = Some(new_value);
4901        self
4902    }
4903
4904    /// Set any additional parameter of the query string used in the request.
4905    /// It should be used to set parameters which are not yet available through their own
4906    /// setters.
4907    ///
4908    /// Please note that this method must not be used to set any of the known parameters
4909    /// which have their own setter method. If done anyway, the request will fail.
4910    ///
4911    /// # Additional Parameters
4912    ///
4913    /// * *$.xgafv* (query-string) - V1 error format.
4914    /// * *access_token* (query-string) - OAuth access token.
4915    /// * *alt* (query-string) - Data format for response.
4916    /// * *callback* (query-string) - JSONP
4917    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4918    /// * *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.
4919    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4920    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4921    /// * *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.
4922    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4923    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4924    pub fn param<T>(mut self, name: T, value: T) -> LienGetCall<'a, C>
4925    where
4926        T: AsRef<str>,
4927    {
4928        self._additional_params
4929            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4930        self
4931    }
4932
4933    /// Identifies the authorization scope for the method you are building.
4934    ///
4935    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4936    /// [`Scope::CloudPlatform`].
4937    ///
4938    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4939    /// tokens for more than one scope.
4940    ///
4941    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4942    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4943    /// sufficient, a read-write scope will do as well.
4944    pub fn add_scope<St>(mut self, scope: St) -> LienGetCall<'a, C>
4945    where
4946        St: AsRef<str>,
4947    {
4948        self._scopes.insert(String::from(scope.as_ref()));
4949        self
4950    }
4951    /// Identifies the authorization scope(s) for the method you are building.
4952    ///
4953    /// See [`Self::add_scope()`] for details.
4954    pub fn add_scopes<I, St>(mut self, scopes: I) -> LienGetCall<'a, C>
4955    where
4956        I: IntoIterator<Item = St>,
4957        St: AsRef<str>,
4958    {
4959        self._scopes
4960            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4961        self
4962    }
4963
4964    /// Removes all scopes, and no default scope will be used either.
4965    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4966    /// for details).
4967    pub fn clear_scopes(mut self) -> LienGetCall<'a, C> {
4968        self._scopes.clear();
4969        self
4970    }
4971}
4972
4973/// List all Liens applied to the `parent` resource. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`.
4974///
4975/// A builder for the *list* method supported by a *lien* resource.
4976/// It is not used directly, but through a [`LienMethods`] instance.
4977///
4978/// # Example
4979///
4980/// Instantiate a resource method builder
4981///
4982/// ```test_harness,no_run
4983/// # extern crate hyper;
4984/// # extern crate hyper_rustls;
4985/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
4986/// # async fn dox() {
4987/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4988///
4989/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4990/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4991/// #     secret,
4992/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4993/// # ).build().await.unwrap();
4994///
4995/// # let client = hyper_util::client::legacy::Client::builder(
4996/// #     hyper_util::rt::TokioExecutor::new()
4997/// # )
4998/// # .build(
4999/// #     hyper_rustls::HttpsConnectorBuilder::new()
5000/// #         .with_native_roots()
5001/// #         .unwrap()
5002/// #         .https_or_http()
5003/// #         .enable_http1()
5004/// #         .build()
5005/// # );
5006/// # let mut hub = CloudResourceManager::new(client, auth);
5007/// // You can configure optional parameters by calling the respective setters at will, and
5008/// // execute the final call using `doit()`.
5009/// // Values shown here are possibly random and not representative !
5010/// let result = hub.liens().list()
5011///              .parent("dolor")
5012///              .page_token("ea")
5013///              .page_size(-55)
5014///              .doit().await;
5015/// # }
5016/// ```
5017pub struct LienListCall<'a, C>
5018where
5019    C: 'a,
5020{
5021    hub: &'a CloudResourceManager<C>,
5022    _parent: Option<String>,
5023    _page_token: Option<String>,
5024    _page_size: Option<i32>,
5025    _delegate: Option<&'a mut dyn common::Delegate>,
5026    _additional_params: HashMap<String, String>,
5027    _scopes: BTreeSet<String>,
5028}
5029
5030impl<'a, C> common::CallBuilder for LienListCall<'a, C> {}
5031
5032impl<'a, C> LienListCall<'a, C>
5033where
5034    C: common::Connector,
5035{
5036    /// Perform the operation you have build so far.
5037    pub async fn doit(mut self) -> common::Result<(common::Response, ListLiensResponse)> {
5038        use std::borrow::Cow;
5039        use std::io::{Read, Seek};
5040
5041        use common::{url::Params, ToParts};
5042        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5043
5044        let mut dd = common::DefaultDelegate;
5045        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5046        dlg.begin(common::MethodInfo {
5047            id: "cloudresourcemanager.liens.list",
5048            http_method: hyper::Method::GET,
5049        });
5050
5051        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5052            if self._additional_params.contains_key(field) {
5053                dlg.finished(false);
5054                return Err(common::Error::FieldClash(field));
5055            }
5056        }
5057
5058        let mut params = Params::with_capacity(5 + self._additional_params.len());
5059        if let Some(value) = self._parent.as_ref() {
5060            params.push("parent", value);
5061        }
5062        if let Some(value) = self._page_token.as_ref() {
5063            params.push("pageToken", value);
5064        }
5065        if let Some(value) = self._page_size.as_ref() {
5066            params.push("pageSize", value.to_string());
5067        }
5068
5069        params.extend(self._additional_params.iter());
5070
5071        params.push("alt", "json");
5072        let mut url = self.hub._base_url.clone() + "v1/liens";
5073        if self._scopes.is_empty() {
5074            self._scopes
5075                .insert(Scope::CloudPlatform.as_ref().to_string());
5076        }
5077
5078        let url = params.parse_with_url(&url);
5079
5080        loop {
5081            let token = match self
5082                .hub
5083                .auth
5084                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5085                .await
5086            {
5087                Ok(token) => token,
5088                Err(e) => match dlg.token(e) {
5089                    Ok(token) => token,
5090                    Err(e) => {
5091                        dlg.finished(false);
5092                        return Err(common::Error::MissingToken(e));
5093                    }
5094                },
5095            };
5096            let mut req_result = {
5097                let client = &self.hub.client;
5098                dlg.pre_request();
5099                let mut req_builder = hyper::Request::builder()
5100                    .method(hyper::Method::GET)
5101                    .uri(url.as_str())
5102                    .header(USER_AGENT, self.hub._user_agent.clone());
5103
5104                if let Some(token) = token.as_ref() {
5105                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5106                }
5107
5108                let request = req_builder
5109                    .header(CONTENT_LENGTH, 0_u64)
5110                    .body(common::to_body::<String>(None));
5111
5112                client.request(request.unwrap()).await
5113            };
5114
5115            match req_result {
5116                Err(err) => {
5117                    if let common::Retry::After(d) = dlg.http_error(&err) {
5118                        sleep(d).await;
5119                        continue;
5120                    }
5121                    dlg.finished(false);
5122                    return Err(common::Error::HttpError(err));
5123                }
5124                Ok(res) => {
5125                    let (mut parts, body) = res.into_parts();
5126                    let mut body = common::Body::new(body);
5127                    if !parts.status.is_success() {
5128                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5129                        let error = serde_json::from_str(&common::to_string(&bytes));
5130                        let response = common::to_response(parts, bytes.into());
5131
5132                        if let common::Retry::After(d) =
5133                            dlg.http_failure(&response, error.as_ref().ok())
5134                        {
5135                            sleep(d).await;
5136                            continue;
5137                        }
5138
5139                        dlg.finished(false);
5140
5141                        return Err(match error {
5142                            Ok(value) => common::Error::BadRequest(value),
5143                            _ => common::Error::Failure(response),
5144                        });
5145                    }
5146                    let response = {
5147                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5148                        let encoded = common::to_string(&bytes);
5149                        match serde_json::from_str(&encoded) {
5150                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5151                            Err(error) => {
5152                                dlg.response_json_decode_error(&encoded, &error);
5153                                return Err(common::Error::JsonDecodeError(
5154                                    encoded.to_string(),
5155                                    error,
5156                                ));
5157                            }
5158                        }
5159                    };
5160
5161                    dlg.finished(true);
5162                    return Ok(response);
5163                }
5164            }
5165        }
5166    }
5167
5168    /// Required. The name of the resource to list all attached Liens. For example, `projects/1234`. (google.api.field_policy).resource_type annotation is not set since the parent depends on the meta api implementation. This field could be a project or other sub project resources.
5169    ///
5170    /// Sets the *parent* query property to the given value.
5171    pub fn parent(mut self, new_value: &str) -> LienListCall<'a, C> {
5172        self._parent = Some(new_value.to_string());
5173        self
5174    }
5175    /// The `next_page_token` value returned from a previous List request, if any.
5176    ///
5177    /// Sets the *page token* query property to the given value.
5178    pub fn page_token(mut self, new_value: &str) -> LienListCall<'a, C> {
5179        self._page_token = Some(new_value.to_string());
5180        self
5181    }
5182    /// The maximum number of items to return. This is a suggestion for the server. The server can return fewer liens than requested. If unspecified, server picks an appropriate default.
5183    ///
5184    /// Sets the *page size* query property to the given value.
5185    pub fn page_size(mut self, new_value: i32) -> LienListCall<'a, C> {
5186        self._page_size = Some(new_value);
5187        self
5188    }
5189    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5190    /// while executing the actual API request.
5191    ///
5192    /// ````text
5193    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5194    /// ````
5195    ///
5196    /// Sets the *delegate* property to the given value.
5197    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienListCall<'a, C> {
5198        self._delegate = Some(new_value);
5199        self
5200    }
5201
5202    /// Set any additional parameter of the query string used in the request.
5203    /// It should be used to set parameters which are not yet available through their own
5204    /// setters.
5205    ///
5206    /// Please note that this method must not be used to set any of the known parameters
5207    /// which have their own setter method. If done anyway, the request will fail.
5208    ///
5209    /// # Additional Parameters
5210    ///
5211    /// * *$.xgafv* (query-string) - V1 error format.
5212    /// * *access_token* (query-string) - OAuth access token.
5213    /// * *alt* (query-string) - Data format for response.
5214    /// * *callback* (query-string) - JSONP
5215    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5216    /// * *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.
5217    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5218    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5219    /// * *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.
5220    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5221    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5222    pub fn param<T>(mut self, name: T, value: T) -> LienListCall<'a, C>
5223    where
5224        T: AsRef<str>,
5225    {
5226        self._additional_params
5227            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5228        self
5229    }
5230
5231    /// Identifies the authorization scope for the method you are building.
5232    ///
5233    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5234    /// [`Scope::CloudPlatform`].
5235    ///
5236    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5237    /// tokens for more than one scope.
5238    ///
5239    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5240    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5241    /// sufficient, a read-write scope will do as well.
5242    pub fn add_scope<St>(mut self, scope: St) -> LienListCall<'a, C>
5243    where
5244        St: AsRef<str>,
5245    {
5246        self._scopes.insert(String::from(scope.as_ref()));
5247        self
5248    }
5249    /// Identifies the authorization scope(s) for the method you are building.
5250    ///
5251    /// See [`Self::add_scope()`] for details.
5252    pub fn add_scopes<I, St>(mut self, scopes: I) -> LienListCall<'a, C>
5253    where
5254        I: IntoIterator<Item = St>,
5255        St: AsRef<str>,
5256    {
5257        self._scopes
5258            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5259        self
5260    }
5261
5262    /// Removes all scopes, and no default scope will be used either.
5263    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5264    /// for details).
5265    pub fn clear_scopes(mut self) -> LienListCall<'a, C> {
5266        self._scopes.clear();
5267        self
5268    }
5269}
5270
5271/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
5272///
5273/// A builder for the *get* method supported by a *operation* resource.
5274/// It is not used directly, but through a [`OperationMethods`] instance.
5275///
5276/// # Example
5277///
5278/// Instantiate a resource method builder
5279///
5280/// ```test_harness,no_run
5281/// # extern crate hyper;
5282/// # extern crate hyper_rustls;
5283/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
5284/// # async fn dox() {
5285/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5286///
5287/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5288/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5289/// #     secret,
5290/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5291/// # ).build().await.unwrap();
5292///
5293/// # let client = hyper_util::client::legacy::Client::builder(
5294/// #     hyper_util::rt::TokioExecutor::new()
5295/// # )
5296/// # .build(
5297/// #     hyper_rustls::HttpsConnectorBuilder::new()
5298/// #         .with_native_roots()
5299/// #         .unwrap()
5300/// #         .https_or_http()
5301/// #         .enable_http1()
5302/// #         .build()
5303/// # );
5304/// # let mut hub = CloudResourceManager::new(client, auth);
5305/// // You can configure optional parameters by calling the respective setters at will, and
5306/// // execute the final call using `doit()`.
5307/// // Values shown here are possibly random and not representative !
5308/// let result = hub.operations().get("name")
5309///              .doit().await;
5310/// # }
5311/// ```
5312pub struct OperationGetCall<'a, C>
5313where
5314    C: 'a,
5315{
5316    hub: &'a CloudResourceManager<C>,
5317    _name: String,
5318    _delegate: Option<&'a mut dyn common::Delegate>,
5319    _additional_params: HashMap<String, String>,
5320    _scopes: BTreeSet<String>,
5321}
5322
5323impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
5324
5325impl<'a, C> OperationGetCall<'a, C>
5326where
5327    C: common::Connector,
5328{
5329    /// Perform the operation you have build so far.
5330    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5331        use std::borrow::Cow;
5332        use std::io::{Read, Seek};
5333
5334        use common::{url::Params, ToParts};
5335        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5336
5337        let mut dd = common::DefaultDelegate;
5338        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5339        dlg.begin(common::MethodInfo {
5340            id: "cloudresourcemanager.operations.get",
5341            http_method: hyper::Method::GET,
5342        });
5343
5344        for &field in ["alt", "name"].iter() {
5345            if self._additional_params.contains_key(field) {
5346                dlg.finished(false);
5347                return Err(common::Error::FieldClash(field));
5348            }
5349        }
5350
5351        let mut params = Params::with_capacity(3 + self._additional_params.len());
5352        params.push("name", self._name);
5353
5354        params.extend(self._additional_params.iter());
5355
5356        params.push("alt", "json");
5357        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5358        if self._scopes.is_empty() {
5359            self._scopes
5360                .insert(Scope::CloudPlatform.as_ref().to_string());
5361        }
5362
5363        #[allow(clippy::single_element_loop)]
5364        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5365            url = params.uri_replacement(url, param_name, find_this, true);
5366        }
5367        {
5368            let to_remove = ["name"];
5369            params.remove_params(&to_remove);
5370        }
5371
5372        let url = params.parse_with_url(&url);
5373
5374        loop {
5375            let token = match self
5376                .hub
5377                .auth
5378                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5379                .await
5380            {
5381                Ok(token) => token,
5382                Err(e) => match dlg.token(e) {
5383                    Ok(token) => token,
5384                    Err(e) => {
5385                        dlg.finished(false);
5386                        return Err(common::Error::MissingToken(e));
5387                    }
5388                },
5389            };
5390            let mut req_result = {
5391                let client = &self.hub.client;
5392                dlg.pre_request();
5393                let mut req_builder = hyper::Request::builder()
5394                    .method(hyper::Method::GET)
5395                    .uri(url.as_str())
5396                    .header(USER_AGENT, self.hub._user_agent.clone());
5397
5398                if let Some(token) = token.as_ref() {
5399                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5400                }
5401
5402                let request = req_builder
5403                    .header(CONTENT_LENGTH, 0_u64)
5404                    .body(common::to_body::<String>(None));
5405
5406                client.request(request.unwrap()).await
5407            };
5408
5409            match req_result {
5410                Err(err) => {
5411                    if let common::Retry::After(d) = dlg.http_error(&err) {
5412                        sleep(d).await;
5413                        continue;
5414                    }
5415                    dlg.finished(false);
5416                    return Err(common::Error::HttpError(err));
5417                }
5418                Ok(res) => {
5419                    let (mut parts, body) = res.into_parts();
5420                    let mut body = common::Body::new(body);
5421                    if !parts.status.is_success() {
5422                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5423                        let error = serde_json::from_str(&common::to_string(&bytes));
5424                        let response = common::to_response(parts, bytes.into());
5425
5426                        if let common::Retry::After(d) =
5427                            dlg.http_failure(&response, error.as_ref().ok())
5428                        {
5429                            sleep(d).await;
5430                            continue;
5431                        }
5432
5433                        dlg.finished(false);
5434
5435                        return Err(match error {
5436                            Ok(value) => common::Error::BadRequest(value),
5437                            _ => common::Error::Failure(response),
5438                        });
5439                    }
5440                    let response = {
5441                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5442                        let encoded = common::to_string(&bytes);
5443                        match serde_json::from_str(&encoded) {
5444                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5445                            Err(error) => {
5446                                dlg.response_json_decode_error(&encoded, &error);
5447                                return Err(common::Error::JsonDecodeError(
5448                                    encoded.to_string(),
5449                                    error,
5450                                ));
5451                            }
5452                        }
5453                    };
5454
5455                    dlg.finished(true);
5456                    return Ok(response);
5457                }
5458            }
5459        }
5460    }
5461
5462    /// The name of the operation resource.
5463    ///
5464    /// Sets the *name* path property to the given value.
5465    ///
5466    /// Even though the property as already been set when instantiating this call,
5467    /// we provide this method for API completeness.
5468    pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
5469        self._name = new_value.to_string();
5470        self
5471    }
5472    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5473    /// while executing the actual API request.
5474    ///
5475    /// ````text
5476    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5477    /// ````
5478    ///
5479    /// Sets the *delegate* property to the given value.
5480    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
5481        self._delegate = Some(new_value);
5482        self
5483    }
5484
5485    /// Set any additional parameter of the query string used in the request.
5486    /// It should be used to set parameters which are not yet available through their own
5487    /// setters.
5488    ///
5489    /// Please note that this method must not be used to set any of the known parameters
5490    /// which have their own setter method. If done anyway, the request will fail.
5491    ///
5492    /// # Additional Parameters
5493    ///
5494    /// * *$.xgafv* (query-string) - V1 error format.
5495    /// * *access_token* (query-string) - OAuth access token.
5496    /// * *alt* (query-string) - Data format for response.
5497    /// * *callback* (query-string) - JSONP
5498    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5499    /// * *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.
5500    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5501    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5502    /// * *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.
5503    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5504    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5505    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
5506    where
5507        T: AsRef<str>,
5508    {
5509        self._additional_params
5510            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5511        self
5512    }
5513
5514    /// Identifies the authorization scope for the method you are building.
5515    ///
5516    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5517    /// [`Scope::CloudPlatform`].
5518    ///
5519    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5520    /// tokens for more than one scope.
5521    ///
5522    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5523    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5524    /// sufficient, a read-write scope will do as well.
5525    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
5526    where
5527        St: AsRef<str>,
5528    {
5529        self._scopes.insert(String::from(scope.as_ref()));
5530        self
5531    }
5532    /// Identifies the authorization scope(s) for the method you are building.
5533    ///
5534    /// See [`Self::add_scope()`] for details.
5535    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
5536    where
5537        I: IntoIterator<Item = St>,
5538        St: AsRef<str>,
5539    {
5540        self._scopes
5541            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5542        self
5543    }
5544
5545    /// Removes all scopes, and no default scope will be used either.
5546    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5547    /// for details).
5548    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
5549        self._scopes.clear();
5550        self
5551    }
5552}
5553
5554/// Clears a `Policy` from a resource.
5555///
5556/// A builder for the *clearOrgPolicy* method supported by a *organization* resource.
5557/// It is not used directly, but through a [`OrganizationMethods`] instance.
5558///
5559/// # Example
5560///
5561/// Instantiate a resource method builder
5562///
5563/// ```test_harness,no_run
5564/// # extern crate hyper;
5565/// # extern crate hyper_rustls;
5566/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
5567/// use cloudresourcemanager1::api::ClearOrgPolicyRequest;
5568/// # async fn dox() {
5569/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5570///
5571/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5572/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5573/// #     secret,
5574/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5575/// # ).build().await.unwrap();
5576///
5577/// # let client = hyper_util::client::legacy::Client::builder(
5578/// #     hyper_util::rt::TokioExecutor::new()
5579/// # )
5580/// # .build(
5581/// #     hyper_rustls::HttpsConnectorBuilder::new()
5582/// #         .with_native_roots()
5583/// #         .unwrap()
5584/// #         .https_or_http()
5585/// #         .enable_http1()
5586/// #         .build()
5587/// # );
5588/// # let mut hub = CloudResourceManager::new(client, auth);
5589/// // As the method needs a request, you would usually fill it with the desired information
5590/// // into the respective structure. Some of the parts shown here might not be applicable !
5591/// // Values shown here are possibly random and not representative !
5592/// let mut req = ClearOrgPolicyRequest::default();
5593///
5594/// // You can configure optional parameters by calling the respective setters at will, and
5595/// // execute the final call using `doit()`.
5596/// // Values shown here are possibly random and not representative !
5597/// let result = hub.organizations().clear_org_policy(req, "resource")
5598///              .doit().await;
5599/// # }
5600/// ```
5601pub struct OrganizationClearOrgPolicyCall<'a, C>
5602where
5603    C: 'a,
5604{
5605    hub: &'a CloudResourceManager<C>,
5606    _request: ClearOrgPolicyRequest,
5607    _resource: String,
5608    _delegate: Option<&'a mut dyn common::Delegate>,
5609    _additional_params: HashMap<String, String>,
5610    _scopes: BTreeSet<String>,
5611}
5612
5613impl<'a, C> common::CallBuilder for OrganizationClearOrgPolicyCall<'a, C> {}
5614
5615impl<'a, C> OrganizationClearOrgPolicyCall<'a, C>
5616where
5617    C: common::Connector,
5618{
5619    /// Perform the operation you have build so far.
5620    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5621        use std::borrow::Cow;
5622        use std::io::{Read, Seek};
5623
5624        use common::{url::Params, ToParts};
5625        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5626
5627        let mut dd = common::DefaultDelegate;
5628        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5629        dlg.begin(common::MethodInfo {
5630            id: "cloudresourcemanager.organizations.clearOrgPolicy",
5631            http_method: hyper::Method::POST,
5632        });
5633
5634        for &field in ["alt", "resource"].iter() {
5635            if self._additional_params.contains_key(field) {
5636                dlg.finished(false);
5637                return Err(common::Error::FieldClash(field));
5638            }
5639        }
5640
5641        let mut params = Params::with_capacity(4 + self._additional_params.len());
5642        params.push("resource", self._resource);
5643
5644        params.extend(self._additional_params.iter());
5645
5646        params.push("alt", "json");
5647        let mut url = self.hub._base_url.clone() + "v1/{+resource}:clearOrgPolicy";
5648        if self._scopes.is_empty() {
5649            self._scopes
5650                .insert(Scope::CloudPlatform.as_ref().to_string());
5651        }
5652
5653        #[allow(clippy::single_element_loop)]
5654        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5655            url = params.uri_replacement(url, param_name, find_this, true);
5656        }
5657        {
5658            let to_remove = ["resource"];
5659            params.remove_params(&to_remove);
5660        }
5661
5662        let url = params.parse_with_url(&url);
5663
5664        let mut json_mime_type = mime::APPLICATION_JSON;
5665        let mut request_value_reader = {
5666            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5667            common::remove_json_null_values(&mut value);
5668            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5669            serde_json::to_writer(&mut dst, &value).unwrap();
5670            dst
5671        };
5672        let request_size = request_value_reader
5673            .seek(std::io::SeekFrom::End(0))
5674            .unwrap();
5675        request_value_reader
5676            .seek(std::io::SeekFrom::Start(0))
5677            .unwrap();
5678
5679        loop {
5680            let token = match self
5681                .hub
5682                .auth
5683                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5684                .await
5685            {
5686                Ok(token) => token,
5687                Err(e) => match dlg.token(e) {
5688                    Ok(token) => token,
5689                    Err(e) => {
5690                        dlg.finished(false);
5691                        return Err(common::Error::MissingToken(e));
5692                    }
5693                },
5694            };
5695            request_value_reader
5696                .seek(std::io::SeekFrom::Start(0))
5697                .unwrap();
5698            let mut req_result = {
5699                let client = &self.hub.client;
5700                dlg.pre_request();
5701                let mut req_builder = hyper::Request::builder()
5702                    .method(hyper::Method::POST)
5703                    .uri(url.as_str())
5704                    .header(USER_AGENT, self.hub._user_agent.clone());
5705
5706                if let Some(token) = token.as_ref() {
5707                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5708                }
5709
5710                let request = req_builder
5711                    .header(CONTENT_TYPE, json_mime_type.to_string())
5712                    .header(CONTENT_LENGTH, request_size as u64)
5713                    .body(common::to_body(
5714                        request_value_reader.get_ref().clone().into(),
5715                    ));
5716
5717                client.request(request.unwrap()).await
5718            };
5719
5720            match req_result {
5721                Err(err) => {
5722                    if let common::Retry::After(d) = dlg.http_error(&err) {
5723                        sleep(d).await;
5724                        continue;
5725                    }
5726                    dlg.finished(false);
5727                    return Err(common::Error::HttpError(err));
5728                }
5729                Ok(res) => {
5730                    let (mut parts, body) = res.into_parts();
5731                    let mut body = common::Body::new(body);
5732                    if !parts.status.is_success() {
5733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5734                        let error = serde_json::from_str(&common::to_string(&bytes));
5735                        let response = common::to_response(parts, bytes.into());
5736
5737                        if let common::Retry::After(d) =
5738                            dlg.http_failure(&response, error.as_ref().ok())
5739                        {
5740                            sleep(d).await;
5741                            continue;
5742                        }
5743
5744                        dlg.finished(false);
5745
5746                        return Err(match error {
5747                            Ok(value) => common::Error::BadRequest(value),
5748                            _ => common::Error::Failure(response),
5749                        });
5750                    }
5751                    let response = {
5752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5753                        let encoded = common::to_string(&bytes);
5754                        match serde_json::from_str(&encoded) {
5755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5756                            Err(error) => {
5757                                dlg.response_json_decode_error(&encoded, &error);
5758                                return Err(common::Error::JsonDecodeError(
5759                                    encoded.to_string(),
5760                                    error,
5761                                ));
5762                            }
5763                        }
5764                    };
5765
5766                    dlg.finished(true);
5767                    return Ok(response);
5768                }
5769            }
5770        }
5771    }
5772
5773    ///
5774    /// Sets the *request* property to the given value.
5775    ///
5776    /// Even though the property as already been set when instantiating this call,
5777    /// we provide this method for API completeness.
5778    pub fn request(
5779        mut self,
5780        new_value: ClearOrgPolicyRequest,
5781    ) -> OrganizationClearOrgPolicyCall<'a, C> {
5782        self._request = new_value;
5783        self
5784    }
5785    /// Name of the resource for the `Policy` to clear.
5786    ///
5787    /// Sets the *resource* path property to the given value.
5788    ///
5789    /// Even though the property as already been set when instantiating this call,
5790    /// we provide this method for API completeness.
5791    pub fn resource(mut self, new_value: &str) -> OrganizationClearOrgPolicyCall<'a, C> {
5792        self._resource = new_value.to_string();
5793        self
5794    }
5795    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5796    /// while executing the actual API request.
5797    ///
5798    /// ````text
5799    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5800    /// ````
5801    ///
5802    /// Sets the *delegate* property to the given value.
5803    pub fn delegate(
5804        mut self,
5805        new_value: &'a mut dyn common::Delegate,
5806    ) -> OrganizationClearOrgPolicyCall<'a, C> {
5807        self._delegate = Some(new_value);
5808        self
5809    }
5810
5811    /// Set any additional parameter of the query string used in the request.
5812    /// It should be used to set parameters which are not yet available through their own
5813    /// setters.
5814    ///
5815    /// Please note that this method must not be used to set any of the known parameters
5816    /// which have their own setter method. If done anyway, the request will fail.
5817    ///
5818    /// # Additional Parameters
5819    ///
5820    /// * *$.xgafv* (query-string) - V1 error format.
5821    /// * *access_token* (query-string) - OAuth access token.
5822    /// * *alt* (query-string) - Data format for response.
5823    /// * *callback* (query-string) - JSONP
5824    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5825    /// * *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.
5826    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5827    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5828    /// * *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.
5829    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5830    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5831    pub fn param<T>(mut self, name: T, value: T) -> OrganizationClearOrgPolicyCall<'a, C>
5832    where
5833        T: AsRef<str>,
5834    {
5835        self._additional_params
5836            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5837        self
5838    }
5839
5840    /// Identifies the authorization scope for the method you are building.
5841    ///
5842    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5843    /// [`Scope::CloudPlatform`].
5844    ///
5845    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5846    /// tokens for more than one scope.
5847    ///
5848    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5849    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5850    /// sufficient, a read-write scope will do as well.
5851    pub fn add_scope<St>(mut self, scope: St) -> OrganizationClearOrgPolicyCall<'a, C>
5852    where
5853        St: AsRef<str>,
5854    {
5855        self._scopes.insert(String::from(scope.as_ref()));
5856        self
5857    }
5858    /// Identifies the authorization scope(s) for the method you are building.
5859    ///
5860    /// See [`Self::add_scope()`] for details.
5861    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationClearOrgPolicyCall<'a, C>
5862    where
5863        I: IntoIterator<Item = St>,
5864        St: AsRef<str>,
5865    {
5866        self._scopes
5867            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5868        self
5869    }
5870
5871    /// Removes all scopes, and no default scope will be used either.
5872    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5873    /// for details).
5874    pub fn clear_scopes(mut self) -> OrganizationClearOrgPolicyCall<'a, C> {
5875        self._scopes.clear();
5876        self
5877    }
5878}
5879
5880/// Fetches an Organization resource identified by the specified resource name.
5881///
5882/// A builder for the *get* method supported by a *organization* resource.
5883/// It is not used directly, but through a [`OrganizationMethods`] instance.
5884///
5885/// # Example
5886///
5887/// Instantiate a resource method builder
5888///
5889/// ```test_harness,no_run
5890/// # extern crate hyper;
5891/// # extern crate hyper_rustls;
5892/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
5893/// # async fn dox() {
5894/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5895///
5896/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5897/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5898/// #     secret,
5899/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5900/// # ).build().await.unwrap();
5901///
5902/// # let client = hyper_util::client::legacy::Client::builder(
5903/// #     hyper_util::rt::TokioExecutor::new()
5904/// # )
5905/// # .build(
5906/// #     hyper_rustls::HttpsConnectorBuilder::new()
5907/// #         .with_native_roots()
5908/// #         .unwrap()
5909/// #         .https_or_http()
5910/// #         .enable_http1()
5911/// #         .build()
5912/// # );
5913/// # let mut hub = CloudResourceManager::new(client, auth);
5914/// // You can configure optional parameters by calling the respective setters at will, and
5915/// // execute the final call using `doit()`.
5916/// // Values shown here are possibly random and not representative !
5917/// let result = hub.organizations().get("name")
5918///              .doit().await;
5919/// # }
5920/// ```
5921pub struct OrganizationGetCall<'a, C>
5922where
5923    C: 'a,
5924{
5925    hub: &'a CloudResourceManager<C>,
5926    _name: String,
5927    _delegate: Option<&'a mut dyn common::Delegate>,
5928    _additional_params: HashMap<String, String>,
5929    _scopes: BTreeSet<String>,
5930}
5931
5932impl<'a, C> common::CallBuilder for OrganizationGetCall<'a, C> {}
5933
5934impl<'a, C> OrganizationGetCall<'a, C>
5935where
5936    C: common::Connector,
5937{
5938    /// Perform the operation you have build so far.
5939    pub async fn doit(mut self) -> common::Result<(common::Response, Organization)> {
5940        use std::borrow::Cow;
5941        use std::io::{Read, Seek};
5942
5943        use common::{url::Params, ToParts};
5944        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5945
5946        let mut dd = common::DefaultDelegate;
5947        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5948        dlg.begin(common::MethodInfo {
5949            id: "cloudresourcemanager.organizations.get",
5950            http_method: hyper::Method::GET,
5951        });
5952
5953        for &field in ["alt", "name"].iter() {
5954            if self._additional_params.contains_key(field) {
5955                dlg.finished(false);
5956                return Err(common::Error::FieldClash(field));
5957            }
5958        }
5959
5960        let mut params = Params::with_capacity(3 + self._additional_params.len());
5961        params.push("name", self._name);
5962
5963        params.extend(self._additional_params.iter());
5964
5965        params.push("alt", "json");
5966        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5967        if self._scopes.is_empty() {
5968            self._scopes
5969                .insert(Scope::CloudPlatform.as_ref().to_string());
5970        }
5971
5972        #[allow(clippy::single_element_loop)]
5973        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5974            url = params.uri_replacement(url, param_name, find_this, true);
5975        }
5976        {
5977            let to_remove = ["name"];
5978            params.remove_params(&to_remove);
5979        }
5980
5981        let url = params.parse_with_url(&url);
5982
5983        loop {
5984            let token = match self
5985                .hub
5986                .auth
5987                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5988                .await
5989            {
5990                Ok(token) => token,
5991                Err(e) => match dlg.token(e) {
5992                    Ok(token) => token,
5993                    Err(e) => {
5994                        dlg.finished(false);
5995                        return Err(common::Error::MissingToken(e));
5996                    }
5997                },
5998            };
5999            let mut req_result = {
6000                let client = &self.hub.client;
6001                dlg.pre_request();
6002                let mut req_builder = hyper::Request::builder()
6003                    .method(hyper::Method::GET)
6004                    .uri(url.as_str())
6005                    .header(USER_AGENT, self.hub._user_agent.clone());
6006
6007                if let Some(token) = token.as_ref() {
6008                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6009                }
6010
6011                let request = req_builder
6012                    .header(CONTENT_LENGTH, 0_u64)
6013                    .body(common::to_body::<String>(None));
6014
6015                client.request(request.unwrap()).await
6016            };
6017
6018            match req_result {
6019                Err(err) => {
6020                    if let common::Retry::After(d) = dlg.http_error(&err) {
6021                        sleep(d).await;
6022                        continue;
6023                    }
6024                    dlg.finished(false);
6025                    return Err(common::Error::HttpError(err));
6026                }
6027                Ok(res) => {
6028                    let (mut parts, body) = res.into_parts();
6029                    let mut body = common::Body::new(body);
6030                    if !parts.status.is_success() {
6031                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6032                        let error = serde_json::from_str(&common::to_string(&bytes));
6033                        let response = common::to_response(parts, bytes.into());
6034
6035                        if let common::Retry::After(d) =
6036                            dlg.http_failure(&response, error.as_ref().ok())
6037                        {
6038                            sleep(d).await;
6039                            continue;
6040                        }
6041
6042                        dlg.finished(false);
6043
6044                        return Err(match error {
6045                            Ok(value) => common::Error::BadRequest(value),
6046                            _ => common::Error::Failure(response),
6047                        });
6048                    }
6049                    let response = {
6050                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6051                        let encoded = common::to_string(&bytes);
6052                        match serde_json::from_str(&encoded) {
6053                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6054                            Err(error) => {
6055                                dlg.response_json_decode_error(&encoded, &error);
6056                                return Err(common::Error::JsonDecodeError(
6057                                    encoded.to_string(),
6058                                    error,
6059                                ));
6060                            }
6061                        }
6062                    };
6063
6064                    dlg.finished(true);
6065                    return Ok(response);
6066                }
6067            }
6068        }
6069    }
6070
6071    /// The resource name of the Organization to fetch. This is the organization's relative path in the API, formatted as "organizations/[organizationId]". For example, "organizations/1234".
6072    ///
6073    /// Sets the *name* path property to the given value.
6074    ///
6075    /// Even though the property as already been set when instantiating this call,
6076    /// we provide this method for API completeness.
6077    pub fn name(mut self, new_value: &str) -> OrganizationGetCall<'a, C> {
6078        self._name = new_value.to_string();
6079        self
6080    }
6081    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6082    /// while executing the actual API request.
6083    ///
6084    /// ````text
6085    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6086    /// ````
6087    ///
6088    /// Sets the *delegate* property to the given value.
6089    pub fn delegate(
6090        mut self,
6091        new_value: &'a mut dyn common::Delegate,
6092    ) -> OrganizationGetCall<'a, C> {
6093        self._delegate = Some(new_value);
6094        self
6095    }
6096
6097    /// Set any additional parameter of the query string used in the request.
6098    /// It should be used to set parameters which are not yet available through their own
6099    /// setters.
6100    ///
6101    /// Please note that this method must not be used to set any of the known parameters
6102    /// which have their own setter method. If done anyway, the request will fail.
6103    ///
6104    /// # Additional Parameters
6105    ///
6106    /// * *$.xgafv* (query-string) - V1 error format.
6107    /// * *access_token* (query-string) - OAuth access token.
6108    /// * *alt* (query-string) - Data format for response.
6109    /// * *callback* (query-string) - JSONP
6110    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6111    /// * *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.
6112    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6113    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6114    /// * *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.
6115    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6116    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6117    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetCall<'a, C>
6118    where
6119        T: AsRef<str>,
6120    {
6121        self._additional_params
6122            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6123        self
6124    }
6125
6126    /// Identifies the authorization scope for the method you are building.
6127    ///
6128    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6129    /// [`Scope::CloudPlatform`].
6130    ///
6131    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6132    /// tokens for more than one scope.
6133    ///
6134    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6135    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6136    /// sufficient, a read-write scope will do as well.
6137    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetCall<'a, C>
6138    where
6139        St: AsRef<str>,
6140    {
6141        self._scopes.insert(String::from(scope.as_ref()));
6142        self
6143    }
6144    /// Identifies the authorization scope(s) for the method you are building.
6145    ///
6146    /// See [`Self::add_scope()`] for details.
6147    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetCall<'a, C>
6148    where
6149        I: IntoIterator<Item = St>,
6150        St: AsRef<str>,
6151    {
6152        self._scopes
6153            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6154        self
6155    }
6156
6157    /// Removes all scopes, and no default scope will be used either.
6158    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6159    /// for details).
6160    pub fn clear_scopes(mut self) -> OrganizationGetCall<'a, C> {
6161        self._scopes.clear();
6162        self
6163    }
6164}
6165
6166/// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
6167///
6168/// A builder for the *getEffectiveOrgPolicy* method supported by a *organization* resource.
6169/// It is not used directly, but through a [`OrganizationMethods`] instance.
6170///
6171/// # Example
6172///
6173/// Instantiate a resource method builder
6174///
6175/// ```test_harness,no_run
6176/// # extern crate hyper;
6177/// # extern crate hyper_rustls;
6178/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
6179/// use cloudresourcemanager1::api::GetEffectiveOrgPolicyRequest;
6180/// # async fn dox() {
6181/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6182///
6183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6184/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6185/// #     secret,
6186/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6187/// # ).build().await.unwrap();
6188///
6189/// # let client = hyper_util::client::legacy::Client::builder(
6190/// #     hyper_util::rt::TokioExecutor::new()
6191/// # )
6192/// # .build(
6193/// #     hyper_rustls::HttpsConnectorBuilder::new()
6194/// #         .with_native_roots()
6195/// #         .unwrap()
6196/// #         .https_or_http()
6197/// #         .enable_http1()
6198/// #         .build()
6199/// # );
6200/// # let mut hub = CloudResourceManager::new(client, auth);
6201/// // As the method needs a request, you would usually fill it with the desired information
6202/// // into the respective structure. Some of the parts shown here might not be applicable !
6203/// // Values shown here are possibly random and not representative !
6204/// let mut req = GetEffectiveOrgPolicyRequest::default();
6205///
6206/// // You can configure optional parameters by calling the respective setters at will, and
6207/// // execute the final call using `doit()`.
6208/// // Values shown here are possibly random and not representative !
6209/// let result = hub.organizations().get_effective_org_policy(req, "resource")
6210///              .doit().await;
6211/// # }
6212/// ```
6213pub struct OrganizationGetEffectiveOrgPolicyCall<'a, C>
6214where
6215    C: 'a,
6216{
6217    hub: &'a CloudResourceManager<C>,
6218    _request: GetEffectiveOrgPolicyRequest,
6219    _resource: String,
6220    _delegate: Option<&'a mut dyn common::Delegate>,
6221    _additional_params: HashMap<String, String>,
6222    _scopes: BTreeSet<String>,
6223}
6224
6225impl<'a, C> common::CallBuilder for OrganizationGetEffectiveOrgPolicyCall<'a, C> {}
6226
6227impl<'a, C> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6228where
6229    C: common::Connector,
6230{
6231    /// Perform the operation you have build so far.
6232    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
6233        use std::borrow::Cow;
6234        use std::io::{Read, Seek};
6235
6236        use common::{url::Params, ToParts};
6237        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6238
6239        let mut dd = common::DefaultDelegate;
6240        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6241        dlg.begin(common::MethodInfo {
6242            id: "cloudresourcemanager.organizations.getEffectiveOrgPolicy",
6243            http_method: hyper::Method::POST,
6244        });
6245
6246        for &field in ["alt", "resource"].iter() {
6247            if self._additional_params.contains_key(field) {
6248                dlg.finished(false);
6249                return Err(common::Error::FieldClash(field));
6250            }
6251        }
6252
6253        let mut params = Params::with_capacity(4 + self._additional_params.len());
6254        params.push("resource", self._resource);
6255
6256        params.extend(self._additional_params.iter());
6257
6258        params.push("alt", "json");
6259        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getEffectiveOrgPolicy";
6260        if self._scopes.is_empty() {
6261            self._scopes
6262                .insert(Scope::CloudPlatform.as_ref().to_string());
6263        }
6264
6265        #[allow(clippy::single_element_loop)]
6266        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6267            url = params.uri_replacement(url, param_name, find_this, true);
6268        }
6269        {
6270            let to_remove = ["resource"];
6271            params.remove_params(&to_remove);
6272        }
6273
6274        let url = params.parse_with_url(&url);
6275
6276        let mut json_mime_type = mime::APPLICATION_JSON;
6277        let mut request_value_reader = {
6278            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6279            common::remove_json_null_values(&mut value);
6280            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6281            serde_json::to_writer(&mut dst, &value).unwrap();
6282            dst
6283        };
6284        let request_size = request_value_reader
6285            .seek(std::io::SeekFrom::End(0))
6286            .unwrap();
6287        request_value_reader
6288            .seek(std::io::SeekFrom::Start(0))
6289            .unwrap();
6290
6291        loop {
6292            let token = match self
6293                .hub
6294                .auth
6295                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6296                .await
6297            {
6298                Ok(token) => token,
6299                Err(e) => match dlg.token(e) {
6300                    Ok(token) => token,
6301                    Err(e) => {
6302                        dlg.finished(false);
6303                        return Err(common::Error::MissingToken(e));
6304                    }
6305                },
6306            };
6307            request_value_reader
6308                .seek(std::io::SeekFrom::Start(0))
6309                .unwrap();
6310            let mut req_result = {
6311                let client = &self.hub.client;
6312                dlg.pre_request();
6313                let mut req_builder = hyper::Request::builder()
6314                    .method(hyper::Method::POST)
6315                    .uri(url.as_str())
6316                    .header(USER_AGENT, self.hub._user_agent.clone());
6317
6318                if let Some(token) = token.as_ref() {
6319                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6320                }
6321
6322                let request = req_builder
6323                    .header(CONTENT_TYPE, json_mime_type.to_string())
6324                    .header(CONTENT_LENGTH, request_size as u64)
6325                    .body(common::to_body(
6326                        request_value_reader.get_ref().clone().into(),
6327                    ));
6328
6329                client.request(request.unwrap()).await
6330            };
6331
6332            match req_result {
6333                Err(err) => {
6334                    if let common::Retry::After(d) = dlg.http_error(&err) {
6335                        sleep(d).await;
6336                        continue;
6337                    }
6338                    dlg.finished(false);
6339                    return Err(common::Error::HttpError(err));
6340                }
6341                Ok(res) => {
6342                    let (mut parts, body) = res.into_parts();
6343                    let mut body = common::Body::new(body);
6344                    if !parts.status.is_success() {
6345                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6346                        let error = serde_json::from_str(&common::to_string(&bytes));
6347                        let response = common::to_response(parts, bytes.into());
6348
6349                        if let common::Retry::After(d) =
6350                            dlg.http_failure(&response, error.as_ref().ok())
6351                        {
6352                            sleep(d).await;
6353                            continue;
6354                        }
6355
6356                        dlg.finished(false);
6357
6358                        return Err(match error {
6359                            Ok(value) => common::Error::BadRequest(value),
6360                            _ => common::Error::Failure(response),
6361                        });
6362                    }
6363                    let response = {
6364                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6365                        let encoded = common::to_string(&bytes);
6366                        match serde_json::from_str(&encoded) {
6367                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6368                            Err(error) => {
6369                                dlg.response_json_decode_error(&encoded, &error);
6370                                return Err(common::Error::JsonDecodeError(
6371                                    encoded.to_string(),
6372                                    error,
6373                                ));
6374                            }
6375                        }
6376                    };
6377
6378                    dlg.finished(true);
6379                    return Ok(response);
6380                }
6381            }
6382        }
6383    }
6384
6385    ///
6386    /// Sets the *request* property to the given value.
6387    ///
6388    /// Even though the property as already been set when instantiating this call,
6389    /// we provide this method for API completeness.
6390    pub fn request(
6391        mut self,
6392        new_value: GetEffectiveOrgPolicyRequest,
6393    ) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6394        self._request = new_value;
6395        self
6396    }
6397    /// The name of the resource to start computing the effective `Policy`.
6398    ///
6399    /// Sets the *resource* path property to the given value.
6400    ///
6401    /// Even though the property as already been set when instantiating this call,
6402    /// we provide this method for API completeness.
6403    pub fn resource(mut self, new_value: &str) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6404        self._resource = new_value.to_string();
6405        self
6406    }
6407    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6408    /// while executing the actual API request.
6409    ///
6410    /// ````text
6411    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6412    /// ````
6413    ///
6414    /// Sets the *delegate* property to the given value.
6415    pub fn delegate(
6416        mut self,
6417        new_value: &'a mut dyn common::Delegate,
6418    ) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6419        self._delegate = Some(new_value);
6420        self
6421    }
6422
6423    /// Set any additional parameter of the query string used in the request.
6424    /// It should be used to set parameters which are not yet available through their own
6425    /// setters.
6426    ///
6427    /// Please note that this method must not be used to set any of the known parameters
6428    /// which have their own setter method. If done anyway, the request will fail.
6429    ///
6430    /// # Additional Parameters
6431    ///
6432    /// * *$.xgafv* (query-string) - V1 error format.
6433    /// * *access_token* (query-string) - OAuth access token.
6434    /// * *alt* (query-string) - Data format for response.
6435    /// * *callback* (query-string) - JSONP
6436    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6437    /// * *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.
6438    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6439    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6440    /// * *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.
6441    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6442    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6443    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6444    where
6445        T: AsRef<str>,
6446    {
6447        self._additional_params
6448            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6449        self
6450    }
6451
6452    /// Identifies the authorization scope for the method you are building.
6453    ///
6454    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6455    /// [`Scope::CloudPlatform`].
6456    ///
6457    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6458    /// tokens for more than one scope.
6459    ///
6460    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6461    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6462    /// sufficient, a read-write scope will do as well.
6463    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6464    where
6465        St: AsRef<str>,
6466    {
6467        self._scopes.insert(String::from(scope.as_ref()));
6468        self
6469    }
6470    /// Identifies the authorization scope(s) for the method you are building.
6471    ///
6472    /// See [`Self::add_scope()`] for details.
6473    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6474    where
6475        I: IntoIterator<Item = St>,
6476        St: AsRef<str>,
6477    {
6478        self._scopes
6479            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6480        self
6481    }
6482
6483    /// Removes all scopes, and no default scope will be used either.
6484    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6485    /// for details).
6486    pub fn clear_scopes(mut self) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6487        self._scopes.clear();
6488        self
6489    }
6490}
6491
6492/// Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization
6493///
6494/// A builder for the *getIamPolicy* method supported by a *organization* resource.
6495/// It is not used directly, but through a [`OrganizationMethods`] instance.
6496///
6497/// # Example
6498///
6499/// Instantiate a resource method builder
6500///
6501/// ```test_harness,no_run
6502/// # extern crate hyper;
6503/// # extern crate hyper_rustls;
6504/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
6505/// use cloudresourcemanager1::api::GetIamPolicyRequest;
6506/// # async fn dox() {
6507/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6508///
6509/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6510/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6511/// #     secret,
6512/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6513/// # ).build().await.unwrap();
6514///
6515/// # let client = hyper_util::client::legacy::Client::builder(
6516/// #     hyper_util::rt::TokioExecutor::new()
6517/// # )
6518/// # .build(
6519/// #     hyper_rustls::HttpsConnectorBuilder::new()
6520/// #         .with_native_roots()
6521/// #         .unwrap()
6522/// #         .https_or_http()
6523/// #         .enable_http1()
6524/// #         .build()
6525/// # );
6526/// # let mut hub = CloudResourceManager::new(client, auth);
6527/// // As the method needs a request, you would usually fill it with the desired information
6528/// // into the respective structure. Some of the parts shown here might not be applicable !
6529/// // Values shown here are possibly random and not representative !
6530/// let mut req = GetIamPolicyRequest::default();
6531///
6532/// // You can configure optional parameters by calling the respective setters at will, and
6533/// // execute the final call using `doit()`.
6534/// // Values shown here are possibly random and not representative !
6535/// let result = hub.organizations().get_iam_policy(req, "resource")
6536///              .doit().await;
6537/// # }
6538/// ```
6539pub struct OrganizationGetIamPolicyCall<'a, C>
6540where
6541    C: 'a,
6542{
6543    hub: &'a CloudResourceManager<C>,
6544    _request: GetIamPolicyRequest,
6545    _resource: String,
6546    _delegate: Option<&'a mut dyn common::Delegate>,
6547    _additional_params: HashMap<String, String>,
6548    _scopes: BTreeSet<String>,
6549}
6550
6551impl<'a, C> common::CallBuilder for OrganizationGetIamPolicyCall<'a, C> {}
6552
6553impl<'a, C> OrganizationGetIamPolicyCall<'a, C>
6554where
6555    C: common::Connector,
6556{
6557    /// Perform the operation you have build so far.
6558    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6559        use std::borrow::Cow;
6560        use std::io::{Read, Seek};
6561
6562        use common::{url::Params, ToParts};
6563        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6564
6565        let mut dd = common::DefaultDelegate;
6566        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6567        dlg.begin(common::MethodInfo {
6568            id: "cloudresourcemanager.organizations.getIamPolicy",
6569            http_method: hyper::Method::POST,
6570        });
6571
6572        for &field in ["alt", "resource"].iter() {
6573            if self._additional_params.contains_key(field) {
6574                dlg.finished(false);
6575                return Err(common::Error::FieldClash(field));
6576            }
6577        }
6578
6579        let mut params = Params::with_capacity(4 + self._additional_params.len());
6580        params.push("resource", self._resource);
6581
6582        params.extend(self._additional_params.iter());
6583
6584        params.push("alt", "json");
6585        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
6586        if self._scopes.is_empty() {
6587            self._scopes
6588                .insert(Scope::CloudPlatform.as_ref().to_string());
6589        }
6590
6591        #[allow(clippy::single_element_loop)]
6592        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6593            url = params.uri_replacement(url, param_name, find_this, true);
6594        }
6595        {
6596            let to_remove = ["resource"];
6597            params.remove_params(&to_remove);
6598        }
6599
6600        let url = params.parse_with_url(&url);
6601
6602        let mut json_mime_type = mime::APPLICATION_JSON;
6603        let mut request_value_reader = {
6604            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6605            common::remove_json_null_values(&mut value);
6606            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6607            serde_json::to_writer(&mut dst, &value).unwrap();
6608            dst
6609        };
6610        let request_size = request_value_reader
6611            .seek(std::io::SeekFrom::End(0))
6612            .unwrap();
6613        request_value_reader
6614            .seek(std::io::SeekFrom::Start(0))
6615            .unwrap();
6616
6617        loop {
6618            let token = match self
6619                .hub
6620                .auth
6621                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6622                .await
6623            {
6624                Ok(token) => token,
6625                Err(e) => match dlg.token(e) {
6626                    Ok(token) => token,
6627                    Err(e) => {
6628                        dlg.finished(false);
6629                        return Err(common::Error::MissingToken(e));
6630                    }
6631                },
6632            };
6633            request_value_reader
6634                .seek(std::io::SeekFrom::Start(0))
6635                .unwrap();
6636            let mut req_result = {
6637                let client = &self.hub.client;
6638                dlg.pre_request();
6639                let mut req_builder = hyper::Request::builder()
6640                    .method(hyper::Method::POST)
6641                    .uri(url.as_str())
6642                    .header(USER_AGENT, self.hub._user_agent.clone());
6643
6644                if let Some(token) = token.as_ref() {
6645                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6646                }
6647
6648                let request = req_builder
6649                    .header(CONTENT_TYPE, json_mime_type.to_string())
6650                    .header(CONTENT_LENGTH, request_size as u64)
6651                    .body(common::to_body(
6652                        request_value_reader.get_ref().clone().into(),
6653                    ));
6654
6655                client.request(request.unwrap()).await
6656            };
6657
6658            match req_result {
6659                Err(err) => {
6660                    if let common::Retry::After(d) = dlg.http_error(&err) {
6661                        sleep(d).await;
6662                        continue;
6663                    }
6664                    dlg.finished(false);
6665                    return Err(common::Error::HttpError(err));
6666                }
6667                Ok(res) => {
6668                    let (mut parts, body) = res.into_parts();
6669                    let mut body = common::Body::new(body);
6670                    if !parts.status.is_success() {
6671                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6672                        let error = serde_json::from_str(&common::to_string(&bytes));
6673                        let response = common::to_response(parts, bytes.into());
6674
6675                        if let common::Retry::After(d) =
6676                            dlg.http_failure(&response, error.as_ref().ok())
6677                        {
6678                            sleep(d).await;
6679                            continue;
6680                        }
6681
6682                        dlg.finished(false);
6683
6684                        return Err(match error {
6685                            Ok(value) => common::Error::BadRequest(value),
6686                            _ => common::Error::Failure(response),
6687                        });
6688                    }
6689                    let response = {
6690                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6691                        let encoded = common::to_string(&bytes);
6692                        match serde_json::from_str(&encoded) {
6693                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6694                            Err(error) => {
6695                                dlg.response_json_decode_error(&encoded, &error);
6696                                return Err(common::Error::JsonDecodeError(
6697                                    encoded.to_string(),
6698                                    error,
6699                                ));
6700                            }
6701                        }
6702                    };
6703
6704                    dlg.finished(true);
6705                    return Ok(response);
6706                }
6707            }
6708        }
6709    }
6710
6711    ///
6712    /// Sets the *request* property to the given value.
6713    ///
6714    /// Even though the property as already been set when instantiating this call,
6715    /// we provide this method for API completeness.
6716    pub fn request(
6717        mut self,
6718        new_value: GetIamPolicyRequest,
6719    ) -> OrganizationGetIamPolicyCall<'a, C> {
6720        self._request = new_value;
6721        self
6722    }
6723    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
6724    ///
6725    /// Sets the *resource* path property to the given value.
6726    ///
6727    /// Even though the property as already been set when instantiating this call,
6728    /// we provide this method for API completeness.
6729    pub fn resource(mut self, new_value: &str) -> OrganizationGetIamPolicyCall<'a, C> {
6730        self._resource = new_value.to_string();
6731        self
6732    }
6733    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6734    /// while executing the actual API request.
6735    ///
6736    /// ````text
6737    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6738    /// ````
6739    ///
6740    /// Sets the *delegate* property to the given value.
6741    pub fn delegate(
6742        mut self,
6743        new_value: &'a mut dyn common::Delegate,
6744    ) -> OrganizationGetIamPolicyCall<'a, C> {
6745        self._delegate = Some(new_value);
6746        self
6747    }
6748
6749    /// Set any additional parameter of the query string used in the request.
6750    /// It should be used to set parameters which are not yet available through their own
6751    /// setters.
6752    ///
6753    /// Please note that this method must not be used to set any of the known parameters
6754    /// which have their own setter method. If done anyway, the request will fail.
6755    ///
6756    /// # Additional Parameters
6757    ///
6758    /// * *$.xgafv* (query-string) - V1 error format.
6759    /// * *access_token* (query-string) - OAuth access token.
6760    /// * *alt* (query-string) - Data format for response.
6761    /// * *callback* (query-string) - JSONP
6762    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6763    /// * *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.
6764    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6765    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6766    /// * *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.
6767    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6768    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6769    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetIamPolicyCall<'a, C>
6770    where
6771        T: AsRef<str>,
6772    {
6773        self._additional_params
6774            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6775        self
6776    }
6777
6778    /// Identifies the authorization scope for the method you are building.
6779    ///
6780    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6781    /// [`Scope::CloudPlatform`].
6782    ///
6783    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6784    /// tokens for more than one scope.
6785    ///
6786    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6787    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6788    /// sufficient, a read-write scope will do as well.
6789    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetIamPolicyCall<'a, C>
6790    where
6791        St: AsRef<str>,
6792    {
6793        self._scopes.insert(String::from(scope.as_ref()));
6794        self
6795    }
6796    /// Identifies the authorization scope(s) for the method you are building.
6797    ///
6798    /// See [`Self::add_scope()`] for details.
6799    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetIamPolicyCall<'a, C>
6800    where
6801        I: IntoIterator<Item = St>,
6802        St: AsRef<str>,
6803    {
6804        self._scopes
6805            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6806        self
6807    }
6808
6809    /// Removes all scopes, and no default scope will be used either.
6810    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6811    /// for details).
6812    pub fn clear_scopes(mut self) -> OrganizationGetIamPolicyCall<'a, C> {
6813        self._scopes.clear();
6814        self
6815    }
6816}
6817
6818/// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
6819///
6820/// A builder for the *getOrgPolicy* method supported by a *organization* resource.
6821/// It is not used directly, but through a [`OrganizationMethods`] instance.
6822///
6823/// # Example
6824///
6825/// Instantiate a resource method builder
6826///
6827/// ```test_harness,no_run
6828/// # extern crate hyper;
6829/// # extern crate hyper_rustls;
6830/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
6831/// use cloudresourcemanager1::api::GetOrgPolicyRequest;
6832/// # async fn dox() {
6833/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6834///
6835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6836/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6837/// #     secret,
6838/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6839/// # ).build().await.unwrap();
6840///
6841/// # let client = hyper_util::client::legacy::Client::builder(
6842/// #     hyper_util::rt::TokioExecutor::new()
6843/// # )
6844/// # .build(
6845/// #     hyper_rustls::HttpsConnectorBuilder::new()
6846/// #         .with_native_roots()
6847/// #         .unwrap()
6848/// #         .https_or_http()
6849/// #         .enable_http1()
6850/// #         .build()
6851/// # );
6852/// # let mut hub = CloudResourceManager::new(client, auth);
6853/// // As the method needs a request, you would usually fill it with the desired information
6854/// // into the respective structure. Some of the parts shown here might not be applicable !
6855/// // Values shown here are possibly random and not representative !
6856/// let mut req = GetOrgPolicyRequest::default();
6857///
6858/// // You can configure optional parameters by calling the respective setters at will, and
6859/// // execute the final call using `doit()`.
6860/// // Values shown here are possibly random and not representative !
6861/// let result = hub.organizations().get_org_policy(req, "resource")
6862///              .doit().await;
6863/// # }
6864/// ```
6865pub struct OrganizationGetOrgPolicyCall<'a, C>
6866where
6867    C: 'a,
6868{
6869    hub: &'a CloudResourceManager<C>,
6870    _request: GetOrgPolicyRequest,
6871    _resource: String,
6872    _delegate: Option<&'a mut dyn common::Delegate>,
6873    _additional_params: HashMap<String, String>,
6874    _scopes: BTreeSet<String>,
6875}
6876
6877impl<'a, C> common::CallBuilder for OrganizationGetOrgPolicyCall<'a, C> {}
6878
6879impl<'a, C> OrganizationGetOrgPolicyCall<'a, C>
6880where
6881    C: common::Connector,
6882{
6883    /// Perform the operation you have build so far.
6884    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
6885        use std::borrow::Cow;
6886        use std::io::{Read, Seek};
6887
6888        use common::{url::Params, ToParts};
6889        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6890
6891        let mut dd = common::DefaultDelegate;
6892        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6893        dlg.begin(common::MethodInfo {
6894            id: "cloudresourcemanager.organizations.getOrgPolicy",
6895            http_method: hyper::Method::POST,
6896        });
6897
6898        for &field in ["alt", "resource"].iter() {
6899            if self._additional_params.contains_key(field) {
6900                dlg.finished(false);
6901                return Err(common::Error::FieldClash(field));
6902            }
6903        }
6904
6905        let mut params = Params::with_capacity(4 + self._additional_params.len());
6906        params.push("resource", self._resource);
6907
6908        params.extend(self._additional_params.iter());
6909
6910        params.push("alt", "json");
6911        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getOrgPolicy";
6912        if self._scopes.is_empty() {
6913            self._scopes
6914                .insert(Scope::CloudPlatform.as_ref().to_string());
6915        }
6916
6917        #[allow(clippy::single_element_loop)]
6918        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6919            url = params.uri_replacement(url, param_name, find_this, true);
6920        }
6921        {
6922            let to_remove = ["resource"];
6923            params.remove_params(&to_remove);
6924        }
6925
6926        let url = params.parse_with_url(&url);
6927
6928        let mut json_mime_type = mime::APPLICATION_JSON;
6929        let mut request_value_reader = {
6930            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6931            common::remove_json_null_values(&mut value);
6932            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6933            serde_json::to_writer(&mut dst, &value).unwrap();
6934            dst
6935        };
6936        let request_size = request_value_reader
6937            .seek(std::io::SeekFrom::End(0))
6938            .unwrap();
6939        request_value_reader
6940            .seek(std::io::SeekFrom::Start(0))
6941            .unwrap();
6942
6943        loop {
6944            let token = match self
6945                .hub
6946                .auth
6947                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6948                .await
6949            {
6950                Ok(token) => token,
6951                Err(e) => match dlg.token(e) {
6952                    Ok(token) => token,
6953                    Err(e) => {
6954                        dlg.finished(false);
6955                        return Err(common::Error::MissingToken(e));
6956                    }
6957                },
6958            };
6959            request_value_reader
6960                .seek(std::io::SeekFrom::Start(0))
6961                .unwrap();
6962            let mut req_result = {
6963                let client = &self.hub.client;
6964                dlg.pre_request();
6965                let mut req_builder = hyper::Request::builder()
6966                    .method(hyper::Method::POST)
6967                    .uri(url.as_str())
6968                    .header(USER_AGENT, self.hub._user_agent.clone());
6969
6970                if let Some(token) = token.as_ref() {
6971                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6972                }
6973
6974                let request = req_builder
6975                    .header(CONTENT_TYPE, json_mime_type.to_string())
6976                    .header(CONTENT_LENGTH, request_size as u64)
6977                    .body(common::to_body(
6978                        request_value_reader.get_ref().clone().into(),
6979                    ));
6980
6981                client.request(request.unwrap()).await
6982            };
6983
6984            match req_result {
6985                Err(err) => {
6986                    if let common::Retry::After(d) = dlg.http_error(&err) {
6987                        sleep(d).await;
6988                        continue;
6989                    }
6990                    dlg.finished(false);
6991                    return Err(common::Error::HttpError(err));
6992                }
6993                Ok(res) => {
6994                    let (mut parts, body) = res.into_parts();
6995                    let mut body = common::Body::new(body);
6996                    if !parts.status.is_success() {
6997                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6998                        let error = serde_json::from_str(&common::to_string(&bytes));
6999                        let response = common::to_response(parts, bytes.into());
7000
7001                        if let common::Retry::After(d) =
7002                            dlg.http_failure(&response, error.as_ref().ok())
7003                        {
7004                            sleep(d).await;
7005                            continue;
7006                        }
7007
7008                        dlg.finished(false);
7009
7010                        return Err(match error {
7011                            Ok(value) => common::Error::BadRequest(value),
7012                            _ => common::Error::Failure(response),
7013                        });
7014                    }
7015                    let response = {
7016                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7017                        let encoded = common::to_string(&bytes);
7018                        match serde_json::from_str(&encoded) {
7019                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7020                            Err(error) => {
7021                                dlg.response_json_decode_error(&encoded, &error);
7022                                return Err(common::Error::JsonDecodeError(
7023                                    encoded.to_string(),
7024                                    error,
7025                                ));
7026                            }
7027                        }
7028                    };
7029
7030                    dlg.finished(true);
7031                    return Ok(response);
7032                }
7033            }
7034        }
7035    }
7036
7037    ///
7038    /// Sets the *request* property to the given value.
7039    ///
7040    /// Even though the property as already been set when instantiating this call,
7041    /// we provide this method for API completeness.
7042    pub fn request(
7043        mut self,
7044        new_value: GetOrgPolicyRequest,
7045    ) -> OrganizationGetOrgPolicyCall<'a, C> {
7046        self._request = new_value;
7047        self
7048    }
7049    /// Name of the resource the `Policy` is set on.
7050    ///
7051    /// Sets the *resource* path property to the given value.
7052    ///
7053    /// Even though the property as already been set when instantiating this call,
7054    /// we provide this method for API completeness.
7055    pub fn resource(mut self, new_value: &str) -> OrganizationGetOrgPolicyCall<'a, C> {
7056        self._resource = new_value.to_string();
7057        self
7058    }
7059    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7060    /// while executing the actual API request.
7061    ///
7062    /// ````text
7063    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7064    /// ````
7065    ///
7066    /// Sets the *delegate* property to the given value.
7067    pub fn delegate(
7068        mut self,
7069        new_value: &'a mut dyn common::Delegate,
7070    ) -> OrganizationGetOrgPolicyCall<'a, C> {
7071        self._delegate = Some(new_value);
7072        self
7073    }
7074
7075    /// Set any additional parameter of the query string used in the request.
7076    /// It should be used to set parameters which are not yet available through their own
7077    /// setters.
7078    ///
7079    /// Please note that this method must not be used to set any of the known parameters
7080    /// which have their own setter method. If done anyway, the request will fail.
7081    ///
7082    /// # Additional Parameters
7083    ///
7084    /// * *$.xgafv* (query-string) - V1 error format.
7085    /// * *access_token* (query-string) - OAuth access token.
7086    /// * *alt* (query-string) - Data format for response.
7087    /// * *callback* (query-string) - JSONP
7088    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7089    /// * *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.
7090    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7091    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7092    /// * *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.
7093    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7094    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7095    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetOrgPolicyCall<'a, C>
7096    where
7097        T: AsRef<str>,
7098    {
7099        self._additional_params
7100            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7101        self
7102    }
7103
7104    /// Identifies the authorization scope for the method you are building.
7105    ///
7106    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7107    /// [`Scope::CloudPlatform`].
7108    ///
7109    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7110    /// tokens for more than one scope.
7111    ///
7112    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7113    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7114    /// sufficient, a read-write scope will do as well.
7115    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetOrgPolicyCall<'a, C>
7116    where
7117        St: AsRef<str>,
7118    {
7119        self._scopes.insert(String::from(scope.as_ref()));
7120        self
7121    }
7122    /// Identifies the authorization scope(s) for the method you are building.
7123    ///
7124    /// See [`Self::add_scope()`] for details.
7125    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetOrgPolicyCall<'a, C>
7126    where
7127        I: IntoIterator<Item = St>,
7128        St: AsRef<str>,
7129    {
7130        self._scopes
7131            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7132        self
7133    }
7134
7135    /// Removes all scopes, and no default scope will be used either.
7136    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7137    /// for details).
7138    pub fn clear_scopes(mut self) -> OrganizationGetOrgPolicyCall<'a, C> {
7139        self._scopes.clear();
7140        self
7141    }
7142}
7143
7144/// Lists `Constraints` that could be applied on the specified resource.
7145///
7146/// A builder for the *listAvailableOrgPolicyConstraints* method supported by a *organization* resource.
7147/// It is not used directly, but through a [`OrganizationMethods`] instance.
7148///
7149/// # Example
7150///
7151/// Instantiate a resource method builder
7152///
7153/// ```test_harness,no_run
7154/// # extern crate hyper;
7155/// # extern crate hyper_rustls;
7156/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
7157/// use cloudresourcemanager1::api::ListAvailableOrgPolicyConstraintsRequest;
7158/// # async fn dox() {
7159/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7160///
7161/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7162/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7163/// #     secret,
7164/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7165/// # ).build().await.unwrap();
7166///
7167/// # let client = hyper_util::client::legacy::Client::builder(
7168/// #     hyper_util::rt::TokioExecutor::new()
7169/// # )
7170/// # .build(
7171/// #     hyper_rustls::HttpsConnectorBuilder::new()
7172/// #         .with_native_roots()
7173/// #         .unwrap()
7174/// #         .https_or_http()
7175/// #         .enable_http1()
7176/// #         .build()
7177/// # );
7178/// # let mut hub = CloudResourceManager::new(client, auth);
7179/// // As the method needs a request, you would usually fill it with the desired information
7180/// // into the respective structure. Some of the parts shown here might not be applicable !
7181/// // Values shown here are possibly random and not representative !
7182/// let mut req = ListAvailableOrgPolicyConstraintsRequest::default();
7183///
7184/// // You can configure optional parameters by calling the respective setters at will, and
7185/// // execute the final call using `doit()`.
7186/// // Values shown here are possibly random and not representative !
7187/// let result = hub.organizations().list_available_org_policy_constraints(req, "resource")
7188///              .doit().await;
7189/// # }
7190/// ```
7191pub struct OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7192where
7193    C: 'a,
7194{
7195    hub: &'a CloudResourceManager<C>,
7196    _request: ListAvailableOrgPolicyConstraintsRequest,
7197    _resource: String,
7198    _delegate: Option<&'a mut dyn common::Delegate>,
7199    _additional_params: HashMap<String, String>,
7200    _scopes: BTreeSet<String>,
7201}
7202
7203impl<'a, C> common::CallBuilder for OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {}
7204
7205impl<'a, C> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7206where
7207    C: common::Connector,
7208{
7209    /// Perform the operation you have build so far.
7210    pub async fn doit(
7211        mut self,
7212    ) -> common::Result<(common::Response, ListAvailableOrgPolicyConstraintsResponse)> {
7213        use std::borrow::Cow;
7214        use std::io::{Read, Seek};
7215
7216        use common::{url::Params, ToParts};
7217        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7218
7219        let mut dd = common::DefaultDelegate;
7220        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7221        dlg.begin(common::MethodInfo {
7222            id: "cloudresourcemanager.organizations.listAvailableOrgPolicyConstraints",
7223            http_method: hyper::Method::POST,
7224        });
7225
7226        for &field in ["alt", "resource"].iter() {
7227            if self._additional_params.contains_key(field) {
7228                dlg.finished(false);
7229                return Err(common::Error::FieldClash(field));
7230            }
7231        }
7232
7233        let mut params = Params::with_capacity(4 + self._additional_params.len());
7234        params.push("resource", self._resource);
7235
7236        params.extend(self._additional_params.iter());
7237
7238        params.push("alt", "json");
7239        let mut url =
7240            self.hub._base_url.clone() + "v1/{+resource}:listAvailableOrgPolicyConstraints";
7241        if self._scopes.is_empty() {
7242            self._scopes
7243                .insert(Scope::CloudPlatform.as_ref().to_string());
7244        }
7245
7246        #[allow(clippy::single_element_loop)]
7247        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7248            url = params.uri_replacement(url, param_name, find_this, true);
7249        }
7250        {
7251            let to_remove = ["resource"];
7252            params.remove_params(&to_remove);
7253        }
7254
7255        let url = params.parse_with_url(&url);
7256
7257        let mut json_mime_type = mime::APPLICATION_JSON;
7258        let mut request_value_reader = {
7259            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7260            common::remove_json_null_values(&mut value);
7261            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7262            serde_json::to_writer(&mut dst, &value).unwrap();
7263            dst
7264        };
7265        let request_size = request_value_reader
7266            .seek(std::io::SeekFrom::End(0))
7267            .unwrap();
7268        request_value_reader
7269            .seek(std::io::SeekFrom::Start(0))
7270            .unwrap();
7271
7272        loop {
7273            let token = match self
7274                .hub
7275                .auth
7276                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7277                .await
7278            {
7279                Ok(token) => token,
7280                Err(e) => match dlg.token(e) {
7281                    Ok(token) => token,
7282                    Err(e) => {
7283                        dlg.finished(false);
7284                        return Err(common::Error::MissingToken(e));
7285                    }
7286                },
7287            };
7288            request_value_reader
7289                .seek(std::io::SeekFrom::Start(0))
7290                .unwrap();
7291            let mut req_result = {
7292                let client = &self.hub.client;
7293                dlg.pre_request();
7294                let mut req_builder = hyper::Request::builder()
7295                    .method(hyper::Method::POST)
7296                    .uri(url.as_str())
7297                    .header(USER_AGENT, self.hub._user_agent.clone());
7298
7299                if let Some(token) = token.as_ref() {
7300                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7301                }
7302
7303                let request = req_builder
7304                    .header(CONTENT_TYPE, json_mime_type.to_string())
7305                    .header(CONTENT_LENGTH, request_size as u64)
7306                    .body(common::to_body(
7307                        request_value_reader.get_ref().clone().into(),
7308                    ));
7309
7310                client.request(request.unwrap()).await
7311            };
7312
7313            match req_result {
7314                Err(err) => {
7315                    if let common::Retry::After(d) = dlg.http_error(&err) {
7316                        sleep(d).await;
7317                        continue;
7318                    }
7319                    dlg.finished(false);
7320                    return Err(common::Error::HttpError(err));
7321                }
7322                Ok(res) => {
7323                    let (mut parts, body) = res.into_parts();
7324                    let mut body = common::Body::new(body);
7325                    if !parts.status.is_success() {
7326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7327                        let error = serde_json::from_str(&common::to_string(&bytes));
7328                        let response = common::to_response(parts, bytes.into());
7329
7330                        if let common::Retry::After(d) =
7331                            dlg.http_failure(&response, error.as_ref().ok())
7332                        {
7333                            sleep(d).await;
7334                            continue;
7335                        }
7336
7337                        dlg.finished(false);
7338
7339                        return Err(match error {
7340                            Ok(value) => common::Error::BadRequest(value),
7341                            _ => common::Error::Failure(response),
7342                        });
7343                    }
7344                    let response = {
7345                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7346                        let encoded = common::to_string(&bytes);
7347                        match serde_json::from_str(&encoded) {
7348                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7349                            Err(error) => {
7350                                dlg.response_json_decode_error(&encoded, &error);
7351                                return Err(common::Error::JsonDecodeError(
7352                                    encoded.to_string(),
7353                                    error,
7354                                ));
7355                            }
7356                        }
7357                    };
7358
7359                    dlg.finished(true);
7360                    return Ok(response);
7361                }
7362            }
7363        }
7364    }
7365
7366    ///
7367    /// Sets the *request* property to the given value.
7368    ///
7369    /// Even though the property as already been set when instantiating this call,
7370    /// we provide this method for API completeness.
7371    pub fn request(
7372        mut self,
7373        new_value: ListAvailableOrgPolicyConstraintsRequest,
7374    ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7375        self._request = new_value;
7376        self
7377    }
7378    /// Name of the resource to list `Constraints` for.
7379    ///
7380    /// Sets the *resource* path property to the given value.
7381    ///
7382    /// Even though the property as already been set when instantiating this call,
7383    /// we provide this method for API completeness.
7384    pub fn resource(
7385        mut self,
7386        new_value: &str,
7387    ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7388        self._resource = new_value.to_string();
7389        self
7390    }
7391    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7392    /// while executing the actual API request.
7393    ///
7394    /// ````text
7395    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7396    /// ````
7397    ///
7398    /// Sets the *delegate* property to the given value.
7399    pub fn delegate(
7400        mut self,
7401        new_value: &'a mut dyn common::Delegate,
7402    ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7403        self._delegate = Some(new_value);
7404        self
7405    }
7406
7407    /// Set any additional parameter of the query string used in the request.
7408    /// It should be used to set parameters which are not yet available through their own
7409    /// setters.
7410    ///
7411    /// Please note that this method must not be used to set any of the known parameters
7412    /// which have their own setter method. If done anyway, the request will fail.
7413    ///
7414    /// # Additional Parameters
7415    ///
7416    /// * *$.xgafv* (query-string) - V1 error format.
7417    /// * *access_token* (query-string) - OAuth access token.
7418    /// * *alt* (query-string) - Data format for response.
7419    /// * *callback* (query-string) - JSONP
7420    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7421    /// * *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.
7422    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7423    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7424    /// * *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.
7425    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7426    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7427    pub fn param<T>(
7428        mut self,
7429        name: T,
7430        value: T,
7431    ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7432    where
7433        T: AsRef<str>,
7434    {
7435        self._additional_params
7436            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7437        self
7438    }
7439
7440    /// Identifies the authorization scope for the method you are building.
7441    ///
7442    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7443    /// [`Scope::CloudPlatform`].
7444    ///
7445    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7446    /// tokens for more than one scope.
7447    ///
7448    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7449    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7450    /// sufficient, a read-write scope will do as well.
7451    pub fn add_scope<St>(
7452        mut self,
7453        scope: St,
7454    ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7455    where
7456        St: AsRef<str>,
7457    {
7458        self._scopes.insert(String::from(scope.as_ref()));
7459        self
7460    }
7461    /// Identifies the authorization scope(s) for the method you are building.
7462    ///
7463    /// See [`Self::add_scope()`] for details.
7464    pub fn add_scopes<I, St>(
7465        mut self,
7466        scopes: I,
7467    ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7468    where
7469        I: IntoIterator<Item = St>,
7470        St: AsRef<str>,
7471    {
7472        self._scopes
7473            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7474        self
7475    }
7476
7477    /// Removes all scopes, and no default scope will be used either.
7478    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7479    /// for details).
7480    pub fn clear_scopes(mut self) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7481        self._scopes.clear();
7482        self
7483    }
7484}
7485
7486/// Lists all the `Policies` set for a particular resource.
7487///
7488/// A builder for the *listOrgPolicies* method supported by a *organization* resource.
7489/// It is not used directly, but through a [`OrganizationMethods`] instance.
7490///
7491/// # Example
7492///
7493/// Instantiate a resource method builder
7494///
7495/// ```test_harness,no_run
7496/// # extern crate hyper;
7497/// # extern crate hyper_rustls;
7498/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
7499/// use cloudresourcemanager1::api::ListOrgPoliciesRequest;
7500/// # async fn dox() {
7501/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7502///
7503/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7504/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7505/// #     secret,
7506/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7507/// # ).build().await.unwrap();
7508///
7509/// # let client = hyper_util::client::legacy::Client::builder(
7510/// #     hyper_util::rt::TokioExecutor::new()
7511/// # )
7512/// # .build(
7513/// #     hyper_rustls::HttpsConnectorBuilder::new()
7514/// #         .with_native_roots()
7515/// #         .unwrap()
7516/// #         .https_or_http()
7517/// #         .enable_http1()
7518/// #         .build()
7519/// # );
7520/// # let mut hub = CloudResourceManager::new(client, auth);
7521/// // As the method needs a request, you would usually fill it with the desired information
7522/// // into the respective structure. Some of the parts shown here might not be applicable !
7523/// // Values shown here are possibly random and not representative !
7524/// let mut req = ListOrgPoliciesRequest::default();
7525///
7526/// // You can configure optional parameters by calling the respective setters at will, and
7527/// // execute the final call using `doit()`.
7528/// // Values shown here are possibly random and not representative !
7529/// let result = hub.organizations().list_org_policies(req, "resource")
7530///              .doit().await;
7531/// # }
7532/// ```
7533pub struct OrganizationListOrgPolicyCall<'a, C>
7534where
7535    C: 'a,
7536{
7537    hub: &'a CloudResourceManager<C>,
7538    _request: ListOrgPoliciesRequest,
7539    _resource: String,
7540    _delegate: Option<&'a mut dyn common::Delegate>,
7541    _additional_params: HashMap<String, String>,
7542    _scopes: BTreeSet<String>,
7543}
7544
7545impl<'a, C> common::CallBuilder for OrganizationListOrgPolicyCall<'a, C> {}
7546
7547impl<'a, C> OrganizationListOrgPolicyCall<'a, C>
7548where
7549    C: common::Connector,
7550{
7551    /// Perform the operation you have build so far.
7552    pub async fn doit(mut self) -> common::Result<(common::Response, ListOrgPoliciesResponse)> {
7553        use std::borrow::Cow;
7554        use std::io::{Read, Seek};
7555
7556        use common::{url::Params, ToParts};
7557        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7558
7559        let mut dd = common::DefaultDelegate;
7560        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7561        dlg.begin(common::MethodInfo {
7562            id: "cloudresourcemanager.organizations.listOrgPolicies",
7563            http_method: hyper::Method::POST,
7564        });
7565
7566        for &field in ["alt", "resource"].iter() {
7567            if self._additional_params.contains_key(field) {
7568                dlg.finished(false);
7569                return Err(common::Error::FieldClash(field));
7570            }
7571        }
7572
7573        let mut params = Params::with_capacity(4 + self._additional_params.len());
7574        params.push("resource", self._resource);
7575
7576        params.extend(self._additional_params.iter());
7577
7578        params.push("alt", "json");
7579        let mut url = self.hub._base_url.clone() + "v1/{+resource}:listOrgPolicies";
7580        if self._scopes.is_empty() {
7581            self._scopes
7582                .insert(Scope::CloudPlatform.as_ref().to_string());
7583        }
7584
7585        #[allow(clippy::single_element_loop)]
7586        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7587            url = params.uri_replacement(url, param_name, find_this, true);
7588        }
7589        {
7590            let to_remove = ["resource"];
7591            params.remove_params(&to_remove);
7592        }
7593
7594        let url = params.parse_with_url(&url);
7595
7596        let mut json_mime_type = mime::APPLICATION_JSON;
7597        let mut request_value_reader = {
7598            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7599            common::remove_json_null_values(&mut value);
7600            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7601            serde_json::to_writer(&mut dst, &value).unwrap();
7602            dst
7603        };
7604        let request_size = request_value_reader
7605            .seek(std::io::SeekFrom::End(0))
7606            .unwrap();
7607        request_value_reader
7608            .seek(std::io::SeekFrom::Start(0))
7609            .unwrap();
7610
7611        loop {
7612            let token = match self
7613                .hub
7614                .auth
7615                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7616                .await
7617            {
7618                Ok(token) => token,
7619                Err(e) => match dlg.token(e) {
7620                    Ok(token) => token,
7621                    Err(e) => {
7622                        dlg.finished(false);
7623                        return Err(common::Error::MissingToken(e));
7624                    }
7625                },
7626            };
7627            request_value_reader
7628                .seek(std::io::SeekFrom::Start(0))
7629                .unwrap();
7630            let mut req_result = {
7631                let client = &self.hub.client;
7632                dlg.pre_request();
7633                let mut req_builder = hyper::Request::builder()
7634                    .method(hyper::Method::POST)
7635                    .uri(url.as_str())
7636                    .header(USER_AGENT, self.hub._user_agent.clone());
7637
7638                if let Some(token) = token.as_ref() {
7639                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7640                }
7641
7642                let request = req_builder
7643                    .header(CONTENT_TYPE, json_mime_type.to_string())
7644                    .header(CONTENT_LENGTH, request_size as u64)
7645                    .body(common::to_body(
7646                        request_value_reader.get_ref().clone().into(),
7647                    ));
7648
7649                client.request(request.unwrap()).await
7650            };
7651
7652            match req_result {
7653                Err(err) => {
7654                    if let common::Retry::After(d) = dlg.http_error(&err) {
7655                        sleep(d).await;
7656                        continue;
7657                    }
7658                    dlg.finished(false);
7659                    return Err(common::Error::HttpError(err));
7660                }
7661                Ok(res) => {
7662                    let (mut parts, body) = res.into_parts();
7663                    let mut body = common::Body::new(body);
7664                    if !parts.status.is_success() {
7665                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7666                        let error = serde_json::from_str(&common::to_string(&bytes));
7667                        let response = common::to_response(parts, bytes.into());
7668
7669                        if let common::Retry::After(d) =
7670                            dlg.http_failure(&response, error.as_ref().ok())
7671                        {
7672                            sleep(d).await;
7673                            continue;
7674                        }
7675
7676                        dlg.finished(false);
7677
7678                        return Err(match error {
7679                            Ok(value) => common::Error::BadRequest(value),
7680                            _ => common::Error::Failure(response),
7681                        });
7682                    }
7683                    let response = {
7684                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7685                        let encoded = common::to_string(&bytes);
7686                        match serde_json::from_str(&encoded) {
7687                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7688                            Err(error) => {
7689                                dlg.response_json_decode_error(&encoded, &error);
7690                                return Err(common::Error::JsonDecodeError(
7691                                    encoded.to_string(),
7692                                    error,
7693                                ));
7694                            }
7695                        }
7696                    };
7697
7698                    dlg.finished(true);
7699                    return Ok(response);
7700                }
7701            }
7702        }
7703    }
7704
7705    ///
7706    /// Sets the *request* property to the given value.
7707    ///
7708    /// Even though the property as already been set when instantiating this call,
7709    /// we provide this method for API completeness.
7710    pub fn request(
7711        mut self,
7712        new_value: ListOrgPoliciesRequest,
7713    ) -> OrganizationListOrgPolicyCall<'a, C> {
7714        self._request = new_value;
7715        self
7716    }
7717    /// Name of the resource to list Policies for.
7718    ///
7719    /// Sets the *resource* path property to the given value.
7720    ///
7721    /// Even though the property as already been set when instantiating this call,
7722    /// we provide this method for API completeness.
7723    pub fn resource(mut self, new_value: &str) -> OrganizationListOrgPolicyCall<'a, C> {
7724        self._resource = new_value.to_string();
7725        self
7726    }
7727    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7728    /// while executing the actual API request.
7729    ///
7730    /// ````text
7731    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7732    /// ````
7733    ///
7734    /// Sets the *delegate* property to the given value.
7735    pub fn delegate(
7736        mut self,
7737        new_value: &'a mut dyn common::Delegate,
7738    ) -> OrganizationListOrgPolicyCall<'a, C> {
7739        self._delegate = Some(new_value);
7740        self
7741    }
7742
7743    /// Set any additional parameter of the query string used in the request.
7744    /// It should be used to set parameters which are not yet available through their own
7745    /// setters.
7746    ///
7747    /// Please note that this method must not be used to set any of the known parameters
7748    /// which have their own setter method. If done anyway, the request will fail.
7749    ///
7750    /// # Additional Parameters
7751    ///
7752    /// * *$.xgafv* (query-string) - V1 error format.
7753    /// * *access_token* (query-string) - OAuth access token.
7754    /// * *alt* (query-string) - Data format for response.
7755    /// * *callback* (query-string) - JSONP
7756    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7757    /// * *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.
7758    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7759    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7760    /// * *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.
7761    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7762    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7763    pub fn param<T>(mut self, name: T, value: T) -> OrganizationListOrgPolicyCall<'a, C>
7764    where
7765        T: AsRef<str>,
7766    {
7767        self._additional_params
7768            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7769        self
7770    }
7771
7772    /// Identifies the authorization scope for the method you are building.
7773    ///
7774    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7775    /// [`Scope::CloudPlatform`].
7776    ///
7777    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7778    /// tokens for more than one scope.
7779    ///
7780    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7781    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7782    /// sufficient, a read-write scope will do as well.
7783    pub fn add_scope<St>(mut self, scope: St) -> OrganizationListOrgPolicyCall<'a, C>
7784    where
7785        St: AsRef<str>,
7786    {
7787        self._scopes.insert(String::from(scope.as_ref()));
7788        self
7789    }
7790    /// Identifies the authorization scope(s) for the method you are building.
7791    ///
7792    /// See [`Self::add_scope()`] for details.
7793    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationListOrgPolicyCall<'a, C>
7794    where
7795        I: IntoIterator<Item = St>,
7796        St: AsRef<str>,
7797    {
7798        self._scopes
7799            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7800        self
7801    }
7802
7803    /// Removes all scopes, and no default scope will be used either.
7804    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7805    /// for details).
7806    pub fn clear_scopes(mut self) -> OrganizationListOrgPolicyCall<'a, C> {
7807        self._scopes.clear();
7808        self
7809    }
7810}
7811
7812/// Searches Organization resources that are visible to the user and satisfy the specified filter. This method returns Organizations in an unspecified order. New Organizations do not necessarily appear at the end of the results. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get` or has super admin privileges.
7813///
7814/// A builder for the *search* method supported by a *organization* resource.
7815/// It is not used directly, but through a [`OrganizationMethods`] instance.
7816///
7817/// # Example
7818///
7819/// Instantiate a resource method builder
7820///
7821/// ```test_harness,no_run
7822/// # extern crate hyper;
7823/// # extern crate hyper_rustls;
7824/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
7825/// use cloudresourcemanager1::api::SearchOrganizationsRequest;
7826/// # async fn dox() {
7827/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7828///
7829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7830/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7831/// #     secret,
7832/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7833/// # ).build().await.unwrap();
7834///
7835/// # let client = hyper_util::client::legacy::Client::builder(
7836/// #     hyper_util::rt::TokioExecutor::new()
7837/// # )
7838/// # .build(
7839/// #     hyper_rustls::HttpsConnectorBuilder::new()
7840/// #         .with_native_roots()
7841/// #         .unwrap()
7842/// #         .https_or_http()
7843/// #         .enable_http1()
7844/// #         .build()
7845/// # );
7846/// # let mut hub = CloudResourceManager::new(client, auth);
7847/// // As the method needs a request, you would usually fill it with the desired information
7848/// // into the respective structure. Some of the parts shown here might not be applicable !
7849/// // Values shown here are possibly random and not representative !
7850/// let mut req = SearchOrganizationsRequest::default();
7851///
7852/// // You can configure optional parameters by calling the respective setters at will, and
7853/// // execute the final call using `doit()`.
7854/// // Values shown here are possibly random and not representative !
7855/// let result = hub.organizations().search(req)
7856///              .doit().await;
7857/// # }
7858/// ```
7859pub struct OrganizationSearchCall<'a, C>
7860where
7861    C: 'a,
7862{
7863    hub: &'a CloudResourceManager<C>,
7864    _request: SearchOrganizationsRequest,
7865    _delegate: Option<&'a mut dyn common::Delegate>,
7866    _additional_params: HashMap<String, String>,
7867    _scopes: BTreeSet<String>,
7868}
7869
7870impl<'a, C> common::CallBuilder for OrganizationSearchCall<'a, C> {}
7871
7872impl<'a, C> OrganizationSearchCall<'a, C>
7873where
7874    C: common::Connector,
7875{
7876    /// Perform the operation you have build so far.
7877    pub async fn doit(mut self) -> common::Result<(common::Response, SearchOrganizationsResponse)> {
7878        use std::borrow::Cow;
7879        use std::io::{Read, Seek};
7880
7881        use common::{url::Params, ToParts};
7882        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7883
7884        let mut dd = common::DefaultDelegate;
7885        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7886        dlg.begin(common::MethodInfo {
7887            id: "cloudresourcemanager.organizations.search",
7888            http_method: hyper::Method::POST,
7889        });
7890
7891        for &field in ["alt"].iter() {
7892            if self._additional_params.contains_key(field) {
7893                dlg.finished(false);
7894                return Err(common::Error::FieldClash(field));
7895            }
7896        }
7897
7898        let mut params = Params::with_capacity(3 + self._additional_params.len());
7899
7900        params.extend(self._additional_params.iter());
7901
7902        params.push("alt", "json");
7903        let mut url = self.hub._base_url.clone() + "v1/organizations:search";
7904        if self._scopes.is_empty() {
7905            self._scopes
7906                .insert(Scope::CloudPlatform.as_ref().to_string());
7907        }
7908
7909        let url = params.parse_with_url(&url);
7910
7911        let mut json_mime_type = mime::APPLICATION_JSON;
7912        let mut request_value_reader = {
7913            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7914            common::remove_json_null_values(&mut value);
7915            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7916            serde_json::to_writer(&mut dst, &value).unwrap();
7917            dst
7918        };
7919        let request_size = request_value_reader
7920            .seek(std::io::SeekFrom::End(0))
7921            .unwrap();
7922        request_value_reader
7923            .seek(std::io::SeekFrom::Start(0))
7924            .unwrap();
7925
7926        loop {
7927            let token = match self
7928                .hub
7929                .auth
7930                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7931                .await
7932            {
7933                Ok(token) => token,
7934                Err(e) => match dlg.token(e) {
7935                    Ok(token) => token,
7936                    Err(e) => {
7937                        dlg.finished(false);
7938                        return Err(common::Error::MissingToken(e));
7939                    }
7940                },
7941            };
7942            request_value_reader
7943                .seek(std::io::SeekFrom::Start(0))
7944                .unwrap();
7945            let mut req_result = {
7946                let client = &self.hub.client;
7947                dlg.pre_request();
7948                let mut req_builder = hyper::Request::builder()
7949                    .method(hyper::Method::POST)
7950                    .uri(url.as_str())
7951                    .header(USER_AGENT, self.hub._user_agent.clone());
7952
7953                if let Some(token) = token.as_ref() {
7954                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7955                }
7956
7957                let request = req_builder
7958                    .header(CONTENT_TYPE, json_mime_type.to_string())
7959                    .header(CONTENT_LENGTH, request_size as u64)
7960                    .body(common::to_body(
7961                        request_value_reader.get_ref().clone().into(),
7962                    ));
7963
7964                client.request(request.unwrap()).await
7965            };
7966
7967            match req_result {
7968                Err(err) => {
7969                    if let common::Retry::After(d) = dlg.http_error(&err) {
7970                        sleep(d).await;
7971                        continue;
7972                    }
7973                    dlg.finished(false);
7974                    return Err(common::Error::HttpError(err));
7975                }
7976                Ok(res) => {
7977                    let (mut parts, body) = res.into_parts();
7978                    let mut body = common::Body::new(body);
7979                    if !parts.status.is_success() {
7980                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7981                        let error = serde_json::from_str(&common::to_string(&bytes));
7982                        let response = common::to_response(parts, bytes.into());
7983
7984                        if let common::Retry::After(d) =
7985                            dlg.http_failure(&response, error.as_ref().ok())
7986                        {
7987                            sleep(d).await;
7988                            continue;
7989                        }
7990
7991                        dlg.finished(false);
7992
7993                        return Err(match error {
7994                            Ok(value) => common::Error::BadRequest(value),
7995                            _ => common::Error::Failure(response),
7996                        });
7997                    }
7998                    let response = {
7999                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8000                        let encoded = common::to_string(&bytes);
8001                        match serde_json::from_str(&encoded) {
8002                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8003                            Err(error) => {
8004                                dlg.response_json_decode_error(&encoded, &error);
8005                                return Err(common::Error::JsonDecodeError(
8006                                    encoded.to_string(),
8007                                    error,
8008                                ));
8009                            }
8010                        }
8011                    };
8012
8013                    dlg.finished(true);
8014                    return Ok(response);
8015                }
8016            }
8017        }
8018    }
8019
8020    ///
8021    /// Sets the *request* property to the given value.
8022    ///
8023    /// Even though the property as already been set when instantiating this call,
8024    /// we provide this method for API completeness.
8025    pub fn request(
8026        mut self,
8027        new_value: SearchOrganizationsRequest,
8028    ) -> OrganizationSearchCall<'a, C> {
8029        self._request = new_value;
8030        self
8031    }
8032    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8033    /// while executing the actual API request.
8034    ///
8035    /// ````text
8036    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8037    /// ````
8038    ///
8039    /// Sets the *delegate* property to the given value.
8040    pub fn delegate(
8041        mut self,
8042        new_value: &'a mut dyn common::Delegate,
8043    ) -> OrganizationSearchCall<'a, C> {
8044        self._delegate = Some(new_value);
8045        self
8046    }
8047
8048    /// Set any additional parameter of the query string used in the request.
8049    /// It should be used to set parameters which are not yet available through their own
8050    /// setters.
8051    ///
8052    /// Please note that this method must not be used to set any of the known parameters
8053    /// which have their own setter method. If done anyway, the request will fail.
8054    ///
8055    /// # Additional Parameters
8056    ///
8057    /// * *$.xgafv* (query-string) - V1 error format.
8058    /// * *access_token* (query-string) - OAuth access token.
8059    /// * *alt* (query-string) - Data format for response.
8060    /// * *callback* (query-string) - JSONP
8061    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8062    /// * *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.
8063    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8064    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8065    /// * *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.
8066    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8067    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8068    pub fn param<T>(mut self, name: T, value: T) -> OrganizationSearchCall<'a, C>
8069    where
8070        T: AsRef<str>,
8071    {
8072        self._additional_params
8073            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8074        self
8075    }
8076
8077    /// Identifies the authorization scope for the method you are building.
8078    ///
8079    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8080    /// [`Scope::CloudPlatform`].
8081    ///
8082    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8083    /// tokens for more than one scope.
8084    ///
8085    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8086    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8087    /// sufficient, a read-write scope will do as well.
8088    pub fn add_scope<St>(mut self, scope: St) -> OrganizationSearchCall<'a, C>
8089    where
8090        St: AsRef<str>,
8091    {
8092        self._scopes.insert(String::from(scope.as_ref()));
8093        self
8094    }
8095    /// Identifies the authorization scope(s) for the method you are building.
8096    ///
8097    /// See [`Self::add_scope()`] for details.
8098    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationSearchCall<'a, C>
8099    where
8100        I: IntoIterator<Item = St>,
8101        St: AsRef<str>,
8102    {
8103        self._scopes
8104            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8105        self
8106    }
8107
8108    /// Removes all scopes, and no default scope will be used either.
8109    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8110    /// for details).
8111    pub fn clear_scopes(mut self) -> OrganizationSearchCall<'a, C> {
8112        self._scopes.clear();
8113        self
8114    }
8115}
8116
8117/// Sets the access control policy on an Organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization
8118///
8119/// A builder for the *setIamPolicy* method supported by a *organization* resource.
8120/// It is not used directly, but through a [`OrganizationMethods`] instance.
8121///
8122/// # Example
8123///
8124/// Instantiate a resource method builder
8125///
8126/// ```test_harness,no_run
8127/// # extern crate hyper;
8128/// # extern crate hyper_rustls;
8129/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
8130/// use cloudresourcemanager1::api::SetIamPolicyRequest;
8131/// # async fn dox() {
8132/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8133///
8134/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8135/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8136/// #     secret,
8137/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8138/// # ).build().await.unwrap();
8139///
8140/// # let client = hyper_util::client::legacy::Client::builder(
8141/// #     hyper_util::rt::TokioExecutor::new()
8142/// # )
8143/// # .build(
8144/// #     hyper_rustls::HttpsConnectorBuilder::new()
8145/// #         .with_native_roots()
8146/// #         .unwrap()
8147/// #         .https_or_http()
8148/// #         .enable_http1()
8149/// #         .build()
8150/// # );
8151/// # let mut hub = CloudResourceManager::new(client, auth);
8152/// // As the method needs a request, you would usually fill it with the desired information
8153/// // into the respective structure. Some of the parts shown here might not be applicable !
8154/// // Values shown here are possibly random and not representative !
8155/// let mut req = SetIamPolicyRequest::default();
8156///
8157/// // You can configure optional parameters by calling the respective setters at will, and
8158/// // execute the final call using `doit()`.
8159/// // Values shown here are possibly random and not representative !
8160/// let result = hub.organizations().set_iam_policy(req, "resource")
8161///              .doit().await;
8162/// # }
8163/// ```
8164pub struct OrganizationSetIamPolicyCall<'a, C>
8165where
8166    C: 'a,
8167{
8168    hub: &'a CloudResourceManager<C>,
8169    _request: SetIamPolicyRequest,
8170    _resource: String,
8171    _delegate: Option<&'a mut dyn common::Delegate>,
8172    _additional_params: HashMap<String, String>,
8173    _scopes: BTreeSet<String>,
8174}
8175
8176impl<'a, C> common::CallBuilder for OrganizationSetIamPolicyCall<'a, C> {}
8177
8178impl<'a, C> OrganizationSetIamPolicyCall<'a, C>
8179where
8180    C: common::Connector,
8181{
8182    /// Perform the operation you have build so far.
8183    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8184        use std::borrow::Cow;
8185        use std::io::{Read, Seek};
8186
8187        use common::{url::Params, ToParts};
8188        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8189
8190        let mut dd = common::DefaultDelegate;
8191        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8192        dlg.begin(common::MethodInfo {
8193            id: "cloudresourcemanager.organizations.setIamPolicy",
8194            http_method: hyper::Method::POST,
8195        });
8196
8197        for &field in ["alt", "resource"].iter() {
8198            if self._additional_params.contains_key(field) {
8199                dlg.finished(false);
8200                return Err(common::Error::FieldClash(field));
8201            }
8202        }
8203
8204        let mut params = Params::with_capacity(4 + self._additional_params.len());
8205        params.push("resource", self._resource);
8206
8207        params.extend(self._additional_params.iter());
8208
8209        params.push("alt", "json");
8210        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8211        if self._scopes.is_empty() {
8212            self._scopes
8213                .insert(Scope::CloudPlatform.as_ref().to_string());
8214        }
8215
8216        #[allow(clippy::single_element_loop)]
8217        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8218            url = params.uri_replacement(url, param_name, find_this, true);
8219        }
8220        {
8221            let to_remove = ["resource"];
8222            params.remove_params(&to_remove);
8223        }
8224
8225        let url = params.parse_with_url(&url);
8226
8227        let mut json_mime_type = mime::APPLICATION_JSON;
8228        let mut request_value_reader = {
8229            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8230            common::remove_json_null_values(&mut value);
8231            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8232            serde_json::to_writer(&mut dst, &value).unwrap();
8233            dst
8234        };
8235        let request_size = request_value_reader
8236            .seek(std::io::SeekFrom::End(0))
8237            .unwrap();
8238        request_value_reader
8239            .seek(std::io::SeekFrom::Start(0))
8240            .unwrap();
8241
8242        loop {
8243            let token = match self
8244                .hub
8245                .auth
8246                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8247                .await
8248            {
8249                Ok(token) => token,
8250                Err(e) => match dlg.token(e) {
8251                    Ok(token) => token,
8252                    Err(e) => {
8253                        dlg.finished(false);
8254                        return Err(common::Error::MissingToken(e));
8255                    }
8256                },
8257            };
8258            request_value_reader
8259                .seek(std::io::SeekFrom::Start(0))
8260                .unwrap();
8261            let mut req_result = {
8262                let client = &self.hub.client;
8263                dlg.pre_request();
8264                let mut req_builder = hyper::Request::builder()
8265                    .method(hyper::Method::POST)
8266                    .uri(url.as_str())
8267                    .header(USER_AGENT, self.hub._user_agent.clone());
8268
8269                if let Some(token) = token.as_ref() {
8270                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8271                }
8272
8273                let request = req_builder
8274                    .header(CONTENT_TYPE, json_mime_type.to_string())
8275                    .header(CONTENT_LENGTH, request_size as u64)
8276                    .body(common::to_body(
8277                        request_value_reader.get_ref().clone().into(),
8278                    ));
8279
8280                client.request(request.unwrap()).await
8281            };
8282
8283            match req_result {
8284                Err(err) => {
8285                    if let common::Retry::After(d) = dlg.http_error(&err) {
8286                        sleep(d).await;
8287                        continue;
8288                    }
8289                    dlg.finished(false);
8290                    return Err(common::Error::HttpError(err));
8291                }
8292                Ok(res) => {
8293                    let (mut parts, body) = res.into_parts();
8294                    let mut body = common::Body::new(body);
8295                    if !parts.status.is_success() {
8296                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8297                        let error = serde_json::from_str(&common::to_string(&bytes));
8298                        let response = common::to_response(parts, bytes.into());
8299
8300                        if let common::Retry::After(d) =
8301                            dlg.http_failure(&response, error.as_ref().ok())
8302                        {
8303                            sleep(d).await;
8304                            continue;
8305                        }
8306
8307                        dlg.finished(false);
8308
8309                        return Err(match error {
8310                            Ok(value) => common::Error::BadRequest(value),
8311                            _ => common::Error::Failure(response),
8312                        });
8313                    }
8314                    let response = {
8315                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8316                        let encoded = common::to_string(&bytes);
8317                        match serde_json::from_str(&encoded) {
8318                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8319                            Err(error) => {
8320                                dlg.response_json_decode_error(&encoded, &error);
8321                                return Err(common::Error::JsonDecodeError(
8322                                    encoded.to_string(),
8323                                    error,
8324                                ));
8325                            }
8326                        }
8327                    };
8328
8329                    dlg.finished(true);
8330                    return Ok(response);
8331                }
8332            }
8333        }
8334    }
8335
8336    ///
8337    /// Sets the *request* property to the given value.
8338    ///
8339    /// Even though the property as already been set when instantiating this call,
8340    /// we provide this method for API completeness.
8341    pub fn request(
8342        mut self,
8343        new_value: SetIamPolicyRequest,
8344    ) -> OrganizationSetIamPolicyCall<'a, C> {
8345        self._request = new_value;
8346        self
8347    }
8348    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8349    ///
8350    /// Sets the *resource* path property to the given value.
8351    ///
8352    /// Even though the property as already been set when instantiating this call,
8353    /// we provide this method for API completeness.
8354    pub fn resource(mut self, new_value: &str) -> OrganizationSetIamPolicyCall<'a, C> {
8355        self._resource = new_value.to_string();
8356        self
8357    }
8358    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8359    /// while executing the actual API request.
8360    ///
8361    /// ````text
8362    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8363    /// ````
8364    ///
8365    /// Sets the *delegate* property to the given value.
8366    pub fn delegate(
8367        mut self,
8368        new_value: &'a mut dyn common::Delegate,
8369    ) -> OrganizationSetIamPolicyCall<'a, C> {
8370        self._delegate = Some(new_value);
8371        self
8372    }
8373
8374    /// Set any additional parameter of the query string used in the request.
8375    /// It should be used to set parameters which are not yet available through their own
8376    /// setters.
8377    ///
8378    /// Please note that this method must not be used to set any of the known parameters
8379    /// which have their own setter method. If done anyway, the request will fail.
8380    ///
8381    /// # Additional Parameters
8382    ///
8383    /// * *$.xgafv* (query-string) - V1 error format.
8384    /// * *access_token* (query-string) - OAuth access token.
8385    /// * *alt* (query-string) - Data format for response.
8386    /// * *callback* (query-string) - JSONP
8387    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8388    /// * *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.
8389    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8390    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8391    /// * *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.
8392    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8393    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8394    pub fn param<T>(mut self, name: T, value: T) -> OrganizationSetIamPolicyCall<'a, C>
8395    where
8396        T: AsRef<str>,
8397    {
8398        self._additional_params
8399            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8400        self
8401    }
8402
8403    /// Identifies the authorization scope for the method you are building.
8404    ///
8405    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8406    /// [`Scope::CloudPlatform`].
8407    ///
8408    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8409    /// tokens for more than one scope.
8410    ///
8411    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8412    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8413    /// sufficient, a read-write scope will do as well.
8414    pub fn add_scope<St>(mut self, scope: St) -> OrganizationSetIamPolicyCall<'a, C>
8415    where
8416        St: AsRef<str>,
8417    {
8418        self._scopes.insert(String::from(scope.as_ref()));
8419        self
8420    }
8421    /// Identifies the authorization scope(s) for the method you are building.
8422    ///
8423    /// See [`Self::add_scope()`] for details.
8424    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationSetIamPolicyCall<'a, C>
8425    where
8426        I: IntoIterator<Item = St>,
8427        St: AsRef<str>,
8428    {
8429        self._scopes
8430            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8431        self
8432    }
8433
8434    /// Removes all scopes, and no default scope will be used either.
8435    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8436    /// for details).
8437    pub fn clear_scopes(mut self) -> OrganizationSetIamPolicyCall<'a, C> {
8438        self._scopes.clear();
8439        self
8440    }
8441}
8442
8443/// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
8444///
8445/// A builder for the *setOrgPolicy* method supported by a *organization* resource.
8446/// It is not used directly, but through a [`OrganizationMethods`] instance.
8447///
8448/// # Example
8449///
8450/// Instantiate a resource method builder
8451///
8452/// ```test_harness,no_run
8453/// # extern crate hyper;
8454/// # extern crate hyper_rustls;
8455/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
8456/// use cloudresourcemanager1::api::SetOrgPolicyRequest;
8457/// # async fn dox() {
8458/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8459///
8460/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8461/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8462/// #     secret,
8463/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8464/// # ).build().await.unwrap();
8465///
8466/// # let client = hyper_util::client::legacy::Client::builder(
8467/// #     hyper_util::rt::TokioExecutor::new()
8468/// # )
8469/// # .build(
8470/// #     hyper_rustls::HttpsConnectorBuilder::new()
8471/// #         .with_native_roots()
8472/// #         .unwrap()
8473/// #         .https_or_http()
8474/// #         .enable_http1()
8475/// #         .build()
8476/// # );
8477/// # let mut hub = CloudResourceManager::new(client, auth);
8478/// // As the method needs a request, you would usually fill it with the desired information
8479/// // into the respective structure. Some of the parts shown here might not be applicable !
8480/// // Values shown here are possibly random and not representative !
8481/// let mut req = SetOrgPolicyRequest::default();
8482///
8483/// // You can configure optional parameters by calling the respective setters at will, and
8484/// // execute the final call using `doit()`.
8485/// // Values shown here are possibly random and not representative !
8486/// let result = hub.organizations().set_org_policy(req, "resource")
8487///              .doit().await;
8488/// # }
8489/// ```
8490pub struct OrganizationSetOrgPolicyCall<'a, C>
8491where
8492    C: 'a,
8493{
8494    hub: &'a CloudResourceManager<C>,
8495    _request: SetOrgPolicyRequest,
8496    _resource: String,
8497    _delegate: Option<&'a mut dyn common::Delegate>,
8498    _additional_params: HashMap<String, String>,
8499    _scopes: BTreeSet<String>,
8500}
8501
8502impl<'a, C> common::CallBuilder for OrganizationSetOrgPolicyCall<'a, C> {}
8503
8504impl<'a, C> OrganizationSetOrgPolicyCall<'a, C>
8505where
8506    C: common::Connector,
8507{
8508    /// Perform the operation you have build so far.
8509    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
8510        use std::borrow::Cow;
8511        use std::io::{Read, Seek};
8512
8513        use common::{url::Params, ToParts};
8514        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8515
8516        let mut dd = common::DefaultDelegate;
8517        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8518        dlg.begin(common::MethodInfo {
8519            id: "cloudresourcemanager.organizations.setOrgPolicy",
8520            http_method: hyper::Method::POST,
8521        });
8522
8523        for &field in ["alt", "resource"].iter() {
8524            if self._additional_params.contains_key(field) {
8525                dlg.finished(false);
8526                return Err(common::Error::FieldClash(field));
8527            }
8528        }
8529
8530        let mut params = Params::with_capacity(4 + self._additional_params.len());
8531        params.push("resource", self._resource);
8532
8533        params.extend(self._additional_params.iter());
8534
8535        params.push("alt", "json");
8536        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setOrgPolicy";
8537        if self._scopes.is_empty() {
8538            self._scopes
8539                .insert(Scope::CloudPlatform.as_ref().to_string());
8540        }
8541
8542        #[allow(clippy::single_element_loop)]
8543        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8544            url = params.uri_replacement(url, param_name, find_this, true);
8545        }
8546        {
8547            let to_remove = ["resource"];
8548            params.remove_params(&to_remove);
8549        }
8550
8551        let url = params.parse_with_url(&url);
8552
8553        let mut json_mime_type = mime::APPLICATION_JSON;
8554        let mut request_value_reader = {
8555            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8556            common::remove_json_null_values(&mut value);
8557            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8558            serde_json::to_writer(&mut dst, &value).unwrap();
8559            dst
8560        };
8561        let request_size = request_value_reader
8562            .seek(std::io::SeekFrom::End(0))
8563            .unwrap();
8564        request_value_reader
8565            .seek(std::io::SeekFrom::Start(0))
8566            .unwrap();
8567
8568        loop {
8569            let token = match self
8570                .hub
8571                .auth
8572                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8573                .await
8574            {
8575                Ok(token) => token,
8576                Err(e) => match dlg.token(e) {
8577                    Ok(token) => token,
8578                    Err(e) => {
8579                        dlg.finished(false);
8580                        return Err(common::Error::MissingToken(e));
8581                    }
8582                },
8583            };
8584            request_value_reader
8585                .seek(std::io::SeekFrom::Start(0))
8586                .unwrap();
8587            let mut req_result = {
8588                let client = &self.hub.client;
8589                dlg.pre_request();
8590                let mut req_builder = hyper::Request::builder()
8591                    .method(hyper::Method::POST)
8592                    .uri(url.as_str())
8593                    .header(USER_AGENT, self.hub._user_agent.clone());
8594
8595                if let Some(token) = token.as_ref() {
8596                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8597                }
8598
8599                let request = req_builder
8600                    .header(CONTENT_TYPE, json_mime_type.to_string())
8601                    .header(CONTENT_LENGTH, request_size as u64)
8602                    .body(common::to_body(
8603                        request_value_reader.get_ref().clone().into(),
8604                    ));
8605
8606                client.request(request.unwrap()).await
8607            };
8608
8609            match req_result {
8610                Err(err) => {
8611                    if let common::Retry::After(d) = dlg.http_error(&err) {
8612                        sleep(d).await;
8613                        continue;
8614                    }
8615                    dlg.finished(false);
8616                    return Err(common::Error::HttpError(err));
8617                }
8618                Ok(res) => {
8619                    let (mut parts, body) = res.into_parts();
8620                    let mut body = common::Body::new(body);
8621                    if !parts.status.is_success() {
8622                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8623                        let error = serde_json::from_str(&common::to_string(&bytes));
8624                        let response = common::to_response(parts, bytes.into());
8625
8626                        if let common::Retry::After(d) =
8627                            dlg.http_failure(&response, error.as_ref().ok())
8628                        {
8629                            sleep(d).await;
8630                            continue;
8631                        }
8632
8633                        dlg.finished(false);
8634
8635                        return Err(match error {
8636                            Ok(value) => common::Error::BadRequest(value),
8637                            _ => common::Error::Failure(response),
8638                        });
8639                    }
8640                    let response = {
8641                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8642                        let encoded = common::to_string(&bytes);
8643                        match serde_json::from_str(&encoded) {
8644                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8645                            Err(error) => {
8646                                dlg.response_json_decode_error(&encoded, &error);
8647                                return Err(common::Error::JsonDecodeError(
8648                                    encoded.to_string(),
8649                                    error,
8650                                ));
8651                            }
8652                        }
8653                    };
8654
8655                    dlg.finished(true);
8656                    return Ok(response);
8657                }
8658            }
8659        }
8660    }
8661
8662    ///
8663    /// Sets the *request* property to the given value.
8664    ///
8665    /// Even though the property as already been set when instantiating this call,
8666    /// we provide this method for API completeness.
8667    pub fn request(
8668        mut self,
8669        new_value: SetOrgPolicyRequest,
8670    ) -> OrganizationSetOrgPolicyCall<'a, C> {
8671        self._request = new_value;
8672        self
8673    }
8674    /// Resource name of the resource to attach the `Policy`.
8675    ///
8676    /// Sets the *resource* path property to the given value.
8677    ///
8678    /// Even though the property as already been set when instantiating this call,
8679    /// we provide this method for API completeness.
8680    pub fn resource(mut self, new_value: &str) -> OrganizationSetOrgPolicyCall<'a, C> {
8681        self._resource = new_value.to_string();
8682        self
8683    }
8684    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8685    /// while executing the actual API request.
8686    ///
8687    /// ````text
8688    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8689    /// ````
8690    ///
8691    /// Sets the *delegate* property to the given value.
8692    pub fn delegate(
8693        mut self,
8694        new_value: &'a mut dyn common::Delegate,
8695    ) -> OrganizationSetOrgPolicyCall<'a, C> {
8696        self._delegate = Some(new_value);
8697        self
8698    }
8699
8700    /// Set any additional parameter of the query string used in the request.
8701    /// It should be used to set parameters which are not yet available through their own
8702    /// setters.
8703    ///
8704    /// Please note that this method must not be used to set any of the known parameters
8705    /// which have their own setter method. If done anyway, the request will fail.
8706    ///
8707    /// # Additional Parameters
8708    ///
8709    /// * *$.xgafv* (query-string) - V1 error format.
8710    /// * *access_token* (query-string) - OAuth access token.
8711    /// * *alt* (query-string) - Data format for response.
8712    /// * *callback* (query-string) - JSONP
8713    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8714    /// * *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.
8715    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8716    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8717    /// * *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.
8718    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8719    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8720    pub fn param<T>(mut self, name: T, value: T) -> OrganizationSetOrgPolicyCall<'a, C>
8721    where
8722        T: AsRef<str>,
8723    {
8724        self._additional_params
8725            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8726        self
8727    }
8728
8729    /// Identifies the authorization scope for the method you are building.
8730    ///
8731    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8732    /// [`Scope::CloudPlatform`].
8733    ///
8734    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8735    /// tokens for more than one scope.
8736    ///
8737    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8738    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8739    /// sufficient, a read-write scope will do as well.
8740    pub fn add_scope<St>(mut self, scope: St) -> OrganizationSetOrgPolicyCall<'a, C>
8741    where
8742        St: AsRef<str>,
8743    {
8744        self._scopes.insert(String::from(scope.as_ref()));
8745        self
8746    }
8747    /// Identifies the authorization scope(s) for the method you are building.
8748    ///
8749    /// See [`Self::add_scope()`] for details.
8750    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationSetOrgPolicyCall<'a, C>
8751    where
8752        I: IntoIterator<Item = St>,
8753        St: AsRef<str>,
8754    {
8755        self._scopes
8756            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8757        self
8758    }
8759
8760    /// Removes all scopes, and no default scope will be used either.
8761    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8762    /// for details).
8763    pub fn clear_scopes(mut self) -> OrganizationSetOrgPolicyCall<'a, C> {
8764        self._scopes.clear();
8765        self
8766    }
8767}
8768
8769/// Returns permissions that a caller has on the specified Organization. The `resource` field should be the organization's resource name, e.g. "organizations/123". There are no permissions required for making this API call.
8770///
8771/// A builder for the *testIamPermissions* method supported by a *organization* resource.
8772/// It is not used directly, but through a [`OrganizationMethods`] instance.
8773///
8774/// # Example
8775///
8776/// Instantiate a resource method builder
8777///
8778/// ```test_harness,no_run
8779/// # extern crate hyper;
8780/// # extern crate hyper_rustls;
8781/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
8782/// use cloudresourcemanager1::api::TestIamPermissionsRequest;
8783/// # async fn dox() {
8784/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8785///
8786/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8787/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8788/// #     secret,
8789/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8790/// # ).build().await.unwrap();
8791///
8792/// # let client = hyper_util::client::legacy::Client::builder(
8793/// #     hyper_util::rt::TokioExecutor::new()
8794/// # )
8795/// # .build(
8796/// #     hyper_rustls::HttpsConnectorBuilder::new()
8797/// #         .with_native_roots()
8798/// #         .unwrap()
8799/// #         .https_or_http()
8800/// #         .enable_http1()
8801/// #         .build()
8802/// # );
8803/// # let mut hub = CloudResourceManager::new(client, auth);
8804/// // As the method needs a request, you would usually fill it with the desired information
8805/// // into the respective structure. Some of the parts shown here might not be applicable !
8806/// // Values shown here are possibly random and not representative !
8807/// let mut req = TestIamPermissionsRequest::default();
8808///
8809/// // You can configure optional parameters by calling the respective setters at will, and
8810/// // execute the final call using `doit()`.
8811/// // Values shown here are possibly random and not representative !
8812/// let result = hub.organizations().test_iam_permissions(req, "resource")
8813///              .doit().await;
8814/// # }
8815/// ```
8816pub struct OrganizationTestIamPermissionCall<'a, C>
8817where
8818    C: 'a,
8819{
8820    hub: &'a CloudResourceManager<C>,
8821    _request: TestIamPermissionsRequest,
8822    _resource: String,
8823    _delegate: Option<&'a mut dyn common::Delegate>,
8824    _additional_params: HashMap<String, String>,
8825    _scopes: BTreeSet<String>,
8826}
8827
8828impl<'a, C> common::CallBuilder for OrganizationTestIamPermissionCall<'a, C> {}
8829
8830impl<'a, C> OrganizationTestIamPermissionCall<'a, C>
8831where
8832    C: common::Connector,
8833{
8834    /// Perform the operation you have build so far.
8835    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8836        use std::borrow::Cow;
8837        use std::io::{Read, Seek};
8838
8839        use common::{url::Params, ToParts};
8840        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8841
8842        let mut dd = common::DefaultDelegate;
8843        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8844        dlg.begin(common::MethodInfo {
8845            id: "cloudresourcemanager.organizations.testIamPermissions",
8846            http_method: hyper::Method::POST,
8847        });
8848
8849        for &field in ["alt", "resource"].iter() {
8850            if self._additional_params.contains_key(field) {
8851                dlg.finished(false);
8852                return Err(common::Error::FieldClash(field));
8853            }
8854        }
8855
8856        let mut params = Params::with_capacity(4 + self._additional_params.len());
8857        params.push("resource", self._resource);
8858
8859        params.extend(self._additional_params.iter());
8860
8861        params.push("alt", "json");
8862        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
8863        if self._scopes.is_empty() {
8864            self._scopes
8865                .insert(Scope::CloudPlatform.as_ref().to_string());
8866        }
8867
8868        #[allow(clippy::single_element_loop)]
8869        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8870            url = params.uri_replacement(url, param_name, find_this, true);
8871        }
8872        {
8873            let to_remove = ["resource"];
8874            params.remove_params(&to_remove);
8875        }
8876
8877        let url = params.parse_with_url(&url);
8878
8879        let mut json_mime_type = mime::APPLICATION_JSON;
8880        let mut request_value_reader = {
8881            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8882            common::remove_json_null_values(&mut value);
8883            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8884            serde_json::to_writer(&mut dst, &value).unwrap();
8885            dst
8886        };
8887        let request_size = request_value_reader
8888            .seek(std::io::SeekFrom::End(0))
8889            .unwrap();
8890        request_value_reader
8891            .seek(std::io::SeekFrom::Start(0))
8892            .unwrap();
8893
8894        loop {
8895            let token = match self
8896                .hub
8897                .auth
8898                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8899                .await
8900            {
8901                Ok(token) => token,
8902                Err(e) => match dlg.token(e) {
8903                    Ok(token) => token,
8904                    Err(e) => {
8905                        dlg.finished(false);
8906                        return Err(common::Error::MissingToken(e));
8907                    }
8908                },
8909            };
8910            request_value_reader
8911                .seek(std::io::SeekFrom::Start(0))
8912                .unwrap();
8913            let mut req_result = {
8914                let client = &self.hub.client;
8915                dlg.pre_request();
8916                let mut req_builder = hyper::Request::builder()
8917                    .method(hyper::Method::POST)
8918                    .uri(url.as_str())
8919                    .header(USER_AGENT, self.hub._user_agent.clone());
8920
8921                if let Some(token) = token.as_ref() {
8922                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8923                }
8924
8925                let request = req_builder
8926                    .header(CONTENT_TYPE, json_mime_type.to_string())
8927                    .header(CONTENT_LENGTH, request_size as u64)
8928                    .body(common::to_body(
8929                        request_value_reader.get_ref().clone().into(),
8930                    ));
8931
8932                client.request(request.unwrap()).await
8933            };
8934
8935            match req_result {
8936                Err(err) => {
8937                    if let common::Retry::After(d) = dlg.http_error(&err) {
8938                        sleep(d).await;
8939                        continue;
8940                    }
8941                    dlg.finished(false);
8942                    return Err(common::Error::HttpError(err));
8943                }
8944                Ok(res) => {
8945                    let (mut parts, body) = res.into_parts();
8946                    let mut body = common::Body::new(body);
8947                    if !parts.status.is_success() {
8948                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8949                        let error = serde_json::from_str(&common::to_string(&bytes));
8950                        let response = common::to_response(parts, bytes.into());
8951
8952                        if let common::Retry::After(d) =
8953                            dlg.http_failure(&response, error.as_ref().ok())
8954                        {
8955                            sleep(d).await;
8956                            continue;
8957                        }
8958
8959                        dlg.finished(false);
8960
8961                        return Err(match error {
8962                            Ok(value) => common::Error::BadRequest(value),
8963                            _ => common::Error::Failure(response),
8964                        });
8965                    }
8966                    let response = {
8967                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8968                        let encoded = common::to_string(&bytes);
8969                        match serde_json::from_str(&encoded) {
8970                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8971                            Err(error) => {
8972                                dlg.response_json_decode_error(&encoded, &error);
8973                                return Err(common::Error::JsonDecodeError(
8974                                    encoded.to_string(),
8975                                    error,
8976                                ));
8977                            }
8978                        }
8979                    };
8980
8981                    dlg.finished(true);
8982                    return Ok(response);
8983                }
8984            }
8985        }
8986    }
8987
8988    ///
8989    /// Sets the *request* property to the given value.
8990    ///
8991    /// Even though the property as already been set when instantiating this call,
8992    /// we provide this method for API completeness.
8993    pub fn request(
8994        mut self,
8995        new_value: TestIamPermissionsRequest,
8996    ) -> OrganizationTestIamPermissionCall<'a, C> {
8997        self._request = new_value;
8998        self
8999    }
9000    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
9001    ///
9002    /// Sets the *resource* path property to the given value.
9003    ///
9004    /// Even though the property as already been set when instantiating this call,
9005    /// we provide this method for API completeness.
9006    pub fn resource(mut self, new_value: &str) -> OrganizationTestIamPermissionCall<'a, C> {
9007        self._resource = new_value.to_string();
9008        self
9009    }
9010    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9011    /// while executing the actual API request.
9012    ///
9013    /// ````text
9014    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9015    /// ````
9016    ///
9017    /// Sets the *delegate* property to the given value.
9018    pub fn delegate(
9019        mut self,
9020        new_value: &'a mut dyn common::Delegate,
9021    ) -> OrganizationTestIamPermissionCall<'a, C> {
9022        self._delegate = Some(new_value);
9023        self
9024    }
9025
9026    /// Set any additional parameter of the query string used in the request.
9027    /// It should be used to set parameters which are not yet available through their own
9028    /// setters.
9029    ///
9030    /// Please note that this method must not be used to set any of the known parameters
9031    /// which have their own setter method. If done anyway, the request will fail.
9032    ///
9033    /// # Additional Parameters
9034    ///
9035    /// * *$.xgafv* (query-string) - V1 error format.
9036    /// * *access_token* (query-string) - OAuth access token.
9037    /// * *alt* (query-string) - Data format for response.
9038    /// * *callback* (query-string) - JSONP
9039    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9040    /// * *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.
9041    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9042    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9043    /// * *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.
9044    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9045    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9046    pub fn param<T>(mut self, name: T, value: T) -> OrganizationTestIamPermissionCall<'a, C>
9047    where
9048        T: AsRef<str>,
9049    {
9050        self._additional_params
9051            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9052        self
9053    }
9054
9055    /// Identifies the authorization scope for the method you are building.
9056    ///
9057    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9058    /// [`Scope::CloudPlatform`].
9059    ///
9060    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9061    /// tokens for more than one scope.
9062    ///
9063    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9064    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9065    /// sufficient, a read-write scope will do as well.
9066    pub fn add_scope<St>(mut self, scope: St) -> OrganizationTestIamPermissionCall<'a, C>
9067    where
9068        St: AsRef<str>,
9069    {
9070        self._scopes.insert(String::from(scope.as_ref()));
9071        self
9072    }
9073    /// Identifies the authorization scope(s) for the method you are building.
9074    ///
9075    /// See [`Self::add_scope()`] for details.
9076    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationTestIamPermissionCall<'a, C>
9077    where
9078        I: IntoIterator<Item = St>,
9079        St: AsRef<str>,
9080    {
9081        self._scopes
9082            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9083        self
9084    }
9085
9086    /// Removes all scopes, and no default scope will be used either.
9087    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9088    /// for details).
9089    pub fn clear_scopes(mut self) -> OrganizationTestIamPermissionCall<'a, C> {
9090        self._scopes.clear();
9091        self
9092    }
9093}
9094
9095/// Clears a `Policy` from a resource.
9096///
9097/// A builder for the *clearOrgPolicy* method supported by a *project* resource.
9098/// It is not used directly, but through a [`ProjectMethods`] instance.
9099///
9100/// # Example
9101///
9102/// Instantiate a resource method builder
9103///
9104/// ```test_harness,no_run
9105/// # extern crate hyper;
9106/// # extern crate hyper_rustls;
9107/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
9108/// use cloudresourcemanager1::api::ClearOrgPolicyRequest;
9109/// # async fn dox() {
9110/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9111///
9112/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9113/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9114/// #     secret,
9115/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9116/// # ).build().await.unwrap();
9117///
9118/// # let client = hyper_util::client::legacy::Client::builder(
9119/// #     hyper_util::rt::TokioExecutor::new()
9120/// # )
9121/// # .build(
9122/// #     hyper_rustls::HttpsConnectorBuilder::new()
9123/// #         .with_native_roots()
9124/// #         .unwrap()
9125/// #         .https_or_http()
9126/// #         .enable_http1()
9127/// #         .build()
9128/// # );
9129/// # let mut hub = CloudResourceManager::new(client, auth);
9130/// // As the method needs a request, you would usually fill it with the desired information
9131/// // into the respective structure. Some of the parts shown here might not be applicable !
9132/// // Values shown here are possibly random and not representative !
9133/// let mut req = ClearOrgPolicyRequest::default();
9134///
9135/// // You can configure optional parameters by calling the respective setters at will, and
9136/// // execute the final call using `doit()`.
9137/// // Values shown here are possibly random and not representative !
9138/// let result = hub.projects().clear_org_policy(req, "resource")
9139///              .doit().await;
9140/// # }
9141/// ```
9142pub struct ProjectClearOrgPolicyCall<'a, C>
9143where
9144    C: 'a,
9145{
9146    hub: &'a CloudResourceManager<C>,
9147    _request: ClearOrgPolicyRequest,
9148    _resource: String,
9149    _delegate: Option<&'a mut dyn common::Delegate>,
9150    _additional_params: HashMap<String, String>,
9151    _scopes: BTreeSet<String>,
9152}
9153
9154impl<'a, C> common::CallBuilder for ProjectClearOrgPolicyCall<'a, C> {}
9155
9156impl<'a, C> ProjectClearOrgPolicyCall<'a, C>
9157where
9158    C: common::Connector,
9159{
9160    /// Perform the operation you have build so far.
9161    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9162        use std::borrow::Cow;
9163        use std::io::{Read, Seek};
9164
9165        use common::{url::Params, ToParts};
9166        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9167
9168        let mut dd = common::DefaultDelegate;
9169        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9170        dlg.begin(common::MethodInfo {
9171            id: "cloudresourcemanager.projects.clearOrgPolicy",
9172            http_method: hyper::Method::POST,
9173        });
9174
9175        for &field in ["alt", "resource"].iter() {
9176            if self._additional_params.contains_key(field) {
9177                dlg.finished(false);
9178                return Err(common::Error::FieldClash(field));
9179            }
9180        }
9181
9182        let mut params = Params::with_capacity(4 + self._additional_params.len());
9183        params.push("resource", self._resource);
9184
9185        params.extend(self._additional_params.iter());
9186
9187        params.push("alt", "json");
9188        let mut url = self.hub._base_url.clone() + "v1/{+resource}:clearOrgPolicy";
9189        if self._scopes.is_empty() {
9190            self._scopes
9191                .insert(Scope::CloudPlatform.as_ref().to_string());
9192        }
9193
9194        #[allow(clippy::single_element_loop)]
9195        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9196            url = params.uri_replacement(url, param_name, find_this, true);
9197        }
9198        {
9199            let to_remove = ["resource"];
9200            params.remove_params(&to_remove);
9201        }
9202
9203        let url = params.parse_with_url(&url);
9204
9205        let mut json_mime_type = mime::APPLICATION_JSON;
9206        let mut request_value_reader = {
9207            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9208            common::remove_json_null_values(&mut value);
9209            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9210            serde_json::to_writer(&mut dst, &value).unwrap();
9211            dst
9212        };
9213        let request_size = request_value_reader
9214            .seek(std::io::SeekFrom::End(0))
9215            .unwrap();
9216        request_value_reader
9217            .seek(std::io::SeekFrom::Start(0))
9218            .unwrap();
9219
9220        loop {
9221            let token = match self
9222                .hub
9223                .auth
9224                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9225                .await
9226            {
9227                Ok(token) => token,
9228                Err(e) => match dlg.token(e) {
9229                    Ok(token) => token,
9230                    Err(e) => {
9231                        dlg.finished(false);
9232                        return Err(common::Error::MissingToken(e));
9233                    }
9234                },
9235            };
9236            request_value_reader
9237                .seek(std::io::SeekFrom::Start(0))
9238                .unwrap();
9239            let mut req_result = {
9240                let client = &self.hub.client;
9241                dlg.pre_request();
9242                let mut req_builder = hyper::Request::builder()
9243                    .method(hyper::Method::POST)
9244                    .uri(url.as_str())
9245                    .header(USER_AGENT, self.hub._user_agent.clone());
9246
9247                if let Some(token) = token.as_ref() {
9248                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9249                }
9250
9251                let request = req_builder
9252                    .header(CONTENT_TYPE, json_mime_type.to_string())
9253                    .header(CONTENT_LENGTH, request_size as u64)
9254                    .body(common::to_body(
9255                        request_value_reader.get_ref().clone().into(),
9256                    ));
9257
9258                client.request(request.unwrap()).await
9259            };
9260
9261            match req_result {
9262                Err(err) => {
9263                    if let common::Retry::After(d) = dlg.http_error(&err) {
9264                        sleep(d).await;
9265                        continue;
9266                    }
9267                    dlg.finished(false);
9268                    return Err(common::Error::HttpError(err));
9269                }
9270                Ok(res) => {
9271                    let (mut parts, body) = res.into_parts();
9272                    let mut body = common::Body::new(body);
9273                    if !parts.status.is_success() {
9274                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9275                        let error = serde_json::from_str(&common::to_string(&bytes));
9276                        let response = common::to_response(parts, bytes.into());
9277
9278                        if let common::Retry::After(d) =
9279                            dlg.http_failure(&response, error.as_ref().ok())
9280                        {
9281                            sleep(d).await;
9282                            continue;
9283                        }
9284
9285                        dlg.finished(false);
9286
9287                        return Err(match error {
9288                            Ok(value) => common::Error::BadRequest(value),
9289                            _ => common::Error::Failure(response),
9290                        });
9291                    }
9292                    let response = {
9293                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9294                        let encoded = common::to_string(&bytes);
9295                        match serde_json::from_str(&encoded) {
9296                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9297                            Err(error) => {
9298                                dlg.response_json_decode_error(&encoded, &error);
9299                                return Err(common::Error::JsonDecodeError(
9300                                    encoded.to_string(),
9301                                    error,
9302                                ));
9303                            }
9304                        }
9305                    };
9306
9307                    dlg.finished(true);
9308                    return Ok(response);
9309                }
9310            }
9311        }
9312    }
9313
9314    ///
9315    /// Sets the *request* property to the given value.
9316    ///
9317    /// Even though the property as already been set when instantiating this call,
9318    /// we provide this method for API completeness.
9319    pub fn request(mut self, new_value: ClearOrgPolicyRequest) -> ProjectClearOrgPolicyCall<'a, C> {
9320        self._request = new_value;
9321        self
9322    }
9323    /// Name of the resource for the `Policy` to clear.
9324    ///
9325    /// Sets the *resource* path property to the given value.
9326    ///
9327    /// Even though the property as already been set when instantiating this call,
9328    /// we provide this method for API completeness.
9329    pub fn resource(mut self, new_value: &str) -> ProjectClearOrgPolicyCall<'a, C> {
9330        self._resource = new_value.to_string();
9331        self
9332    }
9333    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9334    /// while executing the actual API request.
9335    ///
9336    /// ````text
9337    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9338    /// ````
9339    ///
9340    /// Sets the *delegate* property to the given value.
9341    pub fn delegate(
9342        mut self,
9343        new_value: &'a mut dyn common::Delegate,
9344    ) -> ProjectClearOrgPolicyCall<'a, C> {
9345        self._delegate = Some(new_value);
9346        self
9347    }
9348
9349    /// Set any additional parameter of the query string used in the request.
9350    /// It should be used to set parameters which are not yet available through their own
9351    /// setters.
9352    ///
9353    /// Please note that this method must not be used to set any of the known parameters
9354    /// which have their own setter method. If done anyway, the request will fail.
9355    ///
9356    /// # Additional Parameters
9357    ///
9358    /// * *$.xgafv* (query-string) - V1 error format.
9359    /// * *access_token* (query-string) - OAuth access token.
9360    /// * *alt* (query-string) - Data format for response.
9361    /// * *callback* (query-string) - JSONP
9362    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9363    /// * *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.
9364    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9365    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9366    /// * *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.
9367    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9368    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9369    pub fn param<T>(mut self, name: T, value: T) -> ProjectClearOrgPolicyCall<'a, C>
9370    where
9371        T: AsRef<str>,
9372    {
9373        self._additional_params
9374            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9375        self
9376    }
9377
9378    /// Identifies the authorization scope for the method you are building.
9379    ///
9380    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9381    /// [`Scope::CloudPlatform`].
9382    ///
9383    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9384    /// tokens for more than one scope.
9385    ///
9386    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9387    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9388    /// sufficient, a read-write scope will do as well.
9389    pub fn add_scope<St>(mut self, scope: St) -> ProjectClearOrgPolicyCall<'a, C>
9390    where
9391        St: AsRef<str>,
9392    {
9393        self._scopes.insert(String::from(scope.as_ref()));
9394        self
9395    }
9396    /// Identifies the authorization scope(s) for the method you are building.
9397    ///
9398    /// See [`Self::add_scope()`] for details.
9399    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectClearOrgPolicyCall<'a, C>
9400    where
9401        I: IntoIterator<Item = St>,
9402        St: AsRef<str>,
9403    {
9404        self._scopes
9405            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9406        self
9407    }
9408
9409    /// Removes all scopes, and no default scope will be used either.
9410    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9411    /// for details).
9412    pub fn clear_scopes(mut self) -> ProjectClearOrgPolicyCall<'a, C> {
9413        self._scopes.clear();
9414        self
9415    }
9416}
9417
9418/// Request that a new Project be created. The result is an Operation which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking Operation is automatically deleted after a few hours, so there is no need to call DeleteOperation. Authorization requires the Google IAM permission `resourcemanager.projects.create` on the specified parent for the new project. The parent is identified by a specified ResourceId, which must include both an ID and a type, such as organization. This method does not associate the new project with a billing account. You can set or update the billing account associated with a project using the \[`projects.updateBillingInfo`\] (/billing/reference/rest/v1/projects/updateBillingInfo) method.
9419///
9420/// A builder for the *create* method supported by a *project* resource.
9421/// It is not used directly, but through a [`ProjectMethods`] instance.
9422///
9423/// # Example
9424///
9425/// Instantiate a resource method builder
9426///
9427/// ```test_harness,no_run
9428/// # extern crate hyper;
9429/// # extern crate hyper_rustls;
9430/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
9431/// use cloudresourcemanager1::api::Project;
9432/// # async fn dox() {
9433/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9434///
9435/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9436/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9437/// #     secret,
9438/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9439/// # ).build().await.unwrap();
9440///
9441/// # let client = hyper_util::client::legacy::Client::builder(
9442/// #     hyper_util::rt::TokioExecutor::new()
9443/// # )
9444/// # .build(
9445/// #     hyper_rustls::HttpsConnectorBuilder::new()
9446/// #         .with_native_roots()
9447/// #         .unwrap()
9448/// #         .https_or_http()
9449/// #         .enable_http1()
9450/// #         .build()
9451/// # );
9452/// # let mut hub = CloudResourceManager::new(client, auth);
9453/// // As the method needs a request, you would usually fill it with the desired information
9454/// // into the respective structure. Some of the parts shown here might not be applicable !
9455/// // Values shown here are possibly random and not representative !
9456/// let mut req = Project::default();
9457///
9458/// // You can configure optional parameters by calling the respective setters at will, and
9459/// // execute the final call using `doit()`.
9460/// // Values shown here are possibly random and not representative !
9461/// let result = hub.projects().create(req)
9462///              .doit().await;
9463/// # }
9464/// ```
9465pub struct ProjectCreateCall<'a, C>
9466where
9467    C: 'a,
9468{
9469    hub: &'a CloudResourceManager<C>,
9470    _request: Project,
9471    _delegate: Option<&'a mut dyn common::Delegate>,
9472    _additional_params: HashMap<String, String>,
9473    _scopes: BTreeSet<String>,
9474}
9475
9476impl<'a, C> common::CallBuilder for ProjectCreateCall<'a, C> {}
9477
9478impl<'a, C> ProjectCreateCall<'a, C>
9479where
9480    C: common::Connector,
9481{
9482    /// Perform the operation you have build so far.
9483    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9484        use std::borrow::Cow;
9485        use std::io::{Read, Seek};
9486
9487        use common::{url::Params, ToParts};
9488        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9489
9490        let mut dd = common::DefaultDelegate;
9491        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9492        dlg.begin(common::MethodInfo {
9493            id: "cloudresourcemanager.projects.create",
9494            http_method: hyper::Method::POST,
9495        });
9496
9497        for &field in ["alt"].iter() {
9498            if self._additional_params.contains_key(field) {
9499                dlg.finished(false);
9500                return Err(common::Error::FieldClash(field));
9501            }
9502        }
9503
9504        let mut params = Params::with_capacity(3 + self._additional_params.len());
9505
9506        params.extend(self._additional_params.iter());
9507
9508        params.push("alt", "json");
9509        let mut url = self.hub._base_url.clone() + "v1/projects";
9510        if self._scopes.is_empty() {
9511            self._scopes
9512                .insert(Scope::CloudPlatform.as_ref().to_string());
9513        }
9514
9515        let url = params.parse_with_url(&url);
9516
9517        let mut json_mime_type = mime::APPLICATION_JSON;
9518        let mut request_value_reader = {
9519            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9520            common::remove_json_null_values(&mut value);
9521            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9522            serde_json::to_writer(&mut dst, &value).unwrap();
9523            dst
9524        };
9525        let request_size = request_value_reader
9526            .seek(std::io::SeekFrom::End(0))
9527            .unwrap();
9528        request_value_reader
9529            .seek(std::io::SeekFrom::Start(0))
9530            .unwrap();
9531
9532        loop {
9533            let token = match self
9534                .hub
9535                .auth
9536                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9537                .await
9538            {
9539                Ok(token) => token,
9540                Err(e) => match dlg.token(e) {
9541                    Ok(token) => token,
9542                    Err(e) => {
9543                        dlg.finished(false);
9544                        return Err(common::Error::MissingToken(e));
9545                    }
9546                },
9547            };
9548            request_value_reader
9549                .seek(std::io::SeekFrom::Start(0))
9550                .unwrap();
9551            let mut req_result = {
9552                let client = &self.hub.client;
9553                dlg.pre_request();
9554                let mut req_builder = hyper::Request::builder()
9555                    .method(hyper::Method::POST)
9556                    .uri(url.as_str())
9557                    .header(USER_AGENT, self.hub._user_agent.clone());
9558
9559                if let Some(token) = token.as_ref() {
9560                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9561                }
9562
9563                let request = req_builder
9564                    .header(CONTENT_TYPE, json_mime_type.to_string())
9565                    .header(CONTENT_LENGTH, request_size as u64)
9566                    .body(common::to_body(
9567                        request_value_reader.get_ref().clone().into(),
9568                    ));
9569
9570                client.request(request.unwrap()).await
9571            };
9572
9573            match req_result {
9574                Err(err) => {
9575                    if let common::Retry::After(d) = dlg.http_error(&err) {
9576                        sleep(d).await;
9577                        continue;
9578                    }
9579                    dlg.finished(false);
9580                    return Err(common::Error::HttpError(err));
9581                }
9582                Ok(res) => {
9583                    let (mut parts, body) = res.into_parts();
9584                    let mut body = common::Body::new(body);
9585                    if !parts.status.is_success() {
9586                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9587                        let error = serde_json::from_str(&common::to_string(&bytes));
9588                        let response = common::to_response(parts, bytes.into());
9589
9590                        if let common::Retry::After(d) =
9591                            dlg.http_failure(&response, error.as_ref().ok())
9592                        {
9593                            sleep(d).await;
9594                            continue;
9595                        }
9596
9597                        dlg.finished(false);
9598
9599                        return Err(match error {
9600                            Ok(value) => common::Error::BadRequest(value),
9601                            _ => common::Error::Failure(response),
9602                        });
9603                    }
9604                    let response = {
9605                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9606                        let encoded = common::to_string(&bytes);
9607                        match serde_json::from_str(&encoded) {
9608                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9609                            Err(error) => {
9610                                dlg.response_json_decode_error(&encoded, &error);
9611                                return Err(common::Error::JsonDecodeError(
9612                                    encoded.to_string(),
9613                                    error,
9614                                ));
9615                            }
9616                        }
9617                    };
9618
9619                    dlg.finished(true);
9620                    return Ok(response);
9621                }
9622            }
9623        }
9624    }
9625
9626    ///
9627    /// Sets the *request* property to the given value.
9628    ///
9629    /// Even though the property as already been set when instantiating this call,
9630    /// we provide this method for API completeness.
9631    pub fn request(mut self, new_value: Project) -> ProjectCreateCall<'a, C> {
9632        self._request = new_value;
9633        self
9634    }
9635    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9636    /// while executing the actual API request.
9637    ///
9638    /// ````text
9639    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9640    /// ````
9641    ///
9642    /// Sets the *delegate* property to the given value.
9643    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectCreateCall<'a, C> {
9644        self._delegate = Some(new_value);
9645        self
9646    }
9647
9648    /// Set any additional parameter of the query string used in the request.
9649    /// It should be used to set parameters which are not yet available through their own
9650    /// setters.
9651    ///
9652    /// Please note that this method must not be used to set any of the known parameters
9653    /// which have their own setter method. If done anyway, the request will fail.
9654    ///
9655    /// # Additional Parameters
9656    ///
9657    /// * *$.xgafv* (query-string) - V1 error format.
9658    /// * *access_token* (query-string) - OAuth access token.
9659    /// * *alt* (query-string) - Data format for response.
9660    /// * *callback* (query-string) - JSONP
9661    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9662    /// * *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.
9663    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9664    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9665    /// * *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.
9666    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9667    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9668    pub fn param<T>(mut self, name: T, value: T) -> ProjectCreateCall<'a, C>
9669    where
9670        T: AsRef<str>,
9671    {
9672        self._additional_params
9673            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9674        self
9675    }
9676
9677    /// Identifies the authorization scope for the method you are building.
9678    ///
9679    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9680    /// [`Scope::CloudPlatform`].
9681    ///
9682    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9683    /// tokens for more than one scope.
9684    ///
9685    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9686    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9687    /// sufficient, a read-write scope will do as well.
9688    pub fn add_scope<St>(mut self, scope: St) -> ProjectCreateCall<'a, C>
9689    where
9690        St: AsRef<str>,
9691    {
9692        self._scopes.insert(String::from(scope.as_ref()));
9693        self
9694    }
9695    /// Identifies the authorization scope(s) for the method you are building.
9696    ///
9697    /// See [`Self::add_scope()`] for details.
9698    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectCreateCall<'a, C>
9699    where
9700        I: IntoIterator<Item = St>,
9701        St: AsRef<str>,
9702    {
9703        self._scopes
9704            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9705        self
9706    }
9707
9708    /// Removes all scopes, and no default scope will be used either.
9709    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9710    /// for details).
9711    pub fn clear_scopes(mut self) -> ProjectCreateCall<'a, C> {
9712        self._scopes.clear();
9713        self
9714    }
9715}
9716
9717/// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if it has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have delete permissions for this Project.
9718///
9719/// A builder for the *delete* method supported by a *project* resource.
9720/// It is not used directly, but through a [`ProjectMethods`] instance.
9721///
9722/// # Example
9723///
9724/// Instantiate a resource method builder
9725///
9726/// ```test_harness,no_run
9727/// # extern crate hyper;
9728/// # extern crate hyper_rustls;
9729/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
9730/// # async fn dox() {
9731/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9732///
9733/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9734/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9735/// #     secret,
9736/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9737/// # ).build().await.unwrap();
9738///
9739/// # let client = hyper_util::client::legacy::Client::builder(
9740/// #     hyper_util::rt::TokioExecutor::new()
9741/// # )
9742/// # .build(
9743/// #     hyper_rustls::HttpsConnectorBuilder::new()
9744/// #         .with_native_roots()
9745/// #         .unwrap()
9746/// #         .https_or_http()
9747/// #         .enable_http1()
9748/// #         .build()
9749/// # );
9750/// # let mut hub = CloudResourceManager::new(client, auth);
9751/// // You can configure optional parameters by calling the respective setters at will, and
9752/// // execute the final call using `doit()`.
9753/// // Values shown here are possibly random and not representative !
9754/// let result = hub.projects().delete("projectId")
9755///              .doit().await;
9756/// # }
9757/// ```
9758pub struct ProjectDeleteCall<'a, C>
9759where
9760    C: 'a,
9761{
9762    hub: &'a CloudResourceManager<C>,
9763    _project_id: String,
9764    _delegate: Option<&'a mut dyn common::Delegate>,
9765    _additional_params: HashMap<String, String>,
9766    _scopes: BTreeSet<String>,
9767}
9768
9769impl<'a, C> common::CallBuilder for ProjectDeleteCall<'a, C> {}
9770
9771impl<'a, C> ProjectDeleteCall<'a, C>
9772where
9773    C: common::Connector,
9774{
9775    /// Perform the operation you have build so far.
9776    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9777        use std::borrow::Cow;
9778        use std::io::{Read, Seek};
9779
9780        use common::{url::Params, ToParts};
9781        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9782
9783        let mut dd = common::DefaultDelegate;
9784        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9785        dlg.begin(common::MethodInfo {
9786            id: "cloudresourcemanager.projects.delete",
9787            http_method: hyper::Method::DELETE,
9788        });
9789
9790        for &field in ["alt", "projectId"].iter() {
9791            if self._additional_params.contains_key(field) {
9792                dlg.finished(false);
9793                return Err(common::Error::FieldClash(field));
9794            }
9795        }
9796
9797        let mut params = Params::with_capacity(3 + self._additional_params.len());
9798        params.push("projectId", self._project_id);
9799
9800        params.extend(self._additional_params.iter());
9801
9802        params.push("alt", "json");
9803        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}";
9804        if self._scopes.is_empty() {
9805            self._scopes
9806                .insert(Scope::CloudPlatform.as_ref().to_string());
9807        }
9808
9809        #[allow(clippy::single_element_loop)]
9810        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
9811            url = params.uri_replacement(url, param_name, find_this, false);
9812        }
9813        {
9814            let to_remove = ["projectId"];
9815            params.remove_params(&to_remove);
9816        }
9817
9818        let url = params.parse_with_url(&url);
9819
9820        loop {
9821            let token = match self
9822                .hub
9823                .auth
9824                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9825                .await
9826            {
9827                Ok(token) => token,
9828                Err(e) => match dlg.token(e) {
9829                    Ok(token) => token,
9830                    Err(e) => {
9831                        dlg.finished(false);
9832                        return Err(common::Error::MissingToken(e));
9833                    }
9834                },
9835            };
9836            let mut req_result = {
9837                let client = &self.hub.client;
9838                dlg.pre_request();
9839                let mut req_builder = hyper::Request::builder()
9840                    .method(hyper::Method::DELETE)
9841                    .uri(url.as_str())
9842                    .header(USER_AGENT, self.hub._user_agent.clone());
9843
9844                if let Some(token) = token.as_ref() {
9845                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9846                }
9847
9848                let request = req_builder
9849                    .header(CONTENT_LENGTH, 0_u64)
9850                    .body(common::to_body::<String>(None));
9851
9852                client.request(request.unwrap()).await
9853            };
9854
9855            match req_result {
9856                Err(err) => {
9857                    if let common::Retry::After(d) = dlg.http_error(&err) {
9858                        sleep(d).await;
9859                        continue;
9860                    }
9861                    dlg.finished(false);
9862                    return Err(common::Error::HttpError(err));
9863                }
9864                Ok(res) => {
9865                    let (mut parts, body) = res.into_parts();
9866                    let mut body = common::Body::new(body);
9867                    if !parts.status.is_success() {
9868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9869                        let error = serde_json::from_str(&common::to_string(&bytes));
9870                        let response = common::to_response(parts, bytes.into());
9871
9872                        if let common::Retry::After(d) =
9873                            dlg.http_failure(&response, error.as_ref().ok())
9874                        {
9875                            sleep(d).await;
9876                            continue;
9877                        }
9878
9879                        dlg.finished(false);
9880
9881                        return Err(match error {
9882                            Ok(value) => common::Error::BadRequest(value),
9883                            _ => common::Error::Failure(response),
9884                        });
9885                    }
9886                    let response = {
9887                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9888                        let encoded = common::to_string(&bytes);
9889                        match serde_json::from_str(&encoded) {
9890                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9891                            Err(error) => {
9892                                dlg.response_json_decode_error(&encoded, &error);
9893                                return Err(common::Error::JsonDecodeError(
9894                                    encoded.to_string(),
9895                                    error,
9896                                ));
9897                            }
9898                        }
9899                    };
9900
9901                    dlg.finished(true);
9902                    return Ok(response);
9903                }
9904            }
9905        }
9906    }
9907
9908    /// The Project ID (for example, `foo-bar-123`). Required.
9909    ///
9910    /// Sets the *project id* path property to the given value.
9911    ///
9912    /// Even though the property as already been set when instantiating this call,
9913    /// we provide this method for API completeness.
9914    pub fn project_id(mut self, new_value: &str) -> ProjectDeleteCall<'a, C> {
9915        self._project_id = new_value.to_string();
9916        self
9917    }
9918    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9919    /// while executing the actual API request.
9920    ///
9921    /// ````text
9922    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9923    /// ````
9924    ///
9925    /// Sets the *delegate* property to the given value.
9926    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectDeleteCall<'a, C> {
9927        self._delegate = Some(new_value);
9928        self
9929    }
9930
9931    /// Set any additional parameter of the query string used in the request.
9932    /// It should be used to set parameters which are not yet available through their own
9933    /// setters.
9934    ///
9935    /// Please note that this method must not be used to set any of the known parameters
9936    /// which have their own setter method. If done anyway, the request will fail.
9937    ///
9938    /// # Additional Parameters
9939    ///
9940    /// * *$.xgafv* (query-string) - V1 error format.
9941    /// * *access_token* (query-string) - OAuth access token.
9942    /// * *alt* (query-string) - Data format for response.
9943    /// * *callback* (query-string) - JSONP
9944    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9945    /// * *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.
9946    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9947    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9948    /// * *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.
9949    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9950    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9951    pub fn param<T>(mut self, name: T, value: T) -> ProjectDeleteCall<'a, C>
9952    where
9953        T: AsRef<str>,
9954    {
9955        self._additional_params
9956            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9957        self
9958    }
9959
9960    /// Identifies the authorization scope for the method you are building.
9961    ///
9962    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9963    /// [`Scope::CloudPlatform`].
9964    ///
9965    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9966    /// tokens for more than one scope.
9967    ///
9968    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9969    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9970    /// sufficient, a read-write scope will do as well.
9971    pub fn add_scope<St>(mut self, scope: St) -> ProjectDeleteCall<'a, C>
9972    where
9973        St: AsRef<str>,
9974    {
9975        self._scopes.insert(String::from(scope.as_ref()));
9976        self
9977    }
9978    /// Identifies the authorization scope(s) for the method you are building.
9979    ///
9980    /// See [`Self::add_scope()`] for details.
9981    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDeleteCall<'a, C>
9982    where
9983        I: IntoIterator<Item = St>,
9984        St: AsRef<str>,
9985    {
9986        self._scopes
9987            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9988        self
9989    }
9990
9991    /// Removes all scopes, and no default scope will be used either.
9992    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9993    /// for details).
9994    pub fn clear_scopes(mut self) -> ProjectDeleteCall<'a, C> {
9995        self._scopes.clear();
9996        self
9997    }
9998}
9999
10000/// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
10001///
10002/// A builder for the *get* method supported by a *project* resource.
10003/// It is not used directly, but through a [`ProjectMethods`] instance.
10004///
10005/// # Example
10006///
10007/// Instantiate a resource method builder
10008///
10009/// ```test_harness,no_run
10010/// # extern crate hyper;
10011/// # extern crate hyper_rustls;
10012/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10013/// # async fn dox() {
10014/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10015///
10016/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10017/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10018/// #     secret,
10019/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10020/// # ).build().await.unwrap();
10021///
10022/// # let client = hyper_util::client::legacy::Client::builder(
10023/// #     hyper_util::rt::TokioExecutor::new()
10024/// # )
10025/// # .build(
10026/// #     hyper_rustls::HttpsConnectorBuilder::new()
10027/// #         .with_native_roots()
10028/// #         .unwrap()
10029/// #         .https_or_http()
10030/// #         .enable_http1()
10031/// #         .build()
10032/// # );
10033/// # let mut hub = CloudResourceManager::new(client, auth);
10034/// // You can configure optional parameters by calling the respective setters at will, and
10035/// // execute the final call using `doit()`.
10036/// // Values shown here are possibly random and not representative !
10037/// let result = hub.projects().get("projectId")
10038///              .doit().await;
10039/// # }
10040/// ```
10041pub struct ProjectGetCall<'a, C>
10042where
10043    C: 'a,
10044{
10045    hub: &'a CloudResourceManager<C>,
10046    _project_id: String,
10047    _delegate: Option<&'a mut dyn common::Delegate>,
10048    _additional_params: HashMap<String, String>,
10049    _scopes: BTreeSet<String>,
10050}
10051
10052impl<'a, C> common::CallBuilder for ProjectGetCall<'a, C> {}
10053
10054impl<'a, C> ProjectGetCall<'a, C>
10055where
10056    C: common::Connector,
10057{
10058    /// Perform the operation you have build so far.
10059    pub async fn doit(mut self) -> common::Result<(common::Response, Project)> {
10060        use std::borrow::Cow;
10061        use std::io::{Read, Seek};
10062
10063        use common::{url::Params, ToParts};
10064        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10065
10066        let mut dd = common::DefaultDelegate;
10067        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10068        dlg.begin(common::MethodInfo {
10069            id: "cloudresourcemanager.projects.get",
10070            http_method: hyper::Method::GET,
10071        });
10072
10073        for &field in ["alt", "projectId"].iter() {
10074            if self._additional_params.contains_key(field) {
10075                dlg.finished(false);
10076                return Err(common::Error::FieldClash(field));
10077            }
10078        }
10079
10080        let mut params = Params::with_capacity(3 + self._additional_params.len());
10081        params.push("projectId", self._project_id);
10082
10083        params.extend(self._additional_params.iter());
10084
10085        params.push("alt", "json");
10086        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}";
10087        if self._scopes.is_empty() {
10088            self._scopes
10089                .insert(Scope::CloudPlatform.as_ref().to_string());
10090        }
10091
10092        #[allow(clippy::single_element_loop)]
10093        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
10094            url = params.uri_replacement(url, param_name, find_this, false);
10095        }
10096        {
10097            let to_remove = ["projectId"];
10098            params.remove_params(&to_remove);
10099        }
10100
10101        let url = params.parse_with_url(&url);
10102
10103        loop {
10104            let token = match self
10105                .hub
10106                .auth
10107                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10108                .await
10109            {
10110                Ok(token) => token,
10111                Err(e) => match dlg.token(e) {
10112                    Ok(token) => token,
10113                    Err(e) => {
10114                        dlg.finished(false);
10115                        return Err(common::Error::MissingToken(e));
10116                    }
10117                },
10118            };
10119            let mut req_result = {
10120                let client = &self.hub.client;
10121                dlg.pre_request();
10122                let mut req_builder = hyper::Request::builder()
10123                    .method(hyper::Method::GET)
10124                    .uri(url.as_str())
10125                    .header(USER_AGENT, self.hub._user_agent.clone());
10126
10127                if let Some(token) = token.as_ref() {
10128                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10129                }
10130
10131                let request = req_builder
10132                    .header(CONTENT_LENGTH, 0_u64)
10133                    .body(common::to_body::<String>(None));
10134
10135                client.request(request.unwrap()).await
10136            };
10137
10138            match req_result {
10139                Err(err) => {
10140                    if let common::Retry::After(d) = dlg.http_error(&err) {
10141                        sleep(d).await;
10142                        continue;
10143                    }
10144                    dlg.finished(false);
10145                    return Err(common::Error::HttpError(err));
10146                }
10147                Ok(res) => {
10148                    let (mut parts, body) = res.into_parts();
10149                    let mut body = common::Body::new(body);
10150                    if !parts.status.is_success() {
10151                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10152                        let error = serde_json::from_str(&common::to_string(&bytes));
10153                        let response = common::to_response(parts, bytes.into());
10154
10155                        if let common::Retry::After(d) =
10156                            dlg.http_failure(&response, error.as_ref().ok())
10157                        {
10158                            sleep(d).await;
10159                            continue;
10160                        }
10161
10162                        dlg.finished(false);
10163
10164                        return Err(match error {
10165                            Ok(value) => common::Error::BadRequest(value),
10166                            _ => common::Error::Failure(response),
10167                        });
10168                    }
10169                    let response = {
10170                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10171                        let encoded = common::to_string(&bytes);
10172                        match serde_json::from_str(&encoded) {
10173                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10174                            Err(error) => {
10175                                dlg.response_json_decode_error(&encoded, &error);
10176                                return Err(common::Error::JsonDecodeError(
10177                                    encoded.to_string(),
10178                                    error,
10179                                ));
10180                            }
10181                        }
10182                    };
10183
10184                    dlg.finished(true);
10185                    return Ok(response);
10186                }
10187            }
10188        }
10189    }
10190
10191    /// Required. The Project ID (for example, `my-project-123`).
10192    ///
10193    /// Sets the *project id* path property to the given value.
10194    ///
10195    /// Even though the property as already been set when instantiating this call,
10196    /// we provide this method for API completeness.
10197    pub fn project_id(mut self, new_value: &str) -> ProjectGetCall<'a, C> {
10198        self._project_id = new_value.to_string();
10199        self
10200    }
10201    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10202    /// while executing the actual API request.
10203    ///
10204    /// ````text
10205    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10206    /// ````
10207    ///
10208    /// Sets the *delegate* property to the given value.
10209    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectGetCall<'a, C> {
10210        self._delegate = Some(new_value);
10211        self
10212    }
10213
10214    /// Set any additional parameter of the query string used in the request.
10215    /// It should be used to set parameters which are not yet available through their own
10216    /// setters.
10217    ///
10218    /// Please note that this method must not be used to set any of the known parameters
10219    /// which have their own setter method. If done anyway, the request will fail.
10220    ///
10221    /// # Additional Parameters
10222    ///
10223    /// * *$.xgafv* (query-string) - V1 error format.
10224    /// * *access_token* (query-string) - OAuth access token.
10225    /// * *alt* (query-string) - Data format for response.
10226    /// * *callback* (query-string) - JSONP
10227    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10228    /// * *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.
10229    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10230    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10231    /// * *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.
10232    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10233    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10234    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetCall<'a, C>
10235    where
10236        T: AsRef<str>,
10237    {
10238        self._additional_params
10239            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10240        self
10241    }
10242
10243    /// Identifies the authorization scope for the method you are building.
10244    ///
10245    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10246    /// [`Scope::CloudPlatform`].
10247    ///
10248    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10249    /// tokens for more than one scope.
10250    ///
10251    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10252    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10253    /// sufficient, a read-write scope will do as well.
10254    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetCall<'a, C>
10255    where
10256        St: AsRef<str>,
10257    {
10258        self._scopes.insert(String::from(scope.as_ref()));
10259        self
10260    }
10261    /// Identifies the authorization scope(s) for the method you are building.
10262    ///
10263    /// See [`Self::add_scope()`] for details.
10264    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetCall<'a, C>
10265    where
10266        I: IntoIterator<Item = St>,
10267        St: AsRef<str>,
10268    {
10269        self._scopes
10270            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10271        self
10272    }
10273
10274    /// Removes all scopes, and no default scope will be used either.
10275    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10276    /// for details).
10277    pub fn clear_scopes(mut self) -> ProjectGetCall<'a, C> {
10278        self._scopes.clear();
10279        self
10280    }
10281}
10282
10283/// Gets a list of ancestors in the resource hierarchy for the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
10284///
10285/// A builder for the *getAncestry* method supported by a *project* resource.
10286/// It is not used directly, but through a [`ProjectMethods`] instance.
10287///
10288/// # Example
10289///
10290/// Instantiate a resource method builder
10291///
10292/// ```test_harness,no_run
10293/// # extern crate hyper;
10294/// # extern crate hyper_rustls;
10295/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10296/// use cloudresourcemanager1::api::GetAncestryRequest;
10297/// # async fn dox() {
10298/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10299///
10300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10302/// #     secret,
10303/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10304/// # ).build().await.unwrap();
10305///
10306/// # let client = hyper_util::client::legacy::Client::builder(
10307/// #     hyper_util::rt::TokioExecutor::new()
10308/// # )
10309/// # .build(
10310/// #     hyper_rustls::HttpsConnectorBuilder::new()
10311/// #         .with_native_roots()
10312/// #         .unwrap()
10313/// #         .https_or_http()
10314/// #         .enable_http1()
10315/// #         .build()
10316/// # );
10317/// # let mut hub = CloudResourceManager::new(client, auth);
10318/// // As the method needs a request, you would usually fill it with the desired information
10319/// // into the respective structure. Some of the parts shown here might not be applicable !
10320/// // Values shown here are possibly random and not representative !
10321/// let mut req = GetAncestryRequest::default();
10322///
10323/// // You can configure optional parameters by calling the respective setters at will, and
10324/// // execute the final call using `doit()`.
10325/// // Values shown here are possibly random and not representative !
10326/// let result = hub.projects().get_ancestry(req, "projectId")
10327///              .doit().await;
10328/// # }
10329/// ```
10330pub struct ProjectGetAncestryCall<'a, C>
10331where
10332    C: 'a,
10333{
10334    hub: &'a CloudResourceManager<C>,
10335    _request: GetAncestryRequest,
10336    _project_id: String,
10337    _delegate: Option<&'a mut dyn common::Delegate>,
10338    _additional_params: HashMap<String, String>,
10339    _scopes: BTreeSet<String>,
10340}
10341
10342impl<'a, C> common::CallBuilder for ProjectGetAncestryCall<'a, C> {}
10343
10344impl<'a, C> ProjectGetAncestryCall<'a, C>
10345where
10346    C: common::Connector,
10347{
10348    /// Perform the operation you have build so far.
10349    pub async fn doit(mut self) -> common::Result<(common::Response, GetAncestryResponse)> {
10350        use std::borrow::Cow;
10351        use std::io::{Read, Seek};
10352
10353        use common::{url::Params, ToParts};
10354        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10355
10356        let mut dd = common::DefaultDelegate;
10357        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10358        dlg.begin(common::MethodInfo {
10359            id: "cloudresourcemanager.projects.getAncestry",
10360            http_method: hyper::Method::POST,
10361        });
10362
10363        for &field in ["alt", "projectId"].iter() {
10364            if self._additional_params.contains_key(field) {
10365                dlg.finished(false);
10366                return Err(common::Error::FieldClash(field));
10367            }
10368        }
10369
10370        let mut params = Params::with_capacity(4 + self._additional_params.len());
10371        params.push("projectId", self._project_id);
10372
10373        params.extend(self._additional_params.iter());
10374
10375        params.push("alt", "json");
10376        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:getAncestry";
10377        if self._scopes.is_empty() {
10378            self._scopes
10379                .insert(Scope::CloudPlatform.as_ref().to_string());
10380        }
10381
10382        #[allow(clippy::single_element_loop)]
10383        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
10384            url = params.uri_replacement(url, param_name, find_this, false);
10385        }
10386        {
10387            let to_remove = ["projectId"];
10388            params.remove_params(&to_remove);
10389        }
10390
10391        let url = params.parse_with_url(&url);
10392
10393        let mut json_mime_type = mime::APPLICATION_JSON;
10394        let mut request_value_reader = {
10395            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10396            common::remove_json_null_values(&mut value);
10397            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10398            serde_json::to_writer(&mut dst, &value).unwrap();
10399            dst
10400        };
10401        let request_size = request_value_reader
10402            .seek(std::io::SeekFrom::End(0))
10403            .unwrap();
10404        request_value_reader
10405            .seek(std::io::SeekFrom::Start(0))
10406            .unwrap();
10407
10408        loop {
10409            let token = match self
10410                .hub
10411                .auth
10412                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10413                .await
10414            {
10415                Ok(token) => token,
10416                Err(e) => match dlg.token(e) {
10417                    Ok(token) => token,
10418                    Err(e) => {
10419                        dlg.finished(false);
10420                        return Err(common::Error::MissingToken(e));
10421                    }
10422                },
10423            };
10424            request_value_reader
10425                .seek(std::io::SeekFrom::Start(0))
10426                .unwrap();
10427            let mut req_result = {
10428                let client = &self.hub.client;
10429                dlg.pre_request();
10430                let mut req_builder = hyper::Request::builder()
10431                    .method(hyper::Method::POST)
10432                    .uri(url.as_str())
10433                    .header(USER_AGENT, self.hub._user_agent.clone());
10434
10435                if let Some(token) = token.as_ref() {
10436                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10437                }
10438
10439                let request = req_builder
10440                    .header(CONTENT_TYPE, json_mime_type.to_string())
10441                    .header(CONTENT_LENGTH, request_size as u64)
10442                    .body(common::to_body(
10443                        request_value_reader.get_ref().clone().into(),
10444                    ));
10445
10446                client.request(request.unwrap()).await
10447            };
10448
10449            match req_result {
10450                Err(err) => {
10451                    if let common::Retry::After(d) = dlg.http_error(&err) {
10452                        sleep(d).await;
10453                        continue;
10454                    }
10455                    dlg.finished(false);
10456                    return Err(common::Error::HttpError(err));
10457                }
10458                Ok(res) => {
10459                    let (mut parts, body) = res.into_parts();
10460                    let mut body = common::Body::new(body);
10461                    if !parts.status.is_success() {
10462                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10463                        let error = serde_json::from_str(&common::to_string(&bytes));
10464                        let response = common::to_response(parts, bytes.into());
10465
10466                        if let common::Retry::After(d) =
10467                            dlg.http_failure(&response, error.as_ref().ok())
10468                        {
10469                            sleep(d).await;
10470                            continue;
10471                        }
10472
10473                        dlg.finished(false);
10474
10475                        return Err(match error {
10476                            Ok(value) => common::Error::BadRequest(value),
10477                            _ => common::Error::Failure(response),
10478                        });
10479                    }
10480                    let response = {
10481                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10482                        let encoded = common::to_string(&bytes);
10483                        match serde_json::from_str(&encoded) {
10484                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10485                            Err(error) => {
10486                                dlg.response_json_decode_error(&encoded, &error);
10487                                return Err(common::Error::JsonDecodeError(
10488                                    encoded.to_string(),
10489                                    error,
10490                                ));
10491                            }
10492                        }
10493                    };
10494
10495                    dlg.finished(true);
10496                    return Ok(response);
10497                }
10498            }
10499        }
10500    }
10501
10502    ///
10503    /// Sets the *request* property to the given value.
10504    ///
10505    /// Even though the property as already been set when instantiating this call,
10506    /// we provide this method for API completeness.
10507    pub fn request(mut self, new_value: GetAncestryRequest) -> ProjectGetAncestryCall<'a, C> {
10508        self._request = new_value;
10509        self
10510    }
10511    /// Required. The Project ID (for example, `my-project-123`).
10512    ///
10513    /// Sets the *project id* path property to the given value.
10514    ///
10515    /// Even though the property as already been set when instantiating this call,
10516    /// we provide this method for API completeness.
10517    pub fn project_id(mut self, new_value: &str) -> ProjectGetAncestryCall<'a, C> {
10518        self._project_id = new_value.to_string();
10519        self
10520    }
10521    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10522    /// while executing the actual API request.
10523    ///
10524    /// ````text
10525    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10526    /// ````
10527    ///
10528    /// Sets the *delegate* property to the given value.
10529    pub fn delegate(
10530        mut self,
10531        new_value: &'a mut dyn common::Delegate,
10532    ) -> ProjectGetAncestryCall<'a, C> {
10533        self._delegate = Some(new_value);
10534        self
10535    }
10536
10537    /// Set any additional parameter of the query string used in the request.
10538    /// It should be used to set parameters which are not yet available through their own
10539    /// setters.
10540    ///
10541    /// Please note that this method must not be used to set any of the known parameters
10542    /// which have their own setter method. If done anyway, the request will fail.
10543    ///
10544    /// # Additional Parameters
10545    ///
10546    /// * *$.xgafv* (query-string) - V1 error format.
10547    /// * *access_token* (query-string) - OAuth access token.
10548    /// * *alt* (query-string) - Data format for response.
10549    /// * *callback* (query-string) - JSONP
10550    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10551    /// * *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.
10552    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10553    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10554    /// * *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.
10555    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10556    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10557    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetAncestryCall<'a, C>
10558    where
10559        T: AsRef<str>,
10560    {
10561        self._additional_params
10562            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10563        self
10564    }
10565
10566    /// Identifies the authorization scope for the method you are building.
10567    ///
10568    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10569    /// [`Scope::CloudPlatform`].
10570    ///
10571    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10572    /// tokens for more than one scope.
10573    ///
10574    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10575    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10576    /// sufficient, a read-write scope will do as well.
10577    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetAncestryCall<'a, C>
10578    where
10579        St: AsRef<str>,
10580    {
10581        self._scopes.insert(String::from(scope.as_ref()));
10582        self
10583    }
10584    /// Identifies the authorization scope(s) for the method you are building.
10585    ///
10586    /// See [`Self::add_scope()`] for details.
10587    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetAncestryCall<'a, C>
10588    where
10589        I: IntoIterator<Item = St>,
10590        St: AsRef<str>,
10591    {
10592        self._scopes
10593            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10594        self
10595    }
10596
10597    /// Removes all scopes, and no default scope will be used either.
10598    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10599    /// for details).
10600    pub fn clear_scopes(mut self) -> ProjectGetAncestryCall<'a, C> {
10601        self._scopes.clear();
10602        self
10603    }
10604}
10605
10606/// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
10607///
10608/// A builder for the *getEffectiveOrgPolicy* method supported by a *project* resource.
10609/// It is not used directly, but through a [`ProjectMethods`] instance.
10610///
10611/// # Example
10612///
10613/// Instantiate a resource method builder
10614///
10615/// ```test_harness,no_run
10616/// # extern crate hyper;
10617/// # extern crate hyper_rustls;
10618/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10619/// use cloudresourcemanager1::api::GetEffectiveOrgPolicyRequest;
10620/// # async fn dox() {
10621/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10622///
10623/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10625/// #     secret,
10626/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10627/// # ).build().await.unwrap();
10628///
10629/// # let client = hyper_util::client::legacy::Client::builder(
10630/// #     hyper_util::rt::TokioExecutor::new()
10631/// # )
10632/// # .build(
10633/// #     hyper_rustls::HttpsConnectorBuilder::new()
10634/// #         .with_native_roots()
10635/// #         .unwrap()
10636/// #         .https_or_http()
10637/// #         .enable_http1()
10638/// #         .build()
10639/// # );
10640/// # let mut hub = CloudResourceManager::new(client, auth);
10641/// // As the method needs a request, you would usually fill it with the desired information
10642/// // into the respective structure. Some of the parts shown here might not be applicable !
10643/// // Values shown here are possibly random and not representative !
10644/// let mut req = GetEffectiveOrgPolicyRequest::default();
10645///
10646/// // You can configure optional parameters by calling the respective setters at will, and
10647/// // execute the final call using `doit()`.
10648/// // Values shown here are possibly random and not representative !
10649/// let result = hub.projects().get_effective_org_policy(req, "resource")
10650///              .doit().await;
10651/// # }
10652/// ```
10653pub struct ProjectGetEffectiveOrgPolicyCall<'a, C>
10654where
10655    C: 'a,
10656{
10657    hub: &'a CloudResourceManager<C>,
10658    _request: GetEffectiveOrgPolicyRequest,
10659    _resource: String,
10660    _delegate: Option<&'a mut dyn common::Delegate>,
10661    _additional_params: HashMap<String, String>,
10662    _scopes: BTreeSet<String>,
10663}
10664
10665impl<'a, C> common::CallBuilder for ProjectGetEffectiveOrgPolicyCall<'a, C> {}
10666
10667impl<'a, C> ProjectGetEffectiveOrgPolicyCall<'a, C>
10668where
10669    C: common::Connector,
10670{
10671    /// Perform the operation you have build so far.
10672    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
10673        use std::borrow::Cow;
10674        use std::io::{Read, Seek};
10675
10676        use common::{url::Params, ToParts};
10677        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10678
10679        let mut dd = common::DefaultDelegate;
10680        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10681        dlg.begin(common::MethodInfo {
10682            id: "cloudresourcemanager.projects.getEffectiveOrgPolicy",
10683            http_method: hyper::Method::POST,
10684        });
10685
10686        for &field in ["alt", "resource"].iter() {
10687            if self._additional_params.contains_key(field) {
10688                dlg.finished(false);
10689                return Err(common::Error::FieldClash(field));
10690            }
10691        }
10692
10693        let mut params = Params::with_capacity(4 + self._additional_params.len());
10694        params.push("resource", self._resource);
10695
10696        params.extend(self._additional_params.iter());
10697
10698        params.push("alt", "json");
10699        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getEffectiveOrgPolicy";
10700        if self._scopes.is_empty() {
10701            self._scopes
10702                .insert(Scope::CloudPlatform.as_ref().to_string());
10703        }
10704
10705        #[allow(clippy::single_element_loop)]
10706        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10707            url = params.uri_replacement(url, param_name, find_this, true);
10708        }
10709        {
10710            let to_remove = ["resource"];
10711            params.remove_params(&to_remove);
10712        }
10713
10714        let url = params.parse_with_url(&url);
10715
10716        let mut json_mime_type = mime::APPLICATION_JSON;
10717        let mut request_value_reader = {
10718            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10719            common::remove_json_null_values(&mut value);
10720            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10721            serde_json::to_writer(&mut dst, &value).unwrap();
10722            dst
10723        };
10724        let request_size = request_value_reader
10725            .seek(std::io::SeekFrom::End(0))
10726            .unwrap();
10727        request_value_reader
10728            .seek(std::io::SeekFrom::Start(0))
10729            .unwrap();
10730
10731        loop {
10732            let token = match self
10733                .hub
10734                .auth
10735                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10736                .await
10737            {
10738                Ok(token) => token,
10739                Err(e) => match dlg.token(e) {
10740                    Ok(token) => token,
10741                    Err(e) => {
10742                        dlg.finished(false);
10743                        return Err(common::Error::MissingToken(e));
10744                    }
10745                },
10746            };
10747            request_value_reader
10748                .seek(std::io::SeekFrom::Start(0))
10749                .unwrap();
10750            let mut req_result = {
10751                let client = &self.hub.client;
10752                dlg.pre_request();
10753                let mut req_builder = hyper::Request::builder()
10754                    .method(hyper::Method::POST)
10755                    .uri(url.as_str())
10756                    .header(USER_AGENT, self.hub._user_agent.clone());
10757
10758                if let Some(token) = token.as_ref() {
10759                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10760                }
10761
10762                let request = req_builder
10763                    .header(CONTENT_TYPE, json_mime_type.to_string())
10764                    .header(CONTENT_LENGTH, request_size as u64)
10765                    .body(common::to_body(
10766                        request_value_reader.get_ref().clone().into(),
10767                    ));
10768
10769                client.request(request.unwrap()).await
10770            };
10771
10772            match req_result {
10773                Err(err) => {
10774                    if let common::Retry::After(d) = dlg.http_error(&err) {
10775                        sleep(d).await;
10776                        continue;
10777                    }
10778                    dlg.finished(false);
10779                    return Err(common::Error::HttpError(err));
10780                }
10781                Ok(res) => {
10782                    let (mut parts, body) = res.into_parts();
10783                    let mut body = common::Body::new(body);
10784                    if !parts.status.is_success() {
10785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10786                        let error = serde_json::from_str(&common::to_string(&bytes));
10787                        let response = common::to_response(parts, bytes.into());
10788
10789                        if let common::Retry::After(d) =
10790                            dlg.http_failure(&response, error.as_ref().ok())
10791                        {
10792                            sleep(d).await;
10793                            continue;
10794                        }
10795
10796                        dlg.finished(false);
10797
10798                        return Err(match error {
10799                            Ok(value) => common::Error::BadRequest(value),
10800                            _ => common::Error::Failure(response),
10801                        });
10802                    }
10803                    let response = {
10804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10805                        let encoded = common::to_string(&bytes);
10806                        match serde_json::from_str(&encoded) {
10807                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10808                            Err(error) => {
10809                                dlg.response_json_decode_error(&encoded, &error);
10810                                return Err(common::Error::JsonDecodeError(
10811                                    encoded.to_string(),
10812                                    error,
10813                                ));
10814                            }
10815                        }
10816                    };
10817
10818                    dlg.finished(true);
10819                    return Ok(response);
10820                }
10821            }
10822        }
10823    }
10824
10825    ///
10826    /// Sets the *request* property to the given value.
10827    ///
10828    /// Even though the property as already been set when instantiating this call,
10829    /// we provide this method for API completeness.
10830    pub fn request(
10831        mut self,
10832        new_value: GetEffectiveOrgPolicyRequest,
10833    ) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
10834        self._request = new_value;
10835        self
10836    }
10837    /// The name of the resource to start computing the effective `Policy`.
10838    ///
10839    /// Sets the *resource* path property to the given value.
10840    ///
10841    /// Even though the property as already been set when instantiating this call,
10842    /// we provide this method for API completeness.
10843    pub fn resource(mut self, new_value: &str) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
10844        self._resource = new_value.to_string();
10845        self
10846    }
10847    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10848    /// while executing the actual API request.
10849    ///
10850    /// ````text
10851    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10852    /// ````
10853    ///
10854    /// Sets the *delegate* property to the given value.
10855    pub fn delegate(
10856        mut self,
10857        new_value: &'a mut dyn common::Delegate,
10858    ) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
10859        self._delegate = Some(new_value);
10860        self
10861    }
10862
10863    /// Set any additional parameter of the query string used in the request.
10864    /// It should be used to set parameters which are not yet available through their own
10865    /// setters.
10866    ///
10867    /// Please note that this method must not be used to set any of the known parameters
10868    /// which have their own setter method. If done anyway, the request will fail.
10869    ///
10870    /// # Additional Parameters
10871    ///
10872    /// * *$.xgafv* (query-string) - V1 error format.
10873    /// * *access_token* (query-string) - OAuth access token.
10874    /// * *alt* (query-string) - Data format for response.
10875    /// * *callback* (query-string) - JSONP
10876    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10877    /// * *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.
10878    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10879    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10880    /// * *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.
10881    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10882    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10883    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetEffectiveOrgPolicyCall<'a, C>
10884    where
10885        T: AsRef<str>,
10886    {
10887        self._additional_params
10888            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10889        self
10890    }
10891
10892    /// Identifies the authorization scope for the method you are building.
10893    ///
10894    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10895    /// [`Scope::CloudPlatform`].
10896    ///
10897    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10898    /// tokens for more than one scope.
10899    ///
10900    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10901    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10902    /// sufficient, a read-write scope will do as well.
10903    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetEffectiveOrgPolicyCall<'a, C>
10904    where
10905        St: AsRef<str>,
10906    {
10907        self._scopes.insert(String::from(scope.as_ref()));
10908        self
10909    }
10910    /// Identifies the authorization scope(s) for the method you are building.
10911    ///
10912    /// See [`Self::add_scope()`] for details.
10913    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetEffectiveOrgPolicyCall<'a, C>
10914    where
10915        I: IntoIterator<Item = St>,
10916        St: AsRef<str>,
10917    {
10918        self._scopes
10919            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10920        self
10921    }
10922
10923    /// Removes all scopes, and no default scope will be used either.
10924    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10925    /// for details).
10926    pub fn clear_scopes(mut self) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
10927        self._scopes.clear();
10928        self
10929    }
10930}
10931
10932/// Returns the IAM access control policy for the specified Project. Permission is denied if the policy or the resource does not exist. Authorization requires the Google IAM permission `resourcemanager.projects.getIamPolicy` on the project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names).
10933///
10934/// A builder for the *getIamPolicy* method supported by a *project* resource.
10935/// It is not used directly, but through a [`ProjectMethods`] instance.
10936///
10937/// # Example
10938///
10939/// Instantiate a resource method builder
10940///
10941/// ```test_harness,no_run
10942/// # extern crate hyper;
10943/// # extern crate hyper_rustls;
10944/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10945/// use cloudresourcemanager1::api::GetIamPolicyRequest;
10946/// # async fn dox() {
10947/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10948///
10949/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10950/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10951/// #     secret,
10952/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10953/// # ).build().await.unwrap();
10954///
10955/// # let client = hyper_util::client::legacy::Client::builder(
10956/// #     hyper_util::rt::TokioExecutor::new()
10957/// # )
10958/// # .build(
10959/// #     hyper_rustls::HttpsConnectorBuilder::new()
10960/// #         .with_native_roots()
10961/// #         .unwrap()
10962/// #         .https_or_http()
10963/// #         .enable_http1()
10964/// #         .build()
10965/// # );
10966/// # let mut hub = CloudResourceManager::new(client, auth);
10967/// // As the method needs a request, you would usually fill it with the desired information
10968/// // into the respective structure. Some of the parts shown here might not be applicable !
10969/// // Values shown here are possibly random and not representative !
10970/// let mut req = GetIamPolicyRequest::default();
10971///
10972/// // You can configure optional parameters by calling the respective setters at will, and
10973/// // execute the final call using `doit()`.
10974/// // Values shown here are possibly random and not representative !
10975/// let result = hub.projects().get_iam_policy(req, "resource")
10976///              .doit().await;
10977/// # }
10978/// ```
10979pub struct ProjectGetIamPolicyCall<'a, C>
10980where
10981    C: 'a,
10982{
10983    hub: &'a CloudResourceManager<C>,
10984    _request: GetIamPolicyRequest,
10985    _resource: String,
10986    _delegate: Option<&'a mut dyn common::Delegate>,
10987    _additional_params: HashMap<String, String>,
10988    _scopes: BTreeSet<String>,
10989}
10990
10991impl<'a, C> common::CallBuilder for ProjectGetIamPolicyCall<'a, C> {}
10992
10993impl<'a, C> ProjectGetIamPolicyCall<'a, C>
10994where
10995    C: common::Connector,
10996{
10997    /// Perform the operation you have build so far.
10998    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10999        use std::borrow::Cow;
11000        use std::io::{Read, Seek};
11001
11002        use common::{url::Params, ToParts};
11003        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11004
11005        let mut dd = common::DefaultDelegate;
11006        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11007        dlg.begin(common::MethodInfo {
11008            id: "cloudresourcemanager.projects.getIamPolicy",
11009            http_method: hyper::Method::POST,
11010        });
11011
11012        for &field in ["alt", "resource"].iter() {
11013            if self._additional_params.contains_key(field) {
11014                dlg.finished(false);
11015                return Err(common::Error::FieldClash(field));
11016            }
11017        }
11018
11019        let mut params = Params::with_capacity(4 + self._additional_params.len());
11020        params.push("resource", self._resource);
11021
11022        params.extend(self._additional_params.iter());
11023
11024        params.push("alt", "json");
11025        let mut url = self.hub._base_url.clone() + "v1/projects/{resource}:getIamPolicy";
11026        if self._scopes.is_empty() {
11027            self._scopes
11028                .insert(Scope::CloudPlatform.as_ref().to_string());
11029        }
11030
11031        #[allow(clippy::single_element_loop)]
11032        for &(find_this, param_name) in [("{resource}", "resource")].iter() {
11033            url = params.uri_replacement(url, param_name, find_this, false);
11034        }
11035        {
11036            let to_remove = ["resource"];
11037            params.remove_params(&to_remove);
11038        }
11039
11040        let url = params.parse_with_url(&url);
11041
11042        let mut json_mime_type = mime::APPLICATION_JSON;
11043        let mut request_value_reader = {
11044            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11045            common::remove_json_null_values(&mut value);
11046            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11047            serde_json::to_writer(&mut dst, &value).unwrap();
11048            dst
11049        };
11050        let request_size = request_value_reader
11051            .seek(std::io::SeekFrom::End(0))
11052            .unwrap();
11053        request_value_reader
11054            .seek(std::io::SeekFrom::Start(0))
11055            .unwrap();
11056
11057        loop {
11058            let token = match self
11059                .hub
11060                .auth
11061                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11062                .await
11063            {
11064                Ok(token) => token,
11065                Err(e) => match dlg.token(e) {
11066                    Ok(token) => token,
11067                    Err(e) => {
11068                        dlg.finished(false);
11069                        return Err(common::Error::MissingToken(e));
11070                    }
11071                },
11072            };
11073            request_value_reader
11074                .seek(std::io::SeekFrom::Start(0))
11075                .unwrap();
11076            let mut req_result = {
11077                let client = &self.hub.client;
11078                dlg.pre_request();
11079                let mut req_builder = hyper::Request::builder()
11080                    .method(hyper::Method::POST)
11081                    .uri(url.as_str())
11082                    .header(USER_AGENT, self.hub._user_agent.clone());
11083
11084                if let Some(token) = token.as_ref() {
11085                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11086                }
11087
11088                let request = req_builder
11089                    .header(CONTENT_TYPE, json_mime_type.to_string())
11090                    .header(CONTENT_LENGTH, request_size as u64)
11091                    .body(common::to_body(
11092                        request_value_reader.get_ref().clone().into(),
11093                    ));
11094
11095                client.request(request.unwrap()).await
11096            };
11097
11098            match req_result {
11099                Err(err) => {
11100                    if let common::Retry::After(d) = dlg.http_error(&err) {
11101                        sleep(d).await;
11102                        continue;
11103                    }
11104                    dlg.finished(false);
11105                    return Err(common::Error::HttpError(err));
11106                }
11107                Ok(res) => {
11108                    let (mut parts, body) = res.into_parts();
11109                    let mut body = common::Body::new(body);
11110                    if !parts.status.is_success() {
11111                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11112                        let error = serde_json::from_str(&common::to_string(&bytes));
11113                        let response = common::to_response(parts, bytes.into());
11114
11115                        if let common::Retry::After(d) =
11116                            dlg.http_failure(&response, error.as_ref().ok())
11117                        {
11118                            sleep(d).await;
11119                            continue;
11120                        }
11121
11122                        dlg.finished(false);
11123
11124                        return Err(match error {
11125                            Ok(value) => common::Error::BadRequest(value),
11126                            _ => common::Error::Failure(response),
11127                        });
11128                    }
11129                    let response = {
11130                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11131                        let encoded = common::to_string(&bytes);
11132                        match serde_json::from_str(&encoded) {
11133                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11134                            Err(error) => {
11135                                dlg.response_json_decode_error(&encoded, &error);
11136                                return Err(common::Error::JsonDecodeError(
11137                                    encoded.to_string(),
11138                                    error,
11139                                ));
11140                            }
11141                        }
11142                    };
11143
11144                    dlg.finished(true);
11145                    return Ok(response);
11146                }
11147            }
11148        }
11149    }
11150
11151    ///
11152    /// Sets the *request* property to the given value.
11153    ///
11154    /// Even though the property as already been set when instantiating this call,
11155    /// we provide this method for API completeness.
11156    pub fn request(mut self, new_value: GetIamPolicyRequest) -> ProjectGetIamPolicyCall<'a, C> {
11157        self._request = new_value;
11158        self
11159    }
11160    /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
11161    ///
11162    /// Sets the *resource* path property to the given value.
11163    ///
11164    /// Even though the property as already been set when instantiating this call,
11165    /// we provide this method for API completeness.
11166    pub fn resource(mut self, new_value: &str) -> ProjectGetIamPolicyCall<'a, C> {
11167        self._resource = new_value.to_string();
11168        self
11169    }
11170    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11171    /// while executing the actual API request.
11172    ///
11173    /// ````text
11174    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11175    /// ````
11176    ///
11177    /// Sets the *delegate* property to the given value.
11178    pub fn delegate(
11179        mut self,
11180        new_value: &'a mut dyn common::Delegate,
11181    ) -> ProjectGetIamPolicyCall<'a, C> {
11182        self._delegate = Some(new_value);
11183        self
11184    }
11185
11186    /// Set any additional parameter of the query string used in the request.
11187    /// It should be used to set parameters which are not yet available through their own
11188    /// setters.
11189    ///
11190    /// Please note that this method must not be used to set any of the known parameters
11191    /// which have their own setter method. If done anyway, the request will fail.
11192    ///
11193    /// # Additional Parameters
11194    ///
11195    /// * *$.xgafv* (query-string) - V1 error format.
11196    /// * *access_token* (query-string) - OAuth access token.
11197    /// * *alt* (query-string) - Data format for response.
11198    /// * *callback* (query-string) - JSONP
11199    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11200    /// * *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.
11201    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11202    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11203    /// * *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.
11204    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11205    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11206    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetIamPolicyCall<'a, C>
11207    where
11208        T: AsRef<str>,
11209    {
11210        self._additional_params
11211            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11212        self
11213    }
11214
11215    /// Identifies the authorization scope for the method you are building.
11216    ///
11217    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11218    /// [`Scope::CloudPlatform`].
11219    ///
11220    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11221    /// tokens for more than one scope.
11222    ///
11223    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11224    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11225    /// sufficient, a read-write scope will do as well.
11226    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetIamPolicyCall<'a, C>
11227    where
11228        St: AsRef<str>,
11229    {
11230        self._scopes.insert(String::from(scope.as_ref()));
11231        self
11232    }
11233    /// Identifies the authorization scope(s) for the method you are building.
11234    ///
11235    /// See [`Self::add_scope()`] for details.
11236    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetIamPolicyCall<'a, C>
11237    where
11238        I: IntoIterator<Item = St>,
11239        St: AsRef<str>,
11240    {
11241        self._scopes
11242            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11243        self
11244    }
11245
11246    /// Removes all scopes, and no default scope will be used either.
11247    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11248    /// for details).
11249    pub fn clear_scopes(mut self) -> ProjectGetIamPolicyCall<'a, C> {
11250        self._scopes.clear();
11251        self
11252    }
11253}
11254
11255/// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
11256///
11257/// A builder for the *getOrgPolicy* method supported by a *project* resource.
11258/// It is not used directly, but through a [`ProjectMethods`] instance.
11259///
11260/// # Example
11261///
11262/// Instantiate a resource method builder
11263///
11264/// ```test_harness,no_run
11265/// # extern crate hyper;
11266/// # extern crate hyper_rustls;
11267/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
11268/// use cloudresourcemanager1::api::GetOrgPolicyRequest;
11269/// # async fn dox() {
11270/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11271///
11272/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11273/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11274/// #     secret,
11275/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11276/// # ).build().await.unwrap();
11277///
11278/// # let client = hyper_util::client::legacy::Client::builder(
11279/// #     hyper_util::rt::TokioExecutor::new()
11280/// # )
11281/// # .build(
11282/// #     hyper_rustls::HttpsConnectorBuilder::new()
11283/// #         .with_native_roots()
11284/// #         .unwrap()
11285/// #         .https_or_http()
11286/// #         .enable_http1()
11287/// #         .build()
11288/// # );
11289/// # let mut hub = CloudResourceManager::new(client, auth);
11290/// // As the method needs a request, you would usually fill it with the desired information
11291/// // into the respective structure. Some of the parts shown here might not be applicable !
11292/// // Values shown here are possibly random and not representative !
11293/// let mut req = GetOrgPolicyRequest::default();
11294///
11295/// // You can configure optional parameters by calling the respective setters at will, and
11296/// // execute the final call using `doit()`.
11297/// // Values shown here are possibly random and not representative !
11298/// let result = hub.projects().get_org_policy(req, "resource")
11299///              .doit().await;
11300/// # }
11301/// ```
11302pub struct ProjectGetOrgPolicyCall<'a, C>
11303where
11304    C: 'a,
11305{
11306    hub: &'a CloudResourceManager<C>,
11307    _request: GetOrgPolicyRequest,
11308    _resource: String,
11309    _delegate: Option<&'a mut dyn common::Delegate>,
11310    _additional_params: HashMap<String, String>,
11311    _scopes: BTreeSet<String>,
11312}
11313
11314impl<'a, C> common::CallBuilder for ProjectGetOrgPolicyCall<'a, C> {}
11315
11316impl<'a, C> ProjectGetOrgPolicyCall<'a, C>
11317where
11318    C: common::Connector,
11319{
11320    /// Perform the operation you have build so far.
11321    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
11322        use std::borrow::Cow;
11323        use std::io::{Read, Seek};
11324
11325        use common::{url::Params, ToParts};
11326        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11327
11328        let mut dd = common::DefaultDelegate;
11329        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11330        dlg.begin(common::MethodInfo {
11331            id: "cloudresourcemanager.projects.getOrgPolicy",
11332            http_method: hyper::Method::POST,
11333        });
11334
11335        for &field in ["alt", "resource"].iter() {
11336            if self._additional_params.contains_key(field) {
11337                dlg.finished(false);
11338                return Err(common::Error::FieldClash(field));
11339            }
11340        }
11341
11342        let mut params = Params::with_capacity(4 + self._additional_params.len());
11343        params.push("resource", self._resource);
11344
11345        params.extend(self._additional_params.iter());
11346
11347        params.push("alt", "json");
11348        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getOrgPolicy";
11349        if self._scopes.is_empty() {
11350            self._scopes
11351                .insert(Scope::CloudPlatform.as_ref().to_string());
11352        }
11353
11354        #[allow(clippy::single_element_loop)]
11355        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11356            url = params.uri_replacement(url, param_name, find_this, true);
11357        }
11358        {
11359            let to_remove = ["resource"];
11360            params.remove_params(&to_remove);
11361        }
11362
11363        let url = params.parse_with_url(&url);
11364
11365        let mut json_mime_type = mime::APPLICATION_JSON;
11366        let mut request_value_reader = {
11367            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11368            common::remove_json_null_values(&mut value);
11369            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11370            serde_json::to_writer(&mut dst, &value).unwrap();
11371            dst
11372        };
11373        let request_size = request_value_reader
11374            .seek(std::io::SeekFrom::End(0))
11375            .unwrap();
11376        request_value_reader
11377            .seek(std::io::SeekFrom::Start(0))
11378            .unwrap();
11379
11380        loop {
11381            let token = match self
11382                .hub
11383                .auth
11384                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11385                .await
11386            {
11387                Ok(token) => token,
11388                Err(e) => match dlg.token(e) {
11389                    Ok(token) => token,
11390                    Err(e) => {
11391                        dlg.finished(false);
11392                        return Err(common::Error::MissingToken(e));
11393                    }
11394                },
11395            };
11396            request_value_reader
11397                .seek(std::io::SeekFrom::Start(0))
11398                .unwrap();
11399            let mut req_result = {
11400                let client = &self.hub.client;
11401                dlg.pre_request();
11402                let mut req_builder = hyper::Request::builder()
11403                    .method(hyper::Method::POST)
11404                    .uri(url.as_str())
11405                    .header(USER_AGENT, self.hub._user_agent.clone());
11406
11407                if let Some(token) = token.as_ref() {
11408                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11409                }
11410
11411                let request = req_builder
11412                    .header(CONTENT_TYPE, json_mime_type.to_string())
11413                    .header(CONTENT_LENGTH, request_size as u64)
11414                    .body(common::to_body(
11415                        request_value_reader.get_ref().clone().into(),
11416                    ));
11417
11418                client.request(request.unwrap()).await
11419            };
11420
11421            match req_result {
11422                Err(err) => {
11423                    if let common::Retry::After(d) = dlg.http_error(&err) {
11424                        sleep(d).await;
11425                        continue;
11426                    }
11427                    dlg.finished(false);
11428                    return Err(common::Error::HttpError(err));
11429                }
11430                Ok(res) => {
11431                    let (mut parts, body) = res.into_parts();
11432                    let mut body = common::Body::new(body);
11433                    if !parts.status.is_success() {
11434                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11435                        let error = serde_json::from_str(&common::to_string(&bytes));
11436                        let response = common::to_response(parts, bytes.into());
11437
11438                        if let common::Retry::After(d) =
11439                            dlg.http_failure(&response, error.as_ref().ok())
11440                        {
11441                            sleep(d).await;
11442                            continue;
11443                        }
11444
11445                        dlg.finished(false);
11446
11447                        return Err(match error {
11448                            Ok(value) => common::Error::BadRequest(value),
11449                            _ => common::Error::Failure(response),
11450                        });
11451                    }
11452                    let response = {
11453                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11454                        let encoded = common::to_string(&bytes);
11455                        match serde_json::from_str(&encoded) {
11456                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11457                            Err(error) => {
11458                                dlg.response_json_decode_error(&encoded, &error);
11459                                return Err(common::Error::JsonDecodeError(
11460                                    encoded.to_string(),
11461                                    error,
11462                                ));
11463                            }
11464                        }
11465                    };
11466
11467                    dlg.finished(true);
11468                    return Ok(response);
11469                }
11470            }
11471        }
11472    }
11473
11474    ///
11475    /// Sets the *request* property to the given value.
11476    ///
11477    /// Even though the property as already been set when instantiating this call,
11478    /// we provide this method for API completeness.
11479    pub fn request(mut self, new_value: GetOrgPolicyRequest) -> ProjectGetOrgPolicyCall<'a, C> {
11480        self._request = new_value;
11481        self
11482    }
11483    /// Name of the resource the `Policy` is set on.
11484    ///
11485    /// Sets the *resource* path property to the given value.
11486    ///
11487    /// Even though the property as already been set when instantiating this call,
11488    /// we provide this method for API completeness.
11489    pub fn resource(mut self, new_value: &str) -> ProjectGetOrgPolicyCall<'a, C> {
11490        self._resource = new_value.to_string();
11491        self
11492    }
11493    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11494    /// while executing the actual API request.
11495    ///
11496    /// ````text
11497    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11498    /// ````
11499    ///
11500    /// Sets the *delegate* property to the given value.
11501    pub fn delegate(
11502        mut self,
11503        new_value: &'a mut dyn common::Delegate,
11504    ) -> ProjectGetOrgPolicyCall<'a, C> {
11505        self._delegate = Some(new_value);
11506        self
11507    }
11508
11509    /// Set any additional parameter of the query string used in the request.
11510    /// It should be used to set parameters which are not yet available through their own
11511    /// setters.
11512    ///
11513    /// Please note that this method must not be used to set any of the known parameters
11514    /// which have their own setter method. If done anyway, the request will fail.
11515    ///
11516    /// # Additional Parameters
11517    ///
11518    /// * *$.xgafv* (query-string) - V1 error format.
11519    /// * *access_token* (query-string) - OAuth access token.
11520    /// * *alt* (query-string) - Data format for response.
11521    /// * *callback* (query-string) - JSONP
11522    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11523    /// * *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.
11524    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11525    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11526    /// * *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.
11527    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11528    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11529    pub fn param<T>(mut self, name: T, value: T) -> ProjectGetOrgPolicyCall<'a, C>
11530    where
11531        T: AsRef<str>,
11532    {
11533        self._additional_params
11534            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11535        self
11536    }
11537
11538    /// Identifies the authorization scope for the method you are building.
11539    ///
11540    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11541    /// [`Scope::CloudPlatform`].
11542    ///
11543    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11544    /// tokens for more than one scope.
11545    ///
11546    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11547    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11548    /// sufficient, a read-write scope will do as well.
11549    pub fn add_scope<St>(mut self, scope: St) -> ProjectGetOrgPolicyCall<'a, C>
11550    where
11551        St: AsRef<str>,
11552    {
11553        self._scopes.insert(String::from(scope.as_ref()));
11554        self
11555    }
11556    /// Identifies the authorization scope(s) for the method you are building.
11557    ///
11558    /// See [`Self::add_scope()`] for details.
11559    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetOrgPolicyCall<'a, C>
11560    where
11561        I: IntoIterator<Item = St>,
11562        St: AsRef<str>,
11563    {
11564        self._scopes
11565            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11566        self
11567    }
11568
11569    /// Removes all scopes, and no default scope will be used either.
11570    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11571    /// for details).
11572    pub fn clear_scopes(mut self) -> ProjectGetOrgPolicyCall<'a, C> {
11573        self._scopes.clear();
11574        self
11575    }
11576}
11577
11578/// Lists Projects that the caller has the `resourcemanager.projects.get` permission on and satisfy the specified filter. This method returns Projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the GetProject method. NOTE: If the request filter contains a `parent.type` and `parent.id` and the caller has the `resourcemanager.projects.list` permission on the parent, the results will be drawn from an alternate index which provides more consistent results. In future versions of this API, this List method will be split into List and Search to properly capture the behavioral difference.
11579///
11580/// A builder for the *list* method supported by a *project* resource.
11581/// It is not used directly, but through a [`ProjectMethods`] instance.
11582///
11583/// # Example
11584///
11585/// Instantiate a resource method builder
11586///
11587/// ```test_harness,no_run
11588/// # extern crate hyper;
11589/// # extern crate hyper_rustls;
11590/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
11591/// # async fn dox() {
11592/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11593///
11594/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11595/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11596/// #     secret,
11597/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11598/// # ).build().await.unwrap();
11599///
11600/// # let client = hyper_util::client::legacy::Client::builder(
11601/// #     hyper_util::rt::TokioExecutor::new()
11602/// # )
11603/// # .build(
11604/// #     hyper_rustls::HttpsConnectorBuilder::new()
11605/// #         .with_native_roots()
11606/// #         .unwrap()
11607/// #         .https_or_http()
11608/// #         .enable_http1()
11609/// #         .build()
11610/// # );
11611/// # let mut hub = CloudResourceManager::new(client, auth);
11612/// // You can configure optional parameters by calling the respective setters at will, and
11613/// // execute the final call using `doit()`.
11614/// // Values shown here are possibly random and not representative !
11615/// let result = hub.projects().list()
11616///              .page_token("sed")
11617///              .page_size(-70)
11618///              .filter("sed")
11619///              .doit().await;
11620/// # }
11621/// ```
11622pub struct ProjectListCall<'a, C>
11623where
11624    C: 'a,
11625{
11626    hub: &'a CloudResourceManager<C>,
11627    _page_token: Option<String>,
11628    _page_size: Option<i32>,
11629    _filter: Option<String>,
11630    _delegate: Option<&'a mut dyn common::Delegate>,
11631    _additional_params: HashMap<String, String>,
11632    _scopes: BTreeSet<String>,
11633}
11634
11635impl<'a, C> common::CallBuilder for ProjectListCall<'a, C> {}
11636
11637impl<'a, C> ProjectListCall<'a, C>
11638where
11639    C: common::Connector,
11640{
11641    /// Perform the operation you have build so far.
11642    pub async fn doit(mut self) -> common::Result<(common::Response, ListProjectsResponse)> {
11643        use std::borrow::Cow;
11644        use std::io::{Read, Seek};
11645
11646        use common::{url::Params, ToParts};
11647        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11648
11649        let mut dd = common::DefaultDelegate;
11650        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11651        dlg.begin(common::MethodInfo {
11652            id: "cloudresourcemanager.projects.list",
11653            http_method: hyper::Method::GET,
11654        });
11655
11656        for &field in ["alt", "pageToken", "pageSize", "filter"].iter() {
11657            if self._additional_params.contains_key(field) {
11658                dlg.finished(false);
11659                return Err(common::Error::FieldClash(field));
11660            }
11661        }
11662
11663        let mut params = Params::with_capacity(5 + self._additional_params.len());
11664        if let Some(value) = self._page_token.as_ref() {
11665            params.push("pageToken", value);
11666        }
11667        if let Some(value) = self._page_size.as_ref() {
11668            params.push("pageSize", value.to_string());
11669        }
11670        if let Some(value) = self._filter.as_ref() {
11671            params.push("filter", value);
11672        }
11673
11674        params.extend(self._additional_params.iter());
11675
11676        params.push("alt", "json");
11677        let mut url = self.hub._base_url.clone() + "v1/projects";
11678        if self._scopes.is_empty() {
11679            self._scopes
11680                .insert(Scope::CloudPlatform.as_ref().to_string());
11681        }
11682
11683        let url = params.parse_with_url(&url);
11684
11685        loop {
11686            let token = match self
11687                .hub
11688                .auth
11689                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11690                .await
11691            {
11692                Ok(token) => token,
11693                Err(e) => match dlg.token(e) {
11694                    Ok(token) => token,
11695                    Err(e) => {
11696                        dlg.finished(false);
11697                        return Err(common::Error::MissingToken(e));
11698                    }
11699                },
11700            };
11701            let mut req_result = {
11702                let client = &self.hub.client;
11703                dlg.pre_request();
11704                let mut req_builder = hyper::Request::builder()
11705                    .method(hyper::Method::GET)
11706                    .uri(url.as_str())
11707                    .header(USER_AGENT, self.hub._user_agent.clone());
11708
11709                if let Some(token) = token.as_ref() {
11710                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11711                }
11712
11713                let request = req_builder
11714                    .header(CONTENT_LENGTH, 0_u64)
11715                    .body(common::to_body::<String>(None));
11716
11717                client.request(request.unwrap()).await
11718            };
11719
11720            match req_result {
11721                Err(err) => {
11722                    if let common::Retry::After(d) = dlg.http_error(&err) {
11723                        sleep(d).await;
11724                        continue;
11725                    }
11726                    dlg.finished(false);
11727                    return Err(common::Error::HttpError(err));
11728                }
11729                Ok(res) => {
11730                    let (mut parts, body) = res.into_parts();
11731                    let mut body = common::Body::new(body);
11732                    if !parts.status.is_success() {
11733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11734                        let error = serde_json::from_str(&common::to_string(&bytes));
11735                        let response = common::to_response(parts, bytes.into());
11736
11737                        if let common::Retry::After(d) =
11738                            dlg.http_failure(&response, error.as_ref().ok())
11739                        {
11740                            sleep(d).await;
11741                            continue;
11742                        }
11743
11744                        dlg.finished(false);
11745
11746                        return Err(match error {
11747                            Ok(value) => common::Error::BadRequest(value),
11748                            _ => common::Error::Failure(response),
11749                        });
11750                    }
11751                    let response = {
11752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11753                        let encoded = common::to_string(&bytes);
11754                        match serde_json::from_str(&encoded) {
11755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11756                            Err(error) => {
11757                                dlg.response_json_decode_error(&encoded, &error);
11758                                return Err(common::Error::JsonDecodeError(
11759                                    encoded.to_string(),
11760                                    error,
11761                                ));
11762                            }
11763                        }
11764                    };
11765
11766                    dlg.finished(true);
11767                    return Ok(response);
11768                }
11769            }
11770        }
11771    }
11772
11773    /// Optional. A pagination token returned from a previous call to ListProjects that indicates from where listing should continue.
11774    ///
11775    /// Sets the *page token* query property to the given value.
11776    pub fn page_token(mut self, new_value: &str) -> ProjectListCall<'a, C> {
11777        self._page_token = Some(new_value.to_string());
11778        self
11779    }
11780    /// Optional. The maximum number of Projects to return in the response. The server can return fewer Projects than requested. If unspecified, server picks an appropriate default.
11781    ///
11782    /// Sets the *page size* query property to the given value.
11783    pub fn page_size(mut self, new_value: i32) -> ProjectListCall<'a, C> {
11784        self._page_size = Some(new_value);
11785        self
11786    }
11787    /// Optional. An expression for filtering the results of the request. Filter rules are case insensitive. If multiple fields are included in a filter query, the query will return results that match any of the fields. Some eligible fields for filtering are: + `name` + `id` + `labels.` (where *key* is the name of a label) + `parent.type` + `parent.id` + `lifecycleState` Some examples of filter queries: | Query | Description | |------------------|-----------------------------------------------------| | name:how* | The project's name starts with "how". | | name:Howl | The project's name is `Howl` or `howl`. | | name:HOWL | Equivalent to above. | | NAME:howl | Equivalent to above. | | labels.color:* | The project has the label `color`. | | labels.color:red | The project's label `color` has the value `red`. | | labels.color:red labels.size:big | The project's label `color` has the value `red` or its label `size` has the value `big`. | | lifecycleState:DELETE_REQUESTED | Only show projects that are pending deletion.| If no filter is specified, the call will return projects for which the user has the `resourcemanager.projects.get` permission. NOTE: To perform a by-parent query (eg., what projects are directly in a Folder), the caller must have the `resourcemanager.projects.list` permission on the parent and the filter must contain both a `parent.type` and a `parent.id` restriction (example: "parent.type:folder parent.id:123"). In this case an alternate search index is used which provides more consistent results.
11788    ///
11789    /// Sets the *filter* query property to the given value.
11790    pub fn filter(mut self, new_value: &str) -> ProjectListCall<'a, C> {
11791        self._filter = Some(new_value.to_string());
11792        self
11793    }
11794    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11795    /// while executing the actual API request.
11796    ///
11797    /// ````text
11798    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11799    /// ````
11800    ///
11801    /// Sets the *delegate* property to the given value.
11802    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectListCall<'a, C> {
11803        self._delegate = Some(new_value);
11804        self
11805    }
11806
11807    /// Set any additional parameter of the query string used in the request.
11808    /// It should be used to set parameters which are not yet available through their own
11809    /// setters.
11810    ///
11811    /// Please note that this method must not be used to set any of the known parameters
11812    /// which have their own setter method. If done anyway, the request will fail.
11813    ///
11814    /// # Additional Parameters
11815    ///
11816    /// * *$.xgafv* (query-string) - V1 error format.
11817    /// * *access_token* (query-string) - OAuth access token.
11818    /// * *alt* (query-string) - Data format for response.
11819    /// * *callback* (query-string) - JSONP
11820    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11821    /// * *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.
11822    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11823    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11824    /// * *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.
11825    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11826    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11827    pub fn param<T>(mut self, name: T, value: T) -> ProjectListCall<'a, C>
11828    where
11829        T: AsRef<str>,
11830    {
11831        self._additional_params
11832            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11833        self
11834    }
11835
11836    /// Identifies the authorization scope for the method you are building.
11837    ///
11838    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11839    /// [`Scope::CloudPlatform`].
11840    ///
11841    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11842    /// tokens for more than one scope.
11843    ///
11844    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11845    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11846    /// sufficient, a read-write scope will do as well.
11847    pub fn add_scope<St>(mut self, scope: St) -> ProjectListCall<'a, C>
11848    where
11849        St: AsRef<str>,
11850    {
11851        self._scopes.insert(String::from(scope.as_ref()));
11852        self
11853    }
11854    /// Identifies the authorization scope(s) for the method you are building.
11855    ///
11856    /// See [`Self::add_scope()`] for details.
11857    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectListCall<'a, C>
11858    where
11859        I: IntoIterator<Item = St>,
11860        St: AsRef<str>,
11861    {
11862        self._scopes
11863            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11864        self
11865    }
11866
11867    /// Removes all scopes, and no default scope will be used either.
11868    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11869    /// for details).
11870    pub fn clear_scopes(mut self) -> ProjectListCall<'a, C> {
11871        self._scopes.clear();
11872        self
11873    }
11874}
11875
11876/// Lists `Constraints` that could be applied on the specified resource.
11877///
11878/// A builder for the *listAvailableOrgPolicyConstraints* method supported by a *project* resource.
11879/// It is not used directly, but through a [`ProjectMethods`] instance.
11880///
11881/// # Example
11882///
11883/// Instantiate a resource method builder
11884///
11885/// ```test_harness,no_run
11886/// # extern crate hyper;
11887/// # extern crate hyper_rustls;
11888/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
11889/// use cloudresourcemanager1::api::ListAvailableOrgPolicyConstraintsRequest;
11890/// # async fn dox() {
11891/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11892///
11893/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11894/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11895/// #     secret,
11896/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11897/// # ).build().await.unwrap();
11898///
11899/// # let client = hyper_util::client::legacy::Client::builder(
11900/// #     hyper_util::rt::TokioExecutor::new()
11901/// # )
11902/// # .build(
11903/// #     hyper_rustls::HttpsConnectorBuilder::new()
11904/// #         .with_native_roots()
11905/// #         .unwrap()
11906/// #         .https_or_http()
11907/// #         .enable_http1()
11908/// #         .build()
11909/// # );
11910/// # let mut hub = CloudResourceManager::new(client, auth);
11911/// // As the method needs a request, you would usually fill it with the desired information
11912/// // into the respective structure. Some of the parts shown here might not be applicable !
11913/// // Values shown here are possibly random and not representative !
11914/// let mut req = ListAvailableOrgPolicyConstraintsRequest::default();
11915///
11916/// // You can configure optional parameters by calling the respective setters at will, and
11917/// // execute the final call using `doit()`.
11918/// // Values shown here are possibly random and not representative !
11919/// let result = hub.projects().list_available_org_policy_constraints(req, "resource")
11920///              .doit().await;
11921/// # }
11922/// ```
11923pub struct ProjectListAvailableOrgPolicyConstraintCall<'a, C>
11924where
11925    C: 'a,
11926{
11927    hub: &'a CloudResourceManager<C>,
11928    _request: ListAvailableOrgPolicyConstraintsRequest,
11929    _resource: String,
11930    _delegate: Option<&'a mut dyn common::Delegate>,
11931    _additional_params: HashMap<String, String>,
11932    _scopes: BTreeSet<String>,
11933}
11934
11935impl<'a, C> common::CallBuilder for ProjectListAvailableOrgPolicyConstraintCall<'a, C> {}
11936
11937impl<'a, C> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
11938where
11939    C: common::Connector,
11940{
11941    /// Perform the operation you have build so far.
11942    pub async fn doit(
11943        mut self,
11944    ) -> common::Result<(common::Response, ListAvailableOrgPolicyConstraintsResponse)> {
11945        use std::borrow::Cow;
11946        use std::io::{Read, Seek};
11947
11948        use common::{url::Params, ToParts};
11949        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11950
11951        let mut dd = common::DefaultDelegate;
11952        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11953        dlg.begin(common::MethodInfo {
11954            id: "cloudresourcemanager.projects.listAvailableOrgPolicyConstraints",
11955            http_method: hyper::Method::POST,
11956        });
11957
11958        for &field in ["alt", "resource"].iter() {
11959            if self._additional_params.contains_key(field) {
11960                dlg.finished(false);
11961                return Err(common::Error::FieldClash(field));
11962            }
11963        }
11964
11965        let mut params = Params::with_capacity(4 + self._additional_params.len());
11966        params.push("resource", self._resource);
11967
11968        params.extend(self._additional_params.iter());
11969
11970        params.push("alt", "json");
11971        let mut url =
11972            self.hub._base_url.clone() + "v1/{+resource}:listAvailableOrgPolicyConstraints";
11973        if self._scopes.is_empty() {
11974            self._scopes
11975                .insert(Scope::CloudPlatform.as_ref().to_string());
11976        }
11977
11978        #[allow(clippy::single_element_loop)]
11979        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11980            url = params.uri_replacement(url, param_name, find_this, true);
11981        }
11982        {
11983            let to_remove = ["resource"];
11984            params.remove_params(&to_remove);
11985        }
11986
11987        let url = params.parse_with_url(&url);
11988
11989        let mut json_mime_type = mime::APPLICATION_JSON;
11990        let mut request_value_reader = {
11991            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11992            common::remove_json_null_values(&mut value);
11993            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11994            serde_json::to_writer(&mut dst, &value).unwrap();
11995            dst
11996        };
11997        let request_size = request_value_reader
11998            .seek(std::io::SeekFrom::End(0))
11999            .unwrap();
12000        request_value_reader
12001            .seek(std::io::SeekFrom::Start(0))
12002            .unwrap();
12003
12004        loop {
12005            let token = match self
12006                .hub
12007                .auth
12008                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12009                .await
12010            {
12011                Ok(token) => token,
12012                Err(e) => match dlg.token(e) {
12013                    Ok(token) => token,
12014                    Err(e) => {
12015                        dlg.finished(false);
12016                        return Err(common::Error::MissingToken(e));
12017                    }
12018                },
12019            };
12020            request_value_reader
12021                .seek(std::io::SeekFrom::Start(0))
12022                .unwrap();
12023            let mut req_result = {
12024                let client = &self.hub.client;
12025                dlg.pre_request();
12026                let mut req_builder = hyper::Request::builder()
12027                    .method(hyper::Method::POST)
12028                    .uri(url.as_str())
12029                    .header(USER_AGENT, self.hub._user_agent.clone());
12030
12031                if let Some(token) = token.as_ref() {
12032                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12033                }
12034
12035                let request = req_builder
12036                    .header(CONTENT_TYPE, json_mime_type.to_string())
12037                    .header(CONTENT_LENGTH, request_size as u64)
12038                    .body(common::to_body(
12039                        request_value_reader.get_ref().clone().into(),
12040                    ));
12041
12042                client.request(request.unwrap()).await
12043            };
12044
12045            match req_result {
12046                Err(err) => {
12047                    if let common::Retry::After(d) = dlg.http_error(&err) {
12048                        sleep(d).await;
12049                        continue;
12050                    }
12051                    dlg.finished(false);
12052                    return Err(common::Error::HttpError(err));
12053                }
12054                Ok(res) => {
12055                    let (mut parts, body) = res.into_parts();
12056                    let mut body = common::Body::new(body);
12057                    if !parts.status.is_success() {
12058                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12059                        let error = serde_json::from_str(&common::to_string(&bytes));
12060                        let response = common::to_response(parts, bytes.into());
12061
12062                        if let common::Retry::After(d) =
12063                            dlg.http_failure(&response, error.as_ref().ok())
12064                        {
12065                            sleep(d).await;
12066                            continue;
12067                        }
12068
12069                        dlg.finished(false);
12070
12071                        return Err(match error {
12072                            Ok(value) => common::Error::BadRequest(value),
12073                            _ => common::Error::Failure(response),
12074                        });
12075                    }
12076                    let response = {
12077                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12078                        let encoded = common::to_string(&bytes);
12079                        match serde_json::from_str(&encoded) {
12080                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12081                            Err(error) => {
12082                                dlg.response_json_decode_error(&encoded, &error);
12083                                return Err(common::Error::JsonDecodeError(
12084                                    encoded.to_string(),
12085                                    error,
12086                                ));
12087                            }
12088                        }
12089                    };
12090
12091                    dlg.finished(true);
12092                    return Ok(response);
12093                }
12094            }
12095        }
12096    }
12097
12098    ///
12099    /// Sets the *request* property to the given value.
12100    ///
12101    /// Even though the property as already been set when instantiating this call,
12102    /// we provide this method for API completeness.
12103    pub fn request(
12104        mut self,
12105        new_value: ListAvailableOrgPolicyConstraintsRequest,
12106    ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12107        self._request = new_value;
12108        self
12109    }
12110    /// Name of the resource to list `Constraints` for.
12111    ///
12112    /// Sets the *resource* path property to the given value.
12113    ///
12114    /// Even though the property as already been set when instantiating this call,
12115    /// we provide this method for API completeness.
12116    pub fn resource(
12117        mut self,
12118        new_value: &str,
12119    ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12120        self._resource = new_value.to_string();
12121        self
12122    }
12123    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12124    /// while executing the actual API request.
12125    ///
12126    /// ````text
12127    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12128    /// ````
12129    ///
12130    /// Sets the *delegate* property to the given value.
12131    pub fn delegate(
12132        mut self,
12133        new_value: &'a mut dyn common::Delegate,
12134    ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12135        self._delegate = Some(new_value);
12136        self
12137    }
12138
12139    /// Set any additional parameter of the query string used in the request.
12140    /// It should be used to set parameters which are not yet available through their own
12141    /// setters.
12142    ///
12143    /// Please note that this method must not be used to set any of the known parameters
12144    /// which have their own setter method. If done anyway, the request will fail.
12145    ///
12146    /// # Additional Parameters
12147    ///
12148    /// * *$.xgafv* (query-string) - V1 error format.
12149    /// * *access_token* (query-string) - OAuth access token.
12150    /// * *alt* (query-string) - Data format for response.
12151    /// * *callback* (query-string) - JSONP
12152    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12153    /// * *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.
12154    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12155    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12156    /// * *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.
12157    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12158    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12159    pub fn param<T>(
12160        mut self,
12161        name: T,
12162        value: T,
12163    ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12164    where
12165        T: AsRef<str>,
12166    {
12167        self._additional_params
12168            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12169        self
12170    }
12171
12172    /// Identifies the authorization scope for the method you are building.
12173    ///
12174    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12175    /// [`Scope::CloudPlatform`].
12176    ///
12177    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12178    /// tokens for more than one scope.
12179    ///
12180    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12181    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12182    /// sufficient, a read-write scope will do as well.
12183    pub fn add_scope<St>(mut self, scope: St) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12184    where
12185        St: AsRef<str>,
12186    {
12187        self._scopes.insert(String::from(scope.as_ref()));
12188        self
12189    }
12190    /// Identifies the authorization scope(s) for the method you are building.
12191    ///
12192    /// See [`Self::add_scope()`] for details.
12193    pub fn add_scopes<I, St>(
12194        mut self,
12195        scopes: I,
12196    ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12197    where
12198        I: IntoIterator<Item = St>,
12199        St: AsRef<str>,
12200    {
12201        self._scopes
12202            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12203        self
12204    }
12205
12206    /// Removes all scopes, and no default scope will be used either.
12207    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12208    /// for details).
12209    pub fn clear_scopes(mut self) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12210        self._scopes.clear();
12211        self
12212    }
12213}
12214
12215/// Lists all the `Policies` set for a particular resource.
12216///
12217/// A builder for the *listOrgPolicies* method supported by a *project* resource.
12218/// It is not used directly, but through a [`ProjectMethods`] instance.
12219///
12220/// # Example
12221///
12222/// Instantiate a resource method builder
12223///
12224/// ```test_harness,no_run
12225/// # extern crate hyper;
12226/// # extern crate hyper_rustls;
12227/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
12228/// use cloudresourcemanager1::api::ListOrgPoliciesRequest;
12229/// # async fn dox() {
12230/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12231///
12232/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12234/// #     secret,
12235/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12236/// # ).build().await.unwrap();
12237///
12238/// # let client = hyper_util::client::legacy::Client::builder(
12239/// #     hyper_util::rt::TokioExecutor::new()
12240/// # )
12241/// # .build(
12242/// #     hyper_rustls::HttpsConnectorBuilder::new()
12243/// #         .with_native_roots()
12244/// #         .unwrap()
12245/// #         .https_or_http()
12246/// #         .enable_http1()
12247/// #         .build()
12248/// # );
12249/// # let mut hub = CloudResourceManager::new(client, auth);
12250/// // As the method needs a request, you would usually fill it with the desired information
12251/// // into the respective structure. Some of the parts shown here might not be applicable !
12252/// // Values shown here are possibly random and not representative !
12253/// let mut req = ListOrgPoliciesRequest::default();
12254///
12255/// // You can configure optional parameters by calling the respective setters at will, and
12256/// // execute the final call using `doit()`.
12257/// // Values shown here are possibly random and not representative !
12258/// let result = hub.projects().list_org_policies(req, "resource")
12259///              .doit().await;
12260/// # }
12261/// ```
12262pub struct ProjectListOrgPolicyCall<'a, C>
12263where
12264    C: 'a,
12265{
12266    hub: &'a CloudResourceManager<C>,
12267    _request: ListOrgPoliciesRequest,
12268    _resource: String,
12269    _delegate: Option<&'a mut dyn common::Delegate>,
12270    _additional_params: HashMap<String, String>,
12271    _scopes: BTreeSet<String>,
12272}
12273
12274impl<'a, C> common::CallBuilder for ProjectListOrgPolicyCall<'a, C> {}
12275
12276impl<'a, C> ProjectListOrgPolicyCall<'a, C>
12277where
12278    C: common::Connector,
12279{
12280    /// Perform the operation you have build so far.
12281    pub async fn doit(mut self) -> common::Result<(common::Response, ListOrgPoliciesResponse)> {
12282        use std::borrow::Cow;
12283        use std::io::{Read, Seek};
12284
12285        use common::{url::Params, ToParts};
12286        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12287
12288        let mut dd = common::DefaultDelegate;
12289        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12290        dlg.begin(common::MethodInfo {
12291            id: "cloudresourcemanager.projects.listOrgPolicies",
12292            http_method: hyper::Method::POST,
12293        });
12294
12295        for &field in ["alt", "resource"].iter() {
12296            if self._additional_params.contains_key(field) {
12297                dlg.finished(false);
12298                return Err(common::Error::FieldClash(field));
12299            }
12300        }
12301
12302        let mut params = Params::with_capacity(4 + self._additional_params.len());
12303        params.push("resource", self._resource);
12304
12305        params.extend(self._additional_params.iter());
12306
12307        params.push("alt", "json");
12308        let mut url = self.hub._base_url.clone() + "v1/{+resource}:listOrgPolicies";
12309        if self._scopes.is_empty() {
12310            self._scopes
12311                .insert(Scope::CloudPlatform.as_ref().to_string());
12312        }
12313
12314        #[allow(clippy::single_element_loop)]
12315        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12316            url = params.uri_replacement(url, param_name, find_this, true);
12317        }
12318        {
12319            let to_remove = ["resource"];
12320            params.remove_params(&to_remove);
12321        }
12322
12323        let url = params.parse_with_url(&url);
12324
12325        let mut json_mime_type = mime::APPLICATION_JSON;
12326        let mut request_value_reader = {
12327            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12328            common::remove_json_null_values(&mut value);
12329            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12330            serde_json::to_writer(&mut dst, &value).unwrap();
12331            dst
12332        };
12333        let request_size = request_value_reader
12334            .seek(std::io::SeekFrom::End(0))
12335            .unwrap();
12336        request_value_reader
12337            .seek(std::io::SeekFrom::Start(0))
12338            .unwrap();
12339
12340        loop {
12341            let token = match self
12342                .hub
12343                .auth
12344                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12345                .await
12346            {
12347                Ok(token) => token,
12348                Err(e) => match dlg.token(e) {
12349                    Ok(token) => token,
12350                    Err(e) => {
12351                        dlg.finished(false);
12352                        return Err(common::Error::MissingToken(e));
12353                    }
12354                },
12355            };
12356            request_value_reader
12357                .seek(std::io::SeekFrom::Start(0))
12358                .unwrap();
12359            let mut req_result = {
12360                let client = &self.hub.client;
12361                dlg.pre_request();
12362                let mut req_builder = hyper::Request::builder()
12363                    .method(hyper::Method::POST)
12364                    .uri(url.as_str())
12365                    .header(USER_AGENT, self.hub._user_agent.clone());
12366
12367                if let Some(token) = token.as_ref() {
12368                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12369                }
12370
12371                let request = req_builder
12372                    .header(CONTENT_TYPE, json_mime_type.to_string())
12373                    .header(CONTENT_LENGTH, request_size as u64)
12374                    .body(common::to_body(
12375                        request_value_reader.get_ref().clone().into(),
12376                    ));
12377
12378                client.request(request.unwrap()).await
12379            };
12380
12381            match req_result {
12382                Err(err) => {
12383                    if let common::Retry::After(d) = dlg.http_error(&err) {
12384                        sleep(d).await;
12385                        continue;
12386                    }
12387                    dlg.finished(false);
12388                    return Err(common::Error::HttpError(err));
12389                }
12390                Ok(res) => {
12391                    let (mut parts, body) = res.into_parts();
12392                    let mut body = common::Body::new(body);
12393                    if !parts.status.is_success() {
12394                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12395                        let error = serde_json::from_str(&common::to_string(&bytes));
12396                        let response = common::to_response(parts, bytes.into());
12397
12398                        if let common::Retry::After(d) =
12399                            dlg.http_failure(&response, error.as_ref().ok())
12400                        {
12401                            sleep(d).await;
12402                            continue;
12403                        }
12404
12405                        dlg.finished(false);
12406
12407                        return Err(match error {
12408                            Ok(value) => common::Error::BadRequest(value),
12409                            _ => common::Error::Failure(response),
12410                        });
12411                    }
12412                    let response = {
12413                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12414                        let encoded = common::to_string(&bytes);
12415                        match serde_json::from_str(&encoded) {
12416                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12417                            Err(error) => {
12418                                dlg.response_json_decode_error(&encoded, &error);
12419                                return Err(common::Error::JsonDecodeError(
12420                                    encoded.to_string(),
12421                                    error,
12422                                ));
12423                            }
12424                        }
12425                    };
12426
12427                    dlg.finished(true);
12428                    return Ok(response);
12429                }
12430            }
12431        }
12432    }
12433
12434    ///
12435    /// Sets the *request* property to the given value.
12436    ///
12437    /// Even though the property as already been set when instantiating this call,
12438    /// we provide this method for API completeness.
12439    pub fn request(mut self, new_value: ListOrgPoliciesRequest) -> ProjectListOrgPolicyCall<'a, C> {
12440        self._request = new_value;
12441        self
12442    }
12443    /// Name of the resource to list Policies for.
12444    ///
12445    /// Sets the *resource* path property to the given value.
12446    ///
12447    /// Even though the property as already been set when instantiating this call,
12448    /// we provide this method for API completeness.
12449    pub fn resource(mut self, new_value: &str) -> ProjectListOrgPolicyCall<'a, C> {
12450        self._resource = new_value.to_string();
12451        self
12452    }
12453    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12454    /// while executing the actual API request.
12455    ///
12456    /// ````text
12457    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12458    /// ````
12459    ///
12460    /// Sets the *delegate* property to the given value.
12461    pub fn delegate(
12462        mut self,
12463        new_value: &'a mut dyn common::Delegate,
12464    ) -> ProjectListOrgPolicyCall<'a, C> {
12465        self._delegate = Some(new_value);
12466        self
12467    }
12468
12469    /// Set any additional parameter of the query string used in the request.
12470    /// It should be used to set parameters which are not yet available through their own
12471    /// setters.
12472    ///
12473    /// Please note that this method must not be used to set any of the known parameters
12474    /// which have their own setter method. If done anyway, the request will fail.
12475    ///
12476    /// # Additional Parameters
12477    ///
12478    /// * *$.xgafv* (query-string) - V1 error format.
12479    /// * *access_token* (query-string) - OAuth access token.
12480    /// * *alt* (query-string) - Data format for response.
12481    /// * *callback* (query-string) - JSONP
12482    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12483    /// * *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.
12484    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12485    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12486    /// * *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.
12487    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12488    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12489    pub fn param<T>(mut self, name: T, value: T) -> ProjectListOrgPolicyCall<'a, C>
12490    where
12491        T: AsRef<str>,
12492    {
12493        self._additional_params
12494            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12495        self
12496    }
12497
12498    /// Identifies the authorization scope for the method you are building.
12499    ///
12500    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12501    /// [`Scope::CloudPlatform`].
12502    ///
12503    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12504    /// tokens for more than one scope.
12505    ///
12506    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12507    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12508    /// sufficient, a read-write scope will do as well.
12509    pub fn add_scope<St>(mut self, scope: St) -> ProjectListOrgPolicyCall<'a, C>
12510    where
12511        St: AsRef<str>,
12512    {
12513        self._scopes.insert(String::from(scope.as_ref()));
12514        self
12515    }
12516    /// Identifies the authorization scope(s) for the method you are building.
12517    ///
12518    /// See [`Self::add_scope()`] for details.
12519    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectListOrgPolicyCall<'a, C>
12520    where
12521        I: IntoIterator<Item = St>,
12522        St: AsRef<str>,
12523    {
12524        self._scopes
12525            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12526        self
12527    }
12528
12529    /// Removes all scopes, and no default scope will be used either.
12530    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12531    /// for details).
12532    pub fn clear_scopes(mut self) -> ProjectListOrgPolicyCall<'a, C> {
12533        self._scopes.clear();
12534        self
12535    }
12536}
12537
12538/// Sets the IAM access control policy for the specified Project. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. NOTE: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + You can only grant ownership of a project to a member by using the Google Cloud console. Inviting a member will deliver an invitation email that they must accept. An invitation email is not generated if you are granting a role other than owner, or if both the member you are inviting and the project are part of your organization. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible. Authorization requires the Google IAM permission `resourcemanager.projects.setIamPolicy` on the project
12539///
12540/// A builder for the *setIamPolicy* method supported by a *project* resource.
12541/// It is not used directly, but through a [`ProjectMethods`] instance.
12542///
12543/// # Example
12544///
12545/// Instantiate a resource method builder
12546///
12547/// ```test_harness,no_run
12548/// # extern crate hyper;
12549/// # extern crate hyper_rustls;
12550/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
12551/// use cloudresourcemanager1::api::SetIamPolicyRequest;
12552/// # async fn dox() {
12553/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12554///
12555/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12556/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12557/// #     secret,
12558/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12559/// # ).build().await.unwrap();
12560///
12561/// # let client = hyper_util::client::legacy::Client::builder(
12562/// #     hyper_util::rt::TokioExecutor::new()
12563/// # )
12564/// # .build(
12565/// #     hyper_rustls::HttpsConnectorBuilder::new()
12566/// #         .with_native_roots()
12567/// #         .unwrap()
12568/// #         .https_or_http()
12569/// #         .enable_http1()
12570/// #         .build()
12571/// # );
12572/// # let mut hub = CloudResourceManager::new(client, auth);
12573/// // As the method needs a request, you would usually fill it with the desired information
12574/// // into the respective structure. Some of the parts shown here might not be applicable !
12575/// // Values shown here are possibly random and not representative !
12576/// let mut req = SetIamPolicyRequest::default();
12577///
12578/// // You can configure optional parameters by calling the respective setters at will, and
12579/// // execute the final call using `doit()`.
12580/// // Values shown here are possibly random and not representative !
12581/// let result = hub.projects().set_iam_policy(req, "resource")
12582///              .doit().await;
12583/// # }
12584/// ```
12585pub struct ProjectSetIamPolicyCall<'a, C>
12586where
12587    C: 'a,
12588{
12589    hub: &'a CloudResourceManager<C>,
12590    _request: SetIamPolicyRequest,
12591    _resource: String,
12592    _delegate: Option<&'a mut dyn common::Delegate>,
12593    _additional_params: HashMap<String, String>,
12594    _scopes: BTreeSet<String>,
12595}
12596
12597impl<'a, C> common::CallBuilder for ProjectSetIamPolicyCall<'a, C> {}
12598
12599impl<'a, C> ProjectSetIamPolicyCall<'a, C>
12600where
12601    C: common::Connector,
12602{
12603    /// Perform the operation you have build so far.
12604    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
12605        use std::borrow::Cow;
12606        use std::io::{Read, Seek};
12607
12608        use common::{url::Params, ToParts};
12609        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12610
12611        let mut dd = common::DefaultDelegate;
12612        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12613        dlg.begin(common::MethodInfo {
12614            id: "cloudresourcemanager.projects.setIamPolicy",
12615            http_method: hyper::Method::POST,
12616        });
12617
12618        for &field in ["alt", "resource"].iter() {
12619            if self._additional_params.contains_key(field) {
12620                dlg.finished(false);
12621                return Err(common::Error::FieldClash(field));
12622            }
12623        }
12624
12625        let mut params = Params::with_capacity(4 + self._additional_params.len());
12626        params.push("resource", self._resource);
12627
12628        params.extend(self._additional_params.iter());
12629
12630        params.push("alt", "json");
12631        let mut url = self.hub._base_url.clone() + "v1/projects/{resource}:setIamPolicy";
12632        if self._scopes.is_empty() {
12633            self._scopes
12634                .insert(Scope::CloudPlatform.as_ref().to_string());
12635        }
12636
12637        #[allow(clippy::single_element_loop)]
12638        for &(find_this, param_name) in [("{resource}", "resource")].iter() {
12639            url = params.uri_replacement(url, param_name, find_this, false);
12640        }
12641        {
12642            let to_remove = ["resource"];
12643            params.remove_params(&to_remove);
12644        }
12645
12646        let url = params.parse_with_url(&url);
12647
12648        let mut json_mime_type = mime::APPLICATION_JSON;
12649        let mut request_value_reader = {
12650            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12651            common::remove_json_null_values(&mut value);
12652            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12653            serde_json::to_writer(&mut dst, &value).unwrap();
12654            dst
12655        };
12656        let request_size = request_value_reader
12657            .seek(std::io::SeekFrom::End(0))
12658            .unwrap();
12659        request_value_reader
12660            .seek(std::io::SeekFrom::Start(0))
12661            .unwrap();
12662
12663        loop {
12664            let token = match self
12665                .hub
12666                .auth
12667                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12668                .await
12669            {
12670                Ok(token) => token,
12671                Err(e) => match dlg.token(e) {
12672                    Ok(token) => token,
12673                    Err(e) => {
12674                        dlg.finished(false);
12675                        return Err(common::Error::MissingToken(e));
12676                    }
12677                },
12678            };
12679            request_value_reader
12680                .seek(std::io::SeekFrom::Start(0))
12681                .unwrap();
12682            let mut req_result = {
12683                let client = &self.hub.client;
12684                dlg.pre_request();
12685                let mut req_builder = hyper::Request::builder()
12686                    .method(hyper::Method::POST)
12687                    .uri(url.as_str())
12688                    .header(USER_AGENT, self.hub._user_agent.clone());
12689
12690                if let Some(token) = token.as_ref() {
12691                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12692                }
12693
12694                let request = req_builder
12695                    .header(CONTENT_TYPE, json_mime_type.to_string())
12696                    .header(CONTENT_LENGTH, request_size as u64)
12697                    .body(common::to_body(
12698                        request_value_reader.get_ref().clone().into(),
12699                    ));
12700
12701                client.request(request.unwrap()).await
12702            };
12703
12704            match req_result {
12705                Err(err) => {
12706                    if let common::Retry::After(d) = dlg.http_error(&err) {
12707                        sleep(d).await;
12708                        continue;
12709                    }
12710                    dlg.finished(false);
12711                    return Err(common::Error::HttpError(err));
12712                }
12713                Ok(res) => {
12714                    let (mut parts, body) = res.into_parts();
12715                    let mut body = common::Body::new(body);
12716                    if !parts.status.is_success() {
12717                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12718                        let error = serde_json::from_str(&common::to_string(&bytes));
12719                        let response = common::to_response(parts, bytes.into());
12720
12721                        if let common::Retry::After(d) =
12722                            dlg.http_failure(&response, error.as_ref().ok())
12723                        {
12724                            sleep(d).await;
12725                            continue;
12726                        }
12727
12728                        dlg.finished(false);
12729
12730                        return Err(match error {
12731                            Ok(value) => common::Error::BadRequest(value),
12732                            _ => common::Error::Failure(response),
12733                        });
12734                    }
12735                    let response = {
12736                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12737                        let encoded = common::to_string(&bytes);
12738                        match serde_json::from_str(&encoded) {
12739                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12740                            Err(error) => {
12741                                dlg.response_json_decode_error(&encoded, &error);
12742                                return Err(common::Error::JsonDecodeError(
12743                                    encoded.to_string(),
12744                                    error,
12745                                ));
12746                            }
12747                        }
12748                    };
12749
12750                    dlg.finished(true);
12751                    return Ok(response);
12752                }
12753            }
12754        }
12755    }
12756
12757    ///
12758    /// Sets the *request* property to the given value.
12759    ///
12760    /// Even though the property as already been set when instantiating this call,
12761    /// we provide this method for API completeness.
12762    pub fn request(mut self, new_value: SetIamPolicyRequest) -> ProjectSetIamPolicyCall<'a, C> {
12763        self._request = new_value;
12764        self
12765    }
12766    /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
12767    ///
12768    /// Sets the *resource* path property to the given value.
12769    ///
12770    /// Even though the property as already been set when instantiating this call,
12771    /// we provide this method for API completeness.
12772    pub fn resource(mut self, new_value: &str) -> ProjectSetIamPolicyCall<'a, C> {
12773        self._resource = new_value.to_string();
12774        self
12775    }
12776    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12777    /// while executing the actual API request.
12778    ///
12779    /// ````text
12780    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12781    /// ````
12782    ///
12783    /// Sets the *delegate* property to the given value.
12784    pub fn delegate(
12785        mut self,
12786        new_value: &'a mut dyn common::Delegate,
12787    ) -> ProjectSetIamPolicyCall<'a, C> {
12788        self._delegate = Some(new_value);
12789        self
12790    }
12791
12792    /// Set any additional parameter of the query string used in the request.
12793    /// It should be used to set parameters which are not yet available through their own
12794    /// setters.
12795    ///
12796    /// Please note that this method must not be used to set any of the known parameters
12797    /// which have their own setter method. If done anyway, the request will fail.
12798    ///
12799    /// # Additional Parameters
12800    ///
12801    /// * *$.xgafv* (query-string) - V1 error format.
12802    /// * *access_token* (query-string) - OAuth access token.
12803    /// * *alt* (query-string) - Data format for response.
12804    /// * *callback* (query-string) - JSONP
12805    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12806    /// * *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.
12807    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12808    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12809    /// * *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.
12810    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12811    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12812    pub fn param<T>(mut self, name: T, value: T) -> ProjectSetIamPolicyCall<'a, C>
12813    where
12814        T: AsRef<str>,
12815    {
12816        self._additional_params
12817            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12818        self
12819    }
12820
12821    /// Identifies the authorization scope for the method you are building.
12822    ///
12823    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12824    /// [`Scope::CloudPlatform`].
12825    ///
12826    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12827    /// tokens for more than one scope.
12828    ///
12829    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12830    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12831    /// sufficient, a read-write scope will do as well.
12832    pub fn add_scope<St>(mut self, scope: St) -> ProjectSetIamPolicyCall<'a, C>
12833    where
12834        St: AsRef<str>,
12835    {
12836        self._scopes.insert(String::from(scope.as_ref()));
12837        self
12838    }
12839    /// Identifies the authorization scope(s) for the method you are building.
12840    ///
12841    /// See [`Self::add_scope()`] for details.
12842    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSetIamPolicyCall<'a, C>
12843    where
12844        I: IntoIterator<Item = St>,
12845        St: AsRef<str>,
12846    {
12847        self._scopes
12848            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12849        self
12850    }
12851
12852    /// Removes all scopes, and no default scope will be used either.
12853    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12854    /// for details).
12855    pub fn clear_scopes(mut self) -> ProjectSetIamPolicyCall<'a, C> {
12856        self._scopes.clear();
12857        self
12858    }
12859}
12860
12861/// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
12862///
12863/// A builder for the *setOrgPolicy* method supported by a *project* resource.
12864/// It is not used directly, but through a [`ProjectMethods`] instance.
12865///
12866/// # Example
12867///
12868/// Instantiate a resource method builder
12869///
12870/// ```test_harness,no_run
12871/// # extern crate hyper;
12872/// # extern crate hyper_rustls;
12873/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
12874/// use cloudresourcemanager1::api::SetOrgPolicyRequest;
12875/// # async fn dox() {
12876/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12877///
12878/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12879/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12880/// #     secret,
12881/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12882/// # ).build().await.unwrap();
12883///
12884/// # let client = hyper_util::client::legacy::Client::builder(
12885/// #     hyper_util::rt::TokioExecutor::new()
12886/// # )
12887/// # .build(
12888/// #     hyper_rustls::HttpsConnectorBuilder::new()
12889/// #         .with_native_roots()
12890/// #         .unwrap()
12891/// #         .https_or_http()
12892/// #         .enable_http1()
12893/// #         .build()
12894/// # );
12895/// # let mut hub = CloudResourceManager::new(client, auth);
12896/// // As the method needs a request, you would usually fill it with the desired information
12897/// // into the respective structure. Some of the parts shown here might not be applicable !
12898/// // Values shown here are possibly random and not representative !
12899/// let mut req = SetOrgPolicyRequest::default();
12900///
12901/// // You can configure optional parameters by calling the respective setters at will, and
12902/// // execute the final call using `doit()`.
12903/// // Values shown here are possibly random and not representative !
12904/// let result = hub.projects().set_org_policy(req, "resource")
12905///              .doit().await;
12906/// # }
12907/// ```
12908pub struct ProjectSetOrgPolicyCall<'a, C>
12909where
12910    C: 'a,
12911{
12912    hub: &'a CloudResourceManager<C>,
12913    _request: SetOrgPolicyRequest,
12914    _resource: String,
12915    _delegate: Option<&'a mut dyn common::Delegate>,
12916    _additional_params: HashMap<String, String>,
12917    _scopes: BTreeSet<String>,
12918}
12919
12920impl<'a, C> common::CallBuilder for ProjectSetOrgPolicyCall<'a, C> {}
12921
12922impl<'a, C> ProjectSetOrgPolicyCall<'a, C>
12923where
12924    C: common::Connector,
12925{
12926    /// Perform the operation you have build so far.
12927    pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
12928        use std::borrow::Cow;
12929        use std::io::{Read, Seek};
12930
12931        use common::{url::Params, ToParts};
12932        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12933
12934        let mut dd = common::DefaultDelegate;
12935        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12936        dlg.begin(common::MethodInfo {
12937            id: "cloudresourcemanager.projects.setOrgPolicy",
12938            http_method: hyper::Method::POST,
12939        });
12940
12941        for &field in ["alt", "resource"].iter() {
12942            if self._additional_params.contains_key(field) {
12943                dlg.finished(false);
12944                return Err(common::Error::FieldClash(field));
12945            }
12946        }
12947
12948        let mut params = Params::with_capacity(4 + self._additional_params.len());
12949        params.push("resource", self._resource);
12950
12951        params.extend(self._additional_params.iter());
12952
12953        params.push("alt", "json");
12954        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setOrgPolicy";
12955        if self._scopes.is_empty() {
12956            self._scopes
12957                .insert(Scope::CloudPlatform.as_ref().to_string());
12958        }
12959
12960        #[allow(clippy::single_element_loop)]
12961        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12962            url = params.uri_replacement(url, param_name, find_this, true);
12963        }
12964        {
12965            let to_remove = ["resource"];
12966            params.remove_params(&to_remove);
12967        }
12968
12969        let url = params.parse_with_url(&url);
12970
12971        let mut json_mime_type = mime::APPLICATION_JSON;
12972        let mut request_value_reader = {
12973            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12974            common::remove_json_null_values(&mut value);
12975            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12976            serde_json::to_writer(&mut dst, &value).unwrap();
12977            dst
12978        };
12979        let request_size = request_value_reader
12980            .seek(std::io::SeekFrom::End(0))
12981            .unwrap();
12982        request_value_reader
12983            .seek(std::io::SeekFrom::Start(0))
12984            .unwrap();
12985
12986        loop {
12987            let token = match self
12988                .hub
12989                .auth
12990                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12991                .await
12992            {
12993                Ok(token) => token,
12994                Err(e) => match dlg.token(e) {
12995                    Ok(token) => token,
12996                    Err(e) => {
12997                        dlg.finished(false);
12998                        return Err(common::Error::MissingToken(e));
12999                    }
13000                },
13001            };
13002            request_value_reader
13003                .seek(std::io::SeekFrom::Start(0))
13004                .unwrap();
13005            let mut req_result = {
13006                let client = &self.hub.client;
13007                dlg.pre_request();
13008                let mut req_builder = hyper::Request::builder()
13009                    .method(hyper::Method::POST)
13010                    .uri(url.as_str())
13011                    .header(USER_AGENT, self.hub._user_agent.clone());
13012
13013                if let Some(token) = token.as_ref() {
13014                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13015                }
13016
13017                let request = req_builder
13018                    .header(CONTENT_TYPE, json_mime_type.to_string())
13019                    .header(CONTENT_LENGTH, request_size as u64)
13020                    .body(common::to_body(
13021                        request_value_reader.get_ref().clone().into(),
13022                    ));
13023
13024                client.request(request.unwrap()).await
13025            };
13026
13027            match req_result {
13028                Err(err) => {
13029                    if let common::Retry::After(d) = dlg.http_error(&err) {
13030                        sleep(d).await;
13031                        continue;
13032                    }
13033                    dlg.finished(false);
13034                    return Err(common::Error::HttpError(err));
13035                }
13036                Ok(res) => {
13037                    let (mut parts, body) = res.into_parts();
13038                    let mut body = common::Body::new(body);
13039                    if !parts.status.is_success() {
13040                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13041                        let error = serde_json::from_str(&common::to_string(&bytes));
13042                        let response = common::to_response(parts, bytes.into());
13043
13044                        if let common::Retry::After(d) =
13045                            dlg.http_failure(&response, error.as_ref().ok())
13046                        {
13047                            sleep(d).await;
13048                            continue;
13049                        }
13050
13051                        dlg.finished(false);
13052
13053                        return Err(match error {
13054                            Ok(value) => common::Error::BadRequest(value),
13055                            _ => common::Error::Failure(response),
13056                        });
13057                    }
13058                    let response = {
13059                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13060                        let encoded = common::to_string(&bytes);
13061                        match serde_json::from_str(&encoded) {
13062                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13063                            Err(error) => {
13064                                dlg.response_json_decode_error(&encoded, &error);
13065                                return Err(common::Error::JsonDecodeError(
13066                                    encoded.to_string(),
13067                                    error,
13068                                ));
13069                            }
13070                        }
13071                    };
13072
13073                    dlg.finished(true);
13074                    return Ok(response);
13075                }
13076            }
13077        }
13078    }
13079
13080    ///
13081    /// Sets the *request* property to the given value.
13082    ///
13083    /// Even though the property as already been set when instantiating this call,
13084    /// we provide this method for API completeness.
13085    pub fn request(mut self, new_value: SetOrgPolicyRequest) -> ProjectSetOrgPolicyCall<'a, C> {
13086        self._request = new_value;
13087        self
13088    }
13089    /// Resource name of the resource to attach the `Policy`.
13090    ///
13091    /// Sets the *resource* path property to the given value.
13092    ///
13093    /// Even though the property as already been set when instantiating this call,
13094    /// we provide this method for API completeness.
13095    pub fn resource(mut self, new_value: &str) -> ProjectSetOrgPolicyCall<'a, C> {
13096        self._resource = new_value.to_string();
13097        self
13098    }
13099    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13100    /// while executing the actual API request.
13101    ///
13102    /// ````text
13103    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13104    /// ````
13105    ///
13106    /// Sets the *delegate* property to the given value.
13107    pub fn delegate(
13108        mut self,
13109        new_value: &'a mut dyn common::Delegate,
13110    ) -> ProjectSetOrgPolicyCall<'a, C> {
13111        self._delegate = Some(new_value);
13112        self
13113    }
13114
13115    /// Set any additional parameter of the query string used in the request.
13116    /// It should be used to set parameters which are not yet available through their own
13117    /// setters.
13118    ///
13119    /// Please note that this method must not be used to set any of the known parameters
13120    /// which have their own setter method. If done anyway, the request will fail.
13121    ///
13122    /// # Additional Parameters
13123    ///
13124    /// * *$.xgafv* (query-string) - V1 error format.
13125    /// * *access_token* (query-string) - OAuth access token.
13126    /// * *alt* (query-string) - Data format for response.
13127    /// * *callback* (query-string) - JSONP
13128    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13129    /// * *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.
13130    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13131    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13132    /// * *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.
13133    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13134    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13135    pub fn param<T>(mut self, name: T, value: T) -> ProjectSetOrgPolicyCall<'a, C>
13136    where
13137        T: AsRef<str>,
13138    {
13139        self._additional_params
13140            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13141        self
13142    }
13143
13144    /// Identifies the authorization scope for the method you are building.
13145    ///
13146    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13147    /// [`Scope::CloudPlatform`].
13148    ///
13149    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13150    /// tokens for more than one scope.
13151    ///
13152    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13153    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13154    /// sufficient, a read-write scope will do as well.
13155    pub fn add_scope<St>(mut self, scope: St) -> ProjectSetOrgPolicyCall<'a, C>
13156    where
13157        St: AsRef<str>,
13158    {
13159        self._scopes.insert(String::from(scope.as_ref()));
13160        self
13161    }
13162    /// Identifies the authorization scope(s) for the method you are building.
13163    ///
13164    /// See [`Self::add_scope()`] for details.
13165    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSetOrgPolicyCall<'a, C>
13166    where
13167        I: IntoIterator<Item = St>,
13168        St: AsRef<str>,
13169    {
13170        self._scopes
13171            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13172        self
13173    }
13174
13175    /// Removes all scopes, and no default scope will be used either.
13176    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13177    /// for details).
13178    pub fn clear_scopes(mut self) -> ProjectSetOrgPolicyCall<'a, C> {
13179        self._scopes.clear();
13180        self
13181    }
13182}
13183
13184/// Returns permissions that a caller has on the specified Project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). There are no permissions required for making this API call.
13185///
13186/// A builder for the *testIamPermissions* method supported by a *project* resource.
13187/// It is not used directly, but through a [`ProjectMethods`] instance.
13188///
13189/// # Example
13190///
13191/// Instantiate a resource method builder
13192///
13193/// ```test_harness,no_run
13194/// # extern crate hyper;
13195/// # extern crate hyper_rustls;
13196/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
13197/// use cloudresourcemanager1::api::TestIamPermissionsRequest;
13198/// # async fn dox() {
13199/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13200///
13201/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13202/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13203/// #     secret,
13204/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13205/// # ).build().await.unwrap();
13206///
13207/// # let client = hyper_util::client::legacy::Client::builder(
13208/// #     hyper_util::rt::TokioExecutor::new()
13209/// # )
13210/// # .build(
13211/// #     hyper_rustls::HttpsConnectorBuilder::new()
13212/// #         .with_native_roots()
13213/// #         .unwrap()
13214/// #         .https_or_http()
13215/// #         .enable_http1()
13216/// #         .build()
13217/// # );
13218/// # let mut hub = CloudResourceManager::new(client, auth);
13219/// // As the method needs a request, you would usually fill it with the desired information
13220/// // into the respective structure. Some of the parts shown here might not be applicable !
13221/// // Values shown here are possibly random and not representative !
13222/// let mut req = TestIamPermissionsRequest::default();
13223///
13224/// // You can configure optional parameters by calling the respective setters at will, and
13225/// // execute the final call using `doit()`.
13226/// // Values shown here are possibly random and not representative !
13227/// let result = hub.projects().test_iam_permissions(req, "resource")
13228///              .doit().await;
13229/// # }
13230/// ```
13231pub struct ProjectTestIamPermissionCall<'a, C>
13232where
13233    C: 'a,
13234{
13235    hub: &'a CloudResourceManager<C>,
13236    _request: TestIamPermissionsRequest,
13237    _resource: String,
13238    _delegate: Option<&'a mut dyn common::Delegate>,
13239    _additional_params: HashMap<String, String>,
13240    _scopes: BTreeSet<String>,
13241}
13242
13243impl<'a, C> common::CallBuilder for ProjectTestIamPermissionCall<'a, C> {}
13244
13245impl<'a, C> ProjectTestIamPermissionCall<'a, C>
13246where
13247    C: common::Connector,
13248{
13249    /// Perform the operation you have build so far.
13250    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
13251        use std::borrow::Cow;
13252        use std::io::{Read, Seek};
13253
13254        use common::{url::Params, ToParts};
13255        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13256
13257        let mut dd = common::DefaultDelegate;
13258        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13259        dlg.begin(common::MethodInfo {
13260            id: "cloudresourcemanager.projects.testIamPermissions",
13261            http_method: hyper::Method::POST,
13262        });
13263
13264        for &field in ["alt", "resource"].iter() {
13265            if self._additional_params.contains_key(field) {
13266                dlg.finished(false);
13267                return Err(common::Error::FieldClash(field));
13268            }
13269        }
13270
13271        let mut params = Params::with_capacity(4 + self._additional_params.len());
13272        params.push("resource", self._resource);
13273
13274        params.extend(self._additional_params.iter());
13275
13276        params.push("alt", "json");
13277        let mut url = self.hub._base_url.clone() + "v1/projects/{resource}:testIamPermissions";
13278        if self._scopes.is_empty() {
13279            self._scopes
13280                .insert(Scope::CloudPlatform.as_ref().to_string());
13281        }
13282
13283        #[allow(clippy::single_element_loop)]
13284        for &(find_this, param_name) in [("{resource}", "resource")].iter() {
13285            url = params.uri_replacement(url, param_name, find_this, false);
13286        }
13287        {
13288            let to_remove = ["resource"];
13289            params.remove_params(&to_remove);
13290        }
13291
13292        let url = params.parse_with_url(&url);
13293
13294        let mut json_mime_type = mime::APPLICATION_JSON;
13295        let mut request_value_reader = {
13296            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13297            common::remove_json_null_values(&mut value);
13298            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13299            serde_json::to_writer(&mut dst, &value).unwrap();
13300            dst
13301        };
13302        let request_size = request_value_reader
13303            .seek(std::io::SeekFrom::End(0))
13304            .unwrap();
13305        request_value_reader
13306            .seek(std::io::SeekFrom::Start(0))
13307            .unwrap();
13308
13309        loop {
13310            let token = match self
13311                .hub
13312                .auth
13313                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13314                .await
13315            {
13316                Ok(token) => token,
13317                Err(e) => match dlg.token(e) {
13318                    Ok(token) => token,
13319                    Err(e) => {
13320                        dlg.finished(false);
13321                        return Err(common::Error::MissingToken(e));
13322                    }
13323                },
13324            };
13325            request_value_reader
13326                .seek(std::io::SeekFrom::Start(0))
13327                .unwrap();
13328            let mut req_result = {
13329                let client = &self.hub.client;
13330                dlg.pre_request();
13331                let mut req_builder = hyper::Request::builder()
13332                    .method(hyper::Method::POST)
13333                    .uri(url.as_str())
13334                    .header(USER_AGENT, self.hub._user_agent.clone());
13335
13336                if let Some(token) = token.as_ref() {
13337                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13338                }
13339
13340                let request = req_builder
13341                    .header(CONTENT_TYPE, json_mime_type.to_string())
13342                    .header(CONTENT_LENGTH, request_size as u64)
13343                    .body(common::to_body(
13344                        request_value_reader.get_ref().clone().into(),
13345                    ));
13346
13347                client.request(request.unwrap()).await
13348            };
13349
13350            match req_result {
13351                Err(err) => {
13352                    if let common::Retry::After(d) = dlg.http_error(&err) {
13353                        sleep(d).await;
13354                        continue;
13355                    }
13356                    dlg.finished(false);
13357                    return Err(common::Error::HttpError(err));
13358                }
13359                Ok(res) => {
13360                    let (mut parts, body) = res.into_parts();
13361                    let mut body = common::Body::new(body);
13362                    if !parts.status.is_success() {
13363                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13364                        let error = serde_json::from_str(&common::to_string(&bytes));
13365                        let response = common::to_response(parts, bytes.into());
13366
13367                        if let common::Retry::After(d) =
13368                            dlg.http_failure(&response, error.as_ref().ok())
13369                        {
13370                            sleep(d).await;
13371                            continue;
13372                        }
13373
13374                        dlg.finished(false);
13375
13376                        return Err(match error {
13377                            Ok(value) => common::Error::BadRequest(value),
13378                            _ => common::Error::Failure(response),
13379                        });
13380                    }
13381                    let response = {
13382                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13383                        let encoded = common::to_string(&bytes);
13384                        match serde_json::from_str(&encoded) {
13385                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13386                            Err(error) => {
13387                                dlg.response_json_decode_error(&encoded, &error);
13388                                return Err(common::Error::JsonDecodeError(
13389                                    encoded.to_string(),
13390                                    error,
13391                                ));
13392                            }
13393                        }
13394                    };
13395
13396                    dlg.finished(true);
13397                    return Ok(response);
13398                }
13399            }
13400        }
13401    }
13402
13403    ///
13404    /// Sets the *request* property to the given value.
13405    ///
13406    /// Even though the property as already been set when instantiating this call,
13407    /// we provide this method for API completeness.
13408    pub fn request(
13409        mut self,
13410        new_value: TestIamPermissionsRequest,
13411    ) -> ProjectTestIamPermissionCall<'a, C> {
13412        self._request = new_value;
13413        self
13414    }
13415    /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
13416    ///
13417    /// Sets the *resource* path property to the given value.
13418    ///
13419    /// Even though the property as already been set when instantiating this call,
13420    /// we provide this method for API completeness.
13421    pub fn resource(mut self, new_value: &str) -> ProjectTestIamPermissionCall<'a, C> {
13422        self._resource = new_value.to_string();
13423        self
13424    }
13425    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13426    /// while executing the actual API request.
13427    ///
13428    /// ````text
13429    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13430    /// ````
13431    ///
13432    /// Sets the *delegate* property to the given value.
13433    pub fn delegate(
13434        mut self,
13435        new_value: &'a mut dyn common::Delegate,
13436    ) -> ProjectTestIamPermissionCall<'a, C> {
13437        self._delegate = Some(new_value);
13438        self
13439    }
13440
13441    /// Set any additional parameter of the query string used in the request.
13442    /// It should be used to set parameters which are not yet available through their own
13443    /// setters.
13444    ///
13445    /// Please note that this method must not be used to set any of the known parameters
13446    /// which have their own setter method. If done anyway, the request will fail.
13447    ///
13448    /// # Additional Parameters
13449    ///
13450    /// * *$.xgafv* (query-string) - V1 error format.
13451    /// * *access_token* (query-string) - OAuth access token.
13452    /// * *alt* (query-string) - Data format for response.
13453    /// * *callback* (query-string) - JSONP
13454    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13455    /// * *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.
13456    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13457    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13458    /// * *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.
13459    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13460    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13461    pub fn param<T>(mut self, name: T, value: T) -> ProjectTestIamPermissionCall<'a, C>
13462    where
13463        T: AsRef<str>,
13464    {
13465        self._additional_params
13466            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13467        self
13468    }
13469
13470    /// Identifies the authorization scope for the method you are building.
13471    ///
13472    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13473    /// [`Scope::CloudPlatform`].
13474    ///
13475    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13476    /// tokens for more than one scope.
13477    ///
13478    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13479    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13480    /// sufficient, a read-write scope will do as well.
13481    pub fn add_scope<St>(mut self, scope: St) -> ProjectTestIamPermissionCall<'a, C>
13482    where
13483        St: AsRef<str>,
13484    {
13485        self._scopes.insert(String::from(scope.as_ref()));
13486        self
13487    }
13488    /// Identifies the authorization scope(s) for the method you are building.
13489    ///
13490    /// See [`Self::add_scope()`] for details.
13491    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTestIamPermissionCall<'a, C>
13492    where
13493        I: IntoIterator<Item = St>,
13494        St: AsRef<str>,
13495    {
13496        self._scopes
13497            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13498        self
13499    }
13500
13501    /// Removes all scopes, and no default scope will be used either.
13502    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13503    /// for details).
13504    pub fn clear_scopes(mut self) -> ProjectTestIamPermissionCall<'a, C> {
13505        self._scopes.clear();
13506        self
13507    }
13508}
13509
13510/// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have undelete permissions for this Project.
13511///
13512/// A builder for the *undelete* method supported by a *project* resource.
13513/// It is not used directly, but through a [`ProjectMethods`] instance.
13514///
13515/// # Example
13516///
13517/// Instantiate a resource method builder
13518///
13519/// ```test_harness,no_run
13520/// # extern crate hyper;
13521/// # extern crate hyper_rustls;
13522/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
13523/// use cloudresourcemanager1::api::UndeleteProjectRequest;
13524/// # async fn dox() {
13525/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13526///
13527/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13528/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13529/// #     secret,
13530/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13531/// # ).build().await.unwrap();
13532///
13533/// # let client = hyper_util::client::legacy::Client::builder(
13534/// #     hyper_util::rt::TokioExecutor::new()
13535/// # )
13536/// # .build(
13537/// #     hyper_rustls::HttpsConnectorBuilder::new()
13538/// #         .with_native_roots()
13539/// #         .unwrap()
13540/// #         .https_or_http()
13541/// #         .enable_http1()
13542/// #         .build()
13543/// # );
13544/// # let mut hub = CloudResourceManager::new(client, auth);
13545/// // As the method needs a request, you would usually fill it with the desired information
13546/// // into the respective structure. Some of the parts shown here might not be applicable !
13547/// // Values shown here are possibly random and not representative !
13548/// let mut req = UndeleteProjectRequest::default();
13549///
13550/// // You can configure optional parameters by calling the respective setters at will, and
13551/// // execute the final call using `doit()`.
13552/// // Values shown here are possibly random and not representative !
13553/// let result = hub.projects().undelete(req, "projectId")
13554///              .doit().await;
13555/// # }
13556/// ```
13557pub struct ProjectUndeleteCall<'a, C>
13558where
13559    C: 'a,
13560{
13561    hub: &'a CloudResourceManager<C>,
13562    _request: UndeleteProjectRequest,
13563    _project_id: String,
13564    _delegate: Option<&'a mut dyn common::Delegate>,
13565    _additional_params: HashMap<String, String>,
13566    _scopes: BTreeSet<String>,
13567}
13568
13569impl<'a, C> common::CallBuilder for ProjectUndeleteCall<'a, C> {}
13570
13571impl<'a, C> ProjectUndeleteCall<'a, C>
13572where
13573    C: common::Connector,
13574{
13575    /// Perform the operation you have build so far.
13576    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
13577        use std::borrow::Cow;
13578        use std::io::{Read, Seek};
13579
13580        use common::{url::Params, ToParts};
13581        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13582
13583        let mut dd = common::DefaultDelegate;
13584        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13585        dlg.begin(common::MethodInfo {
13586            id: "cloudresourcemanager.projects.undelete",
13587            http_method: hyper::Method::POST,
13588        });
13589
13590        for &field in ["alt", "projectId"].iter() {
13591            if self._additional_params.contains_key(field) {
13592                dlg.finished(false);
13593                return Err(common::Error::FieldClash(field));
13594            }
13595        }
13596
13597        let mut params = Params::with_capacity(4 + self._additional_params.len());
13598        params.push("projectId", self._project_id);
13599
13600        params.extend(self._additional_params.iter());
13601
13602        params.push("alt", "json");
13603        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:undelete";
13604        if self._scopes.is_empty() {
13605            self._scopes
13606                .insert(Scope::CloudPlatform.as_ref().to_string());
13607        }
13608
13609        #[allow(clippy::single_element_loop)]
13610        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
13611            url = params.uri_replacement(url, param_name, find_this, false);
13612        }
13613        {
13614            let to_remove = ["projectId"];
13615            params.remove_params(&to_remove);
13616        }
13617
13618        let url = params.parse_with_url(&url);
13619
13620        let mut json_mime_type = mime::APPLICATION_JSON;
13621        let mut request_value_reader = {
13622            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13623            common::remove_json_null_values(&mut value);
13624            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13625            serde_json::to_writer(&mut dst, &value).unwrap();
13626            dst
13627        };
13628        let request_size = request_value_reader
13629            .seek(std::io::SeekFrom::End(0))
13630            .unwrap();
13631        request_value_reader
13632            .seek(std::io::SeekFrom::Start(0))
13633            .unwrap();
13634
13635        loop {
13636            let token = match self
13637                .hub
13638                .auth
13639                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13640                .await
13641            {
13642                Ok(token) => token,
13643                Err(e) => match dlg.token(e) {
13644                    Ok(token) => token,
13645                    Err(e) => {
13646                        dlg.finished(false);
13647                        return Err(common::Error::MissingToken(e));
13648                    }
13649                },
13650            };
13651            request_value_reader
13652                .seek(std::io::SeekFrom::Start(0))
13653                .unwrap();
13654            let mut req_result = {
13655                let client = &self.hub.client;
13656                dlg.pre_request();
13657                let mut req_builder = hyper::Request::builder()
13658                    .method(hyper::Method::POST)
13659                    .uri(url.as_str())
13660                    .header(USER_AGENT, self.hub._user_agent.clone());
13661
13662                if let Some(token) = token.as_ref() {
13663                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13664                }
13665
13666                let request = req_builder
13667                    .header(CONTENT_TYPE, json_mime_type.to_string())
13668                    .header(CONTENT_LENGTH, request_size as u64)
13669                    .body(common::to_body(
13670                        request_value_reader.get_ref().clone().into(),
13671                    ));
13672
13673                client.request(request.unwrap()).await
13674            };
13675
13676            match req_result {
13677                Err(err) => {
13678                    if let common::Retry::After(d) = dlg.http_error(&err) {
13679                        sleep(d).await;
13680                        continue;
13681                    }
13682                    dlg.finished(false);
13683                    return Err(common::Error::HttpError(err));
13684                }
13685                Ok(res) => {
13686                    let (mut parts, body) = res.into_parts();
13687                    let mut body = common::Body::new(body);
13688                    if !parts.status.is_success() {
13689                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13690                        let error = serde_json::from_str(&common::to_string(&bytes));
13691                        let response = common::to_response(parts, bytes.into());
13692
13693                        if let common::Retry::After(d) =
13694                            dlg.http_failure(&response, error.as_ref().ok())
13695                        {
13696                            sleep(d).await;
13697                            continue;
13698                        }
13699
13700                        dlg.finished(false);
13701
13702                        return Err(match error {
13703                            Ok(value) => common::Error::BadRequest(value),
13704                            _ => common::Error::Failure(response),
13705                        });
13706                    }
13707                    let response = {
13708                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13709                        let encoded = common::to_string(&bytes);
13710                        match serde_json::from_str(&encoded) {
13711                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13712                            Err(error) => {
13713                                dlg.response_json_decode_error(&encoded, &error);
13714                                return Err(common::Error::JsonDecodeError(
13715                                    encoded.to_string(),
13716                                    error,
13717                                ));
13718                            }
13719                        }
13720                    };
13721
13722                    dlg.finished(true);
13723                    return Ok(response);
13724                }
13725            }
13726        }
13727    }
13728
13729    ///
13730    /// Sets the *request* property to the given value.
13731    ///
13732    /// Even though the property as already been set when instantiating this call,
13733    /// we provide this method for API completeness.
13734    pub fn request(mut self, new_value: UndeleteProjectRequest) -> ProjectUndeleteCall<'a, C> {
13735        self._request = new_value;
13736        self
13737    }
13738    /// Required. The project ID (for example, `foo-bar-123`).
13739    ///
13740    /// Sets the *project id* path property to the given value.
13741    ///
13742    /// Even though the property as already been set when instantiating this call,
13743    /// we provide this method for API completeness.
13744    pub fn project_id(mut self, new_value: &str) -> ProjectUndeleteCall<'a, C> {
13745        self._project_id = new_value.to_string();
13746        self
13747    }
13748    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13749    /// while executing the actual API request.
13750    ///
13751    /// ````text
13752    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13753    /// ````
13754    ///
13755    /// Sets the *delegate* property to the given value.
13756    pub fn delegate(
13757        mut self,
13758        new_value: &'a mut dyn common::Delegate,
13759    ) -> ProjectUndeleteCall<'a, C> {
13760        self._delegate = Some(new_value);
13761        self
13762    }
13763
13764    /// Set any additional parameter of the query string used in the request.
13765    /// It should be used to set parameters which are not yet available through their own
13766    /// setters.
13767    ///
13768    /// Please note that this method must not be used to set any of the known parameters
13769    /// which have their own setter method. If done anyway, the request will fail.
13770    ///
13771    /// # Additional Parameters
13772    ///
13773    /// * *$.xgafv* (query-string) - V1 error format.
13774    /// * *access_token* (query-string) - OAuth access token.
13775    /// * *alt* (query-string) - Data format for response.
13776    /// * *callback* (query-string) - JSONP
13777    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13778    /// * *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.
13779    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13780    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13781    /// * *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.
13782    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13783    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13784    pub fn param<T>(mut self, name: T, value: T) -> ProjectUndeleteCall<'a, C>
13785    where
13786        T: AsRef<str>,
13787    {
13788        self._additional_params
13789            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13790        self
13791    }
13792
13793    /// Identifies the authorization scope for the method you are building.
13794    ///
13795    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13796    /// [`Scope::CloudPlatform`].
13797    ///
13798    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13799    /// tokens for more than one scope.
13800    ///
13801    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13802    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13803    /// sufficient, a read-write scope will do as well.
13804    pub fn add_scope<St>(mut self, scope: St) -> ProjectUndeleteCall<'a, C>
13805    where
13806        St: AsRef<str>,
13807    {
13808        self._scopes.insert(String::from(scope.as_ref()));
13809        self
13810    }
13811    /// Identifies the authorization scope(s) for the method you are building.
13812    ///
13813    /// See [`Self::add_scope()`] for details.
13814    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUndeleteCall<'a, C>
13815    where
13816        I: IntoIterator<Item = St>,
13817        St: AsRef<str>,
13818    {
13819        self._scopes
13820            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13821        self
13822    }
13823
13824    /// Removes all scopes, and no default scope will be used either.
13825    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13826    /// for details).
13827    pub fn clear_scopes(mut self) -> ProjectUndeleteCall<'a, C> {
13828        self._scopes.clear();
13829        self
13830    }
13831}
13832
13833/// Updates the attributes of the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have modify permissions for this Project.
13834///
13835/// A builder for the *update* method supported by a *project* resource.
13836/// It is not used directly, but through a [`ProjectMethods`] instance.
13837///
13838/// # Example
13839///
13840/// Instantiate a resource method builder
13841///
13842/// ```test_harness,no_run
13843/// # extern crate hyper;
13844/// # extern crate hyper_rustls;
13845/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
13846/// use cloudresourcemanager1::api::Project;
13847/// # async fn dox() {
13848/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13849///
13850/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13851/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13852/// #     secret,
13853/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13854/// # ).build().await.unwrap();
13855///
13856/// # let client = hyper_util::client::legacy::Client::builder(
13857/// #     hyper_util::rt::TokioExecutor::new()
13858/// # )
13859/// # .build(
13860/// #     hyper_rustls::HttpsConnectorBuilder::new()
13861/// #         .with_native_roots()
13862/// #         .unwrap()
13863/// #         .https_or_http()
13864/// #         .enable_http1()
13865/// #         .build()
13866/// # );
13867/// # let mut hub = CloudResourceManager::new(client, auth);
13868/// // As the method needs a request, you would usually fill it with the desired information
13869/// // into the respective structure. Some of the parts shown here might not be applicable !
13870/// // Values shown here are possibly random and not representative !
13871/// let mut req = Project::default();
13872///
13873/// // You can configure optional parameters by calling the respective setters at will, and
13874/// // execute the final call using `doit()`.
13875/// // Values shown here are possibly random and not representative !
13876/// let result = hub.projects().update(req, "projectId")
13877///              .doit().await;
13878/// # }
13879/// ```
13880pub struct ProjectUpdateCall<'a, C>
13881where
13882    C: 'a,
13883{
13884    hub: &'a CloudResourceManager<C>,
13885    _request: Project,
13886    _project_id: String,
13887    _delegate: Option<&'a mut dyn common::Delegate>,
13888    _additional_params: HashMap<String, String>,
13889    _scopes: BTreeSet<String>,
13890}
13891
13892impl<'a, C> common::CallBuilder for ProjectUpdateCall<'a, C> {}
13893
13894impl<'a, C> ProjectUpdateCall<'a, C>
13895where
13896    C: common::Connector,
13897{
13898    /// Perform the operation you have build so far.
13899    pub async fn doit(mut self) -> common::Result<(common::Response, Project)> {
13900        use std::borrow::Cow;
13901        use std::io::{Read, Seek};
13902
13903        use common::{url::Params, ToParts};
13904        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13905
13906        let mut dd = common::DefaultDelegate;
13907        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13908        dlg.begin(common::MethodInfo {
13909            id: "cloudresourcemanager.projects.update",
13910            http_method: hyper::Method::PUT,
13911        });
13912
13913        for &field in ["alt", "projectId"].iter() {
13914            if self._additional_params.contains_key(field) {
13915                dlg.finished(false);
13916                return Err(common::Error::FieldClash(field));
13917            }
13918        }
13919
13920        let mut params = Params::with_capacity(4 + self._additional_params.len());
13921        params.push("projectId", self._project_id);
13922
13923        params.extend(self._additional_params.iter());
13924
13925        params.push("alt", "json");
13926        let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}";
13927        if self._scopes.is_empty() {
13928            self._scopes
13929                .insert(Scope::CloudPlatform.as_ref().to_string());
13930        }
13931
13932        #[allow(clippy::single_element_loop)]
13933        for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
13934            url = params.uri_replacement(url, param_name, find_this, false);
13935        }
13936        {
13937            let to_remove = ["projectId"];
13938            params.remove_params(&to_remove);
13939        }
13940
13941        let url = params.parse_with_url(&url);
13942
13943        let mut json_mime_type = mime::APPLICATION_JSON;
13944        let mut request_value_reader = {
13945            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13946            common::remove_json_null_values(&mut value);
13947            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13948            serde_json::to_writer(&mut dst, &value).unwrap();
13949            dst
13950        };
13951        let request_size = request_value_reader
13952            .seek(std::io::SeekFrom::End(0))
13953            .unwrap();
13954        request_value_reader
13955            .seek(std::io::SeekFrom::Start(0))
13956            .unwrap();
13957
13958        loop {
13959            let token = match self
13960                .hub
13961                .auth
13962                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13963                .await
13964            {
13965                Ok(token) => token,
13966                Err(e) => match dlg.token(e) {
13967                    Ok(token) => token,
13968                    Err(e) => {
13969                        dlg.finished(false);
13970                        return Err(common::Error::MissingToken(e));
13971                    }
13972                },
13973            };
13974            request_value_reader
13975                .seek(std::io::SeekFrom::Start(0))
13976                .unwrap();
13977            let mut req_result = {
13978                let client = &self.hub.client;
13979                dlg.pre_request();
13980                let mut req_builder = hyper::Request::builder()
13981                    .method(hyper::Method::PUT)
13982                    .uri(url.as_str())
13983                    .header(USER_AGENT, self.hub._user_agent.clone());
13984
13985                if let Some(token) = token.as_ref() {
13986                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13987                }
13988
13989                let request = req_builder
13990                    .header(CONTENT_TYPE, json_mime_type.to_string())
13991                    .header(CONTENT_LENGTH, request_size as u64)
13992                    .body(common::to_body(
13993                        request_value_reader.get_ref().clone().into(),
13994                    ));
13995
13996                client.request(request.unwrap()).await
13997            };
13998
13999            match req_result {
14000                Err(err) => {
14001                    if let common::Retry::After(d) = dlg.http_error(&err) {
14002                        sleep(d).await;
14003                        continue;
14004                    }
14005                    dlg.finished(false);
14006                    return Err(common::Error::HttpError(err));
14007                }
14008                Ok(res) => {
14009                    let (mut parts, body) = res.into_parts();
14010                    let mut body = common::Body::new(body);
14011                    if !parts.status.is_success() {
14012                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14013                        let error = serde_json::from_str(&common::to_string(&bytes));
14014                        let response = common::to_response(parts, bytes.into());
14015
14016                        if let common::Retry::After(d) =
14017                            dlg.http_failure(&response, error.as_ref().ok())
14018                        {
14019                            sleep(d).await;
14020                            continue;
14021                        }
14022
14023                        dlg.finished(false);
14024
14025                        return Err(match error {
14026                            Ok(value) => common::Error::BadRequest(value),
14027                            _ => common::Error::Failure(response),
14028                        });
14029                    }
14030                    let response = {
14031                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14032                        let encoded = common::to_string(&bytes);
14033                        match serde_json::from_str(&encoded) {
14034                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14035                            Err(error) => {
14036                                dlg.response_json_decode_error(&encoded, &error);
14037                                return Err(common::Error::JsonDecodeError(
14038                                    encoded.to_string(),
14039                                    error,
14040                                ));
14041                            }
14042                        }
14043                    };
14044
14045                    dlg.finished(true);
14046                    return Ok(response);
14047                }
14048            }
14049        }
14050    }
14051
14052    ///
14053    /// Sets the *request* property to the given value.
14054    ///
14055    /// Even though the property as already been set when instantiating this call,
14056    /// we provide this method for API completeness.
14057    pub fn request(mut self, new_value: Project) -> ProjectUpdateCall<'a, C> {
14058        self._request = new_value;
14059        self
14060    }
14061    /// The project ID (for example, `my-project-123`). Required.
14062    ///
14063    /// Sets the *project id* path property to the given value.
14064    ///
14065    /// Even though the property as already been set when instantiating this call,
14066    /// we provide this method for API completeness.
14067    pub fn project_id(mut self, new_value: &str) -> ProjectUpdateCall<'a, C> {
14068        self._project_id = new_value.to_string();
14069        self
14070    }
14071    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14072    /// while executing the actual API request.
14073    ///
14074    /// ````text
14075    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14076    /// ````
14077    ///
14078    /// Sets the *delegate* property to the given value.
14079    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectUpdateCall<'a, C> {
14080        self._delegate = Some(new_value);
14081        self
14082    }
14083
14084    /// Set any additional parameter of the query string used in the request.
14085    /// It should be used to set parameters which are not yet available through their own
14086    /// setters.
14087    ///
14088    /// Please note that this method must not be used to set any of the known parameters
14089    /// which have their own setter method. If done anyway, the request will fail.
14090    ///
14091    /// # Additional Parameters
14092    ///
14093    /// * *$.xgafv* (query-string) - V1 error format.
14094    /// * *access_token* (query-string) - OAuth access token.
14095    /// * *alt* (query-string) - Data format for response.
14096    /// * *callback* (query-string) - JSONP
14097    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14098    /// * *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.
14099    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14100    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14101    /// * *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.
14102    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14103    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14104    pub fn param<T>(mut self, name: T, value: T) -> ProjectUpdateCall<'a, C>
14105    where
14106        T: AsRef<str>,
14107    {
14108        self._additional_params
14109            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14110        self
14111    }
14112
14113    /// Identifies the authorization scope for the method you are building.
14114    ///
14115    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14116    /// [`Scope::CloudPlatform`].
14117    ///
14118    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14119    /// tokens for more than one scope.
14120    ///
14121    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14122    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14123    /// sufficient, a read-write scope will do as well.
14124    pub fn add_scope<St>(mut self, scope: St) -> ProjectUpdateCall<'a, C>
14125    where
14126        St: AsRef<str>,
14127    {
14128        self._scopes.insert(String::from(scope.as_ref()));
14129        self
14130    }
14131    /// Identifies the authorization scope(s) for the method you are building.
14132    ///
14133    /// See [`Self::add_scope()`] for details.
14134    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUpdateCall<'a, C>
14135    where
14136        I: IntoIterator<Item = St>,
14137        St: AsRef<str>,
14138    {
14139        self._scopes
14140            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14141        self
14142    }
14143
14144    /// Removes all scopes, and no default scope will be used either.
14145    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14146    /// for details).
14147    pub fn clear_scopes(mut self) -> ProjectUpdateCall<'a, C> {
14148        self._scopes.clear();
14149        self
14150    }
14151}