google_cloudresourcemanager2/
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_cloudresourcemanager2 as cloudresourcemanager2;
55/// use cloudresourcemanager2::{Result, Error};
56/// # async fn dox() {
57/// use cloudresourcemanager2::{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.folders().list()
88///              .show_deleted(true)
89///              .parent("gubergren")
90///              .page_token("Lorem")
91///              .page_size(-12)
92///              .doit().await;
93///
94/// match result {
95///     Err(e) => match e {
96///         // The Error enum provides details about what exactly happened.
97///         // You can also just use its `Debug`, `Display` or `Error` traits
98///          Error::HttpError(_)
99///         |Error::Io(_)
100///         |Error::MissingAPIKey
101///         |Error::MissingToken(_)
102///         |Error::Cancelled
103///         |Error::UploadSizeLimitExceeded(_, _)
104///         |Error::Failure(_)
105///         |Error::BadRequest(_)
106///         |Error::FieldClash(_)
107///         |Error::JsonDecodeError(_, _) => println!("{}", e),
108///     },
109///     Ok(res) => println!("Success: {:?}", res),
110/// }
111/// # }
112/// ```
113#[derive(Clone)]
114pub struct CloudResourceManager<C> {
115    pub client: common::Client<C>,
116    pub auth: Box<dyn common::GetToken>,
117    _user_agent: String,
118    _base_url: String,
119    _root_url: String,
120}
121
122impl<C> common::Hub for CloudResourceManager<C> {}
123
124impl<'a, C> CloudResourceManager<C> {
125    pub fn new<A: 'static + common::GetToken>(
126        client: common::Client<C>,
127        auth: A,
128    ) -> CloudResourceManager<C> {
129        CloudResourceManager {
130            client,
131            auth: Box::new(auth),
132            _user_agent: "google-api-rust-client/6.0.0".to_string(),
133            _base_url: "https://cloudresourcemanager.googleapis.com/".to_string(),
134            _root_url: "https://cloudresourcemanager.googleapis.com/".to_string(),
135        }
136    }
137
138    pub fn folders(&'a self) -> FolderMethods<'a, C> {
139        FolderMethods { hub: self }
140    }
141    pub fn operations(&'a self) -> OperationMethods<'a, C> {
142        OperationMethods { hub: self }
143    }
144
145    /// Set the user-agent header field to use in all requests to the server.
146    /// It defaults to `google-api-rust-client/6.0.0`.
147    ///
148    /// Returns the previously set user-agent.
149    pub fn user_agent(&mut self, agent_name: String) -> String {
150        std::mem::replace(&mut self._user_agent, agent_name)
151    }
152
153    /// Set the base url to use in all requests to the server.
154    /// It defaults to `https://cloudresourcemanager.googleapis.com/`.
155    ///
156    /// Returns the previously set base url.
157    pub fn base_url(&mut self, new_base_url: String) -> String {
158        std::mem::replace(&mut self._base_url, new_base_url)
159    }
160
161    /// Set the root url to use in all requests to the server.
162    /// It defaults to `https://cloudresourcemanager.googleapis.com/`.
163    ///
164    /// Returns the previously set root url.
165    pub fn root_url(&mut self, new_root_url: String) -> String {
166        std::mem::replace(&mut self._root_url, new_root_url)
167    }
168}
169
170// ############
171// SCHEMAS ###
172// ##########
173/// 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.
174///
175/// This type is not used in any activity, and only used as *part* of another schema.
176///
177#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
178#[serde_with::serde_as]
179#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
180pub struct AuditConfig {
181    /// The configuration for logging of each type of permission.
182    #[serde(rename = "auditLogConfigs")]
183    pub audit_log_configs: Option<Vec<AuditLogConfig>>,
184    /// 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.
185    pub service: Option<String>,
186}
187
188impl common::Part for AuditConfig {}
189
190/// 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.
191///
192/// This type is not used in any activity, and only used as *part* of another schema.
193///
194#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
195#[serde_with::serde_as]
196#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
197pub struct AuditLogConfig {
198    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
199    #[serde(rename = "exemptedMembers")]
200    pub exempted_members: Option<Vec<String>>,
201    /// The log type that this config enables.
202    #[serde(rename = "logType")]
203    pub log_type: Option<String>,
204}
205
206impl common::Part for AuditLogConfig {}
207
208/// Associates `members`, or principals, with a `role`.
209///
210/// This type is not used in any activity, and only used as *part* of another schema.
211///
212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
213#[serde_with::serde_as]
214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
215pub struct Binding {
216    /// 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).
217    pub condition: Option<Expr>,
218    /// 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`.
219    pub members: Option<Vec<String>>,
220    /// 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).
221    pub role: Option<String>,
222}
223
224impl common::Part for Binding {}
225
226/// 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.
227///
228/// This type is not used in any activity, and only used as *part* of another schema.
229///
230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
231#[serde_with::serde_as]
232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
233pub struct Expr {
234    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
235    pub description: Option<String>,
236    /// Textual representation of an expression in Common Expression Language syntax.
237    pub expression: Option<String>,
238    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
239    pub location: Option<String>,
240    /// 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.
241    pub title: Option<String>,
242}
243
244impl common::Part for Expr {}
245
246/// A Folder in an Organization’s resource hierarchy, used to organize that Organization’s resources.
247///
248/// # Activities
249///
250/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
251/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
252///
253/// * [create folders](FolderCreateCall) (request)
254/// * [delete folders](FolderDeleteCall) (response)
255/// * [get folders](FolderGetCall) (response)
256/// * [get iam policy folders](FolderGetIamPolicyCall) (none)
257/// * [list folders](FolderListCall) (none)
258/// * [move folders](FolderMoveCall) (none)
259/// * [patch folders](FolderPatchCall) (request|response)
260/// * [search folders](FolderSearchCall) (none)
261/// * [set iam policy folders](FolderSetIamPolicyCall) (none)
262/// * [test iam permissions folders](FolderTestIamPermissionCall) (none)
263/// * [undelete folders](FolderUndeleteCall) (response)
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct Folder {
268    /// Output only. Timestamp when the Folder was created. Assigned by the server.
269    #[serde(rename = "createTime")]
270    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
271    /// The folder’s display name. A folder’s display name must be unique amongst its siblings, e.g. no two folders with the same parent can share the same display name. The display name must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be no longer than 30 characters. This is captured by the regular expression: `[\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?`.
272    #[serde(rename = "displayName")]
273    pub display_name: Option<String>,
274    /// Output only. The lifecycle state of the folder. Updates to the lifecycle_state must be performed via DeleteFolder and UndeleteFolder.
275    #[serde(rename = "lifecycleState")]
276    pub lifecycle_state: Option<String>,
277    /// Output only. The resource name of the Folder. Its format is `folders/{folder_id}`, for example: "folders/1234".
278    pub name: Option<String>,
279    /// Required. The Folder's parent's resource name. Updates to the folder's parent must be performed via MoveFolder.
280    pub parent: Option<String>,
281    /// Optional. Input only. Immutable. Tag keys/values directly bound to this folder. Each item in the map must be expressed as " : ". For example: "123/environment" : "production", "123/costCenter" : "marketing" Note: Currently this field is in Preview.
282    pub tags: Option<HashMap<String, String>>,
283}
284
285impl common::RequestValue for Folder {}
286impl common::Resource for Folder {}
287impl common::ResponseResult for Folder {}
288
289/// Request message for `GetIamPolicy` method.
290///
291/// # Activities
292///
293/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
294/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
295///
296/// * [get iam policy folders](FolderGetIamPolicyCall) (request)
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct GetIamPolicyRequest {
301    /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
302    pub options: Option<GetPolicyOptions>,
303}
304
305impl common::RequestValue for GetIamPolicyRequest {}
306
307/// Encapsulates settings provided to GetIamPolicy.
308///
309/// This type is not used in any activity, and only used as *part* of another schema.
310///
311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
312#[serde_with::serde_as]
313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
314pub struct GetPolicyOptions {
315    /// 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).
316    #[serde(rename = "requestedPolicyVersion")]
317    pub requested_policy_version: Option<i32>,
318}
319
320impl common::Part for GetPolicyOptions {}
321
322/// The ListFolders response message.
323///
324/// # Activities
325///
326/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
327/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
328///
329/// * [list folders](FolderListCall) (response)
330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
331#[serde_with::serde_as]
332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
333pub struct ListFoldersResponse {
334    /// A possibly paginated list of Folders that are direct descendants of the specified parent resource.
335    pub folders: Option<Vec<Folder>>,
336    /// A pagination token returned from a previous call to `ListFolders` that indicates from where listing should continue.
337    #[serde(rename = "nextPageToken")]
338    pub next_page_token: Option<String>,
339}
340
341impl common::ResponseResult for ListFoldersResponse {}
342
343/// The MoveFolder request message.
344///
345/// # Activities
346///
347/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
348/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
349///
350/// * [move folders](FolderMoveCall) (request)
351#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
352#[serde_with::serde_as]
353#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
354pub struct MoveFolderRequest {
355    /// Required. The resource name of the Folder or Organization to reparent the folder under. Must be of the form `folders/{folder_id}` or `organizations/{org_id}`.
356    #[serde(rename = "destinationParent")]
357    pub destination_parent: Option<String>,
358}
359
360impl common::RequestValue for MoveFolderRequest {}
361
362/// This resource represents a long-running operation that is the result of a network API call.
363///
364/// # Activities
365///
366/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
367/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
368///
369/// * [create folders](FolderCreateCall) (response)
370/// * [move folders](FolderMoveCall) (response)
371/// * [get operations](OperationGetCall) (response)
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct Operation {
376    /// 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.
377    pub done: Option<bool>,
378    /// The error result of the operation in case of failure or cancellation.
379    pub error: Option<Status>,
380    /// 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.
381    pub metadata: Option<HashMap<String, serde_json::Value>>,
382    /// 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}`.
383    pub name: Option<String>,
384    /// 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`.
385    pub response: Option<HashMap<String, serde_json::Value>>,
386}
387
388impl common::Resource for Operation {}
389impl common::ResponseResult for Operation {}
390
391/// 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/).
392///
393/// # Activities
394///
395/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
396/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
397///
398/// * [get iam policy folders](FolderGetIamPolicyCall) (response)
399/// * [set iam policy folders](FolderSetIamPolicyCall) (response)
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct Policy {
404    /// Specifies cloud audit logging configuration for this policy.
405    #[serde(rename = "auditConfigs")]
406    pub audit_configs: Option<Vec<AuditConfig>>,
407    /// 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`.
408    pub bindings: Option<Vec<Binding>>,
409    /// `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.
410    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
411    pub etag: Option<Vec<u8>>,
412    /// 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).
413    pub version: Option<i32>,
414}
415
416impl common::ResponseResult for Policy {}
417
418/// The request message for searching folders.
419///
420/// # Activities
421///
422/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
423/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
424///
425/// * [search folders](FolderSearchCall) (request)
426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
427#[serde_with::serde_as]
428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
429pub struct SearchFoldersRequest {
430    /// Optional. The maximum number of folders to return in the response. The server can return fewer folders than requested. If unspecified, server picks an appropriate default.
431    #[serde(rename = "pageSize")]
432    pub page_size: Option<i32>,
433    /// Optional. A pagination token returned from a previous call to `SearchFolders` that indicates from where search should continue.
434    #[serde(rename = "pageToken")]
435    pub page_token: Option<String>,
436    /// Search criteria used to select the Folders to return. If no search criteria is specified then all accessible folders will be returned. Query expressions can be used to restrict results based upon displayName, lifecycleState and parent, where the operators `=`, `NOT`, `AND` and `OR` can be used along with the suffix wildcard symbol `*`. The displayName field in a query expression should use escaped quotes for values that include whitespace to prevent unexpected behavior. Some example queries are: * Query `displayName=Test*` returns Folder resources whose display name starts with "Test". * Query `lifecycleState=ACTIVE` returns Folder resources with `lifecycleState` set to `ACTIVE`. * Query `parent=folders/123` returns Folder resources that have `folders/123` as a parent resource. * Query `parent=folders/123 AND lifecycleState=ACTIVE` returns active Folder resources that have `folders/123` as a parent resource. * Query `displayName=\\"Test String\\"` returns Folder resources with display names that include both "Test" and "String".
437    pub query: Option<String>,
438}
439
440impl common::RequestValue for SearchFoldersRequest {}
441
442/// The response message for searching folders.
443///
444/// # Activities
445///
446/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
447/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
448///
449/// * [search folders](FolderSearchCall) (response)
450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
451#[serde_with::serde_as]
452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
453pub struct SearchFoldersResponse {
454    /// A possibly paginated folder search results. the specified parent resource.
455    pub folders: Option<Vec<Folder>>,
456    /// A pagination token returned from a previous call to `SearchFolders` that indicates from where searching should continue.
457    #[serde(rename = "nextPageToken")]
458    pub next_page_token: Option<String>,
459}
460
461impl common::ResponseResult for SearchFoldersResponse {}
462
463/// Request message for `SetIamPolicy` method.
464///
465/// # Activities
466///
467/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
468/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
469///
470/// * [set iam policy folders](FolderSetIamPolicyCall) (request)
471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
472#[serde_with::serde_as]
473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
474pub struct SetIamPolicyRequest {
475    /// 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.
476    pub policy: Option<Policy>,
477    /// 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"`
478    #[serde(rename = "updateMask")]
479    pub update_mask: Option<common::FieldMask>,
480}
481
482impl common::RequestValue for SetIamPolicyRequest {}
483
484/// 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).
485///
486/// This type is not used in any activity, and only used as *part* of another schema.
487///
488#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
489#[serde_with::serde_as]
490#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
491pub struct Status {
492    /// The status code, which should be an enum value of google.rpc.Code.
493    pub code: Option<i32>,
494    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
495    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
496    /// 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.
497    pub message: Option<String>,
498}
499
500impl common::Part for Status {}
501
502/// Request message for `TestIamPermissions` method.
503///
504/// # Activities
505///
506/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
507/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
508///
509/// * [test iam permissions folders](FolderTestIamPermissionCall) (request)
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct TestIamPermissionsRequest {
514    /// 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).
515    pub permissions: Option<Vec<String>>,
516}
517
518impl common::RequestValue for TestIamPermissionsRequest {}
519
520/// Response message for `TestIamPermissions` method.
521///
522/// # Activities
523///
524/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
525/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
526///
527/// * [test iam permissions folders](FolderTestIamPermissionCall) (response)
528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
529#[serde_with::serde_as]
530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
531pub struct TestIamPermissionsResponse {
532    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
533    pub permissions: Option<Vec<String>>,
534}
535
536impl common::ResponseResult for TestIamPermissionsResponse {}
537
538/// The UndeleteFolder request message.
539///
540/// # Activities
541///
542/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
543/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
544///
545/// * [undelete folders](FolderUndeleteCall) (request)
546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
547#[serde_with::serde_as]
548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
549pub struct UndeleteFolderRequest {
550    _never_set: Option<bool>,
551}
552
553impl common::RequestValue for UndeleteFolderRequest {}
554
555// ###################
556// MethodBuilders ###
557// #################
558
559/// A builder providing access to all methods supported on *folder* resources.
560/// It is not used directly, but through the [`CloudResourceManager`] hub.
561///
562/// # Example
563///
564/// Instantiate a resource builder
565///
566/// ```test_harness,no_run
567/// extern crate hyper;
568/// extern crate hyper_rustls;
569/// extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
570///
571/// # async fn dox() {
572/// use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
573///
574/// let secret: yup_oauth2::ApplicationSecret = Default::default();
575/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
576///     secret,
577///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
578/// ).build().await.unwrap();
579///
580/// let client = hyper_util::client::legacy::Client::builder(
581///     hyper_util::rt::TokioExecutor::new()
582/// )
583/// .build(
584///     hyper_rustls::HttpsConnectorBuilder::new()
585///         .with_native_roots()
586///         .unwrap()
587///         .https_or_http()
588///         .enable_http1()
589///         .build()
590/// );
591/// let mut hub = CloudResourceManager::new(client, auth);
592/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
593/// // like `create(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `list(...)`, `move_(...)`, `patch(...)`, `search(...)`, `set_iam_policy(...)`, `test_iam_permissions(...)` and `undelete(...)`
594/// // to build up your call.
595/// let rb = hub.folders();
596/// # }
597/// ```
598pub struct FolderMethods<'a, C>
599where
600    C: 'a,
601{
602    hub: &'a CloudResourceManager<C>,
603}
604
605impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
606
607impl<'a, C> FolderMethods<'a, C> {
608    /// Create a builder to help you perform the following task:
609    ///
610    /// Creates a Folder in the resource hierarchy. Returns an Operation which can be used to track the progress of the folder creation workflow. Upon success the Operation.response field will be populated with the created Folder. In order to succeed, the addition of this new Folder must not violate the Folder naming, height or fanout constraints. + The Folder's display_name must be distinct from all other Folders that share its parent. + The addition of the Folder must not cause the active Folder hierarchy to exceed a height of 10. Note, the full active + deleted Folder hierarchy is allowed to reach a height of 20; this provides additional headroom when moving folders that contain deleted folders. + The addition of the Folder must not cause the total number of Folders under its parent to exceed 300. If the operation fails due to a folder constraint violation, some errors may be returned by the CreateFolder request, with status code FAILED_PRECONDITION and an error description. Other folder constraint violations will be communicated in the Operation, with the specific PreconditionFailure returned via the details list in the Operation.error field. The caller must have `resourcemanager.folders.create` permission on the identified parent.
611    ///
612    /// # Arguments
613    ///
614    /// * `request` - No description provided.
615    pub fn create(&self, request: Folder) -> FolderCreateCall<'a, C> {
616        FolderCreateCall {
617            hub: self.hub,
618            _request: request,
619            _parent: Default::default(),
620            _delegate: Default::default(),
621            _additional_params: Default::default(),
622            _scopes: Default::default(),
623        }
624    }
625
626    /// Create a builder to help you perform the following task:
627    ///
628    /// Requests deletion of a Folder. The Folder is moved into the DELETE_REQUESTED state immediately, and is deleted approximately 30 days later. This method may only be called on an empty Folder in the ACTIVE state, where a Folder is empty if it doesn't contain any Folders or Projects in the ACTIVE state. The caller must have `resourcemanager.folders.delete` permission on the identified folder.
629    ///
630    /// # Arguments
631    ///
632    /// * `name` - Required. the resource name of the Folder to be deleted. Must be of the form `folders/{folder_id}`.
633    pub fn delete(&self, name: &str) -> FolderDeleteCall<'a, C> {
634        FolderDeleteCall {
635            hub: self.hub,
636            _name: name.to_string(),
637            _delegate: Default::default(),
638            _additional_params: Default::default(),
639            _scopes: Default::default(),
640        }
641    }
642
643    /// Create a builder to help you perform the following task:
644    ///
645    /// Retrieves a Folder identified by the supplied resource name. Valid Folder resource names have the format `folders/{folder_id}` (for example, `folders/1234`). The caller must have `resourcemanager.folders.get` permission on the identified folder.
646    ///
647    /// # Arguments
648    ///
649    /// * `name` - Required. The resource name of the Folder to retrieve. Must be of the form `folders/{folder_id}`.
650    pub fn get(&self, name: &str) -> FolderGetCall<'a, C> {
651        FolderGetCall {
652            hub: self.hub,
653            _name: name.to_string(),
654            _delegate: Default::default(),
655            _additional_params: Default::default(),
656            _scopes: Default::default(),
657        }
658    }
659
660    /// Create a builder to help you perform the following task:
661    ///
662    /// Gets the access control policy for a Folder. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the Folder's resource name, e.g. "folders/1234". The caller must have `resourcemanager.folders.getIamPolicy` permission on the identified folder.
663    ///
664    /// # Arguments
665    ///
666    /// * `request` - No description provided.
667    /// * `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.
668    pub fn get_iam_policy(
669        &self,
670        request: GetIamPolicyRequest,
671        resource: &str,
672    ) -> FolderGetIamPolicyCall<'a, C> {
673        FolderGetIamPolicyCall {
674            hub: self.hub,
675            _request: request,
676            _resource: resource.to_string(),
677            _delegate: Default::default(),
678            _additional_params: Default::default(),
679            _scopes: Default::default(),
680        }
681    }
682
683    /// Create a builder to help you perform the following task:
684    ///
685    /// Lists the Folders that are direct descendants of supplied parent resource. List provides a strongly consistent view of the Folders underneath the specified parent resource. List returns Folders sorted based upon the (ascending) lexical ordering of their display_name. The caller must have `resourcemanager.folders.list` permission on the identified parent.
686    pub fn list(&self) -> FolderListCall<'a, C> {
687        FolderListCall {
688            hub: self.hub,
689            _show_deleted: Default::default(),
690            _parent: Default::default(),
691            _page_token: Default::default(),
692            _page_size: Default::default(),
693            _delegate: Default::default(),
694            _additional_params: Default::default(),
695            _scopes: Default::default(),
696        }
697    }
698
699    /// Create a builder to help you perform the following task:
700    ///
701    /// Moves a Folder under a new resource parent. Returns an Operation which can be used to track the progress of the folder move workflow. Upon success the Operation.response field will be populated with the moved Folder. Upon failure, a FolderOperationError categorizing the failure cause will be returned - if the failure occurs synchronously then the FolderOperationError will be returned via the Status.details field and if it occurs asynchronously then the FolderOperation will be returned via the Operation.error field. In addition, the Operation.metadata field will be populated with a FolderOperation message as an aid to stateless clients. Folder moves will be rejected if they violate either the naming, height or fanout constraints described in the CreateFolder documentation. The caller must have `resourcemanager.folders.move` permission on the folder's current and proposed new parent.
702    ///
703    /// # Arguments
704    ///
705    /// * `request` - No description provided.
706    /// * `name` - Required. The resource name of the Folder to move. Must be of the form folders/{folder_id}
707    pub fn move_(&self, request: MoveFolderRequest, name: &str) -> FolderMoveCall<'a, C> {
708        FolderMoveCall {
709            hub: self.hub,
710            _request: request,
711            _name: name.to_string(),
712            _delegate: Default::default(),
713            _additional_params: Default::default(),
714            _scopes: Default::default(),
715        }
716    }
717
718    /// Create a builder to help you perform the following task:
719    ///
720    /// Updates a Folder, changing its display_name. Changes to the folder display_name will be rejected if they violate either the display_name formatting rules or naming constraints described in the CreateFolder documentation. The Folder's display name must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be between 3 and 30 characters. This is captured by the regular expression: `\p{L}\p{N}{1,28}[\p{L}\p{N}]`. The caller must have `resourcemanager.folders.update` permission on the identified folder. If the update fails due to the unique name constraint then a PreconditionFailure explaining this violation will be returned in the Status.details field.
721    ///
722    /// # Arguments
723    ///
724    /// * `request` - No description provided.
725    /// * `name` - Output only. The resource name of the Folder. Its format is `folders/{folder_id}`, for example: "folders/1234".
726    pub fn patch(&self, request: Folder, name: &str) -> FolderPatchCall<'a, C> {
727        FolderPatchCall {
728            hub: self.hub,
729            _request: request,
730            _name: name.to_string(),
731            _update_mask: Default::default(),
732            _delegate: Default::default(),
733            _additional_params: Default::default(),
734            _scopes: Default::default(),
735        }
736    }
737
738    /// Create a builder to help you perform the following task:
739    ///
740    /// Search for folders that match specific filter criteria. Search provides an eventually consistent view of the folders a user has access to which meet the specified filter criteria. This will only return folders on which the caller has the permission `resourcemanager.folders.get`.
741    ///
742    /// # Arguments
743    ///
744    /// * `request` - No description provided.
745    pub fn search(&self, request: SearchFoldersRequest) -> FolderSearchCall<'a, C> {
746        FolderSearchCall {
747            hub: self.hub,
748            _request: request,
749            _delegate: Default::default(),
750            _additional_params: Default::default(),
751            _scopes: Default::default(),
752        }
753    }
754
755    /// Create a builder to help you perform the following task:
756    ///
757    /// Sets the access control policy on a Folder, replacing any existing policy. The `resource` field should be the Folder's resource name, e.g. "folders/1234". The caller must have `resourcemanager.folders.setIamPolicy` permission on the identified folder.
758    ///
759    /// # Arguments
760    ///
761    /// * `request` - No description provided.
762    /// * `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.
763    pub fn set_iam_policy(
764        &self,
765        request: SetIamPolicyRequest,
766        resource: &str,
767    ) -> FolderSetIamPolicyCall<'a, C> {
768        FolderSetIamPolicyCall {
769            hub: self.hub,
770            _request: request,
771            _resource: resource.to_string(),
772            _delegate: Default::default(),
773            _additional_params: Default::default(),
774            _scopes: Default::default(),
775        }
776    }
777
778    /// Create a builder to help you perform the following task:
779    ///
780    /// Returns permissions that a caller has on the specified Folder. The `resource` field should be the Folder's resource name, e.g. "folders/1234". There are no permissions required for making this API call.
781    ///
782    /// # Arguments
783    ///
784    /// * `request` - No description provided.
785    /// * `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.
786    pub fn test_iam_permissions(
787        &self,
788        request: TestIamPermissionsRequest,
789        resource: &str,
790    ) -> FolderTestIamPermissionCall<'a, C> {
791        FolderTestIamPermissionCall {
792            hub: self.hub,
793            _request: request,
794            _resource: resource.to_string(),
795            _delegate: Default::default(),
796            _additional_params: Default::default(),
797            _scopes: Default::default(),
798        }
799    }
800
801    /// Create a builder to help you perform the following task:
802    ///
803    /// Cancels the deletion request for a Folder. This method may only be called on a Folder in the DELETE_REQUESTED state. In order to succeed, the Folder's parent must be in the ACTIVE state. In addition, reintroducing the folder into the tree must not violate folder naming, height and fanout constraints described in the CreateFolder documentation. The caller must have `resourcemanager.folders.undelete` permission on the identified folder.
804    ///
805    /// # Arguments
806    ///
807    /// * `request` - No description provided.
808    /// * `name` - Required. The resource name of the Folder to undelete. Must be of the form `folders/{folder_id}`.
809    pub fn undelete(
810        &self,
811        request: UndeleteFolderRequest,
812        name: &str,
813    ) -> FolderUndeleteCall<'a, C> {
814        FolderUndeleteCall {
815            hub: self.hub,
816            _request: request,
817            _name: name.to_string(),
818            _delegate: Default::default(),
819            _additional_params: Default::default(),
820            _scopes: Default::default(),
821        }
822    }
823}
824
825/// A builder providing access to all methods supported on *operation* resources.
826/// It is not used directly, but through the [`CloudResourceManager`] hub.
827///
828/// # Example
829///
830/// Instantiate a resource builder
831///
832/// ```test_harness,no_run
833/// extern crate hyper;
834/// extern crate hyper_rustls;
835/// extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
836///
837/// # async fn dox() {
838/// use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
839///
840/// let secret: yup_oauth2::ApplicationSecret = Default::default();
841/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
842///     secret,
843///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
844/// ).build().await.unwrap();
845///
846/// let client = hyper_util::client::legacy::Client::builder(
847///     hyper_util::rt::TokioExecutor::new()
848/// )
849/// .build(
850///     hyper_rustls::HttpsConnectorBuilder::new()
851///         .with_native_roots()
852///         .unwrap()
853///         .https_or_http()
854///         .enable_http1()
855///         .build()
856/// );
857/// let mut hub = CloudResourceManager::new(client, auth);
858/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
859/// // like `get(...)`
860/// // to build up your call.
861/// let rb = hub.operations();
862/// # }
863/// ```
864pub struct OperationMethods<'a, C>
865where
866    C: 'a,
867{
868    hub: &'a CloudResourceManager<C>,
869}
870
871impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
872
873impl<'a, C> OperationMethods<'a, C> {
874    /// Create a builder to help you perform the following task:
875    ///
876    /// 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.
877    ///
878    /// # Arguments
879    ///
880    /// * `name` - The name of the operation resource.
881    pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
882        OperationGetCall {
883            hub: self.hub,
884            _name: name.to_string(),
885            _delegate: Default::default(),
886            _additional_params: Default::default(),
887            _scopes: Default::default(),
888        }
889    }
890}
891
892// ###################
893// CallBuilders   ###
894// #################
895
896/// Creates a Folder in the resource hierarchy. Returns an Operation which can be used to track the progress of the folder creation workflow. Upon success the Operation.response field will be populated with the created Folder. In order to succeed, the addition of this new Folder must not violate the Folder naming, height or fanout constraints. + The Folder's display_name must be distinct from all other Folders that share its parent. + The addition of the Folder must not cause the active Folder hierarchy to exceed a height of 10. Note, the full active + deleted Folder hierarchy is allowed to reach a height of 20; this provides additional headroom when moving folders that contain deleted folders. + The addition of the Folder must not cause the total number of Folders under its parent to exceed 300. If the operation fails due to a folder constraint violation, some errors may be returned by the CreateFolder request, with status code FAILED_PRECONDITION and an error description. Other folder constraint violations will be communicated in the Operation, with the specific PreconditionFailure returned via the details list in the Operation.error field. The caller must have `resourcemanager.folders.create` permission on the identified parent.
897///
898/// A builder for the *create* method supported by a *folder* resource.
899/// It is not used directly, but through a [`FolderMethods`] instance.
900///
901/// # Example
902///
903/// Instantiate a resource method builder
904///
905/// ```test_harness,no_run
906/// # extern crate hyper;
907/// # extern crate hyper_rustls;
908/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
909/// use cloudresourcemanager2::api::Folder;
910/// # async fn dox() {
911/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
912///
913/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
914/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
915/// #     secret,
916/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
917/// # ).build().await.unwrap();
918///
919/// # let client = hyper_util::client::legacy::Client::builder(
920/// #     hyper_util::rt::TokioExecutor::new()
921/// # )
922/// # .build(
923/// #     hyper_rustls::HttpsConnectorBuilder::new()
924/// #         .with_native_roots()
925/// #         .unwrap()
926/// #         .https_or_http()
927/// #         .enable_http1()
928/// #         .build()
929/// # );
930/// # let mut hub = CloudResourceManager::new(client, auth);
931/// // As the method needs a request, you would usually fill it with the desired information
932/// // into the respective structure. Some of the parts shown here might not be applicable !
933/// // Values shown here are possibly random and not representative !
934/// let mut req = Folder::default();
935///
936/// // You can configure optional parameters by calling the respective setters at will, and
937/// // execute the final call using `doit()`.
938/// // Values shown here are possibly random and not representative !
939/// let result = hub.folders().create(req)
940///              .parent("eos")
941///              .doit().await;
942/// # }
943/// ```
944pub struct FolderCreateCall<'a, C>
945where
946    C: 'a,
947{
948    hub: &'a CloudResourceManager<C>,
949    _request: Folder,
950    _parent: Option<String>,
951    _delegate: Option<&'a mut dyn common::Delegate>,
952    _additional_params: HashMap<String, String>,
953    _scopes: BTreeSet<String>,
954}
955
956impl<'a, C> common::CallBuilder for FolderCreateCall<'a, C> {}
957
958impl<'a, C> FolderCreateCall<'a, C>
959where
960    C: common::Connector,
961{
962    /// Perform the operation you have build so far.
963    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
964        use std::borrow::Cow;
965        use std::io::{Read, Seek};
966
967        use common::{url::Params, ToParts};
968        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
969
970        let mut dd = common::DefaultDelegate;
971        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
972        dlg.begin(common::MethodInfo {
973            id: "cloudresourcemanager.folders.create",
974            http_method: hyper::Method::POST,
975        });
976
977        for &field in ["alt", "parent"].iter() {
978            if self._additional_params.contains_key(field) {
979                dlg.finished(false);
980                return Err(common::Error::FieldClash(field));
981            }
982        }
983
984        let mut params = Params::with_capacity(4 + self._additional_params.len());
985        if let Some(value) = self._parent.as_ref() {
986            params.push("parent", value);
987        }
988
989        params.extend(self._additional_params.iter());
990
991        params.push("alt", "json");
992        let mut url = self.hub._base_url.clone() + "v2/folders";
993        if self._scopes.is_empty() {
994            self._scopes
995                .insert(Scope::CloudPlatform.as_ref().to_string());
996        }
997
998        let url = params.parse_with_url(&url);
999
1000        let mut json_mime_type = mime::APPLICATION_JSON;
1001        let mut request_value_reader = {
1002            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1003            common::remove_json_null_values(&mut value);
1004            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1005            serde_json::to_writer(&mut dst, &value).unwrap();
1006            dst
1007        };
1008        let request_size = request_value_reader
1009            .seek(std::io::SeekFrom::End(0))
1010            .unwrap();
1011        request_value_reader
1012            .seek(std::io::SeekFrom::Start(0))
1013            .unwrap();
1014
1015        loop {
1016            let token = match self
1017                .hub
1018                .auth
1019                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1020                .await
1021            {
1022                Ok(token) => token,
1023                Err(e) => match dlg.token(e) {
1024                    Ok(token) => token,
1025                    Err(e) => {
1026                        dlg.finished(false);
1027                        return Err(common::Error::MissingToken(e));
1028                    }
1029                },
1030            };
1031            request_value_reader
1032                .seek(std::io::SeekFrom::Start(0))
1033                .unwrap();
1034            let mut req_result = {
1035                let client = &self.hub.client;
1036                dlg.pre_request();
1037                let mut req_builder = hyper::Request::builder()
1038                    .method(hyper::Method::POST)
1039                    .uri(url.as_str())
1040                    .header(USER_AGENT, self.hub._user_agent.clone());
1041
1042                if let Some(token) = token.as_ref() {
1043                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1044                }
1045
1046                let request = req_builder
1047                    .header(CONTENT_TYPE, json_mime_type.to_string())
1048                    .header(CONTENT_LENGTH, request_size as u64)
1049                    .body(common::to_body(
1050                        request_value_reader.get_ref().clone().into(),
1051                    ));
1052
1053                client.request(request.unwrap()).await
1054            };
1055
1056            match req_result {
1057                Err(err) => {
1058                    if let common::Retry::After(d) = dlg.http_error(&err) {
1059                        sleep(d).await;
1060                        continue;
1061                    }
1062                    dlg.finished(false);
1063                    return Err(common::Error::HttpError(err));
1064                }
1065                Ok(res) => {
1066                    let (mut parts, body) = res.into_parts();
1067                    let mut body = common::Body::new(body);
1068                    if !parts.status.is_success() {
1069                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1070                        let error = serde_json::from_str(&common::to_string(&bytes));
1071                        let response = common::to_response(parts, bytes.into());
1072
1073                        if let common::Retry::After(d) =
1074                            dlg.http_failure(&response, error.as_ref().ok())
1075                        {
1076                            sleep(d).await;
1077                            continue;
1078                        }
1079
1080                        dlg.finished(false);
1081
1082                        return Err(match error {
1083                            Ok(value) => common::Error::BadRequest(value),
1084                            _ => common::Error::Failure(response),
1085                        });
1086                    }
1087                    let response = {
1088                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1089                        let encoded = common::to_string(&bytes);
1090                        match serde_json::from_str(&encoded) {
1091                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1092                            Err(error) => {
1093                                dlg.response_json_decode_error(&encoded, &error);
1094                                return Err(common::Error::JsonDecodeError(
1095                                    encoded.to_string(),
1096                                    error,
1097                                ));
1098                            }
1099                        }
1100                    };
1101
1102                    dlg.finished(true);
1103                    return Ok(response);
1104                }
1105            }
1106        }
1107    }
1108
1109    ///
1110    /// Sets the *request* property to the given value.
1111    ///
1112    /// Even though the property as already been set when instantiating this call,
1113    /// we provide this method for API completeness.
1114    pub fn request(mut self, new_value: Folder) -> FolderCreateCall<'a, C> {
1115        self._request = new_value;
1116        self
1117    }
1118    /// Required. The resource name of the new Folder's parent. Must be of the form `folders/{folder_id}` or `organizations/{org_id}`.
1119    ///
1120    /// Sets the *parent* query property to the given value.
1121    pub fn parent(mut self, new_value: &str) -> FolderCreateCall<'a, C> {
1122        self._parent = Some(new_value.to_string());
1123        self
1124    }
1125    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1126    /// while executing the actual API request.
1127    ///
1128    /// ````text
1129    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1130    /// ````
1131    ///
1132    /// Sets the *delegate* property to the given value.
1133    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderCreateCall<'a, C> {
1134        self._delegate = Some(new_value);
1135        self
1136    }
1137
1138    /// Set any additional parameter of the query string used in the request.
1139    /// It should be used to set parameters which are not yet available through their own
1140    /// setters.
1141    ///
1142    /// Please note that this method must not be used to set any of the known parameters
1143    /// which have their own setter method. If done anyway, the request will fail.
1144    ///
1145    /// # Additional Parameters
1146    ///
1147    /// * *$.xgafv* (query-string) - V1 error format.
1148    /// * *access_token* (query-string) - OAuth access token.
1149    /// * *alt* (query-string) - Data format for response.
1150    /// * *callback* (query-string) - JSONP
1151    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1152    /// * *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.
1153    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1154    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1155    /// * *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.
1156    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1157    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1158    pub fn param<T>(mut self, name: T, value: T) -> FolderCreateCall<'a, C>
1159    where
1160        T: AsRef<str>,
1161    {
1162        self._additional_params
1163            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1164        self
1165    }
1166
1167    /// Identifies the authorization scope for the method you are building.
1168    ///
1169    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1170    /// [`Scope::CloudPlatform`].
1171    ///
1172    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1173    /// tokens for more than one scope.
1174    ///
1175    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1176    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1177    /// sufficient, a read-write scope will do as well.
1178    pub fn add_scope<St>(mut self, scope: St) -> FolderCreateCall<'a, C>
1179    where
1180        St: AsRef<str>,
1181    {
1182        self._scopes.insert(String::from(scope.as_ref()));
1183        self
1184    }
1185    /// Identifies the authorization scope(s) for the method you are building.
1186    ///
1187    /// See [`Self::add_scope()`] for details.
1188    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderCreateCall<'a, C>
1189    where
1190        I: IntoIterator<Item = St>,
1191        St: AsRef<str>,
1192    {
1193        self._scopes
1194            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1195        self
1196    }
1197
1198    /// Removes all scopes, and no default scope will be used either.
1199    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1200    /// for details).
1201    pub fn clear_scopes(mut self) -> FolderCreateCall<'a, C> {
1202        self._scopes.clear();
1203        self
1204    }
1205}
1206
1207/// Requests deletion of a Folder. The Folder is moved into the DELETE_REQUESTED state immediately, and is deleted approximately 30 days later. This method may only be called on an empty Folder in the ACTIVE state, where a Folder is empty if it doesn't contain any Folders or Projects in the ACTIVE state. The caller must have `resourcemanager.folders.delete` permission on the identified folder.
1208///
1209/// A builder for the *delete* method supported by a *folder* resource.
1210/// It is not used directly, but through a [`FolderMethods`] instance.
1211///
1212/// # Example
1213///
1214/// Instantiate a resource method builder
1215///
1216/// ```test_harness,no_run
1217/// # extern crate hyper;
1218/// # extern crate hyper_rustls;
1219/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
1220/// # async fn dox() {
1221/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1222///
1223/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1224/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1225/// #     secret,
1226/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1227/// # ).build().await.unwrap();
1228///
1229/// # let client = hyper_util::client::legacy::Client::builder(
1230/// #     hyper_util::rt::TokioExecutor::new()
1231/// # )
1232/// # .build(
1233/// #     hyper_rustls::HttpsConnectorBuilder::new()
1234/// #         .with_native_roots()
1235/// #         .unwrap()
1236/// #         .https_or_http()
1237/// #         .enable_http1()
1238/// #         .build()
1239/// # );
1240/// # let mut hub = CloudResourceManager::new(client, auth);
1241/// // You can configure optional parameters by calling the respective setters at will, and
1242/// // execute the final call using `doit()`.
1243/// // Values shown here are possibly random and not representative !
1244/// let result = hub.folders().delete("name")
1245///              .doit().await;
1246/// # }
1247/// ```
1248pub struct FolderDeleteCall<'a, C>
1249where
1250    C: 'a,
1251{
1252    hub: &'a CloudResourceManager<C>,
1253    _name: String,
1254    _delegate: Option<&'a mut dyn common::Delegate>,
1255    _additional_params: HashMap<String, String>,
1256    _scopes: BTreeSet<String>,
1257}
1258
1259impl<'a, C> common::CallBuilder for FolderDeleteCall<'a, C> {}
1260
1261impl<'a, C> FolderDeleteCall<'a, C>
1262where
1263    C: common::Connector,
1264{
1265    /// Perform the operation you have build so far.
1266    pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
1267        use std::borrow::Cow;
1268        use std::io::{Read, Seek};
1269
1270        use common::{url::Params, ToParts};
1271        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1272
1273        let mut dd = common::DefaultDelegate;
1274        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1275        dlg.begin(common::MethodInfo {
1276            id: "cloudresourcemanager.folders.delete",
1277            http_method: hyper::Method::DELETE,
1278        });
1279
1280        for &field in ["alt", "name"].iter() {
1281            if self._additional_params.contains_key(field) {
1282                dlg.finished(false);
1283                return Err(common::Error::FieldClash(field));
1284            }
1285        }
1286
1287        let mut params = Params::with_capacity(3 + self._additional_params.len());
1288        params.push("name", self._name);
1289
1290        params.extend(self._additional_params.iter());
1291
1292        params.push("alt", "json");
1293        let mut url = self.hub._base_url.clone() + "v2/{+name}";
1294        if self._scopes.is_empty() {
1295            self._scopes
1296                .insert(Scope::CloudPlatform.as_ref().to_string());
1297        }
1298
1299        #[allow(clippy::single_element_loop)]
1300        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1301            url = params.uri_replacement(url, param_name, find_this, true);
1302        }
1303        {
1304            let to_remove = ["name"];
1305            params.remove_params(&to_remove);
1306        }
1307
1308        let url = params.parse_with_url(&url);
1309
1310        loop {
1311            let token = match self
1312                .hub
1313                .auth
1314                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1315                .await
1316            {
1317                Ok(token) => token,
1318                Err(e) => match dlg.token(e) {
1319                    Ok(token) => token,
1320                    Err(e) => {
1321                        dlg.finished(false);
1322                        return Err(common::Error::MissingToken(e));
1323                    }
1324                },
1325            };
1326            let mut req_result = {
1327                let client = &self.hub.client;
1328                dlg.pre_request();
1329                let mut req_builder = hyper::Request::builder()
1330                    .method(hyper::Method::DELETE)
1331                    .uri(url.as_str())
1332                    .header(USER_AGENT, self.hub._user_agent.clone());
1333
1334                if let Some(token) = token.as_ref() {
1335                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1336                }
1337
1338                let request = req_builder
1339                    .header(CONTENT_LENGTH, 0_u64)
1340                    .body(common::to_body::<String>(None));
1341
1342                client.request(request.unwrap()).await
1343            };
1344
1345            match req_result {
1346                Err(err) => {
1347                    if let common::Retry::After(d) = dlg.http_error(&err) {
1348                        sleep(d).await;
1349                        continue;
1350                    }
1351                    dlg.finished(false);
1352                    return Err(common::Error::HttpError(err));
1353                }
1354                Ok(res) => {
1355                    let (mut parts, body) = res.into_parts();
1356                    let mut body = common::Body::new(body);
1357                    if !parts.status.is_success() {
1358                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1359                        let error = serde_json::from_str(&common::to_string(&bytes));
1360                        let response = common::to_response(parts, bytes.into());
1361
1362                        if let common::Retry::After(d) =
1363                            dlg.http_failure(&response, error.as_ref().ok())
1364                        {
1365                            sleep(d).await;
1366                            continue;
1367                        }
1368
1369                        dlg.finished(false);
1370
1371                        return Err(match error {
1372                            Ok(value) => common::Error::BadRequest(value),
1373                            _ => common::Error::Failure(response),
1374                        });
1375                    }
1376                    let response = {
1377                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1378                        let encoded = common::to_string(&bytes);
1379                        match serde_json::from_str(&encoded) {
1380                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1381                            Err(error) => {
1382                                dlg.response_json_decode_error(&encoded, &error);
1383                                return Err(common::Error::JsonDecodeError(
1384                                    encoded.to_string(),
1385                                    error,
1386                                ));
1387                            }
1388                        }
1389                    };
1390
1391                    dlg.finished(true);
1392                    return Ok(response);
1393                }
1394            }
1395        }
1396    }
1397
1398    /// Required. the resource name of the Folder to be deleted. Must be of the form `folders/{folder_id}`.
1399    ///
1400    /// Sets the *name* path property to the given value.
1401    ///
1402    /// Even though the property as already been set when instantiating this call,
1403    /// we provide this method for API completeness.
1404    pub fn name(mut self, new_value: &str) -> FolderDeleteCall<'a, C> {
1405        self._name = new_value.to_string();
1406        self
1407    }
1408    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1409    /// while executing the actual API request.
1410    ///
1411    /// ````text
1412    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1413    /// ````
1414    ///
1415    /// Sets the *delegate* property to the given value.
1416    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderDeleteCall<'a, C> {
1417        self._delegate = Some(new_value);
1418        self
1419    }
1420
1421    /// Set any additional parameter of the query string used in the request.
1422    /// It should be used to set parameters which are not yet available through their own
1423    /// setters.
1424    ///
1425    /// Please note that this method must not be used to set any of the known parameters
1426    /// which have their own setter method. If done anyway, the request will fail.
1427    ///
1428    /// # Additional Parameters
1429    ///
1430    /// * *$.xgafv* (query-string) - V1 error format.
1431    /// * *access_token* (query-string) - OAuth access token.
1432    /// * *alt* (query-string) - Data format for response.
1433    /// * *callback* (query-string) - JSONP
1434    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1435    /// * *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.
1436    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1437    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1438    /// * *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.
1439    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1440    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1441    pub fn param<T>(mut self, name: T, value: T) -> FolderDeleteCall<'a, C>
1442    where
1443        T: AsRef<str>,
1444    {
1445        self._additional_params
1446            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1447        self
1448    }
1449
1450    /// Identifies the authorization scope for the method you are building.
1451    ///
1452    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1453    /// [`Scope::CloudPlatform`].
1454    ///
1455    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1456    /// tokens for more than one scope.
1457    ///
1458    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1459    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1460    /// sufficient, a read-write scope will do as well.
1461    pub fn add_scope<St>(mut self, scope: St) -> FolderDeleteCall<'a, C>
1462    where
1463        St: AsRef<str>,
1464    {
1465        self._scopes.insert(String::from(scope.as_ref()));
1466        self
1467    }
1468    /// Identifies the authorization scope(s) for the method you are building.
1469    ///
1470    /// See [`Self::add_scope()`] for details.
1471    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderDeleteCall<'a, C>
1472    where
1473        I: IntoIterator<Item = St>,
1474        St: AsRef<str>,
1475    {
1476        self._scopes
1477            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1478        self
1479    }
1480
1481    /// Removes all scopes, and no default scope will be used either.
1482    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1483    /// for details).
1484    pub fn clear_scopes(mut self) -> FolderDeleteCall<'a, C> {
1485        self._scopes.clear();
1486        self
1487    }
1488}
1489
1490/// Retrieves a Folder identified by the supplied resource name. Valid Folder resource names have the format `folders/{folder_id}` (for example, `folders/1234`). The caller must have `resourcemanager.folders.get` permission on the identified folder.
1491///
1492/// A builder for the *get* method supported by a *folder* resource.
1493/// It is not used directly, but through a [`FolderMethods`] instance.
1494///
1495/// # Example
1496///
1497/// Instantiate a resource method builder
1498///
1499/// ```test_harness,no_run
1500/// # extern crate hyper;
1501/// # extern crate hyper_rustls;
1502/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
1503/// # async fn dox() {
1504/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1505///
1506/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1507/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1508/// #     secret,
1509/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1510/// # ).build().await.unwrap();
1511///
1512/// # let client = hyper_util::client::legacy::Client::builder(
1513/// #     hyper_util::rt::TokioExecutor::new()
1514/// # )
1515/// # .build(
1516/// #     hyper_rustls::HttpsConnectorBuilder::new()
1517/// #         .with_native_roots()
1518/// #         .unwrap()
1519/// #         .https_or_http()
1520/// #         .enable_http1()
1521/// #         .build()
1522/// # );
1523/// # let mut hub = CloudResourceManager::new(client, auth);
1524/// // You can configure optional parameters by calling the respective setters at will, and
1525/// // execute the final call using `doit()`.
1526/// // Values shown here are possibly random and not representative !
1527/// let result = hub.folders().get("name")
1528///              .doit().await;
1529/// # }
1530/// ```
1531pub struct FolderGetCall<'a, C>
1532where
1533    C: 'a,
1534{
1535    hub: &'a CloudResourceManager<C>,
1536    _name: String,
1537    _delegate: Option<&'a mut dyn common::Delegate>,
1538    _additional_params: HashMap<String, String>,
1539    _scopes: BTreeSet<String>,
1540}
1541
1542impl<'a, C> common::CallBuilder for FolderGetCall<'a, C> {}
1543
1544impl<'a, C> FolderGetCall<'a, C>
1545where
1546    C: common::Connector,
1547{
1548    /// Perform the operation you have build so far.
1549    pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
1550        use std::borrow::Cow;
1551        use std::io::{Read, Seek};
1552
1553        use common::{url::Params, ToParts};
1554        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1555
1556        let mut dd = common::DefaultDelegate;
1557        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1558        dlg.begin(common::MethodInfo {
1559            id: "cloudresourcemanager.folders.get",
1560            http_method: hyper::Method::GET,
1561        });
1562
1563        for &field in ["alt", "name"].iter() {
1564            if self._additional_params.contains_key(field) {
1565                dlg.finished(false);
1566                return Err(common::Error::FieldClash(field));
1567            }
1568        }
1569
1570        let mut params = Params::with_capacity(3 + self._additional_params.len());
1571        params.push("name", self._name);
1572
1573        params.extend(self._additional_params.iter());
1574
1575        params.push("alt", "json");
1576        let mut url = self.hub._base_url.clone() + "v2/{+name}";
1577        if self._scopes.is_empty() {
1578            self._scopes
1579                .insert(Scope::CloudPlatform.as_ref().to_string());
1580        }
1581
1582        #[allow(clippy::single_element_loop)]
1583        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1584            url = params.uri_replacement(url, param_name, find_this, true);
1585        }
1586        {
1587            let to_remove = ["name"];
1588            params.remove_params(&to_remove);
1589        }
1590
1591        let url = params.parse_with_url(&url);
1592
1593        loop {
1594            let token = match self
1595                .hub
1596                .auth
1597                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1598                .await
1599            {
1600                Ok(token) => token,
1601                Err(e) => match dlg.token(e) {
1602                    Ok(token) => token,
1603                    Err(e) => {
1604                        dlg.finished(false);
1605                        return Err(common::Error::MissingToken(e));
1606                    }
1607                },
1608            };
1609            let mut req_result = {
1610                let client = &self.hub.client;
1611                dlg.pre_request();
1612                let mut req_builder = hyper::Request::builder()
1613                    .method(hyper::Method::GET)
1614                    .uri(url.as_str())
1615                    .header(USER_AGENT, self.hub._user_agent.clone());
1616
1617                if let Some(token) = token.as_ref() {
1618                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1619                }
1620
1621                let request = req_builder
1622                    .header(CONTENT_LENGTH, 0_u64)
1623                    .body(common::to_body::<String>(None));
1624
1625                client.request(request.unwrap()).await
1626            };
1627
1628            match req_result {
1629                Err(err) => {
1630                    if let common::Retry::After(d) = dlg.http_error(&err) {
1631                        sleep(d).await;
1632                        continue;
1633                    }
1634                    dlg.finished(false);
1635                    return Err(common::Error::HttpError(err));
1636                }
1637                Ok(res) => {
1638                    let (mut parts, body) = res.into_parts();
1639                    let mut body = common::Body::new(body);
1640                    if !parts.status.is_success() {
1641                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1642                        let error = serde_json::from_str(&common::to_string(&bytes));
1643                        let response = common::to_response(parts, bytes.into());
1644
1645                        if let common::Retry::After(d) =
1646                            dlg.http_failure(&response, error.as_ref().ok())
1647                        {
1648                            sleep(d).await;
1649                            continue;
1650                        }
1651
1652                        dlg.finished(false);
1653
1654                        return Err(match error {
1655                            Ok(value) => common::Error::BadRequest(value),
1656                            _ => common::Error::Failure(response),
1657                        });
1658                    }
1659                    let response = {
1660                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1661                        let encoded = common::to_string(&bytes);
1662                        match serde_json::from_str(&encoded) {
1663                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1664                            Err(error) => {
1665                                dlg.response_json_decode_error(&encoded, &error);
1666                                return Err(common::Error::JsonDecodeError(
1667                                    encoded.to_string(),
1668                                    error,
1669                                ));
1670                            }
1671                        }
1672                    };
1673
1674                    dlg.finished(true);
1675                    return Ok(response);
1676                }
1677            }
1678        }
1679    }
1680
1681    /// Required. The resource name of the Folder to retrieve. Must be of the form `folders/{folder_id}`.
1682    ///
1683    /// Sets the *name* path property to the given value.
1684    ///
1685    /// Even though the property as already been set when instantiating this call,
1686    /// we provide this method for API completeness.
1687    pub fn name(mut self, new_value: &str) -> FolderGetCall<'a, C> {
1688        self._name = new_value.to_string();
1689        self
1690    }
1691    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1692    /// while executing the actual API request.
1693    ///
1694    /// ````text
1695    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1696    /// ````
1697    ///
1698    /// Sets the *delegate* property to the given value.
1699    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderGetCall<'a, C> {
1700        self._delegate = Some(new_value);
1701        self
1702    }
1703
1704    /// Set any additional parameter of the query string used in the request.
1705    /// It should be used to set parameters which are not yet available through their own
1706    /// setters.
1707    ///
1708    /// Please note that this method must not be used to set any of the known parameters
1709    /// which have their own setter method. If done anyway, the request will fail.
1710    ///
1711    /// # Additional Parameters
1712    ///
1713    /// * *$.xgafv* (query-string) - V1 error format.
1714    /// * *access_token* (query-string) - OAuth access token.
1715    /// * *alt* (query-string) - Data format for response.
1716    /// * *callback* (query-string) - JSONP
1717    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1718    /// * *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.
1719    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1720    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1721    /// * *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.
1722    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1723    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1724    pub fn param<T>(mut self, name: T, value: T) -> FolderGetCall<'a, C>
1725    where
1726        T: AsRef<str>,
1727    {
1728        self._additional_params
1729            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1730        self
1731    }
1732
1733    /// Identifies the authorization scope for the method you are building.
1734    ///
1735    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1736    /// [`Scope::CloudPlatform`].
1737    ///
1738    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1739    /// tokens for more than one scope.
1740    ///
1741    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1742    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1743    /// sufficient, a read-write scope will do as well.
1744    pub fn add_scope<St>(mut self, scope: St) -> FolderGetCall<'a, C>
1745    where
1746        St: AsRef<str>,
1747    {
1748        self._scopes.insert(String::from(scope.as_ref()));
1749        self
1750    }
1751    /// Identifies the authorization scope(s) for the method you are building.
1752    ///
1753    /// See [`Self::add_scope()`] for details.
1754    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetCall<'a, C>
1755    where
1756        I: IntoIterator<Item = St>,
1757        St: AsRef<str>,
1758    {
1759        self._scopes
1760            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1761        self
1762    }
1763
1764    /// Removes all scopes, and no default scope will be used either.
1765    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1766    /// for details).
1767    pub fn clear_scopes(mut self) -> FolderGetCall<'a, C> {
1768        self._scopes.clear();
1769        self
1770    }
1771}
1772
1773/// Gets the access control policy for a Folder. The returned policy may be empty if no such policy or resource exists. The `resource` field should be the Folder's resource name, e.g. "folders/1234". The caller must have `resourcemanager.folders.getIamPolicy` permission on the identified folder.
1774///
1775/// A builder for the *getIamPolicy* method supported by a *folder* resource.
1776/// It is not used directly, but through a [`FolderMethods`] instance.
1777///
1778/// # Example
1779///
1780/// Instantiate a resource method builder
1781///
1782/// ```test_harness,no_run
1783/// # extern crate hyper;
1784/// # extern crate hyper_rustls;
1785/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
1786/// use cloudresourcemanager2::api::GetIamPolicyRequest;
1787/// # async fn dox() {
1788/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1789///
1790/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1791/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1792/// #     secret,
1793/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1794/// # ).build().await.unwrap();
1795///
1796/// # let client = hyper_util::client::legacy::Client::builder(
1797/// #     hyper_util::rt::TokioExecutor::new()
1798/// # )
1799/// # .build(
1800/// #     hyper_rustls::HttpsConnectorBuilder::new()
1801/// #         .with_native_roots()
1802/// #         .unwrap()
1803/// #         .https_or_http()
1804/// #         .enable_http1()
1805/// #         .build()
1806/// # );
1807/// # let mut hub = CloudResourceManager::new(client, auth);
1808/// // As the method needs a request, you would usually fill it with the desired information
1809/// // into the respective structure. Some of the parts shown here might not be applicable !
1810/// // Values shown here are possibly random and not representative !
1811/// let mut req = GetIamPolicyRequest::default();
1812///
1813/// // You can configure optional parameters by calling the respective setters at will, and
1814/// // execute the final call using `doit()`.
1815/// // Values shown here are possibly random and not representative !
1816/// let result = hub.folders().get_iam_policy(req, "resource")
1817///              .doit().await;
1818/// # }
1819/// ```
1820pub struct FolderGetIamPolicyCall<'a, C>
1821where
1822    C: 'a,
1823{
1824    hub: &'a CloudResourceManager<C>,
1825    _request: GetIamPolicyRequest,
1826    _resource: String,
1827    _delegate: Option<&'a mut dyn common::Delegate>,
1828    _additional_params: HashMap<String, String>,
1829    _scopes: BTreeSet<String>,
1830}
1831
1832impl<'a, C> common::CallBuilder for FolderGetIamPolicyCall<'a, C> {}
1833
1834impl<'a, C> FolderGetIamPolicyCall<'a, C>
1835where
1836    C: common::Connector,
1837{
1838    /// Perform the operation you have build so far.
1839    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
1840        use std::borrow::Cow;
1841        use std::io::{Read, Seek};
1842
1843        use common::{url::Params, ToParts};
1844        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1845
1846        let mut dd = common::DefaultDelegate;
1847        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1848        dlg.begin(common::MethodInfo {
1849            id: "cloudresourcemanager.folders.getIamPolicy",
1850            http_method: hyper::Method::POST,
1851        });
1852
1853        for &field in ["alt", "resource"].iter() {
1854            if self._additional_params.contains_key(field) {
1855                dlg.finished(false);
1856                return Err(common::Error::FieldClash(field));
1857            }
1858        }
1859
1860        let mut params = Params::with_capacity(4 + self._additional_params.len());
1861        params.push("resource", self._resource);
1862
1863        params.extend(self._additional_params.iter());
1864
1865        params.push("alt", "json");
1866        let mut url = self.hub._base_url.clone() + "v2/{+resource}:getIamPolicy";
1867        if self._scopes.is_empty() {
1868            self._scopes
1869                .insert(Scope::CloudPlatform.as_ref().to_string());
1870        }
1871
1872        #[allow(clippy::single_element_loop)]
1873        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
1874            url = params.uri_replacement(url, param_name, find_this, true);
1875        }
1876        {
1877            let to_remove = ["resource"];
1878            params.remove_params(&to_remove);
1879        }
1880
1881        let url = params.parse_with_url(&url);
1882
1883        let mut json_mime_type = mime::APPLICATION_JSON;
1884        let mut request_value_reader = {
1885            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1886            common::remove_json_null_values(&mut value);
1887            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1888            serde_json::to_writer(&mut dst, &value).unwrap();
1889            dst
1890        };
1891        let request_size = request_value_reader
1892            .seek(std::io::SeekFrom::End(0))
1893            .unwrap();
1894        request_value_reader
1895            .seek(std::io::SeekFrom::Start(0))
1896            .unwrap();
1897
1898        loop {
1899            let token = match self
1900                .hub
1901                .auth
1902                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1903                .await
1904            {
1905                Ok(token) => token,
1906                Err(e) => match dlg.token(e) {
1907                    Ok(token) => token,
1908                    Err(e) => {
1909                        dlg.finished(false);
1910                        return Err(common::Error::MissingToken(e));
1911                    }
1912                },
1913            };
1914            request_value_reader
1915                .seek(std::io::SeekFrom::Start(0))
1916                .unwrap();
1917            let mut req_result = {
1918                let client = &self.hub.client;
1919                dlg.pre_request();
1920                let mut req_builder = hyper::Request::builder()
1921                    .method(hyper::Method::POST)
1922                    .uri(url.as_str())
1923                    .header(USER_AGENT, self.hub._user_agent.clone());
1924
1925                if let Some(token) = token.as_ref() {
1926                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1927                }
1928
1929                let request = req_builder
1930                    .header(CONTENT_TYPE, json_mime_type.to_string())
1931                    .header(CONTENT_LENGTH, request_size as u64)
1932                    .body(common::to_body(
1933                        request_value_reader.get_ref().clone().into(),
1934                    ));
1935
1936                client.request(request.unwrap()).await
1937            };
1938
1939            match req_result {
1940                Err(err) => {
1941                    if let common::Retry::After(d) = dlg.http_error(&err) {
1942                        sleep(d).await;
1943                        continue;
1944                    }
1945                    dlg.finished(false);
1946                    return Err(common::Error::HttpError(err));
1947                }
1948                Ok(res) => {
1949                    let (mut parts, body) = res.into_parts();
1950                    let mut body = common::Body::new(body);
1951                    if !parts.status.is_success() {
1952                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1953                        let error = serde_json::from_str(&common::to_string(&bytes));
1954                        let response = common::to_response(parts, bytes.into());
1955
1956                        if let common::Retry::After(d) =
1957                            dlg.http_failure(&response, error.as_ref().ok())
1958                        {
1959                            sleep(d).await;
1960                            continue;
1961                        }
1962
1963                        dlg.finished(false);
1964
1965                        return Err(match error {
1966                            Ok(value) => common::Error::BadRequest(value),
1967                            _ => common::Error::Failure(response),
1968                        });
1969                    }
1970                    let response = {
1971                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1972                        let encoded = common::to_string(&bytes);
1973                        match serde_json::from_str(&encoded) {
1974                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1975                            Err(error) => {
1976                                dlg.response_json_decode_error(&encoded, &error);
1977                                return Err(common::Error::JsonDecodeError(
1978                                    encoded.to_string(),
1979                                    error,
1980                                ));
1981                            }
1982                        }
1983                    };
1984
1985                    dlg.finished(true);
1986                    return Ok(response);
1987                }
1988            }
1989        }
1990    }
1991
1992    ///
1993    /// Sets the *request* property to the given value.
1994    ///
1995    /// Even though the property as already been set when instantiating this call,
1996    /// we provide this method for API completeness.
1997    pub fn request(mut self, new_value: GetIamPolicyRequest) -> FolderGetIamPolicyCall<'a, C> {
1998        self._request = new_value;
1999        self
2000    }
2001    /// 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.
2002    ///
2003    /// Sets the *resource* path property to the given value.
2004    ///
2005    /// Even though the property as already been set when instantiating this call,
2006    /// we provide this method for API completeness.
2007    pub fn resource(mut self, new_value: &str) -> FolderGetIamPolicyCall<'a, C> {
2008        self._resource = new_value.to_string();
2009        self
2010    }
2011    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2012    /// while executing the actual API request.
2013    ///
2014    /// ````text
2015    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2016    /// ````
2017    ///
2018    /// Sets the *delegate* property to the given value.
2019    pub fn delegate(
2020        mut self,
2021        new_value: &'a mut dyn common::Delegate,
2022    ) -> FolderGetIamPolicyCall<'a, C> {
2023        self._delegate = Some(new_value);
2024        self
2025    }
2026
2027    /// Set any additional parameter of the query string used in the request.
2028    /// It should be used to set parameters which are not yet available through their own
2029    /// setters.
2030    ///
2031    /// Please note that this method must not be used to set any of the known parameters
2032    /// which have their own setter method. If done anyway, the request will fail.
2033    ///
2034    /// # Additional Parameters
2035    ///
2036    /// * *$.xgafv* (query-string) - V1 error format.
2037    /// * *access_token* (query-string) - OAuth access token.
2038    /// * *alt* (query-string) - Data format for response.
2039    /// * *callback* (query-string) - JSONP
2040    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2041    /// * *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.
2042    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2043    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2044    /// * *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.
2045    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2046    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2047    pub fn param<T>(mut self, name: T, value: T) -> FolderGetIamPolicyCall<'a, C>
2048    where
2049        T: AsRef<str>,
2050    {
2051        self._additional_params
2052            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2053        self
2054    }
2055
2056    /// Identifies the authorization scope for the method you are building.
2057    ///
2058    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2059    /// [`Scope::CloudPlatform`].
2060    ///
2061    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2062    /// tokens for more than one scope.
2063    ///
2064    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2065    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2066    /// sufficient, a read-write scope will do as well.
2067    pub fn add_scope<St>(mut self, scope: St) -> FolderGetIamPolicyCall<'a, C>
2068    where
2069        St: AsRef<str>,
2070    {
2071        self._scopes.insert(String::from(scope.as_ref()));
2072        self
2073    }
2074    /// Identifies the authorization scope(s) for the method you are building.
2075    ///
2076    /// See [`Self::add_scope()`] for details.
2077    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetIamPolicyCall<'a, C>
2078    where
2079        I: IntoIterator<Item = St>,
2080        St: AsRef<str>,
2081    {
2082        self._scopes
2083            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2084        self
2085    }
2086
2087    /// Removes all scopes, and no default scope will be used either.
2088    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2089    /// for details).
2090    pub fn clear_scopes(mut self) -> FolderGetIamPolicyCall<'a, C> {
2091        self._scopes.clear();
2092        self
2093    }
2094}
2095
2096/// Lists the Folders that are direct descendants of supplied parent resource. List provides a strongly consistent view of the Folders underneath the specified parent resource. List returns Folders sorted based upon the (ascending) lexical ordering of their display_name. The caller must have `resourcemanager.folders.list` permission on the identified parent.
2097///
2098/// A builder for the *list* method supported by a *folder* resource.
2099/// It is not used directly, but through a [`FolderMethods`] instance.
2100///
2101/// # Example
2102///
2103/// Instantiate a resource method builder
2104///
2105/// ```test_harness,no_run
2106/// # extern crate hyper;
2107/// # extern crate hyper_rustls;
2108/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
2109/// # async fn dox() {
2110/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2111///
2112/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2113/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2114/// #     secret,
2115/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2116/// # ).build().await.unwrap();
2117///
2118/// # let client = hyper_util::client::legacy::Client::builder(
2119/// #     hyper_util::rt::TokioExecutor::new()
2120/// # )
2121/// # .build(
2122/// #     hyper_rustls::HttpsConnectorBuilder::new()
2123/// #         .with_native_roots()
2124/// #         .unwrap()
2125/// #         .https_or_http()
2126/// #         .enable_http1()
2127/// #         .build()
2128/// # );
2129/// # let mut hub = CloudResourceManager::new(client, auth);
2130/// // You can configure optional parameters by calling the respective setters at will, and
2131/// // execute the final call using `doit()`.
2132/// // Values shown here are possibly random and not representative !
2133/// let result = hub.folders().list()
2134///              .show_deleted(false)
2135///              .parent("amet")
2136///              .page_token("duo")
2137///              .page_size(-50)
2138///              .doit().await;
2139/// # }
2140/// ```
2141pub struct FolderListCall<'a, C>
2142where
2143    C: 'a,
2144{
2145    hub: &'a CloudResourceManager<C>,
2146    _show_deleted: Option<bool>,
2147    _parent: Option<String>,
2148    _page_token: Option<String>,
2149    _page_size: Option<i32>,
2150    _delegate: Option<&'a mut dyn common::Delegate>,
2151    _additional_params: HashMap<String, String>,
2152    _scopes: BTreeSet<String>,
2153}
2154
2155impl<'a, C> common::CallBuilder for FolderListCall<'a, C> {}
2156
2157impl<'a, C> FolderListCall<'a, C>
2158where
2159    C: common::Connector,
2160{
2161    /// Perform the operation you have build so far.
2162    pub async fn doit(mut self) -> common::Result<(common::Response, ListFoldersResponse)> {
2163        use std::borrow::Cow;
2164        use std::io::{Read, Seek};
2165
2166        use common::{url::Params, ToParts};
2167        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2168
2169        let mut dd = common::DefaultDelegate;
2170        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2171        dlg.begin(common::MethodInfo {
2172            id: "cloudresourcemanager.folders.list",
2173            http_method: hyper::Method::GET,
2174        });
2175
2176        for &field in ["alt", "showDeleted", "parent", "pageToken", "pageSize"].iter() {
2177            if self._additional_params.contains_key(field) {
2178                dlg.finished(false);
2179                return Err(common::Error::FieldClash(field));
2180            }
2181        }
2182
2183        let mut params = Params::with_capacity(6 + self._additional_params.len());
2184        if let Some(value) = self._show_deleted.as_ref() {
2185            params.push("showDeleted", value.to_string());
2186        }
2187        if let Some(value) = self._parent.as_ref() {
2188            params.push("parent", value);
2189        }
2190        if let Some(value) = self._page_token.as_ref() {
2191            params.push("pageToken", value);
2192        }
2193        if let Some(value) = self._page_size.as_ref() {
2194            params.push("pageSize", value.to_string());
2195        }
2196
2197        params.extend(self._additional_params.iter());
2198
2199        params.push("alt", "json");
2200        let mut url = self.hub._base_url.clone() + "v2/folders";
2201        if self._scopes.is_empty() {
2202            self._scopes
2203                .insert(Scope::CloudPlatform.as_ref().to_string());
2204        }
2205
2206        let url = params.parse_with_url(&url);
2207
2208        loop {
2209            let token = match self
2210                .hub
2211                .auth
2212                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2213                .await
2214            {
2215                Ok(token) => token,
2216                Err(e) => match dlg.token(e) {
2217                    Ok(token) => token,
2218                    Err(e) => {
2219                        dlg.finished(false);
2220                        return Err(common::Error::MissingToken(e));
2221                    }
2222                },
2223            };
2224            let mut req_result = {
2225                let client = &self.hub.client;
2226                dlg.pre_request();
2227                let mut req_builder = hyper::Request::builder()
2228                    .method(hyper::Method::GET)
2229                    .uri(url.as_str())
2230                    .header(USER_AGENT, self.hub._user_agent.clone());
2231
2232                if let Some(token) = token.as_ref() {
2233                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2234                }
2235
2236                let request = req_builder
2237                    .header(CONTENT_LENGTH, 0_u64)
2238                    .body(common::to_body::<String>(None));
2239
2240                client.request(request.unwrap()).await
2241            };
2242
2243            match req_result {
2244                Err(err) => {
2245                    if let common::Retry::After(d) = dlg.http_error(&err) {
2246                        sleep(d).await;
2247                        continue;
2248                    }
2249                    dlg.finished(false);
2250                    return Err(common::Error::HttpError(err));
2251                }
2252                Ok(res) => {
2253                    let (mut parts, body) = res.into_parts();
2254                    let mut body = common::Body::new(body);
2255                    if !parts.status.is_success() {
2256                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2257                        let error = serde_json::from_str(&common::to_string(&bytes));
2258                        let response = common::to_response(parts, bytes.into());
2259
2260                        if let common::Retry::After(d) =
2261                            dlg.http_failure(&response, error.as_ref().ok())
2262                        {
2263                            sleep(d).await;
2264                            continue;
2265                        }
2266
2267                        dlg.finished(false);
2268
2269                        return Err(match error {
2270                            Ok(value) => common::Error::BadRequest(value),
2271                            _ => common::Error::Failure(response),
2272                        });
2273                    }
2274                    let response = {
2275                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2276                        let encoded = common::to_string(&bytes);
2277                        match serde_json::from_str(&encoded) {
2278                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2279                            Err(error) => {
2280                                dlg.response_json_decode_error(&encoded, &error);
2281                                return Err(common::Error::JsonDecodeError(
2282                                    encoded.to_string(),
2283                                    error,
2284                                ));
2285                            }
2286                        }
2287                    };
2288
2289                    dlg.finished(true);
2290                    return Ok(response);
2291                }
2292            }
2293        }
2294    }
2295
2296    /// Optional. Controls whether Folders in the DELETE_REQUESTED state should be returned. Defaults to false.
2297    ///
2298    /// Sets the *show deleted* query property to the given value.
2299    pub fn show_deleted(mut self, new_value: bool) -> FolderListCall<'a, C> {
2300        self._show_deleted = Some(new_value);
2301        self
2302    }
2303    /// Required. The resource name of the Organization or Folder whose Folders are being listed. Must be of the form `folders/{folder_id}` or `organizations/{org_id}`. Access to this method is controlled by checking the `resourcemanager.folders.list` permission on the `parent`.
2304    ///
2305    /// Sets the *parent* query property to the given value.
2306    pub fn parent(mut self, new_value: &str) -> FolderListCall<'a, C> {
2307        self._parent = Some(new_value.to_string());
2308        self
2309    }
2310    /// Optional. A pagination token returned from a previous call to `ListFolders` that indicates where this listing should continue from.
2311    ///
2312    /// Sets the *page token* query property to the given value.
2313    pub fn page_token(mut self, new_value: &str) -> FolderListCall<'a, C> {
2314        self._page_token = Some(new_value.to_string());
2315        self
2316    }
2317    /// Optional. The maximum number of Folders to return in the response. The server can return fewer folders than requested. If unspecified, server picks an appropriate default.
2318    ///
2319    /// Sets the *page size* query property to the given value.
2320    pub fn page_size(mut self, new_value: i32) -> FolderListCall<'a, C> {
2321        self._page_size = Some(new_value);
2322        self
2323    }
2324    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2325    /// while executing the actual API request.
2326    ///
2327    /// ````text
2328    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2329    /// ````
2330    ///
2331    /// Sets the *delegate* property to the given value.
2332    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderListCall<'a, C> {
2333        self._delegate = Some(new_value);
2334        self
2335    }
2336
2337    /// Set any additional parameter of the query string used in the request.
2338    /// It should be used to set parameters which are not yet available through their own
2339    /// setters.
2340    ///
2341    /// Please note that this method must not be used to set any of the known parameters
2342    /// which have their own setter method. If done anyway, the request will fail.
2343    ///
2344    /// # Additional Parameters
2345    ///
2346    /// * *$.xgafv* (query-string) - V1 error format.
2347    /// * *access_token* (query-string) - OAuth access token.
2348    /// * *alt* (query-string) - Data format for response.
2349    /// * *callback* (query-string) - JSONP
2350    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2351    /// * *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.
2352    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2353    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2354    /// * *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.
2355    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2356    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2357    pub fn param<T>(mut self, name: T, value: T) -> FolderListCall<'a, C>
2358    where
2359        T: AsRef<str>,
2360    {
2361        self._additional_params
2362            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2363        self
2364    }
2365
2366    /// Identifies the authorization scope for the method you are building.
2367    ///
2368    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2369    /// [`Scope::CloudPlatform`].
2370    ///
2371    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2372    /// tokens for more than one scope.
2373    ///
2374    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2375    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2376    /// sufficient, a read-write scope will do as well.
2377    pub fn add_scope<St>(mut self, scope: St) -> FolderListCall<'a, C>
2378    where
2379        St: AsRef<str>,
2380    {
2381        self._scopes.insert(String::from(scope.as_ref()));
2382        self
2383    }
2384    /// Identifies the authorization scope(s) for the method you are building.
2385    ///
2386    /// See [`Self::add_scope()`] for details.
2387    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderListCall<'a, C>
2388    where
2389        I: IntoIterator<Item = St>,
2390        St: AsRef<str>,
2391    {
2392        self._scopes
2393            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2394        self
2395    }
2396
2397    /// Removes all scopes, and no default scope will be used either.
2398    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2399    /// for details).
2400    pub fn clear_scopes(mut self) -> FolderListCall<'a, C> {
2401        self._scopes.clear();
2402        self
2403    }
2404}
2405
2406/// Moves a Folder under a new resource parent. Returns an Operation which can be used to track the progress of the folder move workflow. Upon success the Operation.response field will be populated with the moved Folder. Upon failure, a FolderOperationError categorizing the failure cause will be returned - if the failure occurs synchronously then the FolderOperationError will be returned via the Status.details field and if it occurs asynchronously then the FolderOperation will be returned via the Operation.error field. In addition, the Operation.metadata field will be populated with a FolderOperation message as an aid to stateless clients. Folder moves will be rejected if they violate either the naming, height or fanout constraints described in the CreateFolder documentation. The caller must have `resourcemanager.folders.move` permission on the folder's current and proposed new parent.
2407///
2408/// A builder for the *move* method supported by a *folder* resource.
2409/// It is not used directly, but through a [`FolderMethods`] instance.
2410///
2411/// # Example
2412///
2413/// Instantiate a resource method builder
2414///
2415/// ```test_harness,no_run
2416/// # extern crate hyper;
2417/// # extern crate hyper_rustls;
2418/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
2419/// use cloudresourcemanager2::api::MoveFolderRequest;
2420/// # async fn dox() {
2421/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2422///
2423/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2424/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2425/// #     secret,
2426/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2427/// # ).build().await.unwrap();
2428///
2429/// # let client = hyper_util::client::legacy::Client::builder(
2430/// #     hyper_util::rt::TokioExecutor::new()
2431/// # )
2432/// # .build(
2433/// #     hyper_rustls::HttpsConnectorBuilder::new()
2434/// #         .with_native_roots()
2435/// #         .unwrap()
2436/// #         .https_or_http()
2437/// #         .enable_http1()
2438/// #         .build()
2439/// # );
2440/// # let mut hub = CloudResourceManager::new(client, auth);
2441/// // As the method needs a request, you would usually fill it with the desired information
2442/// // into the respective structure. Some of the parts shown here might not be applicable !
2443/// // Values shown here are possibly random and not representative !
2444/// let mut req = MoveFolderRequest::default();
2445///
2446/// // You can configure optional parameters by calling the respective setters at will, and
2447/// // execute the final call using `doit()`.
2448/// // Values shown here are possibly random and not representative !
2449/// let result = hub.folders().move_(req, "name")
2450///              .doit().await;
2451/// # }
2452/// ```
2453pub struct FolderMoveCall<'a, C>
2454where
2455    C: 'a,
2456{
2457    hub: &'a CloudResourceManager<C>,
2458    _request: MoveFolderRequest,
2459    _name: String,
2460    _delegate: Option<&'a mut dyn common::Delegate>,
2461    _additional_params: HashMap<String, String>,
2462    _scopes: BTreeSet<String>,
2463}
2464
2465impl<'a, C> common::CallBuilder for FolderMoveCall<'a, C> {}
2466
2467impl<'a, C> FolderMoveCall<'a, C>
2468where
2469    C: common::Connector,
2470{
2471    /// Perform the operation you have build so far.
2472    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2473        use std::borrow::Cow;
2474        use std::io::{Read, Seek};
2475
2476        use common::{url::Params, ToParts};
2477        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2478
2479        let mut dd = common::DefaultDelegate;
2480        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2481        dlg.begin(common::MethodInfo {
2482            id: "cloudresourcemanager.folders.move",
2483            http_method: hyper::Method::POST,
2484        });
2485
2486        for &field in ["alt", "name"].iter() {
2487            if self._additional_params.contains_key(field) {
2488                dlg.finished(false);
2489                return Err(common::Error::FieldClash(field));
2490            }
2491        }
2492
2493        let mut params = Params::with_capacity(4 + self._additional_params.len());
2494        params.push("name", self._name);
2495
2496        params.extend(self._additional_params.iter());
2497
2498        params.push("alt", "json");
2499        let mut url = self.hub._base_url.clone() + "v2/{+name}:move";
2500        if self._scopes.is_empty() {
2501            self._scopes
2502                .insert(Scope::CloudPlatform.as_ref().to_string());
2503        }
2504
2505        #[allow(clippy::single_element_loop)]
2506        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2507            url = params.uri_replacement(url, param_name, find_this, true);
2508        }
2509        {
2510            let to_remove = ["name"];
2511            params.remove_params(&to_remove);
2512        }
2513
2514        let url = params.parse_with_url(&url);
2515
2516        let mut json_mime_type = mime::APPLICATION_JSON;
2517        let mut request_value_reader = {
2518            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2519            common::remove_json_null_values(&mut value);
2520            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2521            serde_json::to_writer(&mut dst, &value).unwrap();
2522            dst
2523        };
2524        let request_size = request_value_reader
2525            .seek(std::io::SeekFrom::End(0))
2526            .unwrap();
2527        request_value_reader
2528            .seek(std::io::SeekFrom::Start(0))
2529            .unwrap();
2530
2531        loop {
2532            let token = match self
2533                .hub
2534                .auth
2535                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2536                .await
2537            {
2538                Ok(token) => token,
2539                Err(e) => match dlg.token(e) {
2540                    Ok(token) => token,
2541                    Err(e) => {
2542                        dlg.finished(false);
2543                        return Err(common::Error::MissingToken(e));
2544                    }
2545                },
2546            };
2547            request_value_reader
2548                .seek(std::io::SeekFrom::Start(0))
2549                .unwrap();
2550            let mut req_result = {
2551                let client = &self.hub.client;
2552                dlg.pre_request();
2553                let mut req_builder = hyper::Request::builder()
2554                    .method(hyper::Method::POST)
2555                    .uri(url.as_str())
2556                    .header(USER_AGENT, self.hub._user_agent.clone());
2557
2558                if let Some(token) = token.as_ref() {
2559                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2560                }
2561
2562                let request = req_builder
2563                    .header(CONTENT_TYPE, json_mime_type.to_string())
2564                    .header(CONTENT_LENGTH, request_size as u64)
2565                    .body(common::to_body(
2566                        request_value_reader.get_ref().clone().into(),
2567                    ));
2568
2569                client.request(request.unwrap()).await
2570            };
2571
2572            match req_result {
2573                Err(err) => {
2574                    if let common::Retry::After(d) = dlg.http_error(&err) {
2575                        sleep(d).await;
2576                        continue;
2577                    }
2578                    dlg.finished(false);
2579                    return Err(common::Error::HttpError(err));
2580                }
2581                Ok(res) => {
2582                    let (mut parts, body) = res.into_parts();
2583                    let mut body = common::Body::new(body);
2584                    if !parts.status.is_success() {
2585                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2586                        let error = serde_json::from_str(&common::to_string(&bytes));
2587                        let response = common::to_response(parts, bytes.into());
2588
2589                        if let common::Retry::After(d) =
2590                            dlg.http_failure(&response, error.as_ref().ok())
2591                        {
2592                            sleep(d).await;
2593                            continue;
2594                        }
2595
2596                        dlg.finished(false);
2597
2598                        return Err(match error {
2599                            Ok(value) => common::Error::BadRequest(value),
2600                            _ => common::Error::Failure(response),
2601                        });
2602                    }
2603                    let response = {
2604                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2605                        let encoded = common::to_string(&bytes);
2606                        match serde_json::from_str(&encoded) {
2607                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2608                            Err(error) => {
2609                                dlg.response_json_decode_error(&encoded, &error);
2610                                return Err(common::Error::JsonDecodeError(
2611                                    encoded.to_string(),
2612                                    error,
2613                                ));
2614                            }
2615                        }
2616                    };
2617
2618                    dlg.finished(true);
2619                    return Ok(response);
2620                }
2621            }
2622        }
2623    }
2624
2625    ///
2626    /// Sets the *request* property to the given value.
2627    ///
2628    /// Even though the property as already been set when instantiating this call,
2629    /// we provide this method for API completeness.
2630    pub fn request(mut self, new_value: MoveFolderRequest) -> FolderMoveCall<'a, C> {
2631        self._request = new_value;
2632        self
2633    }
2634    /// Required. The resource name of the Folder to move. Must be of the form folders/{folder_id}
2635    ///
2636    /// Sets the *name* path property to the given value.
2637    ///
2638    /// Even though the property as already been set when instantiating this call,
2639    /// we provide this method for API completeness.
2640    pub fn name(mut self, new_value: &str) -> FolderMoveCall<'a, C> {
2641        self._name = new_value.to_string();
2642        self
2643    }
2644    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2645    /// while executing the actual API request.
2646    ///
2647    /// ````text
2648    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2649    /// ````
2650    ///
2651    /// Sets the *delegate* property to the given value.
2652    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderMoveCall<'a, C> {
2653        self._delegate = Some(new_value);
2654        self
2655    }
2656
2657    /// Set any additional parameter of the query string used in the request.
2658    /// It should be used to set parameters which are not yet available through their own
2659    /// setters.
2660    ///
2661    /// Please note that this method must not be used to set any of the known parameters
2662    /// which have their own setter method. If done anyway, the request will fail.
2663    ///
2664    /// # Additional Parameters
2665    ///
2666    /// * *$.xgafv* (query-string) - V1 error format.
2667    /// * *access_token* (query-string) - OAuth access token.
2668    /// * *alt* (query-string) - Data format for response.
2669    /// * *callback* (query-string) - JSONP
2670    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2671    /// * *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.
2672    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2673    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2674    /// * *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.
2675    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2676    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2677    pub fn param<T>(mut self, name: T, value: T) -> FolderMoveCall<'a, C>
2678    where
2679        T: AsRef<str>,
2680    {
2681        self._additional_params
2682            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2683        self
2684    }
2685
2686    /// Identifies the authorization scope for the method you are building.
2687    ///
2688    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2689    /// [`Scope::CloudPlatform`].
2690    ///
2691    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2692    /// tokens for more than one scope.
2693    ///
2694    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2695    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2696    /// sufficient, a read-write scope will do as well.
2697    pub fn add_scope<St>(mut self, scope: St) -> FolderMoveCall<'a, C>
2698    where
2699        St: AsRef<str>,
2700    {
2701        self._scopes.insert(String::from(scope.as_ref()));
2702        self
2703    }
2704    /// Identifies the authorization scope(s) for the method you are building.
2705    ///
2706    /// See [`Self::add_scope()`] for details.
2707    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderMoveCall<'a, C>
2708    where
2709        I: IntoIterator<Item = St>,
2710        St: AsRef<str>,
2711    {
2712        self._scopes
2713            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2714        self
2715    }
2716
2717    /// Removes all scopes, and no default scope will be used either.
2718    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2719    /// for details).
2720    pub fn clear_scopes(mut self) -> FolderMoveCall<'a, C> {
2721        self._scopes.clear();
2722        self
2723    }
2724}
2725
2726/// Updates a Folder, changing its display_name. Changes to the folder display_name will be rejected if they violate either the display_name formatting rules or naming constraints described in the CreateFolder documentation. The Folder's display name must start and end with a letter or digit, may contain letters, digits, spaces, hyphens and underscores and can be between 3 and 30 characters. This is captured by the regular expression: `\p{L}\p{N}{1,28}[\p{L}\p{N}]`. The caller must have `resourcemanager.folders.update` permission on the identified folder. If the update fails due to the unique name constraint then a PreconditionFailure explaining this violation will be returned in the Status.details field.
2727///
2728/// A builder for the *patch* method supported by a *folder* resource.
2729/// It is not used directly, but through a [`FolderMethods`] instance.
2730///
2731/// # Example
2732///
2733/// Instantiate a resource method builder
2734///
2735/// ```test_harness,no_run
2736/// # extern crate hyper;
2737/// # extern crate hyper_rustls;
2738/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
2739/// use cloudresourcemanager2::api::Folder;
2740/// # async fn dox() {
2741/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2742///
2743/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2744/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2745/// #     secret,
2746/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2747/// # ).build().await.unwrap();
2748///
2749/// # let client = hyper_util::client::legacy::Client::builder(
2750/// #     hyper_util::rt::TokioExecutor::new()
2751/// # )
2752/// # .build(
2753/// #     hyper_rustls::HttpsConnectorBuilder::new()
2754/// #         .with_native_roots()
2755/// #         .unwrap()
2756/// #         .https_or_http()
2757/// #         .enable_http1()
2758/// #         .build()
2759/// # );
2760/// # let mut hub = CloudResourceManager::new(client, auth);
2761/// // As the method needs a request, you would usually fill it with the desired information
2762/// // into the respective structure. Some of the parts shown here might not be applicable !
2763/// // Values shown here are possibly random and not representative !
2764/// let mut req = Folder::default();
2765///
2766/// // You can configure optional parameters by calling the respective setters at will, and
2767/// // execute the final call using `doit()`.
2768/// // Values shown here are possibly random and not representative !
2769/// let result = hub.folders().patch(req, "name")
2770///              .update_mask(FieldMask::new::<&str>(&[]))
2771///              .doit().await;
2772/// # }
2773/// ```
2774pub struct FolderPatchCall<'a, C>
2775where
2776    C: 'a,
2777{
2778    hub: &'a CloudResourceManager<C>,
2779    _request: Folder,
2780    _name: String,
2781    _update_mask: Option<common::FieldMask>,
2782    _delegate: Option<&'a mut dyn common::Delegate>,
2783    _additional_params: HashMap<String, String>,
2784    _scopes: BTreeSet<String>,
2785}
2786
2787impl<'a, C> common::CallBuilder for FolderPatchCall<'a, C> {}
2788
2789impl<'a, C> FolderPatchCall<'a, C>
2790where
2791    C: common::Connector,
2792{
2793    /// Perform the operation you have build so far.
2794    pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
2795        use std::borrow::Cow;
2796        use std::io::{Read, Seek};
2797
2798        use common::{url::Params, ToParts};
2799        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2800
2801        let mut dd = common::DefaultDelegate;
2802        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2803        dlg.begin(common::MethodInfo {
2804            id: "cloudresourcemanager.folders.patch",
2805            http_method: hyper::Method::PATCH,
2806        });
2807
2808        for &field in ["alt", "name", "updateMask"].iter() {
2809            if self._additional_params.contains_key(field) {
2810                dlg.finished(false);
2811                return Err(common::Error::FieldClash(field));
2812            }
2813        }
2814
2815        let mut params = Params::with_capacity(5 + self._additional_params.len());
2816        params.push("name", self._name);
2817        if let Some(value) = self._update_mask.as_ref() {
2818            params.push("updateMask", value.to_string());
2819        }
2820
2821        params.extend(self._additional_params.iter());
2822
2823        params.push("alt", "json");
2824        let mut url = self.hub._base_url.clone() + "v2/{+name}";
2825        if self._scopes.is_empty() {
2826            self._scopes
2827                .insert(Scope::CloudPlatform.as_ref().to_string());
2828        }
2829
2830        #[allow(clippy::single_element_loop)]
2831        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2832            url = params.uri_replacement(url, param_name, find_this, true);
2833        }
2834        {
2835            let to_remove = ["name"];
2836            params.remove_params(&to_remove);
2837        }
2838
2839        let url = params.parse_with_url(&url);
2840
2841        let mut json_mime_type = mime::APPLICATION_JSON;
2842        let mut request_value_reader = {
2843            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2844            common::remove_json_null_values(&mut value);
2845            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2846            serde_json::to_writer(&mut dst, &value).unwrap();
2847            dst
2848        };
2849        let request_size = request_value_reader
2850            .seek(std::io::SeekFrom::End(0))
2851            .unwrap();
2852        request_value_reader
2853            .seek(std::io::SeekFrom::Start(0))
2854            .unwrap();
2855
2856        loop {
2857            let token = match self
2858                .hub
2859                .auth
2860                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2861                .await
2862            {
2863                Ok(token) => token,
2864                Err(e) => match dlg.token(e) {
2865                    Ok(token) => token,
2866                    Err(e) => {
2867                        dlg.finished(false);
2868                        return Err(common::Error::MissingToken(e));
2869                    }
2870                },
2871            };
2872            request_value_reader
2873                .seek(std::io::SeekFrom::Start(0))
2874                .unwrap();
2875            let mut req_result = {
2876                let client = &self.hub.client;
2877                dlg.pre_request();
2878                let mut req_builder = hyper::Request::builder()
2879                    .method(hyper::Method::PATCH)
2880                    .uri(url.as_str())
2881                    .header(USER_AGENT, self.hub._user_agent.clone());
2882
2883                if let Some(token) = token.as_ref() {
2884                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2885                }
2886
2887                let request = req_builder
2888                    .header(CONTENT_TYPE, json_mime_type.to_string())
2889                    .header(CONTENT_LENGTH, request_size as u64)
2890                    .body(common::to_body(
2891                        request_value_reader.get_ref().clone().into(),
2892                    ));
2893
2894                client.request(request.unwrap()).await
2895            };
2896
2897            match req_result {
2898                Err(err) => {
2899                    if let common::Retry::After(d) = dlg.http_error(&err) {
2900                        sleep(d).await;
2901                        continue;
2902                    }
2903                    dlg.finished(false);
2904                    return Err(common::Error::HttpError(err));
2905                }
2906                Ok(res) => {
2907                    let (mut parts, body) = res.into_parts();
2908                    let mut body = common::Body::new(body);
2909                    if !parts.status.is_success() {
2910                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2911                        let error = serde_json::from_str(&common::to_string(&bytes));
2912                        let response = common::to_response(parts, bytes.into());
2913
2914                        if let common::Retry::After(d) =
2915                            dlg.http_failure(&response, error.as_ref().ok())
2916                        {
2917                            sleep(d).await;
2918                            continue;
2919                        }
2920
2921                        dlg.finished(false);
2922
2923                        return Err(match error {
2924                            Ok(value) => common::Error::BadRequest(value),
2925                            _ => common::Error::Failure(response),
2926                        });
2927                    }
2928                    let response = {
2929                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2930                        let encoded = common::to_string(&bytes);
2931                        match serde_json::from_str(&encoded) {
2932                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2933                            Err(error) => {
2934                                dlg.response_json_decode_error(&encoded, &error);
2935                                return Err(common::Error::JsonDecodeError(
2936                                    encoded.to_string(),
2937                                    error,
2938                                ));
2939                            }
2940                        }
2941                    };
2942
2943                    dlg.finished(true);
2944                    return Ok(response);
2945                }
2946            }
2947        }
2948    }
2949
2950    ///
2951    /// Sets the *request* property to the given value.
2952    ///
2953    /// Even though the property as already been set when instantiating this call,
2954    /// we provide this method for API completeness.
2955    pub fn request(mut self, new_value: Folder) -> FolderPatchCall<'a, C> {
2956        self._request = new_value;
2957        self
2958    }
2959    /// Output only. The resource name of the Folder. Its format is `folders/{folder_id}`, for example: "folders/1234".
2960    ///
2961    /// Sets the *name* path property to the given value.
2962    ///
2963    /// Even though the property as already been set when instantiating this call,
2964    /// we provide this method for API completeness.
2965    pub fn name(mut self, new_value: &str) -> FolderPatchCall<'a, C> {
2966        self._name = new_value.to_string();
2967        self
2968    }
2969    /// Required. Fields to be updated. Only the `display_name` can be updated.
2970    ///
2971    /// Sets the *update mask* query property to the given value.
2972    pub fn update_mask(mut self, new_value: common::FieldMask) -> FolderPatchCall<'a, C> {
2973        self._update_mask = Some(new_value);
2974        self
2975    }
2976    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2977    /// while executing the actual API request.
2978    ///
2979    /// ````text
2980    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2981    /// ````
2982    ///
2983    /// Sets the *delegate* property to the given value.
2984    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderPatchCall<'a, C> {
2985        self._delegate = Some(new_value);
2986        self
2987    }
2988
2989    /// Set any additional parameter of the query string used in the request.
2990    /// It should be used to set parameters which are not yet available through their own
2991    /// setters.
2992    ///
2993    /// Please note that this method must not be used to set any of the known parameters
2994    /// which have their own setter method. If done anyway, the request will fail.
2995    ///
2996    /// # Additional Parameters
2997    ///
2998    /// * *$.xgafv* (query-string) - V1 error format.
2999    /// * *access_token* (query-string) - OAuth access token.
3000    /// * *alt* (query-string) - Data format for response.
3001    /// * *callback* (query-string) - JSONP
3002    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3003    /// * *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.
3004    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3005    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3006    /// * *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.
3007    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3008    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3009    pub fn param<T>(mut self, name: T, value: T) -> FolderPatchCall<'a, C>
3010    where
3011        T: AsRef<str>,
3012    {
3013        self._additional_params
3014            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3015        self
3016    }
3017
3018    /// Identifies the authorization scope for the method you are building.
3019    ///
3020    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3021    /// [`Scope::CloudPlatform`].
3022    ///
3023    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3024    /// tokens for more than one scope.
3025    ///
3026    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3027    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3028    /// sufficient, a read-write scope will do as well.
3029    pub fn add_scope<St>(mut self, scope: St) -> FolderPatchCall<'a, C>
3030    where
3031        St: AsRef<str>,
3032    {
3033        self._scopes.insert(String::from(scope.as_ref()));
3034        self
3035    }
3036    /// Identifies the authorization scope(s) for the method you are building.
3037    ///
3038    /// See [`Self::add_scope()`] for details.
3039    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderPatchCall<'a, C>
3040    where
3041        I: IntoIterator<Item = St>,
3042        St: AsRef<str>,
3043    {
3044        self._scopes
3045            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3046        self
3047    }
3048
3049    /// Removes all scopes, and no default scope will be used either.
3050    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3051    /// for details).
3052    pub fn clear_scopes(mut self) -> FolderPatchCall<'a, C> {
3053        self._scopes.clear();
3054        self
3055    }
3056}
3057
3058/// Search for folders that match specific filter criteria. Search provides an eventually consistent view of the folders a user has access to which meet the specified filter criteria. This will only return folders on which the caller has the permission `resourcemanager.folders.get`.
3059///
3060/// A builder for the *search* method supported by a *folder* resource.
3061/// It is not used directly, but through a [`FolderMethods`] instance.
3062///
3063/// # Example
3064///
3065/// Instantiate a resource method builder
3066///
3067/// ```test_harness,no_run
3068/// # extern crate hyper;
3069/// # extern crate hyper_rustls;
3070/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
3071/// use cloudresourcemanager2::api::SearchFoldersRequest;
3072/// # async fn dox() {
3073/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3074///
3075/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3076/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3077/// #     secret,
3078/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3079/// # ).build().await.unwrap();
3080///
3081/// # let client = hyper_util::client::legacy::Client::builder(
3082/// #     hyper_util::rt::TokioExecutor::new()
3083/// # )
3084/// # .build(
3085/// #     hyper_rustls::HttpsConnectorBuilder::new()
3086/// #         .with_native_roots()
3087/// #         .unwrap()
3088/// #         .https_or_http()
3089/// #         .enable_http1()
3090/// #         .build()
3091/// # );
3092/// # let mut hub = CloudResourceManager::new(client, auth);
3093/// // As the method needs a request, you would usually fill it with the desired information
3094/// // into the respective structure. Some of the parts shown here might not be applicable !
3095/// // Values shown here are possibly random and not representative !
3096/// let mut req = SearchFoldersRequest::default();
3097///
3098/// // You can configure optional parameters by calling the respective setters at will, and
3099/// // execute the final call using `doit()`.
3100/// // Values shown here are possibly random and not representative !
3101/// let result = hub.folders().search(req)
3102///              .doit().await;
3103/// # }
3104/// ```
3105pub struct FolderSearchCall<'a, C>
3106where
3107    C: 'a,
3108{
3109    hub: &'a CloudResourceManager<C>,
3110    _request: SearchFoldersRequest,
3111    _delegate: Option<&'a mut dyn common::Delegate>,
3112    _additional_params: HashMap<String, String>,
3113    _scopes: BTreeSet<String>,
3114}
3115
3116impl<'a, C> common::CallBuilder for FolderSearchCall<'a, C> {}
3117
3118impl<'a, C> FolderSearchCall<'a, C>
3119where
3120    C: common::Connector,
3121{
3122    /// Perform the operation you have build so far.
3123    pub async fn doit(mut self) -> common::Result<(common::Response, SearchFoldersResponse)> {
3124        use std::borrow::Cow;
3125        use std::io::{Read, Seek};
3126
3127        use common::{url::Params, ToParts};
3128        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3129
3130        let mut dd = common::DefaultDelegate;
3131        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3132        dlg.begin(common::MethodInfo {
3133            id: "cloudresourcemanager.folders.search",
3134            http_method: hyper::Method::POST,
3135        });
3136
3137        for &field in ["alt"].iter() {
3138            if self._additional_params.contains_key(field) {
3139                dlg.finished(false);
3140                return Err(common::Error::FieldClash(field));
3141            }
3142        }
3143
3144        let mut params = Params::with_capacity(3 + self._additional_params.len());
3145
3146        params.extend(self._additional_params.iter());
3147
3148        params.push("alt", "json");
3149        let mut url = self.hub._base_url.clone() + "v2/folders:search";
3150        if self._scopes.is_empty() {
3151            self._scopes
3152                .insert(Scope::CloudPlatform.as_ref().to_string());
3153        }
3154
3155        let url = params.parse_with_url(&url);
3156
3157        let mut json_mime_type = mime::APPLICATION_JSON;
3158        let mut request_value_reader = {
3159            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3160            common::remove_json_null_values(&mut value);
3161            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3162            serde_json::to_writer(&mut dst, &value).unwrap();
3163            dst
3164        };
3165        let request_size = request_value_reader
3166            .seek(std::io::SeekFrom::End(0))
3167            .unwrap();
3168        request_value_reader
3169            .seek(std::io::SeekFrom::Start(0))
3170            .unwrap();
3171
3172        loop {
3173            let token = match self
3174                .hub
3175                .auth
3176                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3177                .await
3178            {
3179                Ok(token) => token,
3180                Err(e) => match dlg.token(e) {
3181                    Ok(token) => token,
3182                    Err(e) => {
3183                        dlg.finished(false);
3184                        return Err(common::Error::MissingToken(e));
3185                    }
3186                },
3187            };
3188            request_value_reader
3189                .seek(std::io::SeekFrom::Start(0))
3190                .unwrap();
3191            let mut req_result = {
3192                let client = &self.hub.client;
3193                dlg.pre_request();
3194                let mut req_builder = hyper::Request::builder()
3195                    .method(hyper::Method::POST)
3196                    .uri(url.as_str())
3197                    .header(USER_AGENT, self.hub._user_agent.clone());
3198
3199                if let Some(token) = token.as_ref() {
3200                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3201                }
3202
3203                let request = req_builder
3204                    .header(CONTENT_TYPE, json_mime_type.to_string())
3205                    .header(CONTENT_LENGTH, request_size as u64)
3206                    .body(common::to_body(
3207                        request_value_reader.get_ref().clone().into(),
3208                    ));
3209
3210                client.request(request.unwrap()).await
3211            };
3212
3213            match req_result {
3214                Err(err) => {
3215                    if let common::Retry::After(d) = dlg.http_error(&err) {
3216                        sleep(d).await;
3217                        continue;
3218                    }
3219                    dlg.finished(false);
3220                    return Err(common::Error::HttpError(err));
3221                }
3222                Ok(res) => {
3223                    let (mut parts, body) = res.into_parts();
3224                    let mut body = common::Body::new(body);
3225                    if !parts.status.is_success() {
3226                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3227                        let error = serde_json::from_str(&common::to_string(&bytes));
3228                        let response = common::to_response(parts, bytes.into());
3229
3230                        if let common::Retry::After(d) =
3231                            dlg.http_failure(&response, error.as_ref().ok())
3232                        {
3233                            sleep(d).await;
3234                            continue;
3235                        }
3236
3237                        dlg.finished(false);
3238
3239                        return Err(match error {
3240                            Ok(value) => common::Error::BadRequest(value),
3241                            _ => common::Error::Failure(response),
3242                        });
3243                    }
3244                    let response = {
3245                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3246                        let encoded = common::to_string(&bytes);
3247                        match serde_json::from_str(&encoded) {
3248                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3249                            Err(error) => {
3250                                dlg.response_json_decode_error(&encoded, &error);
3251                                return Err(common::Error::JsonDecodeError(
3252                                    encoded.to_string(),
3253                                    error,
3254                                ));
3255                            }
3256                        }
3257                    };
3258
3259                    dlg.finished(true);
3260                    return Ok(response);
3261                }
3262            }
3263        }
3264    }
3265
3266    ///
3267    /// Sets the *request* property to the given value.
3268    ///
3269    /// Even though the property as already been set when instantiating this call,
3270    /// we provide this method for API completeness.
3271    pub fn request(mut self, new_value: SearchFoldersRequest) -> FolderSearchCall<'a, C> {
3272        self._request = new_value;
3273        self
3274    }
3275    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3276    /// while executing the actual API request.
3277    ///
3278    /// ````text
3279    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3280    /// ````
3281    ///
3282    /// Sets the *delegate* property to the given value.
3283    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FolderSearchCall<'a, C> {
3284        self._delegate = Some(new_value);
3285        self
3286    }
3287
3288    /// Set any additional parameter of the query string used in the request.
3289    /// It should be used to set parameters which are not yet available through their own
3290    /// setters.
3291    ///
3292    /// Please note that this method must not be used to set any of the known parameters
3293    /// which have their own setter method. If done anyway, the request will fail.
3294    ///
3295    /// # Additional Parameters
3296    ///
3297    /// * *$.xgafv* (query-string) - V1 error format.
3298    /// * *access_token* (query-string) - OAuth access token.
3299    /// * *alt* (query-string) - Data format for response.
3300    /// * *callback* (query-string) - JSONP
3301    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3302    /// * *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.
3303    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3304    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3305    /// * *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.
3306    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3307    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3308    pub fn param<T>(mut self, name: T, value: T) -> FolderSearchCall<'a, C>
3309    where
3310        T: AsRef<str>,
3311    {
3312        self._additional_params
3313            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3314        self
3315    }
3316
3317    /// Identifies the authorization scope for the method you are building.
3318    ///
3319    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3320    /// [`Scope::CloudPlatform`].
3321    ///
3322    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3323    /// tokens for more than one scope.
3324    ///
3325    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3326    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3327    /// sufficient, a read-write scope will do as well.
3328    pub fn add_scope<St>(mut self, scope: St) -> FolderSearchCall<'a, C>
3329    where
3330        St: AsRef<str>,
3331    {
3332        self._scopes.insert(String::from(scope.as_ref()));
3333        self
3334    }
3335    /// Identifies the authorization scope(s) for the method you are building.
3336    ///
3337    /// See [`Self::add_scope()`] for details.
3338    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderSearchCall<'a, C>
3339    where
3340        I: IntoIterator<Item = St>,
3341        St: AsRef<str>,
3342    {
3343        self._scopes
3344            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3345        self
3346    }
3347
3348    /// Removes all scopes, and no default scope will be used either.
3349    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3350    /// for details).
3351    pub fn clear_scopes(mut self) -> FolderSearchCall<'a, C> {
3352        self._scopes.clear();
3353        self
3354    }
3355}
3356
3357/// Sets the access control policy on a Folder, replacing any existing policy. The `resource` field should be the Folder's resource name, e.g. "folders/1234". The caller must have `resourcemanager.folders.setIamPolicy` permission on the identified folder.
3358///
3359/// A builder for the *setIamPolicy* method supported by a *folder* resource.
3360/// It is not used directly, but through a [`FolderMethods`] instance.
3361///
3362/// # Example
3363///
3364/// Instantiate a resource method builder
3365///
3366/// ```test_harness,no_run
3367/// # extern crate hyper;
3368/// # extern crate hyper_rustls;
3369/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
3370/// use cloudresourcemanager2::api::SetIamPolicyRequest;
3371/// # async fn dox() {
3372/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3373///
3374/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3375/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3376/// #     secret,
3377/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3378/// # ).build().await.unwrap();
3379///
3380/// # let client = hyper_util::client::legacy::Client::builder(
3381/// #     hyper_util::rt::TokioExecutor::new()
3382/// # )
3383/// # .build(
3384/// #     hyper_rustls::HttpsConnectorBuilder::new()
3385/// #         .with_native_roots()
3386/// #         .unwrap()
3387/// #         .https_or_http()
3388/// #         .enable_http1()
3389/// #         .build()
3390/// # );
3391/// # let mut hub = CloudResourceManager::new(client, auth);
3392/// // As the method needs a request, you would usually fill it with the desired information
3393/// // into the respective structure. Some of the parts shown here might not be applicable !
3394/// // Values shown here are possibly random and not representative !
3395/// let mut req = SetIamPolicyRequest::default();
3396///
3397/// // You can configure optional parameters by calling the respective setters at will, and
3398/// // execute the final call using `doit()`.
3399/// // Values shown here are possibly random and not representative !
3400/// let result = hub.folders().set_iam_policy(req, "resource")
3401///              .doit().await;
3402/// # }
3403/// ```
3404pub struct FolderSetIamPolicyCall<'a, C>
3405where
3406    C: 'a,
3407{
3408    hub: &'a CloudResourceManager<C>,
3409    _request: SetIamPolicyRequest,
3410    _resource: String,
3411    _delegate: Option<&'a mut dyn common::Delegate>,
3412    _additional_params: HashMap<String, String>,
3413    _scopes: BTreeSet<String>,
3414}
3415
3416impl<'a, C> common::CallBuilder for FolderSetIamPolicyCall<'a, C> {}
3417
3418impl<'a, C> FolderSetIamPolicyCall<'a, C>
3419where
3420    C: common::Connector,
3421{
3422    /// Perform the operation you have build so far.
3423    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
3424        use std::borrow::Cow;
3425        use std::io::{Read, Seek};
3426
3427        use common::{url::Params, ToParts};
3428        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3429
3430        let mut dd = common::DefaultDelegate;
3431        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3432        dlg.begin(common::MethodInfo {
3433            id: "cloudresourcemanager.folders.setIamPolicy",
3434            http_method: hyper::Method::POST,
3435        });
3436
3437        for &field in ["alt", "resource"].iter() {
3438            if self._additional_params.contains_key(field) {
3439                dlg.finished(false);
3440                return Err(common::Error::FieldClash(field));
3441            }
3442        }
3443
3444        let mut params = Params::with_capacity(4 + self._additional_params.len());
3445        params.push("resource", self._resource);
3446
3447        params.extend(self._additional_params.iter());
3448
3449        params.push("alt", "json");
3450        let mut url = self.hub._base_url.clone() + "v2/{+resource}:setIamPolicy";
3451        if self._scopes.is_empty() {
3452            self._scopes
3453                .insert(Scope::CloudPlatform.as_ref().to_string());
3454        }
3455
3456        #[allow(clippy::single_element_loop)]
3457        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3458            url = params.uri_replacement(url, param_name, find_this, true);
3459        }
3460        {
3461            let to_remove = ["resource"];
3462            params.remove_params(&to_remove);
3463        }
3464
3465        let url = params.parse_with_url(&url);
3466
3467        let mut json_mime_type = mime::APPLICATION_JSON;
3468        let mut request_value_reader = {
3469            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3470            common::remove_json_null_values(&mut value);
3471            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3472            serde_json::to_writer(&mut dst, &value).unwrap();
3473            dst
3474        };
3475        let request_size = request_value_reader
3476            .seek(std::io::SeekFrom::End(0))
3477            .unwrap();
3478        request_value_reader
3479            .seek(std::io::SeekFrom::Start(0))
3480            .unwrap();
3481
3482        loop {
3483            let token = match self
3484                .hub
3485                .auth
3486                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3487                .await
3488            {
3489                Ok(token) => token,
3490                Err(e) => match dlg.token(e) {
3491                    Ok(token) => token,
3492                    Err(e) => {
3493                        dlg.finished(false);
3494                        return Err(common::Error::MissingToken(e));
3495                    }
3496                },
3497            };
3498            request_value_reader
3499                .seek(std::io::SeekFrom::Start(0))
3500                .unwrap();
3501            let mut req_result = {
3502                let client = &self.hub.client;
3503                dlg.pre_request();
3504                let mut req_builder = hyper::Request::builder()
3505                    .method(hyper::Method::POST)
3506                    .uri(url.as_str())
3507                    .header(USER_AGENT, self.hub._user_agent.clone());
3508
3509                if let Some(token) = token.as_ref() {
3510                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3511                }
3512
3513                let request = req_builder
3514                    .header(CONTENT_TYPE, json_mime_type.to_string())
3515                    .header(CONTENT_LENGTH, request_size as u64)
3516                    .body(common::to_body(
3517                        request_value_reader.get_ref().clone().into(),
3518                    ));
3519
3520                client.request(request.unwrap()).await
3521            };
3522
3523            match req_result {
3524                Err(err) => {
3525                    if let common::Retry::After(d) = dlg.http_error(&err) {
3526                        sleep(d).await;
3527                        continue;
3528                    }
3529                    dlg.finished(false);
3530                    return Err(common::Error::HttpError(err));
3531                }
3532                Ok(res) => {
3533                    let (mut parts, body) = res.into_parts();
3534                    let mut body = common::Body::new(body);
3535                    if !parts.status.is_success() {
3536                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3537                        let error = serde_json::from_str(&common::to_string(&bytes));
3538                        let response = common::to_response(parts, bytes.into());
3539
3540                        if let common::Retry::After(d) =
3541                            dlg.http_failure(&response, error.as_ref().ok())
3542                        {
3543                            sleep(d).await;
3544                            continue;
3545                        }
3546
3547                        dlg.finished(false);
3548
3549                        return Err(match error {
3550                            Ok(value) => common::Error::BadRequest(value),
3551                            _ => common::Error::Failure(response),
3552                        });
3553                    }
3554                    let response = {
3555                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3556                        let encoded = common::to_string(&bytes);
3557                        match serde_json::from_str(&encoded) {
3558                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3559                            Err(error) => {
3560                                dlg.response_json_decode_error(&encoded, &error);
3561                                return Err(common::Error::JsonDecodeError(
3562                                    encoded.to_string(),
3563                                    error,
3564                                ));
3565                            }
3566                        }
3567                    };
3568
3569                    dlg.finished(true);
3570                    return Ok(response);
3571                }
3572            }
3573        }
3574    }
3575
3576    ///
3577    /// Sets the *request* property to the given value.
3578    ///
3579    /// Even though the property as already been set when instantiating this call,
3580    /// we provide this method for API completeness.
3581    pub fn request(mut self, new_value: SetIamPolicyRequest) -> FolderSetIamPolicyCall<'a, C> {
3582        self._request = new_value;
3583        self
3584    }
3585    /// 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.
3586    ///
3587    /// Sets the *resource* path property to the given value.
3588    ///
3589    /// Even though the property as already been set when instantiating this call,
3590    /// we provide this method for API completeness.
3591    pub fn resource(mut self, new_value: &str) -> FolderSetIamPolicyCall<'a, C> {
3592        self._resource = new_value.to_string();
3593        self
3594    }
3595    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3596    /// while executing the actual API request.
3597    ///
3598    /// ````text
3599    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3600    /// ````
3601    ///
3602    /// Sets the *delegate* property to the given value.
3603    pub fn delegate(
3604        mut self,
3605        new_value: &'a mut dyn common::Delegate,
3606    ) -> FolderSetIamPolicyCall<'a, C> {
3607        self._delegate = Some(new_value);
3608        self
3609    }
3610
3611    /// Set any additional parameter of the query string used in the request.
3612    /// It should be used to set parameters which are not yet available through their own
3613    /// setters.
3614    ///
3615    /// Please note that this method must not be used to set any of the known parameters
3616    /// which have their own setter method. If done anyway, the request will fail.
3617    ///
3618    /// # Additional Parameters
3619    ///
3620    /// * *$.xgafv* (query-string) - V1 error format.
3621    /// * *access_token* (query-string) - OAuth access token.
3622    /// * *alt* (query-string) - Data format for response.
3623    /// * *callback* (query-string) - JSONP
3624    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3625    /// * *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.
3626    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3627    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3628    /// * *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.
3629    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3630    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3631    pub fn param<T>(mut self, name: T, value: T) -> FolderSetIamPolicyCall<'a, C>
3632    where
3633        T: AsRef<str>,
3634    {
3635        self._additional_params
3636            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3637        self
3638    }
3639
3640    /// Identifies the authorization scope for the method you are building.
3641    ///
3642    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3643    /// [`Scope::CloudPlatform`].
3644    ///
3645    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3646    /// tokens for more than one scope.
3647    ///
3648    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3649    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3650    /// sufficient, a read-write scope will do as well.
3651    pub fn add_scope<St>(mut self, scope: St) -> FolderSetIamPolicyCall<'a, C>
3652    where
3653        St: AsRef<str>,
3654    {
3655        self._scopes.insert(String::from(scope.as_ref()));
3656        self
3657    }
3658    /// Identifies the authorization scope(s) for the method you are building.
3659    ///
3660    /// See [`Self::add_scope()`] for details.
3661    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderSetIamPolicyCall<'a, C>
3662    where
3663        I: IntoIterator<Item = St>,
3664        St: AsRef<str>,
3665    {
3666        self._scopes
3667            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3668        self
3669    }
3670
3671    /// Removes all scopes, and no default scope will be used either.
3672    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3673    /// for details).
3674    pub fn clear_scopes(mut self) -> FolderSetIamPolicyCall<'a, C> {
3675        self._scopes.clear();
3676        self
3677    }
3678}
3679
3680/// Returns permissions that a caller has on the specified Folder. The `resource` field should be the Folder's resource name, e.g. "folders/1234". There are no permissions required for making this API call.
3681///
3682/// A builder for the *testIamPermissions* method supported by a *folder* resource.
3683/// It is not used directly, but through a [`FolderMethods`] instance.
3684///
3685/// # Example
3686///
3687/// Instantiate a resource method builder
3688///
3689/// ```test_harness,no_run
3690/// # extern crate hyper;
3691/// # extern crate hyper_rustls;
3692/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
3693/// use cloudresourcemanager2::api::TestIamPermissionsRequest;
3694/// # async fn dox() {
3695/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3696///
3697/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3698/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3699/// #     secret,
3700/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3701/// # ).build().await.unwrap();
3702///
3703/// # let client = hyper_util::client::legacy::Client::builder(
3704/// #     hyper_util::rt::TokioExecutor::new()
3705/// # )
3706/// # .build(
3707/// #     hyper_rustls::HttpsConnectorBuilder::new()
3708/// #         .with_native_roots()
3709/// #         .unwrap()
3710/// #         .https_or_http()
3711/// #         .enable_http1()
3712/// #         .build()
3713/// # );
3714/// # let mut hub = CloudResourceManager::new(client, auth);
3715/// // As the method needs a request, you would usually fill it with the desired information
3716/// // into the respective structure. Some of the parts shown here might not be applicable !
3717/// // Values shown here are possibly random and not representative !
3718/// let mut req = TestIamPermissionsRequest::default();
3719///
3720/// // You can configure optional parameters by calling the respective setters at will, and
3721/// // execute the final call using `doit()`.
3722/// // Values shown here are possibly random and not representative !
3723/// let result = hub.folders().test_iam_permissions(req, "resource")
3724///              .doit().await;
3725/// # }
3726/// ```
3727pub struct FolderTestIamPermissionCall<'a, C>
3728where
3729    C: 'a,
3730{
3731    hub: &'a CloudResourceManager<C>,
3732    _request: TestIamPermissionsRequest,
3733    _resource: String,
3734    _delegate: Option<&'a mut dyn common::Delegate>,
3735    _additional_params: HashMap<String, String>,
3736    _scopes: BTreeSet<String>,
3737}
3738
3739impl<'a, C> common::CallBuilder for FolderTestIamPermissionCall<'a, C> {}
3740
3741impl<'a, C> FolderTestIamPermissionCall<'a, C>
3742where
3743    C: common::Connector,
3744{
3745    /// Perform the operation you have build so far.
3746    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
3747        use std::borrow::Cow;
3748        use std::io::{Read, Seek};
3749
3750        use common::{url::Params, ToParts};
3751        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3752
3753        let mut dd = common::DefaultDelegate;
3754        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3755        dlg.begin(common::MethodInfo {
3756            id: "cloudresourcemanager.folders.testIamPermissions",
3757            http_method: hyper::Method::POST,
3758        });
3759
3760        for &field in ["alt", "resource"].iter() {
3761            if self._additional_params.contains_key(field) {
3762                dlg.finished(false);
3763                return Err(common::Error::FieldClash(field));
3764            }
3765        }
3766
3767        let mut params = Params::with_capacity(4 + self._additional_params.len());
3768        params.push("resource", self._resource);
3769
3770        params.extend(self._additional_params.iter());
3771
3772        params.push("alt", "json");
3773        let mut url = self.hub._base_url.clone() + "v2/{+resource}:testIamPermissions";
3774        if self._scopes.is_empty() {
3775            self._scopes
3776                .insert(Scope::CloudPlatform.as_ref().to_string());
3777        }
3778
3779        #[allow(clippy::single_element_loop)]
3780        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3781            url = params.uri_replacement(url, param_name, find_this, true);
3782        }
3783        {
3784            let to_remove = ["resource"];
3785            params.remove_params(&to_remove);
3786        }
3787
3788        let url = params.parse_with_url(&url);
3789
3790        let mut json_mime_type = mime::APPLICATION_JSON;
3791        let mut request_value_reader = {
3792            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3793            common::remove_json_null_values(&mut value);
3794            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3795            serde_json::to_writer(&mut dst, &value).unwrap();
3796            dst
3797        };
3798        let request_size = request_value_reader
3799            .seek(std::io::SeekFrom::End(0))
3800            .unwrap();
3801        request_value_reader
3802            .seek(std::io::SeekFrom::Start(0))
3803            .unwrap();
3804
3805        loop {
3806            let token = match self
3807                .hub
3808                .auth
3809                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3810                .await
3811            {
3812                Ok(token) => token,
3813                Err(e) => match dlg.token(e) {
3814                    Ok(token) => token,
3815                    Err(e) => {
3816                        dlg.finished(false);
3817                        return Err(common::Error::MissingToken(e));
3818                    }
3819                },
3820            };
3821            request_value_reader
3822                .seek(std::io::SeekFrom::Start(0))
3823                .unwrap();
3824            let mut req_result = {
3825                let client = &self.hub.client;
3826                dlg.pre_request();
3827                let mut req_builder = hyper::Request::builder()
3828                    .method(hyper::Method::POST)
3829                    .uri(url.as_str())
3830                    .header(USER_AGENT, self.hub._user_agent.clone());
3831
3832                if let Some(token) = token.as_ref() {
3833                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3834                }
3835
3836                let request = req_builder
3837                    .header(CONTENT_TYPE, json_mime_type.to_string())
3838                    .header(CONTENT_LENGTH, request_size as u64)
3839                    .body(common::to_body(
3840                        request_value_reader.get_ref().clone().into(),
3841                    ));
3842
3843                client.request(request.unwrap()).await
3844            };
3845
3846            match req_result {
3847                Err(err) => {
3848                    if let common::Retry::After(d) = dlg.http_error(&err) {
3849                        sleep(d).await;
3850                        continue;
3851                    }
3852                    dlg.finished(false);
3853                    return Err(common::Error::HttpError(err));
3854                }
3855                Ok(res) => {
3856                    let (mut parts, body) = res.into_parts();
3857                    let mut body = common::Body::new(body);
3858                    if !parts.status.is_success() {
3859                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3860                        let error = serde_json::from_str(&common::to_string(&bytes));
3861                        let response = common::to_response(parts, bytes.into());
3862
3863                        if let common::Retry::After(d) =
3864                            dlg.http_failure(&response, error.as_ref().ok())
3865                        {
3866                            sleep(d).await;
3867                            continue;
3868                        }
3869
3870                        dlg.finished(false);
3871
3872                        return Err(match error {
3873                            Ok(value) => common::Error::BadRequest(value),
3874                            _ => common::Error::Failure(response),
3875                        });
3876                    }
3877                    let response = {
3878                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3879                        let encoded = common::to_string(&bytes);
3880                        match serde_json::from_str(&encoded) {
3881                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3882                            Err(error) => {
3883                                dlg.response_json_decode_error(&encoded, &error);
3884                                return Err(common::Error::JsonDecodeError(
3885                                    encoded.to_string(),
3886                                    error,
3887                                ));
3888                            }
3889                        }
3890                    };
3891
3892                    dlg.finished(true);
3893                    return Ok(response);
3894                }
3895            }
3896        }
3897    }
3898
3899    ///
3900    /// Sets the *request* property to the given value.
3901    ///
3902    /// Even though the property as already been set when instantiating this call,
3903    /// we provide this method for API completeness.
3904    pub fn request(
3905        mut self,
3906        new_value: TestIamPermissionsRequest,
3907    ) -> FolderTestIamPermissionCall<'a, C> {
3908        self._request = new_value;
3909        self
3910    }
3911    /// 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.
3912    ///
3913    /// Sets the *resource* path property to the given value.
3914    ///
3915    /// Even though the property as already been set when instantiating this call,
3916    /// we provide this method for API completeness.
3917    pub fn resource(mut self, new_value: &str) -> FolderTestIamPermissionCall<'a, C> {
3918        self._resource = new_value.to_string();
3919        self
3920    }
3921    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3922    /// while executing the actual API request.
3923    ///
3924    /// ````text
3925    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3926    /// ````
3927    ///
3928    /// Sets the *delegate* property to the given value.
3929    pub fn delegate(
3930        mut self,
3931        new_value: &'a mut dyn common::Delegate,
3932    ) -> FolderTestIamPermissionCall<'a, C> {
3933        self._delegate = Some(new_value);
3934        self
3935    }
3936
3937    /// Set any additional parameter of the query string used in the request.
3938    /// It should be used to set parameters which are not yet available through their own
3939    /// setters.
3940    ///
3941    /// Please note that this method must not be used to set any of the known parameters
3942    /// which have their own setter method. If done anyway, the request will fail.
3943    ///
3944    /// # Additional Parameters
3945    ///
3946    /// * *$.xgafv* (query-string) - V1 error format.
3947    /// * *access_token* (query-string) - OAuth access token.
3948    /// * *alt* (query-string) - Data format for response.
3949    /// * *callback* (query-string) - JSONP
3950    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3951    /// * *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.
3952    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3953    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3954    /// * *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.
3955    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3956    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3957    pub fn param<T>(mut self, name: T, value: T) -> FolderTestIamPermissionCall<'a, C>
3958    where
3959        T: AsRef<str>,
3960    {
3961        self._additional_params
3962            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3963        self
3964    }
3965
3966    /// Identifies the authorization scope for the method you are building.
3967    ///
3968    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3969    /// [`Scope::CloudPlatform`].
3970    ///
3971    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3972    /// tokens for more than one scope.
3973    ///
3974    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3975    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3976    /// sufficient, a read-write scope will do as well.
3977    pub fn add_scope<St>(mut self, scope: St) -> FolderTestIamPermissionCall<'a, C>
3978    where
3979        St: AsRef<str>,
3980    {
3981        self._scopes.insert(String::from(scope.as_ref()));
3982        self
3983    }
3984    /// Identifies the authorization scope(s) for the method you are building.
3985    ///
3986    /// See [`Self::add_scope()`] for details.
3987    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderTestIamPermissionCall<'a, C>
3988    where
3989        I: IntoIterator<Item = St>,
3990        St: AsRef<str>,
3991    {
3992        self._scopes
3993            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3994        self
3995    }
3996
3997    /// Removes all scopes, and no default scope will be used either.
3998    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3999    /// for details).
4000    pub fn clear_scopes(mut self) -> FolderTestIamPermissionCall<'a, C> {
4001        self._scopes.clear();
4002        self
4003    }
4004}
4005
4006/// Cancels the deletion request for a Folder. This method may only be called on a Folder in the DELETE_REQUESTED state. In order to succeed, the Folder's parent must be in the ACTIVE state. In addition, reintroducing the folder into the tree must not violate folder naming, height and fanout constraints described in the CreateFolder documentation. The caller must have `resourcemanager.folders.undelete` permission on the identified folder.
4007///
4008/// A builder for the *undelete* method supported by a *folder* resource.
4009/// It is not used directly, but through a [`FolderMethods`] instance.
4010///
4011/// # Example
4012///
4013/// Instantiate a resource method builder
4014///
4015/// ```test_harness,no_run
4016/// # extern crate hyper;
4017/// # extern crate hyper_rustls;
4018/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
4019/// use cloudresourcemanager2::api::UndeleteFolderRequest;
4020/// # async fn dox() {
4021/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4022///
4023/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4024/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4025/// #     secret,
4026/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4027/// # ).build().await.unwrap();
4028///
4029/// # let client = hyper_util::client::legacy::Client::builder(
4030/// #     hyper_util::rt::TokioExecutor::new()
4031/// # )
4032/// # .build(
4033/// #     hyper_rustls::HttpsConnectorBuilder::new()
4034/// #         .with_native_roots()
4035/// #         .unwrap()
4036/// #         .https_or_http()
4037/// #         .enable_http1()
4038/// #         .build()
4039/// # );
4040/// # let mut hub = CloudResourceManager::new(client, auth);
4041/// // As the method needs a request, you would usually fill it with the desired information
4042/// // into the respective structure. Some of the parts shown here might not be applicable !
4043/// // Values shown here are possibly random and not representative !
4044/// let mut req = UndeleteFolderRequest::default();
4045///
4046/// // You can configure optional parameters by calling the respective setters at will, and
4047/// // execute the final call using `doit()`.
4048/// // Values shown here are possibly random and not representative !
4049/// let result = hub.folders().undelete(req, "name")
4050///              .doit().await;
4051/// # }
4052/// ```
4053pub struct FolderUndeleteCall<'a, C>
4054where
4055    C: 'a,
4056{
4057    hub: &'a CloudResourceManager<C>,
4058    _request: UndeleteFolderRequest,
4059    _name: String,
4060    _delegate: Option<&'a mut dyn common::Delegate>,
4061    _additional_params: HashMap<String, String>,
4062    _scopes: BTreeSet<String>,
4063}
4064
4065impl<'a, C> common::CallBuilder for FolderUndeleteCall<'a, C> {}
4066
4067impl<'a, C> FolderUndeleteCall<'a, C>
4068where
4069    C: common::Connector,
4070{
4071    /// Perform the operation you have build so far.
4072    pub async fn doit(mut self) -> common::Result<(common::Response, Folder)> {
4073        use std::borrow::Cow;
4074        use std::io::{Read, Seek};
4075
4076        use common::{url::Params, ToParts};
4077        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4078
4079        let mut dd = common::DefaultDelegate;
4080        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4081        dlg.begin(common::MethodInfo {
4082            id: "cloudresourcemanager.folders.undelete",
4083            http_method: hyper::Method::POST,
4084        });
4085
4086        for &field in ["alt", "name"].iter() {
4087            if self._additional_params.contains_key(field) {
4088                dlg.finished(false);
4089                return Err(common::Error::FieldClash(field));
4090            }
4091        }
4092
4093        let mut params = Params::with_capacity(4 + self._additional_params.len());
4094        params.push("name", self._name);
4095
4096        params.extend(self._additional_params.iter());
4097
4098        params.push("alt", "json");
4099        let mut url = self.hub._base_url.clone() + "v2/{+name}:undelete";
4100        if self._scopes.is_empty() {
4101            self._scopes
4102                .insert(Scope::CloudPlatform.as_ref().to_string());
4103        }
4104
4105        #[allow(clippy::single_element_loop)]
4106        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4107            url = params.uri_replacement(url, param_name, find_this, true);
4108        }
4109        {
4110            let to_remove = ["name"];
4111            params.remove_params(&to_remove);
4112        }
4113
4114        let url = params.parse_with_url(&url);
4115
4116        let mut json_mime_type = mime::APPLICATION_JSON;
4117        let mut request_value_reader = {
4118            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4119            common::remove_json_null_values(&mut value);
4120            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4121            serde_json::to_writer(&mut dst, &value).unwrap();
4122            dst
4123        };
4124        let request_size = request_value_reader
4125            .seek(std::io::SeekFrom::End(0))
4126            .unwrap();
4127        request_value_reader
4128            .seek(std::io::SeekFrom::Start(0))
4129            .unwrap();
4130
4131        loop {
4132            let token = match self
4133                .hub
4134                .auth
4135                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4136                .await
4137            {
4138                Ok(token) => token,
4139                Err(e) => match dlg.token(e) {
4140                    Ok(token) => token,
4141                    Err(e) => {
4142                        dlg.finished(false);
4143                        return Err(common::Error::MissingToken(e));
4144                    }
4145                },
4146            };
4147            request_value_reader
4148                .seek(std::io::SeekFrom::Start(0))
4149                .unwrap();
4150            let mut req_result = {
4151                let client = &self.hub.client;
4152                dlg.pre_request();
4153                let mut req_builder = hyper::Request::builder()
4154                    .method(hyper::Method::POST)
4155                    .uri(url.as_str())
4156                    .header(USER_AGENT, self.hub._user_agent.clone());
4157
4158                if let Some(token) = token.as_ref() {
4159                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4160                }
4161
4162                let request = req_builder
4163                    .header(CONTENT_TYPE, json_mime_type.to_string())
4164                    .header(CONTENT_LENGTH, request_size as u64)
4165                    .body(common::to_body(
4166                        request_value_reader.get_ref().clone().into(),
4167                    ));
4168
4169                client.request(request.unwrap()).await
4170            };
4171
4172            match req_result {
4173                Err(err) => {
4174                    if let common::Retry::After(d) = dlg.http_error(&err) {
4175                        sleep(d).await;
4176                        continue;
4177                    }
4178                    dlg.finished(false);
4179                    return Err(common::Error::HttpError(err));
4180                }
4181                Ok(res) => {
4182                    let (mut parts, body) = res.into_parts();
4183                    let mut body = common::Body::new(body);
4184                    if !parts.status.is_success() {
4185                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4186                        let error = serde_json::from_str(&common::to_string(&bytes));
4187                        let response = common::to_response(parts, bytes.into());
4188
4189                        if let common::Retry::After(d) =
4190                            dlg.http_failure(&response, error.as_ref().ok())
4191                        {
4192                            sleep(d).await;
4193                            continue;
4194                        }
4195
4196                        dlg.finished(false);
4197
4198                        return Err(match error {
4199                            Ok(value) => common::Error::BadRequest(value),
4200                            _ => common::Error::Failure(response),
4201                        });
4202                    }
4203                    let response = {
4204                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4205                        let encoded = common::to_string(&bytes);
4206                        match serde_json::from_str(&encoded) {
4207                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4208                            Err(error) => {
4209                                dlg.response_json_decode_error(&encoded, &error);
4210                                return Err(common::Error::JsonDecodeError(
4211                                    encoded.to_string(),
4212                                    error,
4213                                ));
4214                            }
4215                        }
4216                    };
4217
4218                    dlg.finished(true);
4219                    return Ok(response);
4220                }
4221            }
4222        }
4223    }
4224
4225    ///
4226    /// Sets the *request* property to the given value.
4227    ///
4228    /// Even though the property as already been set when instantiating this call,
4229    /// we provide this method for API completeness.
4230    pub fn request(mut self, new_value: UndeleteFolderRequest) -> FolderUndeleteCall<'a, C> {
4231        self._request = new_value;
4232        self
4233    }
4234    /// Required. The resource name of the Folder to undelete. Must be of the form `folders/{folder_id}`.
4235    ///
4236    /// Sets the *name* path property to the given value.
4237    ///
4238    /// Even though the property as already been set when instantiating this call,
4239    /// we provide this method for API completeness.
4240    pub fn name(mut self, new_value: &str) -> FolderUndeleteCall<'a, C> {
4241        self._name = new_value.to_string();
4242        self
4243    }
4244    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4245    /// while executing the actual API request.
4246    ///
4247    /// ````text
4248    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4249    /// ````
4250    ///
4251    /// Sets the *delegate* property to the given value.
4252    pub fn delegate(
4253        mut self,
4254        new_value: &'a mut dyn common::Delegate,
4255    ) -> FolderUndeleteCall<'a, C> {
4256        self._delegate = Some(new_value);
4257        self
4258    }
4259
4260    /// Set any additional parameter of the query string used in the request.
4261    /// It should be used to set parameters which are not yet available through their own
4262    /// setters.
4263    ///
4264    /// Please note that this method must not be used to set any of the known parameters
4265    /// which have their own setter method. If done anyway, the request will fail.
4266    ///
4267    /// # Additional Parameters
4268    ///
4269    /// * *$.xgafv* (query-string) - V1 error format.
4270    /// * *access_token* (query-string) - OAuth access token.
4271    /// * *alt* (query-string) - Data format for response.
4272    /// * *callback* (query-string) - JSONP
4273    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4274    /// * *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.
4275    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4276    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4277    /// * *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.
4278    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4279    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4280    pub fn param<T>(mut self, name: T, value: T) -> FolderUndeleteCall<'a, C>
4281    where
4282        T: AsRef<str>,
4283    {
4284        self._additional_params
4285            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4286        self
4287    }
4288
4289    /// Identifies the authorization scope for the method you are building.
4290    ///
4291    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4292    /// [`Scope::CloudPlatform`].
4293    ///
4294    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4295    /// tokens for more than one scope.
4296    ///
4297    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4298    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4299    /// sufficient, a read-write scope will do as well.
4300    pub fn add_scope<St>(mut self, scope: St) -> FolderUndeleteCall<'a, C>
4301    where
4302        St: AsRef<str>,
4303    {
4304        self._scopes.insert(String::from(scope.as_ref()));
4305        self
4306    }
4307    /// Identifies the authorization scope(s) for the method you are building.
4308    ///
4309    /// See [`Self::add_scope()`] for details.
4310    pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderUndeleteCall<'a, C>
4311    where
4312        I: IntoIterator<Item = St>,
4313        St: AsRef<str>,
4314    {
4315        self._scopes
4316            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4317        self
4318    }
4319
4320    /// Removes all scopes, and no default scope will be used either.
4321    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4322    /// for details).
4323    pub fn clear_scopes(mut self) -> FolderUndeleteCall<'a, C> {
4324        self._scopes.clear();
4325        self
4326    }
4327}
4328
4329/// 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.
4330///
4331/// A builder for the *get* method supported by a *operation* resource.
4332/// It is not used directly, but through a [`OperationMethods`] instance.
4333///
4334/// # Example
4335///
4336/// Instantiate a resource method builder
4337///
4338/// ```test_harness,no_run
4339/// # extern crate hyper;
4340/// # extern crate hyper_rustls;
4341/// # extern crate google_cloudresourcemanager2 as cloudresourcemanager2;
4342/// # async fn dox() {
4343/// # use cloudresourcemanager2::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4344///
4345/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4346/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4347/// #     secret,
4348/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4349/// # ).build().await.unwrap();
4350///
4351/// # let client = hyper_util::client::legacy::Client::builder(
4352/// #     hyper_util::rt::TokioExecutor::new()
4353/// # )
4354/// # .build(
4355/// #     hyper_rustls::HttpsConnectorBuilder::new()
4356/// #         .with_native_roots()
4357/// #         .unwrap()
4358/// #         .https_or_http()
4359/// #         .enable_http1()
4360/// #         .build()
4361/// # );
4362/// # let mut hub = CloudResourceManager::new(client, auth);
4363/// // You can configure optional parameters by calling the respective setters at will, and
4364/// // execute the final call using `doit()`.
4365/// // Values shown here are possibly random and not representative !
4366/// let result = hub.operations().get("name")
4367///              .doit().await;
4368/// # }
4369/// ```
4370pub struct OperationGetCall<'a, C>
4371where
4372    C: 'a,
4373{
4374    hub: &'a CloudResourceManager<C>,
4375    _name: String,
4376    _delegate: Option<&'a mut dyn common::Delegate>,
4377    _additional_params: HashMap<String, String>,
4378    _scopes: BTreeSet<String>,
4379}
4380
4381impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
4382
4383impl<'a, C> OperationGetCall<'a, C>
4384where
4385    C: common::Connector,
4386{
4387    /// Perform the operation you have build so far.
4388    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4389        use std::borrow::Cow;
4390        use std::io::{Read, Seek};
4391
4392        use common::{url::Params, ToParts};
4393        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4394
4395        let mut dd = common::DefaultDelegate;
4396        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4397        dlg.begin(common::MethodInfo {
4398            id: "cloudresourcemanager.operations.get",
4399            http_method: hyper::Method::GET,
4400        });
4401
4402        for &field in ["alt", "name"].iter() {
4403            if self._additional_params.contains_key(field) {
4404                dlg.finished(false);
4405                return Err(common::Error::FieldClash(field));
4406            }
4407        }
4408
4409        let mut params = Params::with_capacity(3 + self._additional_params.len());
4410        params.push("name", self._name);
4411
4412        params.extend(self._additional_params.iter());
4413
4414        params.push("alt", "json");
4415        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4416        if self._scopes.is_empty() {
4417            self._scopes
4418                .insert(Scope::CloudPlatform.as_ref().to_string());
4419        }
4420
4421        #[allow(clippy::single_element_loop)]
4422        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4423            url = params.uri_replacement(url, param_name, find_this, true);
4424        }
4425        {
4426            let to_remove = ["name"];
4427            params.remove_params(&to_remove);
4428        }
4429
4430        let url = params.parse_with_url(&url);
4431
4432        loop {
4433            let token = match self
4434                .hub
4435                .auth
4436                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4437                .await
4438            {
4439                Ok(token) => token,
4440                Err(e) => match dlg.token(e) {
4441                    Ok(token) => token,
4442                    Err(e) => {
4443                        dlg.finished(false);
4444                        return Err(common::Error::MissingToken(e));
4445                    }
4446                },
4447            };
4448            let mut req_result = {
4449                let client = &self.hub.client;
4450                dlg.pre_request();
4451                let mut req_builder = hyper::Request::builder()
4452                    .method(hyper::Method::GET)
4453                    .uri(url.as_str())
4454                    .header(USER_AGENT, self.hub._user_agent.clone());
4455
4456                if let Some(token) = token.as_ref() {
4457                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4458                }
4459
4460                let request = req_builder
4461                    .header(CONTENT_LENGTH, 0_u64)
4462                    .body(common::to_body::<String>(None));
4463
4464                client.request(request.unwrap()).await
4465            };
4466
4467            match req_result {
4468                Err(err) => {
4469                    if let common::Retry::After(d) = dlg.http_error(&err) {
4470                        sleep(d).await;
4471                        continue;
4472                    }
4473                    dlg.finished(false);
4474                    return Err(common::Error::HttpError(err));
4475                }
4476                Ok(res) => {
4477                    let (mut parts, body) = res.into_parts();
4478                    let mut body = common::Body::new(body);
4479                    if !parts.status.is_success() {
4480                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4481                        let error = serde_json::from_str(&common::to_string(&bytes));
4482                        let response = common::to_response(parts, bytes.into());
4483
4484                        if let common::Retry::After(d) =
4485                            dlg.http_failure(&response, error.as_ref().ok())
4486                        {
4487                            sleep(d).await;
4488                            continue;
4489                        }
4490
4491                        dlg.finished(false);
4492
4493                        return Err(match error {
4494                            Ok(value) => common::Error::BadRequest(value),
4495                            _ => common::Error::Failure(response),
4496                        });
4497                    }
4498                    let response = {
4499                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4500                        let encoded = common::to_string(&bytes);
4501                        match serde_json::from_str(&encoded) {
4502                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4503                            Err(error) => {
4504                                dlg.response_json_decode_error(&encoded, &error);
4505                                return Err(common::Error::JsonDecodeError(
4506                                    encoded.to_string(),
4507                                    error,
4508                                ));
4509                            }
4510                        }
4511                    };
4512
4513                    dlg.finished(true);
4514                    return Ok(response);
4515                }
4516            }
4517        }
4518    }
4519
4520    /// The name of the operation resource.
4521    ///
4522    /// Sets the *name* path property to the given value.
4523    ///
4524    /// Even though the property as already been set when instantiating this call,
4525    /// we provide this method for API completeness.
4526    pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
4527        self._name = new_value.to_string();
4528        self
4529    }
4530    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4531    /// while executing the actual API request.
4532    ///
4533    /// ````text
4534    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4535    /// ````
4536    ///
4537    /// Sets the *delegate* property to the given value.
4538    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
4539        self._delegate = Some(new_value);
4540        self
4541    }
4542
4543    /// Set any additional parameter of the query string used in the request.
4544    /// It should be used to set parameters which are not yet available through their own
4545    /// setters.
4546    ///
4547    /// Please note that this method must not be used to set any of the known parameters
4548    /// which have their own setter method. If done anyway, the request will fail.
4549    ///
4550    /// # Additional Parameters
4551    ///
4552    /// * *$.xgafv* (query-string) - V1 error format.
4553    /// * *access_token* (query-string) - OAuth access token.
4554    /// * *alt* (query-string) - Data format for response.
4555    /// * *callback* (query-string) - JSONP
4556    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4557    /// * *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.
4558    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4559    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4560    /// * *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.
4561    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4562    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4563    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
4564    where
4565        T: AsRef<str>,
4566    {
4567        self._additional_params
4568            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4569        self
4570    }
4571
4572    /// Identifies the authorization scope for the method you are building.
4573    ///
4574    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4575    /// [`Scope::CloudPlatform`].
4576    ///
4577    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4578    /// tokens for more than one scope.
4579    ///
4580    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4581    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4582    /// sufficient, a read-write scope will do as well.
4583    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
4584    where
4585        St: AsRef<str>,
4586    {
4587        self._scopes.insert(String::from(scope.as_ref()));
4588        self
4589    }
4590    /// Identifies the authorization scope(s) for the method you are building.
4591    ///
4592    /// See [`Self::add_scope()`] for details.
4593    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
4594    where
4595        I: IntoIterator<Item = St>,
4596        St: AsRef<str>,
4597    {
4598        self._scopes
4599            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4600        self
4601    }
4602
4603    /// Removes all scopes, and no default scope will be used either.
4604    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4605    /// for details).
4606    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
4607        self._scopes.clear();
4608        self
4609    }
4610}