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