google_cloudresourcemanager1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18
19 /// View your data across Google Cloud services and see the email address of your Google Account
20 CloudPlatformReadOnly,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27 Scope::CloudPlatformReadOnly => {
28 "https://www.googleapis.com/auth/cloud-platform.read-only"
29 }
30 }
31 }
32}
33
34#[allow(clippy::derivable_impls)]
35impl Default for Scope {
36 fn default() -> Scope {
37 Scope::CloudPlatform
38 }
39}
40
41// ########
42// HUB ###
43// ######
44
45/// Central instance to access all CloudResourceManager related resource activities
46///
47/// # Examples
48///
49/// Instantiate a new hub
50///
51/// ```test_harness,no_run
52/// extern crate hyper;
53/// extern crate hyper_rustls;
54/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
55/// use cloudresourcemanager1::{Result, Error};
56/// # async fn dox() {
57/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
58///
59/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
60/// // `client_secret`, among other things.
61/// let secret: yup_oauth2::ApplicationSecret = Default::default();
62/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
63/// // unless you replace `None` with the desired Flow.
64/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
65/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
66/// // retrieve them from storage.
67/// let 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.projects().list()
99/// .page_token("sanctus")
100/// .page_size(-80)
101/// .filter("amet.")
102/// .doit().await;
103///
104/// match result {
105/// Err(e) => match e {
106/// // The Error enum provides details about what exactly happened.
107/// // You can also just use its `Debug`, `Display` or `Error` traits
108/// Error::HttpError(_)
109/// |Error::Io(_)
110/// |Error::MissingAPIKey
111/// |Error::MissingToken(_)
112/// |Error::Cancelled
113/// |Error::UploadSizeLimitExceeded(_, _)
114/// |Error::Failure(_)
115/// |Error::BadRequest(_)
116/// |Error::FieldClash(_)
117/// |Error::JsonDecodeError(_, _) => println!("{}", e),
118/// },
119/// Ok(res) => println!("Success: {:?}", res),
120/// }
121/// # }
122/// ```
123#[derive(Clone)]
124pub struct CloudResourceManager<C> {
125 pub client: common::Client<C>,
126 pub auth: Box<dyn common::GetToken>,
127 _user_agent: String,
128 _base_url: String,
129 _root_url: String,
130}
131
132impl<C> common::Hub for CloudResourceManager<C> {}
133
134impl<'a, C> CloudResourceManager<C> {
135 pub fn new<A: 'static + common::GetToken>(
136 client: common::Client<C>,
137 auth: A,
138 ) -> CloudResourceManager<C> {
139 CloudResourceManager {
140 client,
141 auth: Box::new(auth),
142 _user_agent: "google-api-rust-client/7.0.0".to_string(),
143 _base_url: "https://cloudresourcemanager.googleapis.com/".to_string(),
144 _root_url: "https://cloudresourcemanager.googleapis.com/".to_string(),
145 }
146 }
147
148 pub fn folders(&'a self) -> FolderMethods<'a, C> {
149 FolderMethods { hub: self }
150 }
151 pub fn liens(&'a self) -> LienMethods<'a, C> {
152 LienMethods { hub: self }
153 }
154 pub fn operations(&'a self) -> OperationMethods<'a, C> {
155 OperationMethods { hub: self }
156 }
157 pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
158 OrganizationMethods { hub: self }
159 }
160 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
161 ProjectMethods { hub: self }
162 }
163
164 /// Set the user-agent header field to use in all requests to the server.
165 /// It defaults to `google-api-rust-client/7.0.0`.
166 ///
167 /// Returns the previously set user-agent.
168 pub fn user_agent(&mut self, agent_name: String) -> String {
169 std::mem::replace(&mut self._user_agent, agent_name)
170 }
171
172 /// Set the base url to use in all requests to the server.
173 /// It defaults to `https://cloudresourcemanager.googleapis.com/`.
174 ///
175 /// Returns the previously set base url.
176 pub fn base_url(&mut self, new_base_url: String) -> String {
177 std::mem::replace(&mut self._base_url, new_base_url)
178 }
179
180 /// Set the root url to use in all requests to the server.
181 /// It defaults to `https://cloudresourcemanager.googleapis.com/`.
182 ///
183 /// Returns the previously set root url.
184 pub fn root_url(&mut self, new_root_url: String) -> String {
185 std::mem::replace(&mut self._root_url, new_root_url)
186 }
187}
188
189// ############
190// SCHEMAS ###
191// ##########
192/// Identifying information for a single ancestor of a project.
193///
194/// This type is not used in any activity, and only used as *part* of another schema.
195///
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct Ancestor {
200 /// Resource id of the ancestor.
201 #[serde(rename = "resourceId")]
202 pub resource_id: Option<ResourceId>,
203}
204
205impl common::Part for Ancestor {}
206
207/// 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.
208///
209/// This type is not used in any activity, and only used as *part* of another schema.
210///
211#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
212#[serde_with::serde_as]
213#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
214pub struct AuditConfig {
215 /// The configuration for logging of each type of permission.
216 #[serde(rename = "auditLogConfigs")]
217 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
218 /// 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.
219 pub service: Option<String>,
220}
221
222impl common::Part for AuditConfig {}
223
224/// 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.
225///
226/// This type is not used in any activity, and only used as *part* of another schema.
227///
228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
229#[serde_with::serde_as]
230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
231pub struct AuditLogConfig {
232 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
233 #[serde(rename = "exemptedMembers")]
234 pub exempted_members: Option<Vec<String>>,
235 /// The log type that this config enables.
236 #[serde(rename = "logType")]
237 pub log_type: Option<String>,
238}
239
240impl common::Part for AuditLogConfig {}
241
242/// Associates `members`, or principals, with a `role`.
243///
244/// This type is not used in any activity, and only used as *part* of another schema.
245///
246#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
247#[serde_with::serde_as]
248#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
249pub struct Binding {
250 /// 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).
251 pub condition: Option<Expr>,
252 /// 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`.
253 pub members: Option<Vec<String>>,
254 /// 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).
255 pub role: Option<String>,
256}
257
258impl common::Part for Binding {}
259
260/// A `Constraint` that is either enforced or not. For example a constraint `constraints/compute.disableSerialPortAccess`. If it is enforced on a VM instance, serial port connections will not be opened to that instance.
261///
262/// This type is not used in any activity, and only used as *part* of another schema.
263///
264#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
265#[serde_with::serde_as]
266#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
267pub struct BooleanConstraint {
268 _never_set: Option<bool>,
269}
270
271impl common::Part for BooleanConstraint {}
272
273/// Used in `policy_type` to specify how `boolean_policy` will behave at this resource.
274///
275/// This type is not used in any activity, and only used as *part* of another schema.
276///
277#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
278#[serde_with::serde_as]
279#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
280pub struct BooleanPolicy {
281 /// If `true`, then the `Policy` is enforced. If `false`, then any configuration is acceptable. Suppose you have a `Constraint` `constraints/compute.disableSerialPortAccess` with `constraint_default` set to `ALLOW`. A `Policy` for that `Constraint` exhibits the following behavior: - If the `Policy` at this resource has enforced set to `false`, serial port connection attempts will be allowed. - If the `Policy` at this resource has enforced set to `true`, serial port connection attempts will be refused. - If the `Policy` at this resource is `RestoreDefault`, serial port connection attempts will be allowed. - If no `Policy` is set at this resource or anywhere higher in the resource hierarchy, serial port connection attempts will be allowed. - If no `Policy` is set at this resource, but one exists higher in the resource hierarchy, the behavior is as if the`Policy` were set at this resource. The following examples demonstrate the different possible layerings: Example 1 (nearest `Constraint` wins): `organizations/foo` has a `Policy` with: {enforced: false} `projects/bar` has no `Policy` set. The constraint at `projects/bar` and `organizations/foo` will not be enforced. Example 2 (enforcement gets replaced): `organizations/foo` has a `Policy` with: {enforced: false} `projects/bar` has a `Policy` with: {enforced: true} The constraint at `organizations/foo` is not enforced. The constraint at `projects/bar` is enforced. Example 3 (RestoreDefault): `organizations/foo` has a `Policy` with: {enforced: true} `projects/bar` has a `Policy` with: {RestoreDefault: {}} The constraint at `organizations/foo` is enforced. The constraint at `projects/bar` is not enforced, because `constraint_default` for the `Constraint` is `ALLOW`.
282 pub enforced: Option<bool>,
283}
284
285impl common::Part for BooleanPolicy {}
286
287/// The request sent to the ClearOrgPolicy method.
288///
289/// # Activities
290///
291/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
292/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
293///
294/// * [clear org policy folders](FolderClearOrgPolicyCall) (request)
295/// * [clear org policy organizations](OrganizationClearOrgPolicyCall) (request)
296/// * [clear org policy projects](ProjectClearOrgPolicyCall) (request)
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct ClearOrgPolicyRequest {
301 /// Name of the `Constraint` of the `Policy` to clear.
302 pub constraint: Option<String>,
303 /// The current version, for concurrency control. Not sending an `etag` will cause the `Policy` to be cleared blindly.
304 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
305 pub etag: Option<Vec<u8>>,
306}
307
308impl common::RequestValue for ClearOrgPolicyRequest {}
309
310/// A `Constraint` describes a way in which a resource’s configuration can be restricted. For example, it controls which cloud services can be activated across an organization, or whether a Compute Engine instance can have serial port connections established. `Constraints` can be configured by the organization’s policy administrator to fit the needs of the organzation by setting Policies for `Constraints` at different locations in the organization’s resource hierarchy. Policies are inherited down the resource hierarchy from higher levels, but can also be overridden. For details about the inheritance rules please read about [Policies](https://cloud.google.com/resource-manager/reference/rest/v1/Policy). `Constraints` have a default behavior determined by the `constraint_default` field, which is the enforcement behavior that is used in the absence of a `Policy` being defined or inherited for the resource in question.
311///
312/// This type is not used in any activity, and only used as *part* of another schema.
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct Constraint {
317 /// Defines this constraint as being a BooleanConstraint.
318 #[serde(rename = "booleanConstraint")]
319 pub boolean_constraint: Option<BooleanConstraint>,
320 /// The evaluation behavior of this constraint in the absence of 'Policy'.
321 #[serde(rename = "constraintDefault")]
322 pub constraint_default: Option<String>,
323 /// Detailed description of what this `Constraint` controls as well as how and where it is enforced. Mutable.
324 pub description: Option<String>,
325 /// The human readable name. Mutable.
326 #[serde(rename = "displayName")]
327 pub display_name: Option<String>,
328 /// Defines this constraint as being a ListConstraint.
329 #[serde(rename = "listConstraint")]
330 pub list_constraint: Option<ListConstraint>,
331 /// Immutable value, required to globally be unique. For example, `constraints/serviceuser.services`
332 pub name: Option<String>,
333 /// Version of the `Constraint`. Default version is 0;
334 pub version: Option<i32>,
335}
336
337impl common::Part for Constraint {}
338
339/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
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/// * [clear org policy folders](FolderClearOrgPolicyCall) (response)
347/// * [delete liens](LienDeleteCall) (response)
348/// * [clear org policy organizations](OrganizationClearOrgPolicyCall) (response)
349/// * [clear org policy projects](ProjectClearOrgPolicyCall) (response)
350/// * [delete projects](ProjectDeleteCall) (response)
351/// * [undelete projects](ProjectUndeleteCall) (response)
352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
353#[serde_with::serde_as]
354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
355pub struct Empty {
356 _never_set: Option<bool>,
357}
358
359impl common::ResponseResult for Empty {}
360
361/// 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.
362///
363/// This type is not used in any activity, and only used as *part* of another schema.
364///
365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
366#[serde_with::serde_as]
367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
368pub struct Expr {
369 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
370 pub description: Option<String>,
371 /// Textual representation of an expression in Common Expression Language syntax.
372 pub expression: Option<String>,
373 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
374 pub location: Option<String>,
375 /// 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.
376 pub title: Option<String>,
377}
378
379impl common::Part for Expr {}
380
381/// The request sent to the GetAncestry method.
382///
383/// # Activities
384///
385/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
386/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
387///
388/// * [get ancestry projects](ProjectGetAncestryCall) (request)
389#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
390#[serde_with::serde_as]
391#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
392pub struct GetAncestryRequest {
393 _never_set: Option<bool>,
394}
395
396impl common::RequestValue for GetAncestryRequest {}
397
398/// Response from the projects.getAncestry method.
399///
400/// # Activities
401///
402/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
403/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
404///
405/// * [get ancestry projects](ProjectGetAncestryCall) (response)
406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
407#[serde_with::serde_as]
408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
409pub struct GetAncestryResponse {
410 /// Ancestors are ordered from bottom to top of the resource hierarchy. The first ancestor is the project itself, followed by the project's parent, etc..
411 pub ancestor: Option<Vec<Ancestor>>,
412}
413
414impl common::ResponseResult for GetAncestryResponse {}
415
416/// The request sent to the GetEffectiveOrgPolicy method.
417///
418/// # Activities
419///
420/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
421/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
422///
423/// * [get effective org policy folders](FolderGetEffectiveOrgPolicyCall) (request)
424/// * [get effective org policy organizations](OrganizationGetEffectiveOrgPolicyCall) (request)
425/// * [get effective org policy projects](ProjectGetEffectiveOrgPolicyCall) (request)
426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
427#[serde_with::serde_as]
428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
429pub struct GetEffectiveOrgPolicyRequest {
430 /// The name of the `Constraint` to compute the effective `Policy`.
431 pub constraint: Option<String>,
432}
433
434impl common::RequestValue for GetEffectiveOrgPolicyRequest {}
435
436/// Request message for `GetIamPolicy` method.
437///
438/// # Activities
439///
440/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
441/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
442///
443/// * [get iam policy organizations](OrganizationGetIamPolicyCall) (request)
444/// * [get iam policy projects](ProjectGetIamPolicyCall) (request)
445#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
446#[serde_with::serde_as]
447#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
448pub struct GetIamPolicyRequest {
449 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
450 pub options: Option<GetPolicyOptions>,
451}
452
453impl common::RequestValue for GetIamPolicyRequest {}
454
455/// The request sent to the GetOrgPolicy method.
456///
457/// # Activities
458///
459/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
460/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
461///
462/// * [get org policy folders](FolderGetOrgPolicyCall) (request)
463/// * [get org policy organizations](OrganizationGetOrgPolicyCall) (request)
464/// * [get org policy projects](ProjectGetOrgPolicyCall) (request)
465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
466#[serde_with::serde_as]
467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
468pub struct GetOrgPolicyRequest {
469 /// Name of the `Constraint` to get the `Policy`.
470 pub constraint: Option<String>,
471}
472
473impl common::RequestValue for GetOrgPolicyRequest {}
474
475/// Encapsulates settings provided to GetIamPolicy.
476///
477/// This type is not used in any activity, and only used as *part* of another schema.
478///
479#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
480#[serde_with::serde_as]
481#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
482pub struct GetPolicyOptions {
483 /// 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).
484 #[serde(rename = "requestedPolicyVersion")]
485 pub requested_policy_version: Option<i32>,
486}
487
488impl common::Part for GetPolicyOptions {}
489
490/// A Lien represents an encumbrance on the actions that can be performed on a resource.
491///
492/// # Activities
493///
494/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
495/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
496///
497/// * [create liens](LienCreateCall) (request|response)
498/// * [delete liens](LienDeleteCall) (none)
499/// * [get liens](LienGetCall) (response)
500/// * [list liens](LienListCall) (none)
501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
502#[serde_with::serde_as]
503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
504pub struct Lien {
505 /// The creation time of this Lien.
506 #[serde(rename = "createTime")]
507 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
508 /// A system-generated unique identifier for this Lien. Example: `liens/1234abcd`
509 pub name: Option<String>,
510 /// A stable, user-visible/meaningful string identifying the origin of the Lien, intended to be inspected programmatically. Maximum length of 200 characters. Example: 'compute.googleapis.com'
511 pub origin: Option<String>,
512 /// A reference to the resource this Lien is attached to. The server will validate the parent against those for which Liens are supported. Example: `projects/1234`
513 pub parent: Option<String>,
514 /// Concise user-visible strings indicating why an action cannot be performed on a resource. Maximum length of 200 characters. Example: 'Holds production API key'
515 pub reason: Option<String>,
516 /// The types of operations which should be blocked as a result of this Lien. Each value should correspond to an IAM permission. The server will validate the permissions against those for which Liens are supported. An empty list is meaningless and will be rejected. Example: ['resourcemanager.projects.delete']
517 pub restrictions: Option<Vec<String>>,
518}
519
520impl common::RequestValue for Lien {}
521impl common::Resource for Lien {}
522impl common::ResponseResult for Lien {}
523
524/// The request sent to the `ListAvailableOrgPolicyConstraints` method on the project, folder, or organization.
525///
526/// # Activities
527///
528/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
529/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
530///
531/// * [list available org policy constraints folders](FolderListAvailableOrgPolicyConstraintCall) (request)
532/// * [list available org policy constraints organizations](OrganizationListAvailableOrgPolicyConstraintCall) (request)
533/// * [list available org policy constraints projects](ProjectListAvailableOrgPolicyConstraintCall) (request)
534#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
535#[serde_with::serde_as]
536#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
537pub struct ListAvailableOrgPolicyConstraintsRequest {
538 /// Size of the pages to be returned. This is currently unsupported and will be ignored. The server may at any point start using this field to limit page size.
539 #[serde(rename = "pageSize")]
540 pub page_size: Option<i32>,
541 /// Page token used to retrieve the next page. This is currently unsupported and will be ignored. The server may at any point start using this field.
542 #[serde(rename = "pageToken")]
543 pub page_token: Option<String>,
544}
545
546impl common::RequestValue for ListAvailableOrgPolicyConstraintsRequest {}
547
548/// The response returned from the `ListAvailableOrgPolicyConstraints` method. Returns all `Constraints` that could be set at this level of the hierarchy (contrast with the response from `ListPolicies`, which returns all policies which are set).
549///
550/// # Activities
551///
552/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
553/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
554///
555/// * [list available org policy constraints folders](FolderListAvailableOrgPolicyConstraintCall) (response)
556/// * [list available org policy constraints organizations](OrganizationListAvailableOrgPolicyConstraintCall) (response)
557/// * [list available org policy constraints projects](ProjectListAvailableOrgPolicyConstraintCall) (response)
558#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
559#[serde_with::serde_as]
560#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
561pub struct ListAvailableOrgPolicyConstraintsResponse {
562 /// The collection of constraints that are settable on the request resource.
563 pub constraints: Option<Vec<Constraint>>,
564 /// Page token used to retrieve the next page. This is currently not used.
565 #[serde(rename = "nextPageToken")]
566 pub next_page_token: Option<String>,
567}
568
569impl common::ResponseResult for ListAvailableOrgPolicyConstraintsResponse {}
570
571/// A `Constraint` that allows or disallows a list of string values, which are configured by an Organization's policy administrator with a `Policy`.
572///
573/// This type is not used in any activity, and only used as *part* of another schema.
574///
575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
576#[serde_with::serde_as]
577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
578pub struct ListConstraint {
579 /// Optional. The Google Cloud Console will try to default to a configuration that matches the value specified in this `Constraint`.
580 #[serde(rename = "suggestedValue")]
581 pub suggested_value: Option<String>,
582 /// Indicates whether subtrees of Cloud Resource Manager resource hierarchy can be used in `Policy.allowed_values` and `Policy.denied_values`. For example, `"under:folders/123"` would match any resource under the 'folders/123' folder.
583 #[serde(rename = "supportsUnder")]
584 pub supports_under: Option<bool>,
585}
586
587impl common::Part for ListConstraint {}
588
589/// The response message for Liens.ListLiens.
590///
591/// # Activities
592///
593/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
594/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
595///
596/// * [list liens](LienListCall) (response)
597#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
598#[serde_with::serde_as]
599#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
600pub struct ListLiensResponse {
601 /// A list of Liens.
602 pub liens: Option<Vec<Lien>>,
603 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
604 #[serde(rename = "nextPageToken")]
605 pub next_page_token: Option<String>,
606}
607
608impl common::ResponseResult for ListLiensResponse {}
609
610/// The request sent to the ListOrgPolicies method.
611///
612/// # Activities
613///
614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
616///
617/// * [list org policies folders](FolderListOrgPolicyCall) (request)
618/// * [list org policies organizations](OrganizationListOrgPolicyCall) (request)
619/// * [list org policies projects](ProjectListOrgPolicyCall) (request)
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct ListOrgPoliciesRequest {
624 /// Size of the pages to be returned. This is currently unsupported and will be ignored. The server may at any point start using this field to limit page size.
625 #[serde(rename = "pageSize")]
626 pub page_size: Option<i32>,
627 /// Page token used to retrieve the next page. This is currently unsupported and will be ignored. The server may at any point start using this field.
628 #[serde(rename = "pageToken")]
629 pub page_token: Option<String>,
630}
631
632impl common::RequestValue for ListOrgPoliciesRequest {}
633
634/// The response returned from the `ListOrgPolicies` method. It will be empty if no `Policies` are set on the resource.
635///
636/// # Activities
637///
638/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
639/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
640///
641/// * [list org policies folders](FolderListOrgPolicyCall) (response)
642/// * [list org policies organizations](OrganizationListOrgPolicyCall) (response)
643/// * [list org policies projects](ProjectListOrgPolicyCall) (response)
644#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
645#[serde_with::serde_as]
646#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
647pub struct ListOrgPoliciesResponse {
648 /// Page token used to retrieve the next page. This is currently not used, but the server may at any point start supplying a valid token.
649 #[serde(rename = "nextPageToken")]
650 pub next_page_token: Option<String>,
651 /// The `Policies` that are set on the resource. It will be empty if no `Policies` are set.
652 pub policies: Option<Vec<OrgPolicy>>,
653}
654
655impl common::ResponseResult for ListOrgPoliciesResponse {}
656
657/// Used in `policy_type` to specify how `list_policy` behaves at this resource. `ListPolicy` can define specific values and subtrees of Cloud Resource Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that are allowed or denied by setting the `allowed_values` and `denied_values` fields. This is achieved by using the `under:` and optional `is:` prefixes. The `under:` prefix is used to denote resource subtree values. The `is:` prefix is used to denote specific values, and is required only if the value contains a ":". Values prefixed with "is:" are treated the same as values with no prefix. Ancestry subtrees must be in one of the following formats: - "projects/", e.g. "projects/tokyo-rain-123" - "folders/", e.g. "folders/1234" - "organizations/", e.g. "organizations/1234" The `supports_under` field of the associated `Constraint` defines whether ancestry prefixes can be used. You can set `allowed_values` and `denied_values` in the same `Policy` if `all_values` is `ALL_VALUES_UNSPECIFIED`. `ALLOW` or `DENY` are used to allow or deny all values. If `all_values` is set to either `ALLOW` or `DENY`, `allowed_values` and `denied_values` must be unset.
658///
659/// This type is not used in any activity, and only used as *part* of another schema.
660///
661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
662#[serde_with::serde_as]
663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
664pub struct ListPolicy {
665 /// The policy all_values state.
666 #[serde(rename = "allValues")]
667 pub all_values: Option<String>,
668 /// List of values allowed at this resource. Can only be set if `all_values` is set to `ALL_VALUES_UNSPECIFIED`.
669 #[serde(rename = "allowedValues")]
670 pub allowed_values: Option<Vec<String>>,
671 /// List of values denied at this resource. Can only be set if `all_values` is set to `ALL_VALUES_UNSPECIFIED`.
672 #[serde(rename = "deniedValues")]
673 pub denied_values: Option<Vec<String>>,
674 /// Determines the inheritance behavior for this `Policy`. By default, a `ListPolicy` set at a resource supersedes any `Policy` set anywhere up the resource hierarchy. However, if `inherit_from_parent` is set to `true`, then the values from the effective `Policy` of the parent resource are inherited, meaning the values set in this `Policy` are added to the values inherited up the hierarchy. Setting `Policy` hierarchies that inherit both allowed values and denied values isn't recommended in most circumstances to keep the configuration simple and understandable. However, it is possible to set a `Policy` with `allowed_values` set that inherits a `Policy` with `denied_values` set. In this case, the values that are allowed must be in `allowed_values` and not present in `denied_values`. For example, suppose you have a `Constraint` `constraints/serviceuser.services`, which has a `constraint_type` of `list_constraint`, and with `constraint_default` set to `ALLOW`. Suppose that at the Organization level, a `Policy` is applied that restricts the allowed API activations to {`E1`, `E2`}. Then, if a `Policy` is applied to a project below the Organization that has `inherit_from_parent` set to `false` and field all_values set to DENY, then an attempt to activate any API will be denied. The following examples demonstrate different possible layerings for `projects/bar` parented by `organizations/foo`: Example 1 (no inherited values): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values:"E2"} `projects/bar` has `inherit_from_parent` `false` and values: {allowed_values: "E3" allowed_values: "E4"} The accepted values at `organizations/foo` are `E1`, `E2`. The accepted values at `projects/bar` are `E3`, and `E4`. Example 2 (inherited values): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values:"E2"} `projects/bar` has a `Policy` with values: {value: "E3" value: "E4" inherit_from_parent: true} The accepted values at `organizations/foo` are `E1`, `E2`. The accepted values at `projects/bar` are `E1`, `E2`, `E3`, and `E4`. Example 3 (inheriting both allowed and denied values): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values: "E2"} `projects/bar` has a `Policy` with: {denied_values: "E1"} The accepted values at `organizations/foo` are `E1`, `E2`. The value accepted at `projects/bar` is `E2`. Example 4 (RestoreDefault): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values:"E2"} `projects/bar` has a `Policy` with values: {RestoreDefault: {}} The accepted values at `organizations/foo` are `E1`, `E2`. The accepted values at `projects/bar` are either all or none depending on the value of `constraint_default` (if `ALLOW`, all; if `DENY`, none). Example 5 (no policy inherits parent policy): `organizations/foo` has no `Policy` set. `projects/bar` has no `Policy` set. The accepted values at both levels are either all or none depending on the value of `constraint_default` (if `ALLOW`, all; if `DENY`, none). Example 6 (ListConstraint allowing all): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values: "E2"} `projects/bar` has a `Policy` with: {all: ALLOW} The accepted values at `organizations/foo` are `E1`, E2`. Any value is accepted at `projects/bar`. Example 7 (ListConstraint allowing none): `organizations/foo` has a `Policy` with values: {allowed_values: "E1" allowed_values: "E2"} `projects/bar` has a `Policy` with: {all: DENY} The accepted values at `organizations/foo` are `E1`, E2`. No value is accepted at `projects/bar`. Example 10 (allowed and denied subtrees of Resource Manager hierarchy): Given the following resource hierarchy O1->{F1, F2}; F1->{P1}; F2->{P2, P3}, `organizations/foo` has a `Policy` with values: {allowed_values: "under:organizations/O1"} `projects/bar` has a `Policy` with: {allowed_values: "under:projects/P3"} {denied_values: "under:folders/F2"} The accepted values at `organizations/foo` are `organizations/O1`, `folders/F1`, `folders/F2`, `projects/P1`, `projects/P2`, `projects/P3`. The accepted values at `projects/bar` are `organizations/O1`, `folders/F1`, `projects/P1`.
675 #[serde(rename = "inheritFromParent")]
676 pub inherit_from_parent: Option<bool>,
677 /// Optional. The Google Cloud Console will try to default to a configuration that matches the value specified in this `Policy`. If `suggested_value` is not set, it will inherit the value specified higher in the hierarchy, unless `inherit_from_parent` is `false`.
678 #[serde(rename = "suggestedValue")]
679 pub suggested_value: Option<String>,
680}
681
682impl common::Part for ListPolicy {}
683
684/// A page of the response received from the ListProjects method. A paginated response where more pages are available has `next_page_token` set. This token can be used in a subsequent request to retrieve the next request page.
685///
686/// # Activities
687///
688/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
689/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
690///
691/// * [list projects](ProjectListCall) (response)
692#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
693#[serde_with::serde_as]
694#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
695pub struct ListProjectsResponse {
696 /// Pagination token. If the result set is too large to fit in a single response, this token is returned. It encodes the position of the current result cursor. Feeding this value into a new list request with the `page_token` parameter gives the next page of the results. When `next_page_token` is not filled in, there is no next page and the list returned is the last page in the result set. Pagination tokens have a limited lifetime.
697 #[serde(rename = "nextPageToken")]
698 pub next_page_token: Option<String>,
699 /// The list of Projects that matched the list filter. This list can be paginated.
700 pub projects: Option<Vec<Project>>,
701}
702
703impl common::ResponseResult for ListProjectsResponse {}
704
705/// This resource represents a long-running operation that is the result of a network API call.
706///
707/// # Activities
708///
709/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
710/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
711///
712/// * [get operations](OperationGetCall) (response)
713/// * [create projects](ProjectCreateCall) (response)
714#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
715#[serde_with::serde_as]
716#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
717pub struct Operation {
718 /// 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.
719 pub done: Option<bool>,
720 /// The error result of the operation in case of failure or cancellation.
721 pub error: Option<Status>,
722 /// 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.
723 pub metadata: Option<HashMap<String, serde_json::Value>>,
724 /// 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}`.
725 pub name: Option<String>,
726 /// 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`.
727 pub response: Option<HashMap<String, serde_json::Value>>,
728}
729
730impl common::Resource for Operation {}
731impl common::ResponseResult for Operation {}
732
733/// Defines a Cloud Organization `Policy` which is used to specify `Constraints` for configurations of Cloud Platform resources.
734///
735/// # Activities
736///
737/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
738/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
739///
740/// * [get effective org policy folders](FolderGetEffectiveOrgPolicyCall) (response)
741/// * [get org policy folders](FolderGetOrgPolicyCall) (response)
742/// * [set org policy folders](FolderSetOrgPolicyCall) (response)
743/// * [get effective org policy organizations](OrganizationGetEffectiveOrgPolicyCall) (response)
744/// * [get org policy organizations](OrganizationGetOrgPolicyCall) (response)
745/// * [set org policy organizations](OrganizationSetOrgPolicyCall) (response)
746/// * [get effective org policy projects](ProjectGetEffectiveOrgPolicyCall) (response)
747/// * [get org policy projects](ProjectGetOrgPolicyCall) (response)
748/// * [set org policy projects](ProjectSetOrgPolicyCall) (response)
749#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
750#[serde_with::serde_as]
751#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
752pub struct OrgPolicy {
753 /// For boolean `Constraints`, whether to enforce the `Constraint` or not.
754 #[serde(rename = "booleanPolicy")]
755 pub boolean_policy: Option<BooleanPolicy>,
756 /// The name of the `Constraint` the `Policy` is configuring, for example, `constraints/serviceuser.services`. A [list of available constraints](https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints) is available. Immutable after creation.
757 pub constraint: Option<String>,
758 /// An opaque tag indicating the current version of the `Policy`, used for concurrency control. When the `Policy` is returned from either a `GetPolicy` or a `ListOrgPolicy` request, this `etag` indicates the version of the current `Policy` to use when executing a read-modify-write loop. When the `Policy` is returned from a `GetEffectivePolicy` request, the `etag` will be unset. When the `Policy` is used in a `SetOrgPolicy` method, use the `etag` value that was returned from a `GetOrgPolicy` request as part of a read-modify-write loop for concurrency control. Not setting the `etag`in a `SetOrgPolicy` request will result in an unconditional write of the `Policy`.
759 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
760 pub etag: Option<Vec<u8>>,
761 /// List of values either allowed or disallowed.
762 #[serde(rename = "listPolicy")]
763 pub list_policy: Option<ListPolicy>,
764 /// Restores the default behavior of the constraint; independent of `Constraint` type.
765 #[serde(rename = "restoreDefault")]
766 pub restore_default: Option<RestoreDefault>,
767 /// The time stamp the `Policy` was previously updated. This is set by the server, not specified by the caller, and represents the last time a call to `SetOrgPolicy` was made for that `Policy`. Any value set by the client will be ignored.
768 #[serde(rename = "updateTime")]
769 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
770 /// Version of the `Policy`. Default version is 0;
771 pub version: Option<i32>,
772}
773
774impl common::ResponseResult for OrgPolicy {}
775
776/// The root node in the resource hierarchy to which a particular entity’s (e.g., company) resources belong.
777///
778/// # Activities
779///
780/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
781/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
782///
783/// * [clear org policy organizations](OrganizationClearOrgPolicyCall) (none)
784/// * [get organizations](OrganizationGetCall) (response)
785/// * [get effective org policy organizations](OrganizationGetEffectiveOrgPolicyCall) (none)
786/// * [get iam policy organizations](OrganizationGetIamPolicyCall) (none)
787/// * [get org policy organizations](OrganizationGetOrgPolicyCall) (none)
788/// * [list available org policy constraints organizations](OrganizationListAvailableOrgPolicyConstraintCall) (none)
789/// * [list org policies organizations](OrganizationListOrgPolicyCall) (none)
790/// * [search organizations](OrganizationSearchCall) (none)
791/// * [set iam policy organizations](OrganizationSetIamPolicyCall) (none)
792/// * [set org policy organizations](OrganizationSetOrgPolicyCall) (none)
793/// * [test iam permissions organizations](OrganizationTestIamPermissionCall) (none)
794#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
795#[serde_with::serde_as]
796#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
797pub struct Organization {
798 /// Timestamp when the Organization was created. Assigned by the server.
799 #[serde(rename = "creationTime")]
800 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
801 /// A human-readable string that refers to the Organization in the Google Cloud console. This string is set by the server and cannot be changed. The string will be set to the primary domain (for example, "google.com") of the G Suite customer that owns the organization.
802 #[serde(rename = "displayName")]
803 pub display_name: Option<String>,
804 /// The organization's current lifecycle state. Assigned by the server.
805 #[serde(rename = "lifecycleState")]
806 pub lifecycle_state: Option<String>,
807 /// Output only. The resource name of the organization. This is the organization's relative path in the API. Its format is "organizations/[organization_id]". For example, "organizations/1234".
808 pub name: Option<String>,
809 /// The owner of this Organization. The owner should be specified on creation. Once set, it cannot be changed. This field is required.
810 pub owner: Option<OrganizationOwner>,
811}
812
813impl common::Resource for Organization {}
814impl common::ResponseResult for Organization {}
815
816/// The entity that owns an Organization. The lifetime of the Organization and all of its descendants are bound to the `OrganizationOwner`. If the `OrganizationOwner` is deleted, the Organization and all its descendants will be deleted.
817///
818/// This type is not used in any activity, and only used as *part* of another schema.
819///
820#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
821#[serde_with::serde_as]
822#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
823pub struct OrganizationOwner {
824 /// The G Suite customer id used in the Directory API.
825 #[serde(rename = "directoryCustomerId")]
826 pub directory_customer_id: Option<String>,
827}
828
829impl common::Part for OrganizationOwner {}
830
831/// 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/).
832///
833/// # Activities
834///
835/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
836/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
837///
838/// * [get iam policy organizations](OrganizationGetIamPolicyCall) (response)
839/// * [set iam policy organizations](OrganizationSetIamPolicyCall) (response)
840/// * [get iam policy projects](ProjectGetIamPolicyCall) (response)
841/// * [set iam policy projects](ProjectSetIamPolicyCall) (response)
842#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
843#[serde_with::serde_as]
844#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
845pub struct Policy {
846 /// Specifies cloud audit logging configuration for this policy.
847 #[serde(rename = "auditConfigs")]
848 pub audit_configs: Option<Vec<AuditConfig>>,
849 /// 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`.
850 pub bindings: Option<Vec<Binding>>,
851 /// `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.
852 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
853 pub etag: Option<Vec<u8>>,
854 /// 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).
855 pub version: Option<i32>,
856}
857
858impl common::ResponseResult for Policy {}
859
860/// A Project is a high-level Google Cloud Platform entity. It is a container for ACLs, APIs, App Engine Apps, VMs, and other Google Cloud Platform resources.
861///
862/// # Activities
863///
864/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
865/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
866///
867/// * [clear org policy projects](ProjectClearOrgPolicyCall) (none)
868/// * [create projects](ProjectCreateCall) (request)
869/// * [delete projects](ProjectDeleteCall) (none)
870/// * [get projects](ProjectGetCall) (response)
871/// * [get ancestry projects](ProjectGetAncestryCall) (none)
872/// * [get effective org policy projects](ProjectGetEffectiveOrgPolicyCall) (none)
873/// * [get iam policy projects](ProjectGetIamPolicyCall) (none)
874/// * [get org policy projects](ProjectGetOrgPolicyCall) (none)
875/// * [list projects](ProjectListCall) (none)
876/// * [list available org policy constraints projects](ProjectListAvailableOrgPolicyConstraintCall) (none)
877/// * [list org policies projects](ProjectListOrgPolicyCall) (none)
878/// * [set iam policy projects](ProjectSetIamPolicyCall) (none)
879/// * [set org policy projects](ProjectSetOrgPolicyCall) (none)
880/// * [test iam permissions projects](ProjectTestIamPermissionCall) (none)
881/// * [undelete projects](ProjectUndeleteCall) (none)
882/// * [update projects](ProjectUpdateCall) (request|response)
883#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
884#[serde_with::serde_as]
885#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
886pub struct Project {
887 /// Output only. If this project is a Management Project, list of capabilities configured on the parent folder. Note, presence of any capability implies that this is a Management Project. Example: `folders/123/capabilities/app-management`. OUTPUT ONLY.
888 #[serde(rename = "configuredCapabilities")]
889 pub configured_capabilities: Option<Vec<String>>,
890 /// Creation time. Read-only.
891 #[serde(rename = "createTime")]
892 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
893 /// The labels associated with this Project. Label keys must be between 1 and 63 characters long and must conform to the following regular expression: a-z{0,62}. Label values must be between 0 and 63 characters long and must conform to the regular expression [a-z0-9_-]{0,63}. A label value can be empty. No more than 256 labels can be associated with a given resource. Clients should store labels in a representation such as JSON that does not depend on specific characters being disallowed. Example: "environment" : "dev" Read-write.
894 pub labels: Option<HashMap<String, String>>,
895 /// The Project lifecycle state. Read-only.
896 #[serde(rename = "lifecycleState")]
897 pub lifecycle_state: Option<String>,
898 /// The optional user-assigned display name of the Project. When present it must be between 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote, double-quote, space, and exclamation point. Example: `My Project` Read-write.
899 pub name: Option<String>,
900 /// An optional reference to a parent Resource. Supported parent types include "organization" and "folder". Once set, the parent cannot be cleared. The `parent` can be set on creation or using the `UpdateProject` method; the end user must have the `resourcemanager.projects.create` permission on the parent.
901 pub parent: Option<ResourceId>,
902 /// The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited. Example: `tokyo-rain-123` Read-only after creation.
903 #[serde(rename = "projectId")]
904 pub project_id: Option<String>,
905 /// The number uniquely identifying the project. Example: `415104041262` Read-only.
906 #[serde(rename = "projectNumber")]
907 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
908 pub project_number: Option<i64>,
909 /// Optional. Input only. Immutable. Tag keys/values directly bound to this project. Each item in the map must be expressed as " : ". For example: "123/environment" : "production", "123/costCenter" : "marketing" Note: Currently this field is in Preview.
910 pub tags: Option<HashMap<String, String>>,
911}
912
913impl common::RequestValue for Project {}
914impl common::Resource for Project {}
915impl common::ResponseResult for Project {}
916
917/// A container to reference an id for any resource type. A `resource` in Google Cloud Platform is a generic term for something you (a developer) may want to interact with through one of our API's. Some examples are an App Engine app, a Compute Engine instance, a Cloud SQL database, and so on.
918///
919/// This type is not used in any activity, and only used as *part* of another schema.
920///
921#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
922#[serde_with::serde_as]
923#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
924pub struct ResourceId {
925 /// The type-specific id. This should correspond to the id used in the type-specific API's.
926 pub id: Option<String>,
927 /// The resource type this id is for. At present, the valid types are: "organization", "folder", and "project".
928 #[serde(rename = "type")]
929 pub type_: Option<String>,
930}
931
932impl common::Part for ResourceId {}
933
934/// Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific `Constraint` at this resource. Suppose that `constraint_default` is set to `ALLOW` for the `Constraint` `constraints/serviceuser.services`. Suppose that organization foo.com sets a `Policy` at their Organization resource node that restricts the allowed service activations to deny all service activations. They could then set a `Policy` with the `policy_type` `restore_default` on several experimental projects, restoring the `constraint_default` enforcement of the `Constraint` for only those projects, allowing those projects to have all services activated.
935///
936/// This type is not used in any activity, and only used as *part* of another schema.
937///
938#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
939#[serde_with::serde_as]
940#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
941pub struct RestoreDefault {
942 _never_set: Option<bool>,
943}
944
945impl common::Part for RestoreDefault {}
946
947/// The request sent to the `SearchOrganizations` method.
948///
949/// # Activities
950///
951/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
952/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
953///
954/// * [search organizations](OrganizationSearchCall) (request)
955#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
956#[serde_with::serde_as]
957#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
958pub struct SearchOrganizationsRequest {
959 /// An optional query string used to filter the Organizations to return in the response. Filter rules are case-insensitive. Organizations may be filtered by `owner.directoryCustomerId` or by `domain`, where the domain is a verified G Suite domain, for example: * Filter `owner.directorycustomerid:123456789` returns Organization resources with `owner.directory_customer_id` equal to `123456789`. * Filter `domain:google.com` returns Organization resources corresponding to the domain `google.com`. This field is optional.
960 pub filter: Option<String>,
961 /// The maximum number of Organizations to return in the response. The server can return fewer organizations than requested. If unspecified, server picks an appropriate default.
962 #[serde(rename = "pageSize")]
963 pub page_size: Option<i32>,
964 /// A pagination token returned from a previous call to `SearchOrganizations` that indicates from where listing should continue. This field is optional.
965 #[serde(rename = "pageToken")]
966 pub page_token: Option<String>,
967}
968
969impl common::RequestValue for SearchOrganizationsRequest {}
970
971/// The response returned from the `SearchOrganizations` method.
972///
973/// # Activities
974///
975/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
976/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
977///
978/// * [search organizations](OrganizationSearchCall) (response)
979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
980#[serde_with::serde_as]
981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
982pub struct SearchOrganizationsResponse {
983 /// A pagination token to be used to retrieve the next page of results. If the result is too large to fit within the page size specified in the request, this field will be set with a token that can be used to fetch the next page of results. If this field is empty, it indicates that this response contains the last page of results.
984 #[serde(rename = "nextPageToken")]
985 pub next_page_token: Option<String>,
986 /// The list of Organizations that matched the search query, possibly paginated.
987 pub organizations: Option<Vec<Organization>>,
988}
989
990impl common::ResponseResult for SearchOrganizationsResponse {}
991
992/// Request message for `SetIamPolicy` method.
993///
994/// # Activities
995///
996/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
997/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
998///
999/// * [set iam policy organizations](OrganizationSetIamPolicyCall) (request)
1000/// * [set iam policy projects](ProjectSetIamPolicyCall) (request)
1001#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1002#[serde_with::serde_as]
1003#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1004pub struct SetIamPolicyRequest {
1005 /// 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.
1006 pub policy: Option<Policy>,
1007 /// 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"`
1008 #[serde(rename = "updateMask")]
1009 pub update_mask: Option<common::FieldMask>,
1010}
1011
1012impl common::RequestValue for SetIamPolicyRequest {}
1013
1014/// The request sent to the SetOrgPolicyRequest method.
1015///
1016/// # Activities
1017///
1018/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1019/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1020///
1021/// * [set org policy folders](FolderSetOrgPolicyCall) (request)
1022/// * [set org policy organizations](OrganizationSetOrgPolicyCall) (request)
1023/// * [set org policy projects](ProjectSetOrgPolicyCall) (request)
1024#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1025#[serde_with::serde_as]
1026#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1027pub struct SetOrgPolicyRequest {
1028 /// `Policy` to set on the resource.
1029 pub policy: Option<OrgPolicy>,
1030}
1031
1032impl common::RequestValue for SetOrgPolicyRequest {}
1033
1034/// 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).
1035///
1036/// This type is not used in any activity, and only used as *part* of another schema.
1037///
1038#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1039#[serde_with::serde_as]
1040#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1041pub struct Status {
1042 /// The status code, which should be an enum value of google.rpc.Code.
1043 pub code: Option<i32>,
1044 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1045 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1046 /// 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.
1047 pub message: Option<String>,
1048}
1049
1050impl common::Part for Status {}
1051
1052/// Request message for `TestIamPermissions` method.
1053///
1054/// # Activities
1055///
1056/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1057/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1058///
1059/// * [test iam permissions organizations](OrganizationTestIamPermissionCall) (request)
1060/// * [test iam permissions projects](ProjectTestIamPermissionCall) (request)
1061#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1062#[serde_with::serde_as]
1063#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1064pub struct TestIamPermissionsRequest {
1065 /// 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).
1066 pub permissions: Option<Vec<String>>,
1067}
1068
1069impl common::RequestValue for TestIamPermissionsRequest {}
1070
1071/// Response message for `TestIamPermissions` method.
1072///
1073/// # Activities
1074///
1075/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1076/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1077///
1078/// * [test iam permissions organizations](OrganizationTestIamPermissionCall) (response)
1079/// * [test iam permissions projects](ProjectTestIamPermissionCall) (response)
1080#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1081#[serde_with::serde_as]
1082#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1083pub struct TestIamPermissionsResponse {
1084 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1085 pub permissions: Option<Vec<String>>,
1086}
1087
1088impl common::ResponseResult for TestIamPermissionsResponse {}
1089
1090/// The request sent to the UndeleteProject method.
1091///
1092/// # Activities
1093///
1094/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1095/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1096///
1097/// * [undelete projects](ProjectUndeleteCall) (request)
1098#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1099#[serde_with::serde_as]
1100#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1101pub struct UndeleteProjectRequest {
1102 _never_set: Option<bool>,
1103}
1104
1105impl common::RequestValue for UndeleteProjectRequest {}
1106
1107// ###################
1108// MethodBuilders ###
1109// #################
1110
1111/// A builder providing access to all methods supported on *folder* resources.
1112/// It is not used directly, but through the [`CloudResourceManager`] hub.
1113///
1114/// # Example
1115///
1116/// Instantiate a resource builder
1117///
1118/// ```test_harness,no_run
1119/// extern crate hyper;
1120/// extern crate hyper_rustls;
1121/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1122///
1123/// # async fn dox() {
1124/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1125///
1126/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1127/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1128/// .with_native_roots()
1129/// .unwrap()
1130/// .https_only()
1131/// .enable_http2()
1132/// .build();
1133///
1134/// let executor = hyper_util::rt::TokioExecutor::new();
1135/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1136/// secret,
1137/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1138/// yup_oauth2::client::CustomHyperClientBuilder::from(
1139/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1140/// ),
1141/// ).build().await.unwrap();
1142///
1143/// let client = hyper_util::client::legacy::Client::builder(
1144/// hyper_util::rt::TokioExecutor::new()
1145/// )
1146/// .build(
1147/// hyper_rustls::HttpsConnectorBuilder::new()
1148/// .with_native_roots()
1149/// .unwrap()
1150/// .https_or_http()
1151/// .enable_http2()
1152/// .build()
1153/// );
1154/// let mut hub = CloudResourceManager::new(client, auth);
1155/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1156/// // like `clear_org_policy(...)`, `get_effective_org_policy(...)`, `get_org_policy(...)`, `list_available_org_policy_constraints(...)`, `list_org_policies(...)` and `set_org_policy(...)`
1157/// // to build up your call.
1158/// let rb = hub.folders();
1159/// # }
1160/// ```
1161pub struct FolderMethods<'a, C>
1162where
1163 C: 'a,
1164{
1165 hub: &'a CloudResourceManager<C>,
1166}
1167
1168impl<'a, C> common::MethodsBuilder for FolderMethods<'a, C> {}
1169
1170impl<'a, C> FolderMethods<'a, C> {
1171 /// Create a builder to help you perform the following task:
1172 ///
1173 /// Clears a `Policy` from a resource.
1174 ///
1175 /// # Arguments
1176 ///
1177 /// * `request` - No description provided.
1178 /// * `resource` - Name of the resource for the `Policy` to clear.
1179 pub fn clear_org_policy(
1180 &self,
1181 request: ClearOrgPolicyRequest,
1182 resource: &str,
1183 ) -> FolderClearOrgPolicyCall<'a, C> {
1184 FolderClearOrgPolicyCall {
1185 hub: self.hub,
1186 _request: request,
1187 _resource: resource.to_string(),
1188 _delegate: Default::default(),
1189 _additional_params: Default::default(),
1190 _scopes: Default::default(),
1191 }
1192 }
1193
1194 /// Create a builder to help you perform the following task:
1195 ///
1196 /// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
1197 ///
1198 /// # Arguments
1199 ///
1200 /// * `request` - No description provided.
1201 /// * `resource` - The name of the resource to start computing the effective `Policy`.
1202 pub fn get_effective_org_policy(
1203 &self,
1204 request: GetEffectiveOrgPolicyRequest,
1205 resource: &str,
1206 ) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
1207 FolderGetEffectiveOrgPolicyCall {
1208 hub: self.hub,
1209 _request: request,
1210 _resource: resource.to_string(),
1211 _delegate: Default::default(),
1212 _additional_params: Default::default(),
1213 _scopes: Default::default(),
1214 }
1215 }
1216
1217 /// Create a builder to help you perform the following task:
1218 ///
1219 /// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
1220 ///
1221 /// # Arguments
1222 ///
1223 /// * `request` - No description provided.
1224 /// * `resource` - Name of the resource the `Policy` is set on.
1225 pub fn get_org_policy(
1226 &self,
1227 request: GetOrgPolicyRequest,
1228 resource: &str,
1229 ) -> FolderGetOrgPolicyCall<'a, C> {
1230 FolderGetOrgPolicyCall {
1231 hub: self.hub,
1232 _request: request,
1233 _resource: resource.to_string(),
1234 _delegate: Default::default(),
1235 _additional_params: Default::default(),
1236 _scopes: Default::default(),
1237 }
1238 }
1239
1240 /// Create a builder to help you perform the following task:
1241 ///
1242 /// Lists `Constraints` that could be applied on the specified resource.
1243 ///
1244 /// # Arguments
1245 ///
1246 /// * `request` - No description provided.
1247 /// * `resource` - Name of the resource to list `Constraints` for.
1248 pub fn list_available_org_policy_constraints(
1249 &self,
1250 request: ListAvailableOrgPolicyConstraintsRequest,
1251 resource: &str,
1252 ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
1253 FolderListAvailableOrgPolicyConstraintCall {
1254 hub: self.hub,
1255 _request: request,
1256 _resource: resource.to_string(),
1257 _delegate: Default::default(),
1258 _additional_params: Default::default(),
1259 _scopes: Default::default(),
1260 }
1261 }
1262
1263 /// Create a builder to help you perform the following task:
1264 ///
1265 /// Lists all the `Policies` set for a particular resource.
1266 ///
1267 /// # Arguments
1268 ///
1269 /// * `request` - No description provided.
1270 /// * `resource` - Name of the resource to list Policies for.
1271 pub fn list_org_policies(
1272 &self,
1273 request: ListOrgPoliciesRequest,
1274 resource: &str,
1275 ) -> FolderListOrgPolicyCall<'a, C> {
1276 FolderListOrgPolicyCall {
1277 hub: self.hub,
1278 _request: request,
1279 _resource: resource.to_string(),
1280 _delegate: Default::default(),
1281 _additional_params: Default::default(),
1282 _scopes: Default::default(),
1283 }
1284 }
1285
1286 /// Create a builder to help you perform the following task:
1287 ///
1288 /// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
1289 ///
1290 /// # Arguments
1291 ///
1292 /// * `request` - No description provided.
1293 /// * `resource` - Resource name of the resource to attach the `Policy`.
1294 pub fn set_org_policy(
1295 &self,
1296 request: SetOrgPolicyRequest,
1297 resource: &str,
1298 ) -> FolderSetOrgPolicyCall<'a, C> {
1299 FolderSetOrgPolicyCall {
1300 hub: self.hub,
1301 _request: request,
1302 _resource: resource.to_string(),
1303 _delegate: Default::default(),
1304 _additional_params: Default::default(),
1305 _scopes: Default::default(),
1306 }
1307 }
1308}
1309
1310/// A builder providing access to all methods supported on *lien* resources.
1311/// It is not used directly, but through the [`CloudResourceManager`] hub.
1312///
1313/// # Example
1314///
1315/// Instantiate a resource builder
1316///
1317/// ```test_harness,no_run
1318/// extern crate hyper;
1319/// extern crate hyper_rustls;
1320/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1321///
1322/// # async fn dox() {
1323/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1324///
1325/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1326/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1327/// .with_native_roots()
1328/// .unwrap()
1329/// .https_only()
1330/// .enable_http2()
1331/// .build();
1332///
1333/// let executor = hyper_util::rt::TokioExecutor::new();
1334/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1335/// secret,
1336/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1337/// yup_oauth2::client::CustomHyperClientBuilder::from(
1338/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1339/// ),
1340/// ).build().await.unwrap();
1341///
1342/// let client = hyper_util::client::legacy::Client::builder(
1343/// hyper_util::rt::TokioExecutor::new()
1344/// )
1345/// .build(
1346/// hyper_rustls::HttpsConnectorBuilder::new()
1347/// .with_native_roots()
1348/// .unwrap()
1349/// .https_or_http()
1350/// .enable_http2()
1351/// .build()
1352/// );
1353/// let mut hub = CloudResourceManager::new(client, auth);
1354/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1355/// // like `create(...)`, `delete(...)`, `get(...)` and `list(...)`
1356/// // to build up your call.
1357/// let rb = hub.liens();
1358/// # }
1359/// ```
1360pub struct LienMethods<'a, C>
1361where
1362 C: 'a,
1363{
1364 hub: &'a CloudResourceManager<C>,
1365}
1366
1367impl<'a, C> common::MethodsBuilder for LienMethods<'a, C> {}
1368
1369impl<'a, C> LienMethods<'a, C> {
1370 /// Create a builder to help you perform the following task:
1371 ///
1372 /// Create a Lien which applies to the resource denoted by the `parent` field. Callers of this method will require permission on the `parent` resource. For example, applying to `projects/1234` requires permission `resourcemanager.projects.updateLiens`. NOTE: Some resources may limit the number of Liens which may be applied.
1373 ///
1374 /// # Arguments
1375 ///
1376 /// * `request` - No description provided.
1377 pub fn create(&self, request: Lien) -> LienCreateCall<'a, C> {
1378 LienCreateCall {
1379 hub: self.hub,
1380 _request: request,
1381 _delegate: Default::default(),
1382 _additional_params: Default::default(),
1383 _scopes: Default::default(),
1384 }
1385 }
1386
1387 /// Create a builder to help you perform the following task:
1388 ///
1389 /// Delete a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.updateLiens`.
1390 ///
1391 /// # Arguments
1392 ///
1393 /// * `name` - Required. The name/identifier of the Lien to delete.
1394 pub fn delete(&self, name: &str) -> LienDeleteCall<'a, C> {
1395 LienDeleteCall {
1396 hub: self.hub,
1397 _name: name.to_string(),
1398 _delegate: Default::default(),
1399 _additional_params: Default::default(),
1400 _scopes: Default::default(),
1401 }
1402 }
1403
1404 /// Create a builder to help you perform the following task:
1405 ///
1406 /// Retrieve a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`
1407 ///
1408 /// # Arguments
1409 ///
1410 /// * `name` - Required. The name/identifier of the Lien.
1411 pub fn get(&self, name: &str) -> LienGetCall<'a, C> {
1412 LienGetCall {
1413 hub: self.hub,
1414 _name: name.to_string(),
1415 _delegate: Default::default(),
1416 _additional_params: Default::default(),
1417 _scopes: Default::default(),
1418 }
1419 }
1420
1421 /// Create a builder to help you perform the following task:
1422 ///
1423 /// List all Liens applied to the `parent` resource. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`.
1424 pub fn list(&self) -> LienListCall<'a, C> {
1425 LienListCall {
1426 hub: self.hub,
1427 _parent: Default::default(),
1428 _page_token: Default::default(),
1429 _page_size: Default::default(),
1430 _delegate: Default::default(),
1431 _additional_params: Default::default(),
1432 _scopes: Default::default(),
1433 }
1434 }
1435}
1436
1437/// A builder providing access to all methods supported on *operation* resources.
1438/// It is not used directly, but through the [`CloudResourceManager`] hub.
1439///
1440/// # Example
1441///
1442/// Instantiate a resource builder
1443///
1444/// ```test_harness,no_run
1445/// extern crate hyper;
1446/// extern crate hyper_rustls;
1447/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1448///
1449/// # async fn dox() {
1450/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1451///
1452/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1453/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1454/// .with_native_roots()
1455/// .unwrap()
1456/// .https_only()
1457/// .enable_http2()
1458/// .build();
1459///
1460/// let executor = hyper_util::rt::TokioExecutor::new();
1461/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1462/// secret,
1463/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1464/// yup_oauth2::client::CustomHyperClientBuilder::from(
1465/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1466/// ),
1467/// ).build().await.unwrap();
1468///
1469/// let client = hyper_util::client::legacy::Client::builder(
1470/// hyper_util::rt::TokioExecutor::new()
1471/// )
1472/// .build(
1473/// hyper_rustls::HttpsConnectorBuilder::new()
1474/// .with_native_roots()
1475/// .unwrap()
1476/// .https_or_http()
1477/// .enable_http2()
1478/// .build()
1479/// );
1480/// let mut hub = CloudResourceManager::new(client, auth);
1481/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1482/// // like `get(...)`
1483/// // to build up your call.
1484/// let rb = hub.operations();
1485/// # }
1486/// ```
1487pub struct OperationMethods<'a, C>
1488where
1489 C: 'a,
1490{
1491 hub: &'a CloudResourceManager<C>,
1492}
1493
1494impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
1495
1496impl<'a, C> OperationMethods<'a, C> {
1497 /// Create a builder to help you perform the following task:
1498 ///
1499 /// 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.
1500 ///
1501 /// # Arguments
1502 ///
1503 /// * `name` - The name of the operation resource.
1504 pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
1505 OperationGetCall {
1506 hub: self.hub,
1507 _name: name.to_string(),
1508 _delegate: Default::default(),
1509 _additional_params: Default::default(),
1510 _scopes: Default::default(),
1511 }
1512 }
1513}
1514
1515/// A builder providing access to all methods supported on *organization* resources.
1516/// It is not used directly, but through the [`CloudResourceManager`] hub.
1517///
1518/// # Example
1519///
1520/// Instantiate a resource builder
1521///
1522/// ```test_harness,no_run
1523/// extern crate hyper;
1524/// extern crate hyper_rustls;
1525/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1526///
1527/// # async fn dox() {
1528/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1529///
1530/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1531/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1532/// .with_native_roots()
1533/// .unwrap()
1534/// .https_only()
1535/// .enable_http2()
1536/// .build();
1537///
1538/// let executor = hyper_util::rt::TokioExecutor::new();
1539/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1540/// secret,
1541/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1542/// yup_oauth2::client::CustomHyperClientBuilder::from(
1543/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1544/// ),
1545/// ).build().await.unwrap();
1546///
1547/// let client = hyper_util::client::legacy::Client::builder(
1548/// hyper_util::rt::TokioExecutor::new()
1549/// )
1550/// .build(
1551/// hyper_rustls::HttpsConnectorBuilder::new()
1552/// .with_native_roots()
1553/// .unwrap()
1554/// .https_or_http()
1555/// .enable_http2()
1556/// .build()
1557/// );
1558/// let mut hub = CloudResourceManager::new(client, auth);
1559/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1560/// // like `clear_org_policy(...)`, `get(...)`, `get_effective_org_policy(...)`, `get_iam_policy(...)`, `get_org_policy(...)`, `list_available_org_policy_constraints(...)`, `list_org_policies(...)`, `search(...)`, `set_iam_policy(...)`, `set_org_policy(...)` and `test_iam_permissions(...)`
1561/// // to build up your call.
1562/// let rb = hub.organizations();
1563/// # }
1564/// ```
1565pub struct OrganizationMethods<'a, C>
1566where
1567 C: 'a,
1568{
1569 hub: &'a CloudResourceManager<C>,
1570}
1571
1572impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
1573
1574impl<'a, C> OrganizationMethods<'a, C> {
1575 /// Create a builder to help you perform the following task:
1576 ///
1577 /// Clears a `Policy` from a resource.
1578 ///
1579 /// # Arguments
1580 ///
1581 /// * `request` - No description provided.
1582 /// * `resource` - Name of the resource for the `Policy` to clear.
1583 pub fn clear_org_policy(
1584 &self,
1585 request: ClearOrgPolicyRequest,
1586 resource: &str,
1587 ) -> OrganizationClearOrgPolicyCall<'a, C> {
1588 OrganizationClearOrgPolicyCall {
1589 hub: self.hub,
1590 _request: request,
1591 _resource: resource.to_string(),
1592 _delegate: Default::default(),
1593 _additional_params: Default::default(),
1594 _scopes: Default::default(),
1595 }
1596 }
1597
1598 /// Create a builder to help you perform the following task:
1599 ///
1600 /// Fetches an Organization resource identified by the specified resource name.
1601 ///
1602 /// # Arguments
1603 ///
1604 /// * `name` - The resource name of the Organization to fetch. This is the organization's relative path in the API, formatted as "organizations/[organizationId]". For example, "organizations/1234".
1605 pub fn get(&self, name: &str) -> OrganizationGetCall<'a, C> {
1606 OrganizationGetCall {
1607 hub: self.hub,
1608 _name: name.to_string(),
1609 _delegate: Default::default(),
1610 _additional_params: Default::default(),
1611 _scopes: Default::default(),
1612 }
1613 }
1614
1615 /// Create a builder to help you perform the following task:
1616 ///
1617 /// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
1618 ///
1619 /// # Arguments
1620 ///
1621 /// * `request` - No description provided.
1622 /// * `resource` - The name of the resource to start computing the effective `Policy`.
1623 pub fn get_effective_org_policy(
1624 &self,
1625 request: GetEffectiveOrgPolicyRequest,
1626 resource: &str,
1627 ) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
1628 OrganizationGetEffectiveOrgPolicyCall {
1629 hub: self.hub,
1630 _request: request,
1631 _resource: resource.to_string(),
1632 _delegate: Default::default(),
1633 _additional_params: Default::default(),
1634 _scopes: Default::default(),
1635 }
1636 }
1637
1638 /// Create a builder to help you perform the following task:
1639 ///
1640 /// Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization
1641 ///
1642 /// # Arguments
1643 ///
1644 /// * `request` - No description provided.
1645 /// * `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.
1646 pub fn get_iam_policy(
1647 &self,
1648 request: GetIamPolicyRequest,
1649 resource: &str,
1650 ) -> OrganizationGetIamPolicyCall<'a, C> {
1651 OrganizationGetIamPolicyCall {
1652 hub: self.hub,
1653 _request: request,
1654 _resource: resource.to_string(),
1655 _delegate: Default::default(),
1656 _additional_params: Default::default(),
1657 _scopes: Default::default(),
1658 }
1659 }
1660
1661 /// Create a builder to help you perform the following task:
1662 ///
1663 /// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
1664 ///
1665 /// # Arguments
1666 ///
1667 /// * `request` - No description provided.
1668 /// * `resource` - Name of the resource the `Policy` is set on.
1669 pub fn get_org_policy(
1670 &self,
1671 request: GetOrgPolicyRequest,
1672 resource: &str,
1673 ) -> OrganizationGetOrgPolicyCall<'a, C> {
1674 OrganizationGetOrgPolicyCall {
1675 hub: self.hub,
1676 _request: request,
1677 _resource: resource.to_string(),
1678 _delegate: Default::default(),
1679 _additional_params: Default::default(),
1680 _scopes: Default::default(),
1681 }
1682 }
1683
1684 /// Create a builder to help you perform the following task:
1685 ///
1686 /// Lists `Constraints` that could be applied on the specified resource.
1687 ///
1688 /// # Arguments
1689 ///
1690 /// * `request` - No description provided.
1691 /// * `resource` - Name of the resource to list `Constraints` for.
1692 pub fn list_available_org_policy_constraints(
1693 &self,
1694 request: ListAvailableOrgPolicyConstraintsRequest,
1695 resource: &str,
1696 ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
1697 OrganizationListAvailableOrgPolicyConstraintCall {
1698 hub: self.hub,
1699 _request: request,
1700 _resource: resource.to_string(),
1701 _delegate: Default::default(),
1702 _additional_params: Default::default(),
1703 _scopes: Default::default(),
1704 }
1705 }
1706
1707 /// Create a builder to help you perform the following task:
1708 ///
1709 /// Lists all the `Policies` set for a particular resource.
1710 ///
1711 /// # Arguments
1712 ///
1713 /// * `request` - No description provided.
1714 /// * `resource` - Name of the resource to list Policies for.
1715 pub fn list_org_policies(
1716 &self,
1717 request: ListOrgPoliciesRequest,
1718 resource: &str,
1719 ) -> OrganizationListOrgPolicyCall<'a, C> {
1720 OrganizationListOrgPolicyCall {
1721 hub: self.hub,
1722 _request: request,
1723 _resource: resource.to_string(),
1724 _delegate: Default::default(),
1725 _additional_params: Default::default(),
1726 _scopes: Default::default(),
1727 }
1728 }
1729
1730 /// Create a builder to help you perform the following task:
1731 ///
1732 /// Searches Organization resources that are visible to the user and satisfy the specified filter. This method returns Organizations in an unspecified order. New Organizations do not necessarily appear at the end of the results. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get` or has super admin privileges.
1733 ///
1734 /// # Arguments
1735 ///
1736 /// * `request` - No description provided.
1737 pub fn search(&self, request: SearchOrganizationsRequest) -> OrganizationSearchCall<'a, C> {
1738 OrganizationSearchCall {
1739 hub: self.hub,
1740 _request: request,
1741 _delegate: Default::default(),
1742 _additional_params: Default::default(),
1743 _scopes: Default::default(),
1744 }
1745 }
1746
1747 /// Create a builder to help you perform the following task:
1748 ///
1749 /// Sets the access control policy on an Organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization
1750 ///
1751 /// # Arguments
1752 ///
1753 /// * `request` - No description provided.
1754 /// * `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.
1755 pub fn set_iam_policy(
1756 &self,
1757 request: SetIamPolicyRequest,
1758 resource: &str,
1759 ) -> OrganizationSetIamPolicyCall<'a, C> {
1760 OrganizationSetIamPolicyCall {
1761 hub: self.hub,
1762 _request: request,
1763 _resource: resource.to_string(),
1764 _delegate: Default::default(),
1765 _additional_params: Default::default(),
1766 _scopes: Default::default(),
1767 }
1768 }
1769
1770 /// Create a builder to help you perform the following task:
1771 ///
1772 /// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
1773 ///
1774 /// # Arguments
1775 ///
1776 /// * `request` - No description provided.
1777 /// * `resource` - Resource name of the resource to attach the `Policy`.
1778 pub fn set_org_policy(
1779 &self,
1780 request: SetOrgPolicyRequest,
1781 resource: &str,
1782 ) -> OrganizationSetOrgPolicyCall<'a, C> {
1783 OrganizationSetOrgPolicyCall {
1784 hub: self.hub,
1785 _request: request,
1786 _resource: resource.to_string(),
1787 _delegate: Default::default(),
1788 _additional_params: Default::default(),
1789 _scopes: Default::default(),
1790 }
1791 }
1792
1793 /// Create a builder to help you perform the following task:
1794 ///
1795 /// Returns permissions that a caller has on the specified Organization. The `resource` field should be the organization's resource name, e.g. "organizations/123". There are no permissions required for making this API call.
1796 ///
1797 /// # Arguments
1798 ///
1799 /// * `request` - No description provided.
1800 /// * `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.
1801 pub fn test_iam_permissions(
1802 &self,
1803 request: TestIamPermissionsRequest,
1804 resource: &str,
1805 ) -> OrganizationTestIamPermissionCall<'a, C> {
1806 OrganizationTestIamPermissionCall {
1807 hub: self.hub,
1808 _request: request,
1809 _resource: resource.to_string(),
1810 _delegate: Default::default(),
1811 _additional_params: Default::default(),
1812 _scopes: Default::default(),
1813 }
1814 }
1815}
1816
1817/// A builder providing access to all methods supported on *project* resources.
1818/// It is not used directly, but through the [`CloudResourceManager`] hub.
1819///
1820/// # Example
1821///
1822/// Instantiate a resource builder
1823///
1824/// ```test_harness,no_run
1825/// extern crate hyper;
1826/// extern crate hyper_rustls;
1827/// extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
1828///
1829/// # async fn dox() {
1830/// use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1831///
1832/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1833/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1834/// .with_native_roots()
1835/// .unwrap()
1836/// .https_only()
1837/// .enable_http2()
1838/// .build();
1839///
1840/// let executor = hyper_util::rt::TokioExecutor::new();
1841/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1842/// secret,
1843/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1844/// yup_oauth2::client::CustomHyperClientBuilder::from(
1845/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1846/// ),
1847/// ).build().await.unwrap();
1848///
1849/// let client = hyper_util::client::legacy::Client::builder(
1850/// hyper_util::rt::TokioExecutor::new()
1851/// )
1852/// .build(
1853/// hyper_rustls::HttpsConnectorBuilder::new()
1854/// .with_native_roots()
1855/// .unwrap()
1856/// .https_or_http()
1857/// .enable_http2()
1858/// .build()
1859/// );
1860/// let mut hub = CloudResourceManager::new(client, auth);
1861/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1862/// // like `clear_org_policy(...)`, `create(...)`, `delete(...)`, `get(...)`, `get_ancestry(...)`, `get_effective_org_policy(...)`, `get_iam_policy(...)`, `get_org_policy(...)`, `list(...)`, `list_available_org_policy_constraints(...)`, `list_org_policies(...)`, `set_iam_policy(...)`, `set_org_policy(...)`, `test_iam_permissions(...)`, `undelete(...)` and `update(...)`
1863/// // to build up your call.
1864/// let rb = hub.projects();
1865/// # }
1866/// ```
1867pub struct ProjectMethods<'a, C>
1868where
1869 C: 'a,
1870{
1871 hub: &'a CloudResourceManager<C>,
1872}
1873
1874impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1875
1876impl<'a, C> ProjectMethods<'a, C> {
1877 /// Create a builder to help you perform the following task:
1878 ///
1879 /// Clears a `Policy` from a resource.
1880 ///
1881 /// # Arguments
1882 ///
1883 /// * `request` - No description provided.
1884 /// * `resource` - Name of the resource for the `Policy` to clear.
1885 pub fn clear_org_policy(
1886 &self,
1887 request: ClearOrgPolicyRequest,
1888 resource: &str,
1889 ) -> ProjectClearOrgPolicyCall<'a, C> {
1890 ProjectClearOrgPolicyCall {
1891 hub: self.hub,
1892 _request: request,
1893 _resource: resource.to_string(),
1894 _delegate: Default::default(),
1895 _additional_params: Default::default(),
1896 _scopes: Default::default(),
1897 }
1898 }
1899
1900 /// Create a builder to help you perform the following task:
1901 ///
1902 /// Request that a new Project be created. The result is an Operation which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking Operation is automatically deleted after a few hours, so there is no need to call DeleteOperation. Authorization requires the Google IAM permission `resourcemanager.projects.create` on the specified parent for the new project. The parent is identified by a specified ResourceId, which must include both an ID and a type, such as organization. This method does not associate the new project with a billing account. You can set or update the billing account associated with a project using the \[`projects.updateBillingInfo`\] (/billing/reference/rest/v1/projects/updateBillingInfo) method.
1903 ///
1904 /// # Arguments
1905 ///
1906 /// * `request` - No description provided.
1907 pub fn create(&self, request: Project) -> ProjectCreateCall<'a, C> {
1908 ProjectCreateCall {
1909 hub: self.hub,
1910 _request: request,
1911 _delegate: Default::default(),
1912 _additional_params: Default::default(),
1913 _scopes: Default::default(),
1914 }
1915 }
1916
1917 /// Create a builder to help you perform the following task:
1918 ///
1919 /// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if it has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have delete permissions for this Project.
1920 ///
1921 /// # Arguments
1922 ///
1923 /// * `projectId` - The Project ID (for example, `foo-bar-123`). Required.
1924 pub fn delete(&self, project_id: &str) -> ProjectDeleteCall<'a, C> {
1925 ProjectDeleteCall {
1926 hub: self.hub,
1927 _project_id: project_id.to_string(),
1928 _delegate: Default::default(),
1929 _additional_params: Default::default(),
1930 _scopes: Default::default(),
1931 }
1932 }
1933
1934 /// Create a builder to help you perform the following task:
1935 ///
1936 /// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
1937 ///
1938 /// # Arguments
1939 ///
1940 /// * `projectId` - Required. The Project ID (for example, `my-project-123`).
1941 pub fn get(&self, project_id: &str) -> ProjectGetCall<'a, C> {
1942 ProjectGetCall {
1943 hub: self.hub,
1944 _project_id: project_id.to_string(),
1945 _delegate: Default::default(),
1946 _additional_params: Default::default(),
1947 _scopes: Default::default(),
1948 }
1949 }
1950
1951 /// Create a builder to help you perform the following task:
1952 ///
1953 /// Gets a list of ancestors in the resource hierarchy for the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
1954 ///
1955 /// # Arguments
1956 ///
1957 /// * `request` - No description provided.
1958 /// * `projectId` - Required. The Project ID (for example, `my-project-123`).
1959 pub fn get_ancestry(
1960 &self,
1961 request: GetAncestryRequest,
1962 project_id: &str,
1963 ) -> ProjectGetAncestryCall<'a, C> {
1964 ProjectGetAncestryCall {
1965 hub: self.hub,
1966 _request: request,
1967 _project_id: project_id.to_string(),
1968 _delegate: Default::default(),
1969 _additional_params: Default::default(),
1970 _scopes: Default::default(),
1971 }
1972 }
1973
1974 /// Create a builder to help you perform the following task:
1975 ///
1976 /// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
1977 ///
1978 /// # Arguments
1979 ///
1980 /// * `request` - No description provided.
1981 /// * `resource` - The name of the resource to start computing the effective `Policy`.
1982 pub fn get_effective_org_policy(
1983 &self,
1984 request: GetEffectiveOrgPolicyRequest,
1985 resource: &str,
1986 ) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
1987 ProjectGetEffectiveOrgPolicyCall {
1988 hub: self.hub,
1989 _request: request,
1990 _resource: resource.to_string(),
1991 _delegate: Default::default(),
1992 _additional_params: Default::default(),
1993 _scopes: Default::default(),
1994 }
1995 }
1996
1997 /// Create a builder to help you perform the following task:
1998 ///
1999 /// Returns the IAM access control policy for the specified Project. Permission is denied if the policy or the resource does not exist. Authorization requires the Google IAM permission `resourcemanager.projects.getIamPolicy` on the project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names).
2000 ///
2001 /// # Arguments
2002 ///
2003 /// * `request` - No description provided.
2004 /// * `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.
2005 pub fn get_iam_policy(
2006 &self,
2007 request: GetIamPolicyRequest,
2008 resource: &str,
2009 ) -> ProjectGetIamPolicyCall<'a, C> {
2010 ProjectGetIamPolicyCall {
2011 hub: self.hub,
2012 _request: request,
2013 _resource: resource.to_string(),
2014 _delegate: Default::default(),
2015 _additional_params: Default::default(),
2016 _scopes: Default::default(),
2017 }
2018 }
2019
2020 /// Create a builder to help you perform the following task:
2021 ///
2022 /// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
2023 ///
2024 /// # Arguments
2025 ///
2026 /// * `request` - No description provided.
2027 /// * `resource` - Name of the resource the `Policy` is set on.
2028 pub fn get_org_policy(
2029 &self,
2030 request: GetOrgPolicyRequest,
2031 resource: &str,
2032 ) -> ProjectGetOrgPolicyCall<'a, C> {
2033 ProjectGetOrgPolicyCall {
2034 hub: self.hub,
2035 _request: request,
2036 _resource: resource.to_string(),
2037 _delegate: Default::default(),
2038 _additional_params: Default::default(),
2039 _scopes: Default::default(),
2040 }
2041 }
2042
2043 /// Create a builder to help you perform the following task:
2044 ///
2045 /// Lists Projects that the caller has the `resourcemanager.projects.get` permission on and satisfy the specified filter. This method returns Projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the GetProject method. NOTE: If the request filter contains a `parent.type` and `parent.id` and the caller has the `resourcemanager.projects.list` permission on the parent, the results will be drawn from an alternate index which provides more consistent results. In future versions of this API, this List method will be split into List and Search to properly capture the behavioral difference.
2046 pub fn list(&self) -> ProjectListCall<'a, C> {
2047 ProjectListCall {
2048 hub: self.hub,
2049 _page_token: Default::default(),
2050 _page_size: Default::default(),
2051 _filter: Default::default(),
2052 _delegate: Default::default(),
2053 _additional_params: Default::default(),
2054 _scopes: Default::default(),
2055 }
2056 }
2057
2058 /// Create a builder to help you perform the following task:
2059 ///
2060 /// Lists `Constraints` that could be applied on the specified resource.
2061 ///
2062 /// # Arguments
2063 ///
2064 /// * `request` - No description provided.
2065 /// * `resource` - Name of the resource to list `Constraints` for.
2066 pub fn list_available_org_policy_constraints(
2067 &self,
2068 request: ListAvailableOrgPolicyConstraintsRequest,
2069 resource: &str,
2070 ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
2071 ProjectListAvailableOrgPolicyConstraintCall {
2072 hub: self.hub,
2073 _request: request,
2074 _resource: resource.to_string(),
2075 _delegate: Default::default(),
2076 _additional_params: Default::default(),
2077 _scopes: Default::default(),
2078 }
2079 }
2080
2081 /// Create a builder to help you perform the following task:
2082 ///
2083 /// Lists all the `Policies` set for a particular resource.
2084 ///
2085 /// # Arguments
2086 ///
2087 /// * `request` - No description provided.
2088 /// * `resource` - Name of the resource to list Policies for.
2089 pub fn list_org_policies(
2090 &self,
2091 request: ListOrgPoliciesRequest,
2092 resource: &str,
2093 ) -> ProjectListOrgPolicyCall<'a, C> {
2094 ProjectListOrgPolicyCall {
2095 hub: self.hub,
2096 _request: request,
2097 _resource: resource.to_string(),
2098 _delegate: Default::default(),
2099 _additional_params: Default::default(),
2100 _scopes: Default::default(),
2101 }
2102 }
2103
2104 /// Create a builder to help you perform the following task:
2105 ///
2106 /// Sets the IAM access control policy for the specified Project. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. NOTE: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + You can only grant ownership of a project to a member by using the Google Cloud console. Inviting a member will deliver an invitation email that they must accept. An invitation email is not generated if you are granting a role other than owner, or if both the member you are inviting and the project are part of your organization. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible. Authorization requires the Google IAM permission `resourcemanager.projects.setIamPolicy` on the project
2107 ///
2108 /// # Arguments
2109 ///
2110 /// * `request` - No description provided.
2111 /// * `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.
2112 pub fn set_iam_policy(
2113 &self,
2114 request: SetIamPolicyRequest,
2115 resource: &str,
2116 ) -> ProjectSetIamPolicyCall<'a, C> {
2117 ProjectSetIamPolicyCall {
2118 hub: self.hub,
2119 _request: request,
2120 _resource: resource.to_string(),
2121 _delegate: Default::default(),
2122 _additional_params: Default::default(),
2123 _scopes: Default::default(),
2124 }
2125 }
2126
2127 /// Create a builder to help you perform the following task:
2128 ///
2129 /// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
2130 ///
2131 /// # Arguments
2132 ///
2133 /// * `request` - No description provided.
2134 /// * `resource` - Resource name of the resource to attach the `Policy`.
2135 pub fn set_org_policy(
2136 &self,
2137 request: SetOrgPolicyRequest,
2138 resource: &str,
2139 ) -> ProjectSetOrgPolicyCall<'a, C> {
2140 ProjectSetOrgPolicyCall {
2141 hub: self.hub,
2142 _request: request,
2143 _resource: resource.to_string(),
2144 _delegate: Default::default(),
2145 _additional_params: Default::default(),
2146 _scopes: Default::default(),
2147 }
2148 }
2149
2150 /// Create a builder to help you perform the following task:
2151 ///
2152 /// Returns permissions that a caller has on the specified Project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). There are no permissions required for making this API call.
2153 ///
2154 /// # Arguments
2155 ///
2156 /// * `request` - No description provided.
2157 /// * `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.
2158 pub fn test_iam_permissions(
2159 &self,
2160 request: TestIamPermissionsRequest,
2161 resource: &str,
2162 ) -> ProjectTestIamPermissionCall<'a, C> {
2163 ProjectTestIamPermissionCall {
2164 hub: self.hub,
2165 _request: request,
2166 _resource: resource.to_string(),
2167 _delegate: Default::default(),
2168 _additional_params: Default::default(),
2169 _scopes: Default::default(),
2170 }
2171 }
2172
2173 /// Create a builder to help you perform the following task:
2174 ///
2175 /// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have undelete permissions for this Project.
2176 ///
2177 /// # Arguments
2178 ///
2179 /// * `request` - No description provided.
2180 /// * `projectId` - Required. The project ID (for example, `foo-bar-123`).
2181 pub fn undelete(
2182 &self,
2183 request: UndeleteProjectRequest,
2184 project_id: &str,
2185 ) -> ProjectUndeleteCall<'a, C> {
2186 ProjectUndeleteCall {
2187 hub: self.hub,
2188 _request: request,
2189 _project_id: project_id.to_string(),
2190 _delegate: Default::default(),
2191 _additional_params: Default::default(),
2192 _scopes: Default::default(),
2193 }
2194 }
2195
2196 /// Create a builder to help you perform the following task:
2197 ///
2198 /// Updates the attributes of the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have modify permissions for this Project.
2199 ///
2200 /// # Arguments
2201 ///
2202 /// * `request` - No description provided.
2203 /// * `projectId` - The project ID (for example, `my-project-123`). Required.
2204 pub fn update(&self, request: Project, project_id: &str) -> ProjectUpdateCall<'a, C> {
2205 ProjectUpdateCall {
2206 hub: self.hub,
2207 _request: request,
2208 _project_id: project_id.to_string(),
2209 _delegate: Default::default(),
2210 _additional_params: Default::default(),
2211 _scopes: Default::default(),
2212 }
2213 }
2214}
2215
2216// ###################
2217// CallBuilders ###
2218// #################
2219
2220/// Clears a `Policy` from a resource.
2221///
2222/// A builder for the *clearOrgPolicy* method supported by a *folder* resource.
2223/// It is not used directly, but through a [`FolderMethods`] instance.
2224///
2225/// # Example
2226///
2227/// Instantiate a resource method builder
2228///
2229/// ```test_harness,no_run
2230/// # extern crate hyper;
2231/// # extern crate hyper_rustls;
2232/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
2233/// use cloudresourcemanager1::api::ClearOrgPolicyRequest;
2234/// # async fn dox() {
2235/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2236///
2237/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2238/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2239/// # .with_native_roots()
2240/// # .unwrap()
2241/// # .https_only()
2242/// # .enable_http2()
2243/// # .build();
2244///
2245/// # let executor = hyper_util::rt::TokioExecutor::new();
2246/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2247/// # secret,
2248/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2249/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2250/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2251/// # ),
2252/// # ).build().await.unwrap();
2253///
2254/// # let client = hyper_util::client::legacy::Client::builder(
2255/// # hyper_util::rt::TokioExecutor::new()
2256/// # )
2257/// # .build(
2258/// # hyper_rustls::HttpsConnectorBuilder::new()
2259/// # .with_native_roots()
2260/// # .unwrap()
2261/// # .https_or_http()
2262/// # .enable_http2()
2263/// # .build()
2264/// # );
2265/// # let mut hub = CloudResourceManager::new(client, auth);
2266/// // As the method needs a request, you would usually fill it with the desired information
2267/// // into the respective structure. Some of the parts shown here might not be applicable !
2268/// // Values shown here are possibly random and not representative !
2269/// let mut req = ClearOrgPolicyRequest::default();
2270///
2271/// // You can configure optional parameters by calling the respective setters at will, and
2272/// // execute the final call using `doit()`.
2273/// // Values shown here are possibly random and not representative !
2274/// let result = hub.folders().clear_org_policy(req, "resource")
2275/// .doit().await;
2276/// # }
2277/// ```
2278pub struct FolderClearOrgPolicyCall<'a, C>
2279where
2280 C: 'a,
2281{
2282 hub: &'a CloudResourceManager<C>,
2283 _request: ClearOrgPolicyRequest,
2284 _resource: String,
2285 _delegate: Option<&'a mut dyn common::Delegate>,
2286 _additional_params: HashMap<String, String>,
2287 _scopes: BTreeSet<String>,
2288}
2289
2290impl<'a, C> common::CallBuilder for FolderClearOrgPolicyCall<'a, C> {}
2291
2292impl<'a, C> FolderClearOrgPolicyCall<'a, C>
2293where
2294 C: common::Connector,
2295{
2296 /// Perform the operation you have build so far.
2297 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2298 use std::borrow::Cow;
2299 use std::io::{Read, Seek};
2300
2301 use common::{url::Params, ToParts};
2302 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2303
2304 let mut dd = common::DefaultDelegate;
2305 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2306 dlg.begin(common::MethodInfo {
2307 id: "cloudresourcemanager.folders.clearOrgPolicy",
2308 http_method: hyper::Method::POST,
2309 });
2310
2311 for &field in ["alt", "resource"].iter() {
2312 if self._additional_params.contains_key(field) {
2313 dlg.finished(false);
2314 return Err(common::Error::FieldClash(field));
2315 }
2316 }
2317
2318 let mut params = Params::with_capacity(4 + self._additional_params.len());
2319 params.push("resource", self._resource);
2320
2321 params.extend(self._additional_params.iter());
2322
2323 params.push("alt", "json");
2324 let mut url = self.hub._base_url.clone() + "v1/{+resource}:clearOrgPolicy";
2325 if self._scopes.is_empty() {
2326 self._scopes
2327 .insert(Scope::CloudPlatform.as_ref().to_string());
2328 }
2329
2330 #[allow(clippy::single_element_loop)]
2331 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2332 url = params.uri_replacement(url, param_name, find_this, true);
2333 }
2334 {
2335 let to_remove = ["resource"];
2336 params.remove_params(&to_remove);
2337 }
2338
2339 let url = params.parse_with_url(&url);
2340
2341 let mut json_mime_type = mime::APPLICATION_JSON;
2342 let mut request_value_reader = {
2343 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2344 common::remove_json_null_values(&mut value);
2345 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2346 serde_json::to_writer(&mut dst, &value).unwrap();
2347 dst
2348 };
2349 let request_size = request_value_reader
2350 .seek(std::io::SeekFrom::End(0))
2351 .unwrap();
2352 request_value_reader
2353 .seek(std::io::SeekFrom::Start(0))
2354 .unwrap();
2355
2356 loop {
2357 let token = match self
2358 .hub
2359 .auth
2360 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2361 .await
2362 {
2363 Ok(token) => token,
2364 Err(e) => match dlg.token(e) {
2365 Ok(token) => token,
2366 Err(e) => {
2367 dlg.finished(false);
2368 return Err(common::Error::MissingToken(e));
2369 }
2370 },
2371 };
2372 request_value_reader
2373 .seek(std::io::SeekFrom::Start(0))
2374 .unwrap();
2375 let mut req_result = {
2376 let client = &self.hub.client;
2377 dlg.pre_request();
2378 let mut req_builder = hyper::Request::builder()
2379 .method(hyper::Method::POST)
2380 .uri(url.as_str())
2381 .header(USER_AGENT, self.hub._user_agent.clone());
2382
2383 if let Some(token) = token.as_ref() {
2384 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2385 }
2386
2387 let request = req_builder
2388 .header(CONTENT_TYPE, json_mime_type.to_string())
2389 .header(CONTENT_LENGTH, request_size as u64)
2390 .body(common::to_body(
2391 request_value_reader.get_ref().clone().into(),
2392 ));
2393
2394 client.request(request.unwrap()).await
2395 };
2396
2397 match req_result {
2398 Err(err) => {
2399 if let common::Retry::After(d) = dlg.http_error(&err) {
2400 sleep(d).await;
2401 continue;
2402 }
2403 dlg.finished(false);
2404 return Err(common::Error::HttpError(err));
2405 }
2406 Ok(res) => {
2407 let (mut parts, body) = res.into_parts();
2408 let mut body = common::Body::new(body);
2409 if !parts.status.is_success() {
2410 let bytes = common::to_bytes(body).await.unwrap_or_default();
2411 let error = serde_json::from_str(&common::to_string(&bytes));
2412 let response = common::to_response(parts, bytes.into());
2413
2414 if let common::Retry::After(d) =
2415 dlg.http_failure(&response, error.as_ref().ok())
2416 {
2417 sleep(d).await;
2418 continue;
2419 }
2420
2421 dlg.finished(false);
2422
2423 return Err(match error {
2424 Ok(value) => common::Error::BadRequest(value),
2425 _ => common::Error::Failure(response),
2426 });
2427 }
2428 let response = {
2429 let bytes = common::to_bytes(body).await.unwrap_or_default();
2430 let encoded = common::to_string(&bytes);
2431 match serde_json::from_str(&encoded) {
2432 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2433 Err(error) => {
2434 dlg.response_json_decode_error(&encoded, &error);
2435 return Err(common::Error::JsonDecodeError(
2436 encoded.to_string(),
2437 error,
2438 ));
2439 }
2440 }
2441 };
2442
2443 dlg.finished(true);
2444 return Ok(response);
2445 }
2446 }
2447 }
2448 }
2449
2450 ///
2451 /// Sets the *request* property to the given value.
2452 ///
2453 /// Even though the property as already been set when instantiating this call,
2454 /// we provide this method for API completeness.
2455 pub fn request(mut self, new_value: ClearOrgPolicyRequest) -> FolderClearOrgPolicyCall<'a, C> {
2456 self._request = new_value;
2457 self
2458 }
2459 /// Name of the resource for the `Policy` to clear.
2460 ///
2461 /// Sets the *resource* path property to the given value.
2462 ///
2463 /// Even though the property as already been set when instantiating this call,
2464 /// we provide this method for API completeness.
2465 pub fn resource(mut self, new_value: &str) -> FolderClearOrgPolicyCall<'a, C> {
2466 self._resource = new_value.to_string();
2467 self
2468 }
2469 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2470 /// while executing the actual API request.
2471 ///
2472 /// ````text
2473 /// It should be used to handle progress information, and to implement a certain level of resilience.
2474 /// ````
2475 ///
2476 /// Sets the *delegate* property to the given value.
2477 pub fn delegate(
2478 mut self,
2479 new_value: &'a mut dyn common::Delegate,
2480 ) -> FolderClearOrgPolicyCall<'a, C> {
2481 self._delegate = Some(new_value);
2482 self
2483 }
2484
2485 /// Set any additional parameter of the query string used in the request.
2486 /// It should be used to set parameters which are not yet available through their own
2487 /// setters.
2488 ///
2489 /// Please note that this method must not be used to set any of the known parameters
2490 /// which have their own setter method. If done anyway, the request will fail.
2491 ///
2492 /// # Additional Parameters
2493 ///
2494 /// * *$.xgafv* (query-string) - V1 error format.
2495 /// * *access_token* (query-string) - OAuth access token.
2496 /// * *alt* (query-string) - Data format for response.
2497 /// * *callback* (query-string) - JSONP
2498 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2499 /// * *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.
2500 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2501 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2502 /// * *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.
2503 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2504 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2505 pub fn param<T>(mut self, name: T, value: T) -> FolderClearOrgPolicyCall<'a, C>
2506 where
2507 T: AsRef<str>,
2508 {
2509 self._additional_params
2510 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2511 self
2512 }
2513
2514 /// Identifies the authorization scope for the method you are building.
2515 ///
2516 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2517 /// [`Scope::CloudPlatform`].
2518 ///
2519 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2520 /// tokens for more than one scope.
2521 ///
2522 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2523 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2524 /// sufficient, a read-write scope will do as well.
2525 pub fn add_scope<St>(mut self, scope: St) -> FolderClearOrgPolicyCall<'a, C>
2526 where
2527 St: AsRef<str>,
2528 {
2529 self._scopes.insert(String::from(scope.as_ref()));
2530 self
2531 }
2532 /// Identifies the authorization scope(s) for the method you are building.
2533 ///
2534 /// See [`Self::add_scope()`] for details.
2535 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderClearOrgPolicyCall<'a, C>
2536 where
2537 I: IntoIterator<Item = St>,
2538 St: AsRef<str>,
2539 {
2540 self._scopes
2541 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2542 self
2543 }
2544
2545 /// Removes all scopes, and no default scope will be used either.
2546 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2547 /// for details).
2548 pub fn clear_scopes(mut self) -> FolderClearOrgPolicyCall<'a, C> {
2549 self._scopes.clear();
2550 self
2551 }
2552}
2553
2554/// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
2555///
2556/// A builder for the *getEffectiveOrgPolicy* method supported by a *folder* resource.
2557/// It is not used directly, but through a [`FolderMethods`] instance.
2558///
2559/// # Example
2560///
2561/// Instantiate a resource method builder
2562///
2563/// ```test_harness,no_run
2564/// # extern crate hyper;
2565/// # extern crate hyper_rustls;
2566/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
2567/// use cloudresourcemanager1::api::GetEffectiveOrgPolicyRequest;
2568/// # async fn dox() {
2569/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2570///
2571/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2572/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2573/// # .with_native_roots()
2574/// # .unwrap()
2575/// # .https_only()
2576/// # .enable_http2()
2577/// # .build();
2578///
2579/// # let executor = hyper_util::rt::TokioExecutor::new();
2580/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2581/// # secret,
2582/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2583/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2584/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2585/// # ),
2586/// # ).build().await.unwrap();
2587///
2588/// # let client = hyper_util::client::legacy::Client::builder(
2589/// # hyper_util::rt::TokioExecutor::new()
2590/// # )
2591/// # .build(
2592/// # hyper_rustls::HttpsConnectorBuilder::new()
2593/// # .with_native_roots()
2594/// # .unwrap()
2595/// # .https_or_http()
2596/// # .enable_http2()
2597/// # .build()
2598/// # );
2599/// # let mut hub = CloudResourceManager::new(client, auth);
2600/// // As the method needs a request, you would usually fill it with the desired information
2601/// // into the respective structure. Some of the parts shown here might not be applicable !
2602/// // Values shown here are possibly random and not representative !
2603/// let mut req = GetEffectiveOrgPolicyRequest::default();
2604///
2605/// // You can configure optional parameters by calling the respective setters at will, and
2606/// // execute the final call using `doit()`.
2607/// // Values shown here are possibly random and not representative !
2608/// let result = hub.folders().get_effective_org_policy(req, "resource")
2609/// .doit().await;
2610/// # }
2611/// ```
2612pub struct FolderGetEffectiveOrgPolicyCall<'a, C>
2613where
2614 C: 'a,
2615{
2616 hub: &'a CloudResourceManager<C>,
2617 _request: GetEffectiveOrgPolicyRequest,
2618 _resource: String,
2619 _delegate: Option<&'a mut dyn common::Delegate>,
2620 _additional_params: HashMap<String, String>,
2621 _scopes: BTreeSet<String>,
2622}
2623
2624impl<'a, C> common::CallBuilder for FolderGetEffectiveOrgPolicyCall<'a, C> {}
2625
2626impl<'a, C> FolderGetEffectiveOrgPolicyCall<'a, C>
2627where
2628 C: common::Connector,
2629{
2630 /// Perform the operation you have build so far.
2631 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
2632 use std::borrow::Cow;
2633 use std::io::{Read, Seek};
2634
2635 use common::{url::Params, ToParts};
2636 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2637
2638 let mut dd = common::DefaultDelegate;
2639 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2640 dlg.begin(common::MethodInfo {
2641 id: "cloudresourcemanager.folders.getEffectiveOrgPolicy",
2642 http_method: hyper::Method::POST,
2643 });
2644
2645 for &field in ["alt", "resource"].iter() {
2646 if self._additional_params.contains_key(field) {
2647 dlg.finished(false);
2648 return Err(common::Error::FieldClash(field));
2649 }
2650 }
2651
2652 let mut params = Params::with_capacity(4 + self._additional_params.len());
2653 params.push("resource", self._resource);
2654
2655 params.extend(self._additional_params.iter());
2656
2657 params.push("alt", "json");
2658 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getEffectiveOrgPolicy";
2659 if self._scopes.is_empty() {
2660 self._scopes
2661 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
2662 }
2663
2664 #[allow(clippy::single_element_loop)]
2665 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2666 url = params.uri_replacement(url, param_name, find_this, true);
2667 }
2668 {
2669 let to_remove = ["resource"];
2670 params.remove_params(&to_remove);
2671 }
2672
2673 let url = params.parse_with_url(&url);
2674
2675 let mut json_mime_type = mime::APPLICATION_JSON;
2676 let mut request_value_reader = {
2677 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2678 common::remove_json_null_values(&mut value);
2679 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2680 serde_json::to_writer(&mut dst, &value).unwrap();
2681 dst
2682 };
2683 let request_size = request_value_reader
2684 .seek(std::io::SeekFrom::End(0))
2685 .unwrap();
2686 request_value_reader
2687 .seek(std::io::SeekFrom::Start(0))
2688 .unwrap();
2689
2690 loop {
2691 let token = match self
2692 .hub
2693 .auth
2694 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2695 .await
2696 {
2697 Ok(token) => token,
2698 Err(e) => match dlg.token(e) {
2699 Ok(token) => token,
2700 Err(e) => {
2701 dlg.finished(false);
2702 return Err(common::Error::MissingToken(e));
2703 }
2704 },
2705 };
2706 request_value_reader
2707 .seek(std::io::SeekFrom::Start(0))
2708 .unwrap();
2709 let mut req_result = {
2710 let client = &self.hub.client;
2711 dlg.pre_request();
2712 let mut req_builder = hyper::Request::builder()
2713 .method(hyper::Method::POST)
2714 .uri(url.as_str())
2715 .header(USER_AGENT, self.hub._user_agent.clone());
2716
2717 if let Some(token) = token.as_ref() {
2718 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2719 }
2720
2721 let request = req_builder
2722 .header(CONTENT_TYPE, json_mime_type.to_string())
2723 .header(CONTENT_LENGTH, request_size as u64)
2724 .body(common::to_body(
2725 request_value_reader.get_ref().clone().into(),
2726 ));
2727
2728 client.request(request.unwrap()).await
2729 };
2730
2731 match req_result {
2732 Err(err) => {
2733 if let common::Retry::After(d) = dlg.http_error(&err) {
2734 sleep(d).await;
2735 continue;
2736 }
2737 dlg.finished(false);
2738 return Err(common::Error::HttpError(err));
2739 }
2740 Ok(res) => {
2741 let (mut parts, body) = res.into_parts();
2742 let mut body = common::Body::new(body);
2743 if !parts.status.is_success() {
2744 let bytes = common::to_bytes(body).await.unwrap_or_default();
2745 let error = serde_json::from_str(&common::to_string(&bytes));
2746 let response = common::to_response(parts, bytes.into());
2747
2748 if let common::Retry::After(d) =
2749 dlg.http_failure(&response, error.as_ref().ok())
2750 {
2751 sleep(d).await;
2752 continue;
2753 }
2754
2755 dlg.finished(false);
2756
2757 return Err(match error {
2758 Ok(value) => common::Error::BadRequest(value),
2759 _ => common::Error::Failure(response),
2760 });
2761 }
2762 let response = {
2763 let bytes = common::to_bytes(body).await.unwrap_or_default();
2764 let encoded = common::to_string(&bytes);
2765 match serde_json::from_str(&encoded) {
2766 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2767 Err(error) => {
2768 dlg.response_json_decode_error(&encoded, &error);
2769 return Err(common::Error::JsonDecodeError(
2770 encoded.to_string(),
2771 error,
2772 ));
2773 }
2774 }
2775 };
2776
2777 dlg.finished(true);
2778 return Ok(response);
2779 }
2780 }
2781 }
2782 }
2783
2784 ///
2785 /// Sets the *request* property to the given value.
2786 ///
2787 /// Even though the property as already been set when instantiating this call,
2788 /// we provide this method for API completeness.
2789 pub fn request(
2790 mut self,
2791 new_value: GetEffectiveOrgPolicyRequest,
2792 ) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2793 self._request = new_value;
2794 self
2795 }
2796 /// The name of the resource to start computing the effective `Policy`.
2797 ///
2798 /// Sets the *resource* path property to the given value.
2799 ///
2800 /// Even though the property as already been set when instantiating this call,
2801 /// we provide this method for API completeness.
2802 pub fn resource(mut self, new_value: &str) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2803 self._resource = new_value.to_string();
2804 self
2805 }
2806 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2807 /// while executing the actual API request.
2808 ///
2809 /// ````text
2810 /// It should be used to handle progress information, and to implement a certain level of resilience.
2811 /// ````
2812 ///
2813 /// Sets the *delegate* property to the given value.
2814 pub fn delegate(
2815 mut self,
2816 new_value: &'a mut dyn common::Delegate,
2817 ) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2818 self._delegate = Some(new_value);
2819 self
2820 }
2821
2822 /// Set any additional parameter of the query string used in the request.
2823 /// It should be used to set parameters which are not yet available through their own
2824 /// setters.
2825 ///
2826 /// Please note that this method must not be used to set any of the known parameters
2827 /// which have their own setter method. If done anyway, the request will fail.
2828 ///
2829 /// # Additional Parameters
2830 ///
2831 /// * *$.xgafv* (query-string) - V1 error format.
2832 /// * *access_token* (query-string) - OAuth access token.
2833 /// * *alt* (query-string) - Data format for response.
2834 /// * *callback* (query-string) - JSONP
2835 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2836 /// * *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.
2837 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2838 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2839 /// * *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.
2840 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2841 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2842 pub fn param<T>(mut self, name: T, value: T) -> FolderGetEffectiveOrgPolicyCall<'a, C>
2843 where
2844 T: AsRef<str>,
2845 {
2846 self._additional_params
2847 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2848 self
2849 }
2850
2851 /// Identifies the authorization scope for the method you are building.
2852 ///
2853 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2854 /// [`Scope::CloudPlatformReadOnly`].
2855 ///
2856 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2857 /// tokens for more than one scope.
2858 ///
2859 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2860 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2861 /// sufficient, a read-write scope will do as well.
2862 pub fn add_scope<St>(mut self, scope: St) -> FolderGetEffectiveOrgPolicyCall<'a, C>
2863 where
2864 St: AsRef<str>,
2865 {
2866 self._scopes.insert(String::from(scope.as_ref()));
2867 self
2868 }
2869 /// Identifies the authorization scope(s) for the method you are building.
2870 ///
2871 /// See [`Self::add_scope()`] for details.
2872 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetEffectiveOrgPolicyCall<'a, C>
2873 where
2874 I: IntoIterator<Item = St>,
2875 St: AsRef<str>,
2876 {
2877 self._scopes
2878 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2879 self
2880 }
2881
2882 /// Removes all scopes, and no default scope will be used either.
2883 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2884 /// for details).
2885 pub fn clear_scopes(mut self) -> FolderGetEffectiveOrgPolicyCall<'a, C> {
2886 self._scopes.clear();
2887 self
2888 }
2889}
2890
2891/// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
2892///
2893/// A builder for the *getOrgPolicy* method supported by a *folder* resource.
2894/// It is not used directly, but through a [`FolderMethods`] instance.
2895///
2896/// # Example
2897///
2898/// Instantiate a resource method builder
2899///
2900/// ```test_harness,no_run
2901/// # extern crate hyper;
2902/// # extern crate hyper_rustls;
2903/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
2904/// use cloudresourcemanager1::api::GetOrgPolicyRequest;
2905/// # async fn dox() {
2906/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2907///
2908/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2909/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2910/// # .with_native_roots()
2911/// # .unwrap()
2912/// # .https_only()
2913/// # .enable_http2()
2914/// # .build();
2915///
2916/// # let executor = hyper_util::rt::TokioExecutor::new();
2917/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2918/// # secret,
2919/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2920/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2921/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2922/// # ),
2923/// # ).build().await.unwrap();
2924///
2925/// # let client = hyper_util::client::legacy::Client::builder(
2926/// # hyper_util::rt::TokioExecutor::new()
2927/// # )
2928/// # .build(
2929/// # hyper_rustls::HttpsConnectorBuilder::new()
2930/// # .with_native_roots()
2931/// # .unwrap()
2932/// # .https_or_http()
2933/// # .enable_http2()
2934/// # .build()
2935/// # );
2936/// # let mut hub = CloudResourceManager::new(client, auth);
2937/// // As the method needs a request, you would usually fill it with the desired information
2938/// // into the respective structure. Some of the parts shown here might not be applicable !
2939/// // Values shown here are possibly random and not representative !
2940/// let mut req = GetOrgPolicyRequest::default();
2941///
2942/// // You can configure optional parameters by calling the respective setters at will, and
2943/// // execute the final call using `doit()`.
2944/// // Values shown here are possibly random and not representative !
2945/// let result = hub.folders().get_org_policy(req, "resource")
2946/// .doit().await;
2947/// # }
2948/// ```
2949pub struct FolderGetOrgPolicyCall<'a, C>
2950where
2951 C: 'a,
2952{
2953 hub: &'a CloudResourceManager<C>,
2954 _request: GetOrgPolicyRequest,
2955 _resource: String,
2956 _delegate: Option<&'a mut dyn common::Delegate>,
2957 _additional_params: HashMap<String, String>,
2958 _scopes: BTreeSet<String>,
2959}
2960
2961impl<'a, C> common::CallBuilder for FolderGetOrgPolicyCall<'a, C> {}
2962
2963impl<'a, C> FolderGetOrgPolicyCall<'a, C>
2964where
2965 C: common::Connector,
2966{
2967 /// Perform the operation you have build so far.
2968 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
2969 use std::borrow::Cow;
2970 use std::io::{Read, Seek};
2971
2972 use common::{url::Params, ToParts};
2973 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2974
2975 let mut dd = common::DefaultDelegate;
2976 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2977 dlg.begin(common::MethodInfo {
2978 id: "cloudresourcemanager.folders.getOrgPolicy",
2979 http_method: hyper::Method::POST,
2980 });
2981
2982 for &field in ["alt", "resource"].iter() {
2983 if self._additional_params.contains_key(field) {
2984 dlg.finished(false);
2985 return Err(common::Error::FieldClash(field));
2986 }
2987 }
2988
2989 let mut params = Params::with_capacity(4 + self._additional_params.len());
2990 params.push("resource", self._resource);
2991
2992 params.extend(self._additional_params.iter());
2993
2994 params.push("alt", "json");
2995 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getOrgPolicy";
2996 if self._scopes.is_empty() {
2997 self._scopes
2998 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
2999 }
3000
3001 #[allow(clippy::single_element_loop)]
3002 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3003 url = params.uri_replacement(url, param_name, find_this, true);
3004 }
3005 {
3006 let to_remove = ["resource"];
3007 params.remove_params(&to_remove);
3008 }
3009
3010 let url = params.parse_with_url(&url);
3011
3012 let mut json_mime_type = mime::APPLICATION_JSON;
3013 let mut request_value_reader = {
3014 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3015 common::remove_json_null_values(&mut value);
3016 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3017 serde_json::to_writer(&mut dst, &value).unwrap();
3018 dst
3019 };
3020 let request_size = request_value_reader
3021 .seek(std::io::SeekFrom::End(0))
3022 .unwrap();
3023 request_value_reader
3024 .seek(std::io::SeekFrom::Start(0))
3025 .unwrap();
3026
3027 loop {
3028 let token = match self
3029 .hub
3030 .auth
3031 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3032 .await
3033 {
3034 Ok(token) => token,
3035 Err(e) => match dlg.token(e) {
3036 Ok(token) => token,
3037 Err(e) => {
3038 dlg.finished(false);
3039 return Err(common::Error::MissingToken(e));
3040 }
3041 },
3042 };
3043 request_value_reader
3044 .seek(std::io::SeekFrom::Start(0))
3045 .unwrap();
3046 let mut req_result = {
3047 let client = &self.hub.client;
3048 dlg.pre_request();
3049 let mut req_builder = hyper::Request::builder()
3050 .method(hyper::Method::POST)
3051 .uri(url.as_str())
3052 .header(USER_AGENT, self.hub._user_agent.clone());
3053
3054 if let Some(token) = token.as_ref() {
3055 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3056 }
3057
3058 let request = req_builder
3059 .header(CONTENT_TYPE, json_mime_type.to_string())
3060 .header(CONTENT_LENGTH, request_size as u64)
3061 .body(common::to_body(
3062 request_value_reader.get_ref().clone().into(),
3063 ));
3064
3065 client.request(request.unwrap()).await
3066 };
3067
3068 match req_result {
3069 Err(err) => {
3070 if let common::Retry::After(d) = dlg.http_error(&err) {
3071 sleep(d).await;
3072 continue;
3073 }
3074 dlg.finished(false);
3075 return Err(common::Error::HttpError(err));
3076 }
3077 Ok(res) => {
3078 let (mut parts, body) = res.into_parts();
3079 let mut body = common::Body::new(body);
3080 if !parts.status.is_success() {
3081 let bytes = common::to_bytes(body).await.unwrap_or_default();
3082 let error = serde_json::from_str(&common::to_string(&bytes));
3083 let response = common::to_response(parts, bytes.into());
3084
3085 if let common::Retry::After(d) =
3086 dlg.http_failure(&response, error.as_ref().ok())
3087 {
3088 sleep(d).await;
3089 continue;
3090 }
3091
3092 dlg.finished(false);
3093
3094 return Err(match error {
3095 Ok(value) => common::Error::BadRequest(value),
3096 _ => common::Error::Failure(response),
3097 });
3098 }
3099 let response = {
3100 let bytes = common::to_bytes(body).await.unwrap_or_default();
3101 let encoded = common::to_string(&bytes);
3102 match serde_json::from_str(&encoded) {
3103 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3104 Err(error) => {
3105 dlg.response_json_decode_error(&encoded, &error);
3106 return Err(common::Error::JsonDecodeError(
3107 encoded.to_string(),
3108 error,
3109 ));
3110 }
3111 }
3112 };
3113
3114 dlg.finished(true);
3115 return Ok(response);
3116 }
3117 }
3118 }
3119 }
3120
3121 ///
3122 /// Sets the *request* property to the given value.
3123 ///
3124 /// Even though the property as already been set when instantiating this call,
3125 /// we provide this method for API completeness.
3126 pub fn request(mut self, new_value: GetOrgPolicyRequest) -> FolderGetOrgPolicyCall<'a, C> {
3127 self._request = new_value;
3128 self
3129 }
3130 /// Name of the resource the `Policy` is set on.
3131 ///
3132 /// Sets the *resource* path property to the given value.
3133 ///
3134 /// Even though the property as already been set when instantiating this call,
3135 /// we provide this method for API completeness.
3136 pub fn resource(mut self, new_value: &str) -> FolderGetOrgPolicyCall<'a, C> {
3137 self._resource = new_value.to_string();
3138 self
3139 }
3140 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3141 /// while executing the actual API request.
3142 ///
3143 /// ````text
3144 /// It should be used to handle progress information, and to implement a certain level of resilience.
3145 /// ````
3146 ///
3147 /// Sets the *delegate* property to the given value.
3148 pub fn delegate(
3149 mut self,
3150 new_value: &'a mut dyn common::Delegate,
3151 ) -> FolderGetOrgPolicyCall<'a, C> {
3152 self._delegate = Some(new_value);
3153 self
3154 }
3155
3156 /// Set any additional parameter of the query string used in the request.
3157 /// It should be used to set parameters which are not yet available through their own
3158 /// setters.
3159 ///
3160 /// Please note that this method must not be used to set any of the known parameters
3161 /// which have their own setter method. If done anyway, the request will fail.
3162 ///
3163 /// # Additional Parameters
3164 ///
3165 /// * *$.xgafv* (query-string) - V1 error format.
3166 /// * *access_token* (query-string) - OAuth access token.
3167 /// * *alt* (query-string) - Data format for response.
3168 /// * *callback* (query-string) - JSONP
3169 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3170 /// * *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.
3171 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3172 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3173 /// * *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.
3174 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3175 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3176 pub fn param<T>(mut self, name: T, value: T) -> FolderGetOrgPolicyCall<'a, C>
3177 where
3178 T: AsRef<str>,
3179 {
3180 self._additional_params
3181 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3182 self
3183 }
3184
3185 /// Identifies the authorization scope for the method you are building.
3186 ///
3187 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3188 /// [`Scope::CloudPlatformReadOnly`].
3189 ///
3190 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3191 /// tokens for more than one scope.
3192 ///
3193 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3194 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3195 /// sufficient, a read-write scope will do as well.
3196 pub fn add_scope<St>(mut self, scope: St) -> FolderGetOrgPolicyCall<'a, C>
3197 where
3198 St: AsRef<str>,
3199 {
3200 self._scopes.insert(String::from(scope.as_ref()));
3201 self
3202 }
3203 /// Identifies the authorization scope(s) for the method you are building.
3204 ///
3205 /// See [`Self::add_scope()`] for details.
3206 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderGetOrgPolicyCall<'a, C>
3207 where
3208 I: IntoIterator<Item = St>,
3209 St: AsRef<str>,
3210 {
3211 self._scopes
3212 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3213 self
3214 }
3215
3216 /// Removes all scopes, and no default scope will be used either.
3217 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3218 /// for details).
3219 pub fn clear_scopes(mut self) -> FolderGetOrgPolicyCall<'a, C> {
3220 self._scopes.clear();
3221 self
3222 }
3223}
3224
3225/// Lists `Constraints` that could be applied on the specified resource.
3226///
3227/// A builder for the *listAvailableOrgPolicyConstraints* method supported by a *folder* resource.
3228/// It is not used directly, but through a [`FolderMethods`] instance.
3229///
3230/// # Example
3231///
3232/// Instantiate a resource method builder
3233///
3234/// ```test_harness,no_run
3235/// # extern crate hyper;
3236/// # extern crate hyper_rustls;
3237/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
3238/// use cloudresourcemanager1::api::ListAvailableOrgPolicyConstraintsRequest;
3239/// # async fn dox() {
3240/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3241///
3242/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3243/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3244/// # .with_native_roots()
3245/// # .unwrap()
3246/// # .https_only()
3247/// # .enable_http2()
3248/// # .build();
3249///
3250/// # let executor = hyper_util::rt::TokioExecutor::new();
3251/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3252/// # secret,
3253/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3254/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3255/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3256/// # ),
3257/// # ).build().await.unwrap();
3258///
3259/// # let client = hyper_util::client::legacy::Client::builder(
3260/// # hyper_util::rt::TokioExecutor::new()
3261/// # )
3262/// # .build(
3263/// # hyper_rustls::HttpsConnectorBuilder::new()
3264/// # .with_native_roots()
3265/// # .unwrap()
3266/// # .https_or_http()
3267/// # .enable_http2()
3268/// # .build()
3269/// # );
3270/// # let mut hub = CloudResourceManager::new(client, auth);
3271/// // As the method needs a request, you would usually fill it with the desired information
3272/// // into the respective structure. Some of the parts shown here might not be applicable !
3273/// // Values shown here are possibly random and not representative !
3274/// let mut req = ListAvailableOrgPolicyConstraintsRequest::default();
3275///
3276/// // You can configure optional parameters by calling the respective setters at will, and
3277/// // execute the final call using `doit()`.
3278/// // Values shown here are possibly random and not representative !
3279/// let result = hub.folders().list_available_org_policy_constraints(req, "resource")
3280/// .doit().await;
3281/// # }
3282/// ```
3283pub struct FolderListAvailableOrgPolicyConstraintCall<'a, C>
3284where
3285 C: 'a,
3286{
3287 hub: &'a CloudResourceManager<C>,
3288 _request: ListAvailableOrgPolicyConstraintsRequest,
3289 _resource: String,
3290 _delegate: Option<&'a mut dyn common::Delegate>,
3291 _additional_params: HashMap<String, String>,
3292 _scopes: BTreeSet<String>,
3293}
3294
3295impl<'a, C> common::CallBuilder for FolderListAvailableOrgPolicyConstraintCall<'a, C> {}
3296
3297impl<'a, C> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3298where
3299 C: common::Connector,
3300{
3301 /// Perform the operation you have build so far.
3302 pub async fn doit(
3303 mut self,
3304 ) -> common::Result<(common::Response, ListAvailableOrgPolicyConstraintsResponse)> {
3305 use std::borrow::Cow;
3306 use std::io::{Read, Seek};
3307
3308 use common::{url::Params, ToParts};
3309 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3310
3311 let mut dd = common::DefaultDelegate;
3312 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3313 dlg.begin(common::MethodInfo {
3314 id: "cloudresourcemanager.folders.listAvailableOrgPolicyConstraints",
3315 http_method: hyper::Method::POST,
3316 });
3317
3318 for &field in ["alt", "resource"].iter() {
3319 if self._additional_params.contains_key(field) {
3320 dlg.finished(false);
3321 return Err(common::Error::FieldClash(field));
3322 }
3323 }
3324
3325 let mut params = Params::with_capacity(4 + self._additional_params.len());
3326 params.push("resource", self._resource);
3327
3328 params.extend(self._additional_params.iter());
3329
3330 params.push("alt", "json");
3331 let mut url =
3332 self.hub._base_url.clone() + "v1/{+resource}:listAvailableOrgPolicyConstraints";
3333 if self._scopes.is_empty() {
3334 self._scopes
3335 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
3336 }
3337
3338 #[allow(clippy::single_element_loop)]
3339 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3340 url = params.uri_replacement(url, param_name, find_this, true);
3341 }
3342 {
3343 let to_remove = ["resource"];
3344 params.remove_params(&to_remove);
3345 }
3346
3347 let url = params.parse_with_url(&url);
3348
3349 let mut json_mime_type = mime::APPLICATION_JSON;
3350 let mut request_value_reader = {
3351 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3352 common::remove_json_null_values(&mut value);
3353 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3354 serde_json::to_writer(&mut dst, &value).unwrap();
3355 dst
3356 };
3357 let request_size = request_value_reader
3358 .seek(std::io::SeekFrom::End(0))
3359 .unwrap();
3360 request_value_reader
3361 .seek(std::io::SeekFrom::Start(0))
3362 .unwrap();
3363
3364 loop {
3365 let token = match self
3366 .hub
3367 .auth
3368 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3369 .await
3370 {
3371 Ok(token) => token,
3372 Err(e) => match dlg.token(e) {
3373 Ok(token) => token,
3374 Err(e) => {
3375 dlg.finished(false);
3376 return Err(common::Error::MissingToken(e));
3377 }
3378 },
3379 };
3380 request_value_reader
3381 .seek(std::io::SeekFrom::Start(0))
3382 .unwrap();
3383 let mut req_result = {
3384 let client = &self.hub.client;
3385 dlg.pre_request();
3386 let mut req_builder = hyper::Request::builder()
3387 .method(hyper::Method::POST)
3388 .uri(url.as_str())
3389 .header(USER_AGENT, self.hub._user_agent.clone());
3390
3391 if let Some(token) = token.as_ref() {
3392 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3393 }
3394
3395 let request = req_builder
3396 .header(CONTENT_TYPE, json_mime_type.to_string())
3397 .header(CONTENT_LENGTH, request_size as u64)
3398 .body(common::to_body(
3399 request_value_reader.get_ref().clone().into(),
3400 ));
3401
3402 client.request(request.unwrap()).await
3403 };
3404
3405 match req_result {
3406 Err(err) => {
3407 if let common::Retry::After(d) = dlg.http_error(&err) {
3408 sleep(d).await;
3409 continue;
3410 }
3411 dlg.finished(false);
3412 return Err(common::Error::HttpError(err));
3413 }
3414 Ok(res) => {
3415 let (mut parts, body) = res.into_parts();
3416 let mut body = common::Body::new(body);
3417 if !parts.status.is_success() {
3418 let bytes = common::to_bytes(body).await.unwrap_or_default();
3419 let error = serde_json::from_str(&common::to_string(&bytes));
3420 let response = common::to_response(parts, bytes.into());
3421
3422 if let common::Retry::After(d) =
3423 dlg.http_failure(&response, error.as_ref().ok())
3424 {
3425 sleep(d).await;
3426 continue;
3427 }
3428
3429 dlg.finished(false);
3430
3431 return Err(match error {
3432 Ok(value) => common::Error::BadRequest(value),
3433 _ => common::Error::Failure(response),
3434 });
3435 }
3436 let response = {
3437 let bytes = common::to_bytes(body).await.unwrap_or_default();
3438 let encoded = common::to_string(&bytes);
3439 match serde_json::from_str(&encoded) {
3440 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3441 Err(error) => {
3442 dlg.response_json_decode_error(&encoded, &error);
3443 return Err(common::Error::JsonDecodeError(
3444 encoded.to_string(),
3445 error,
3446 ));
3447 }
3448 }
3449 };
3450
3451 dlg.finished(true);
3452 return Ok(response);
3453 }
3454 }
3455 }
3456 }
3457
3458 ///
3459 /// Sets the *request* property to the given value.
3460 ///
3461 /// Even though the property as already been set when instantiating this call,
3462 /// we provide this method for API completeness.
3463 pub fn request(
3464 mut self,
3465 new_value: ListAvailableOrgPolicyConstraintsRequest,
3466 ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3467 self._request = new_value;
3468 self
3469 }
3470 /// Name of the resource to list `Constraints` for.
3471 ///
3472 /// Sets the *resource* path property to the given value.
3473 ///
3474 /// Even though the property as already been set when instantiating this call,
3475 /// we provide this method for API completeness.
3476 pub fn resource(
3477 mut self,
3478 new_value: &str,
3479 ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3480 self._resource = new_value.to_string();
3481 self
3482 }
3483 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3484 /// while executing the actual API request.
3485 ///
3486 /// ````text
3487 /// It should be used to handle progress information, and to implement a certain level of resilience.
3488 /// ````
3489 ///
3490 /// Sets the *delegate* property to the given value.
3491 pub fn delegate(
3492 mut self,
3493 new_value: &'a mut dyn common::Delegate,
3494 ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3495 self._delegate = Some(new_value);
3496 self
3497 }
3498
3499 /// Set any additional parameter of the query string used in the request.
3500 /// It should be used to set parameters which are not yet available through their own
3501 /// setters.
3502 ///
3503 /// Please note that this method must not be used to set any of the known parameters
3504 /// which have their own setter method. If done anyway, the request will fail.
3505 ///
3506 /// # Additional Parameters
3507 ///
3508 /// * *$.xgafv* (query-string) - V1 error format.
3509 /// * *access_token* (query-string) - OAuth access token.
3510 /// * *alt* (query-string) - Data format for response.
3511 /// * *callback* (query-string) - JSONP
3512 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3513 /// * *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.
3514 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3515 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3516 /// * *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.
3517 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3518 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3519 pub fn param<T>(
3520 mut self,
3521 name: T,
3522 value: T,
3523 ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3524 where
3525 T: AsRef<str>,
3526 {
3527 self._additional_params
3528 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3529 self
3530 }
3531
3532 /// Identifies the authorization scope for the method you are building.
3533 ///
3534 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3535 /// [`Scope::CloudPlatformReadOnly`].
3536 ///
3537 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3538 /// tokens for more than one scope.
3539 ///
3540 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3541 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3542 /// sufficient, a read-write scope will do as well.
3543 pub fn add_scope<St>(mut self, scope: St) -> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3544 where
3545 St: AsRef<str>,
3546 {
3547 self._scopes.insert(String::from(scope.as_ref()));
3548 self
3549 }
3550 /// Identifies the authorization scope(s) for the method you are building.
3551 ///
3552 /// See [`Self::add_scope()`] for details.
3553 pub fn add_scopes<I, St>(
3554 mut self,
3555 scopes: I,
3556 ) -> FolderListAvailableOrgPolicyConstraintCall<'a, C>
3557 where
3558 I: IntoIterator<Item = St>,
3559 St: AsRef<str>,
3560 {
3561 self._scopes
3562 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3563 self
3564 }
3565
3566 /// Removes all scopes, and no default scope will be used either.
3567 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3568 /// for details).
3569 pub fn clear_scopes(mut self) -> FolderListAvailableOrgPolicyConstraintCall<'a, C> {
3570 self._scopes.clear();
3571 self
3572 }
3573}
3574
3575/// Lists all the `Policies` set for a particular resource.
3576///
3577/// A builder for the *listOrgPolicies* method supported by a *folder* resource.
3578/// It is not used directly, but through a [`FolderMethods`] instance.
3579///
3580/// # Example
3581///
3582/// Instantiate a resource method builder
3583///
3584/// ```test_harness,no_run
3585/// # extern crate hyper;
3586/// # extern crate hyper_rustls;
3587/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
3588/// use cloudresourcemanager1::api::ListOrgPoliciesRequest;
3589/// # async fn dox() {
3590/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3591///
3592/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3593/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3594/// # .with_native_roots()
3595/// # .unwrap()
3596/// # .https_only()
3597/// # .enable_http2()
3598/// # .build();
3599///
3600/// # let executor = hyper_util::rt::TokioExecutor::new();
3601/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3602/// # secret,
3603/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3604/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3605/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3606/// # ),
3607/// # ).build().await.unwrap();
3608///
3609/// # let client = hyper_util::client::legacy::Client::builder(
3610/// # hyper_util::rt::TokioExecutor::new()
3611/// # )
3612/// # .build(
3613/// # hyper_rustls::HttpsConnectorBuilder::new()
3614/// # .with_native_roots()
3615/// # .unwrap()
3616/// # .https_or_http()
3617/// # .enable_http2()
3618/// # .build()
3619/// # );
3620/// # let mut hub = CloudResourceManager::new(client, auth);
3621/// // As the method needs a request, you would usually fill it with the desired information
3622/// // into the respective structure. Some of the parts shown here might not be applicable !
3623/// // Values shown here are possibly random and not representative !
3624/// let mut req = ListOrgPoliciesRequest::default();
3625///
3626/// // You can configure optional parameters by calling the respective setters at will, and
3627/// // execute the final call using `doit()`.
3628/// // Values shown here are possibly random and not representative !
3629/// let result = hub.folders().list_org_policies(req, "resource")
3630/// .doit().await;
3631/// # }
3632/// ```
3633pub struct FolderListOrgPolicyCall<'a, C>
3634where
3635 C: 'a,
3636{
3637 hub: &'a CloudResourceManager<C>,
3638 _request: ListOrgPoliciesRequest,
3639 _resource: String,
3640 _delegate: Option<&'a mut dyn common::Delegate>,
3641 _additional_params: HashMap<String, String>,
3642 _scopes: BTreeSet<String>,
3643}
3644
3645impl<'a, C> common::CallBuilder for FolderListOrgPolicyCall<'a, C> {}
3646
3647impl<'a, C> FolderListOrgPolicyCall<'a, C>
3648where
3649 C: common::Connector,
3650{
3651 /// Perform the operation you have build so far.
3652 pub async fn doit(mut self) -> common::Result<(common::Response, ListOrgPoliciesResponse)> {
3653 use std::borrow::Cow;
3654 use std::io::{Read, Seek};
3655
3656 use common::{url::Params, ToParts};
3657 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3658
3659 let mut dd = common::DefaultDelegate;
3660 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3661 dlg.begin(common::MethodInfo {
3662 id: "cloudresourcemanager.folders.listOrgPolicies",
3663 http_method: hyper::Method::POST,
3664 });
3665
3666 for &field in ["alt", "resource"].iter() {
3667 if self._additional_params.contains_key(field) {
3668 dlg.finished(false);
3669 return Err(common::Error::FieldClash(field));
3670 }
3671 }
3672
3673 let mut params = Params::with_capacity(4 + self._additional_params.len());
3674 params.push("resource", self._resource);
3675
3676 params.extend(self._additional_params.iter());
3677
3678 params.push("alt", "json");
3679 let mut url = self.hub._base_url.clone() + "v1/{+resource}:listOrgPolicies";
3680 if self._scopes.is_empty() {
3681 self._scopes
3682 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
3683 }
3684
3685 #[allow(clippy::single_element_loop)]
3686 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3687 url = params.uri_replacement(url, param_name, find_this, true);
3688 }
3689 {
3690 let to_remove = ["resource"];
3691 params.remove_params(&to_remove);
3692 }
3693
3694 let url = params.parse_with_url(&url);
3695
3696 let mut json_mime_type = mime::APPLICATION_JSON;
3697 let mut request_value_reader = {
3698 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3699 common::remove_json_null_values(&mut value);
3700 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3701 serde_json::to_writer(&mut dst, &value).unwrap();
3702 dst
3703 };
3704 let request_size = request_value_reader
3705 .seek(std::io::SeekFrom::End(0))
3706 .unwrap();
3707 request_value_reader
3708 .seek(std::io::SeekFrom::Start(0))
3709 .unwrap();
3710
3711 loop {
3712 let token = match self
3713 .hub
3714 .auth
3715 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3716 .await
3717 {
3718 Ok(token) => token,
3719 Err(e) => match dlg.token(e) {
3720 Ok(token) => token,
3721 Err(e) => {
3722 dlg.finished(false);
3723 return Err(common::Error::MissingToken(e));
3724 }
3725 },
3726 };
3727 request_value_reader
3728 .seek(std::io::SeekFrom::Start(0))
3729 .unwrap();
3730 let mut req_result = {
3731 let client = &self.hub.client;
3732 dlg.pre_request();
3733 let mut req_builder = hyper::Request::builder()
3734 .method(hyper::Method::POST)
3735 .uri(url.as_str())
3736 .header(USER_AGENT, self.hub._user_agent.clone());
3737
3738 if let Some(token) = token.as_ref() {
3739 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3740 }
3741
3742 let request = req_builder
3743 .header(CONTENT_TYPE, json_mime_type.to_string())
3744 .header(CONTENT_LENGTH, request_size as u64)
3745 .body(common::to_body(
3746 request_value_reader.get_ref().clone().into(),
3747 ));
3748
3749 client.request(request.unwrap()).await
3750 };
3751
3752 match req_result {
3753 Err(err) => {
3754 if let common::Retry::After(d) = dlg.http_error(&err) {
3755 sleep(d).await;
3756 continue;
3757 }
3758 dlg.finished(false);
3759 return Err(common::Error::HttpError(err));
3760 }
3761 Ok(res) => {
3762 let (mut parts, body) = res.into_parts();
3763 let mut body = common::Body::new(body);
3764 if !parts.status.is_success() {
3765 let bytes = common::to_bytes(body).await.unwrap_or_default();
3766 let error = serde_json::from_str(&common::to_string(&bytes));
3767 let response = common::to_response(parts, bytes.into());
3768
3769 if let common::Retry::After(d) =
3770 dlg.http_failure(&response, error.as_ref().ok())
3771 {
3772 sleep(d).await;
3773 continue;
3774 }
3775
3776 dlg.finished(false);
3777
3778 return Err(match error {
3779 Ok(value) => common::Error::BadRequest(value),
3780 _ => common::Error::Failure(response),
3781 });
3782 }
3783 let response = {
3784 let bytes = common::to_bytes(body).await.unwrap_or_default();
3785 let encoded = common::to_string(&bytes);
3786 match serde_json::from_str(&encoded) {
3787 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3788 Err(error) => {
3789 dlg.response_json_decode_error(&encoded, &error);
3790 return Err(common::Error::JsonDecodeError(
3791 encoded.to_string(),
3792 error,
3793 ));
3794 }
3795 }
3796 };
3797
3798 dlg.finished(true);
3799 return Ok(response);
3800 }
3801 }
3802 }
3803 }
3804
3805 ///
3806 /// Sets the *request* property to the given value.
3807 ///
3808 /// Even though the property as already been set when instantiating this call,
3809 /// we provide this method for API completeness.
3810 pub fn request(mut self, new_value: ListOrgPoliciesRequest) -> FolderListOrgPolicyCall<'a, C> {
3811 self._request = new_value;
3812 self
3813 }
3814 /// Name of the resource to list Policies for.
3815 ///
3816 /// Sets the *resource* path property to the given value.
3817 ///
3818 /// Even though the property as already been set when instantiating this call,
3819 /// we provide this method for API completeness.
3820 pub fn resource(mut self, new_value: &str) -> FolderListOrgPolicyCall<'a, C> {
3821 self._resource = new_value.to_string();
3822 self
3823 }
3824 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3825 /// while executing the actual API request.
3826 ///
3827 /// ````text
3828 /// It should be used to handle progress information, and to implement a certain level of resilience.
3829 /// ````
3830 ///
3831 /// Sets the *delegate* property to the given value.
3832 pub fn delegate(
3833 mut self,
3834 new_value: &'a mut dyn common::Delegate,
3835 ) -> FolderListOrgPolicyCall<'a, C> {
3836 self._delegate = Some(new_value);
3837 self
3838 }
3839
3840 /// Set any additional parameter of the query string used in the request.
3841 /// It should be used to set parameters which are not yet available through their own
3842 /// setters.
3843 ///
3844 /// Please note that this method must not be used to set any of the known parameters
3845 /// which have their own setter method. If done anyway, the request will fail.
3846 ///
3847 /// # Additional Parameters
3848 ///
3849 /// * *$.xgafv* (query-string) - V1 error format.
3850 /// * *access_token* (query-string) - OAuth access token.
3851 /// * *alt* (query-string) - Data format for response.
3852 /// * *callback* (query-string) - JSONP
3853 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3854 /// * *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.
3855 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3856 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3857 /// * *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.
3858 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3859 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3860 pub fn param<T>(mut self, name: T, value: T) -> FolderListOrgPolicyCall<'a, C>
3861 where
3862 T: AsRef<str>,
3863 {
3864 self._additional_params
3865 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3866 self
3867 }
3868
3869 /// Identifies the authorization scope for the method you are building.
3870 ///
3871 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3872 /// [`Scope::CloudPlatformReadOnly`].
3873 ///
3874 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3875 /// tokens for more than one scope.
3876 ///
3877 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3878 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3879 /// sufficient, a read-write scope will do as well.
3880 pub fn add_scope<St>(mut self, scope: St) -> FolderListOrgPolicyCall<'a, C>
3881 where
3882 St: AsRef<str>,
3883 {
3884 self._scopes.insert(String::from(scope.as_ref()));
3885 self
3886 }
3887 /// Identifies the authorization scope(s) for the method you are building.
3888 ///
3889 /// See [`Self::add_scope()`] for details.
3890 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderListOrgPolicyCall<'a, C>
3891 where
3892 I: IntoIterator<Item = St>,
3893 St: AsRef<str>,
3894 {
3895 self._scopes
3896 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3897 self
3898 }
3899
3900 /// Removes all scopes, and no default scope will be used either.
3901 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3902 /// for details).
3903 pub fn clear_scopes(mut self) -> FolderListOrgPolicyCall<'a, C> {
3904 self._scopes.clear();
3905 self
3906 }
3907}
3908
3909/// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
3910///
3911/// A builder for the *setOrgPolicy* method supported by a *folder* resource.
3912/// It is not used directly, but through a [`FolderMethods`] instance.
3913///
3914/// # Example
3915///
3916/// Instantiate a resource method builder
3917///
3918/// ```test_harness,no_run
3919/// # extern crate hyper;
3920/// # extern crate hyper_rustls;
3921/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
3922/// use cloudresourcemanager1::api::SetOrgPolicyRequest;
3923/// # async fn dox() {
3924/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3925///
3926/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3927/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3928/// # .with_native_roots()
3929/// # .unwrap()
3930/// # .https_only()
3931/// # .enable_http2()
3932/// # .build();
3933///
3934/// # let executor = hyper_util::rt::TokioExecutor::new();
3935/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3936/// # secret,
3937/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3938/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3939/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3940/// # ),
3941/// # ).build().await.unwrap();
3942///
3943/// # let client = hyper_util::client::legacy::Client::builder(
3944/// # hyper_util::rt::TokioExecutor::new()
3945/// # )
3946/// # .build(
3947/// # hyper_rustls::HttpsConnectorBuilder::new()
3948/// # .with_native_roots()
3949/// # .unwrap()
3950/// # .https_or_http()
3951/// # .enable_http2()
3952/// # .build()
3953/// # );
3954/// # let mut hub = CloudResourceManager::new(client, auth);
3955/// // As the method needs a request, you would usually fill it with the desired information
3956/// // into the respective structure. Some of the parts shown here might not be applicable !
3957/// // Values shown here are possibly random and not representative !
3958/// let mut req = SetOrgPolicyRequest::default();
3959///
3960/// // You can configure optional parameters by calling the respective setters at will, and
3961/// // execute the final call using `doit()`.
3962/// // Values shown here are possibly random and not representative !
3963/// let result = hub.folders().set_org_policy(req, "resource")
3964/// .doit().await;
3965/// # }
3966/// ```
3967pub struct FolderSetOrgPolicyCall<'a, C>
3968where
3969 C: 'a,
3970{
3971 hub: &'a CloudResourceManager<C>,
3972 _request: SetOrgPolicyRequest,
3973 _resource: String,
3974 _delegate: Option<&'a mut dyn common::Delegate>,
3975 _additional_params: HashMap<String, String>,
3976 _scopes: BTreeSet<String>,
3977}
3978
3979impl<'a, C> common::CallBuilder for FolderSetOrgPolicyCall<'a, C> {}
3980
3981impl<'a, C> FolderSetOrgPolicyCall<'a, C>
3982where
3983 C: common::Connector,
3984{
3985 /// Perform the operation you have build so far.
3986 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
3987 use std::borrow::Cow;
3988 use std::io::{Read, Seek};
3989
3990 use common::{url::Params, ToParts};
3991 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3992
3993 let mut dd = common::DefaultDelegate;
3994 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3995 dlg.begin(common::MethodInfo {
3996 id: "cloudresourcemanager.folders.setOrgPolicy",
3997 http_method: hyper::Method::POST,
3998 });
3999
4000 for &field in ["alt", "resource"].iter() {
4001 if self._additional_params.contains_key(field) {
4002 dlg.finished(false);
4003 return Err(common::Error::FieldClash(field));
4004 }
4005 }
4006
4007 let mut params = Params::with_capacity(4 + self._additional_params.len());
4008 params.push("resource", self._resource);
4009
4010 params.extend(self._additional_params.iter());
4011
4012 params.push("alt", "json");
4013 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setOrgPolicy";
4014 if self._scopes.is_empty() {
4015 self._scopes
4016 .insert(Scope::CloudPlatform.as_ref().to_string());
4017 }
4018
4019 #[allow(clippy::single_element_loop)]
4020 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4021 url = params.uri_replacement(url, param_name, find_this, true);
4022 }
4023 {
4024 let to_remove = ["resource"];
4025 params.remove_params(&to_remove);
4026 }
4027
4028 let url = params.parse_with_url(&url);
4029
4030 let mut json_mime_type = mime::APPLICATION_JSON;
4031 let mut request_value_reader = {
4032 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4033 common::remove_json_null_values(&mut value);
4034 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4035 serde_json::to_writer(&mut dst, &value).unwrap();
4036 dst
4037 };
4038 let request_size = request_value_reader
4039 .seek(std::io::SeekFrom::End(0))
4040 .unwrap();
4041 request_value_reader
4042 .seek(std::io::SeekFrom::Start(0))
4043 .unwrap();
4044
4045 loop {
4046 let token = match self
4047 .hub
4048 .auth
4049 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4050 .await
4051 {
4052 Ok(token) => token,
4053 Err(e) => match dlg.token(e) {
4054 Ok(token) => token,
4055 Err(e) => {
4056 dlg.finished(false);
4057 return Err(common::Error::MissingToken(e));
4058 }
4059 },
4060 };
4061 request_value_reader
4062 .seek(std::io::SeekFrom::Start(0))
4063 .unwrap();
4064 let mut req_result = {
4065 let client = &self.hub.client;
4066 dlg.pre_request();
4067 let mut req_builder = hyper::Request::builder()
4068 .method(hyper::Method::POST)
4069 .uri(url.as_str())
4070 .header(USER_AGENT, self.hub._user_agent.clone());
4071
4072 if let Some(token) = token.as_ref() {
4073 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4074 }
4075
4076 let request = req_builder
4077 .header(CONTENT_TYPE, json_mime_type.to_string())
4078 .header(CONTENT_LENGTH, request_size as u64)
4079 .body(common::to_body(
4080 request_value_reader.get_ref().clone().into(),
4081 ));
4082
4083 client.request(request.unwrap()).await
4084 };
4085
4086 match req_result {
4087 Err(err) => {
4088 if let common::Retry::After(d) = dlg.http_error(&err) {
4089 sleep(d).await;
4090 continue;
4091 }
4092 dlg.finished(false);
4093 return Err(common::Error::HttpError(err));
4094 }
4095 Ok(res) => {
4096 let (mut parts, body) = res.into_parts();
4097 let mut body = common::Body::new(body);
4098 if !parts.status.is_success() {
4099 let bytes = common::to_bytes(body).await.unwrap_or_default();
4100 let error = serde_json::from_str(&common::to_string(&bytes));
4101 let response = common::to_response(parts, bytes.into());
4102
4103 if let common::Retry::After(d) =
4104 dlg.http_failure(&response, error.as_ref().ok())
4105 {
4106 sleep(d).await;
4107 continue;
4108 }
4109
4110 dlg.finished(false);
4111
4112 return Err(match error {
4113 Ok(value) => common::Error::BadRequest(value),
4114 _ => common::Error::Failure(response),
4115 });
4116 }
4117 let response = {
4118 let bytes = common::to_bytes(body).await.unwrap_or_default();
4119 let encoded = common::to_string(&bytes);
4120 match serde_json::from_str(&encoded) {
4121 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4122 Err(error) => {
4123 dlg.response_json_decode_error(&encoded, &error);
4124 return Err(common::Error::JsonDecodeError(
4125 encoded.to_string(),
4126 error,
4127 ));
4128 }
4129 }
4130 };
4131
4132 dlg.finished(true);
4133 return Ok(response);
4134 }
4135 }
4136 }
4137 }
4138
4139 ///
4140 /// Sets the *request* property to the given value.
4141 ///
4142 /// Even though the property as already been set when instantiating this call,
4143 /// we provide this method for API completeness.
4144 pub fn request(mut self, new_value: SetOrgPolicyRequest) -> FolderSetOrgPolicyCall<'a, C> {
4145 self._request = new_value;
4146 self
4147 }
4148 /// Resource name of the resource to attach the `Policy`.
4149 ///
4150 /// Sets the *resource* path property to the given value.
4151 ///
4152 /// Even though the property as already been set when instantiating this call,
4153 /// we provide this method for API completeness.
4154 pub fn resource(mut self, new_value: &str) -> FolderSetOrgPolicyCall<'a, C> {
4155 self._resource = new_value.to_string();
4156 self
4157 }
4158 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4159 /// while executing the actual API request.
4160 ///
4161 /// ````text
4162 /// It should be used to handle progress information, and to implement a certain level of resilience.
4163 /// ````
4164 ///
4165 /// Sets the *delegate* property to the given value.
4166 pub fn delegate(
4167 mut self,
4168 new_value: &'a mut dyn common::Delegate,
4169 ) -> FolderSetOrgPolicyCall<'a, C> {
4170 self._delegate = Some(new_value);
4171 self
4172 }
4173
4174 /// Set any additional parameter of the query string used in the request.
4175 /// It should be used to set parameters which are not yet available through their own
4176 /// setters.
4177 ///
4178 /// Please note that this method must not be used to set any of the known parameters
4179 /// which have their own setter method. If done anyway, the request will fail.
4180 ///
4181 /// # Additional Parameters
4182 ///
4183 /// * *$.xgafv* (query-string) - V1 error format.
4184 /// * *access_token* (query-string) - OAuth access token.
4185 /// * *alt* (query-string) - Data format for response.
4186 /// * *callback* (query-string) - JSONP
4187 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4188 /// * *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.
4189 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4190 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4191 /// * *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.
4192 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4193 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4194 pub fn param<T>(mut self, name: T, value: T) -> FolderSetOrgPolicyCall<'a, C>
4195 where
4196 T: AsRef<str>,
4197 {
4198 self._additional_params
4199 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4200 self
4201 }
4202
4203 /// Identifies the authorization scope for the method you are building.
4204 ///
4205 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4206 /// [`Scope::CloudPlatform`].
4207 ///
4208 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4209 /// tokens for more than one scope.
4210 ///
4211 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4212 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4213 /// sufficient, a read-write scope will do as well.
4214 pub fn add_scope<St>(mut self, scope: St) -> FolderSetOrgPolicyCall<'a, C>
4215 where
4216 St: AsRef<str>,
4217 {
4218 self._scopes.insert(String::from(scope.as_ref()));
4219 self
4220 }
4221 /// Identifies the authorization scope(s) for the method you are building.
4222 ///
4223 /// See [`Self::add_scope()`] for details.
4224 pub fn add_scopes<I, St>(mut self, scopes: I) -> FolderSetOrgPolicyCall<'a, C>
4225 where
4226 I: IntoIterator<Item = St>,
4227 St: AsRef<str>,
4228 {
4229 self._scopes
4230 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4231 self
4232 }
4233
4234 /// Removes all scopes, and no default scope will be used either.
4235 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4236 /// for details).
4237 pub fn clear_scopes(mut self) -> FolderSetOrgPolicyCall<'a, C> {
4238 self._scopes.clear();
4239 self
4240 }
4241}
4242
4243/// Create a Lien which applies to the resource denoted by the `parent` field. Callers of this method will require permission on the `parent` resource. For example, applying to `projects/1234` requires permission `resourcemanager.projects.updateLiens`. NOTE: Some resources may limit the number of Liens which may be applied.
4244///
4245/// A builder for the *create* method supported by a *lien* resource.
4246/// It is not used directly, but through a [`LienMethods`] instance.
4247///
4248/// # Example
4249///
4250/// Instantiate a resource method builder
4251///
4252/// ```test_harness,no_run
4253/// # extern crate hyper;
4254/// # extern crate hyper_rustls;
4255/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
4256/// use cloudresourcemanager1::api::Lien;
4257/// # async fn dox() {
4258/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4259///
4260/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4261/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4262/// # .with_native_roots()
4263/// # .unwrap()
4264/// # .https_only()
4265/// # .enable_http2()
4266/// # .build();
4267///
4268/// # let executor = hyper_util::rt::TokioExecutor::new();
4269/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4270/// # secret,
4271/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4272/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4273/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4274/// # ),
4275/// # ).build().await.unwrap();
4276///
4277/// # let client = hyper_util::client::legacy::Client::builder(
4278/// # hyper_util::rt::TokioExecutor::new()
4279/// # )
4280/// # .build(
4281/// # hyper_rustls::HttpsConnectorBuilder::new()
4282/// # .with_native_roots()
4283/// # .unwrap()
4284/// # .https_or_http()
4285/// # .enable_http2()
4286/// # .build()
4287/// # );
4288/// # let mut hub = CloudResourceManager::new(client, auth);
4289/// // As the method needs a request, you would usually fill it with the desired information
4290/// // into the respective structure. Some of the parts shown here might not be applicable !
4291/// // Values shown here are possibly random and not representative !
4292/// let mut req = Lien::default();
4293///
4294/// // You can configure optional parameters by calling the respective setters at will, and
4295/// // execute the final call using `doit()`.
4296/// // Values shown here are possibly random and not representative !
4297/// let result = hub.liens().create(req)
4298/// .doit().await;
4299/// # }
4300/// ```
4301pub struct LienCreateCall<'a, C>
4302where
4303 C: 'a,
4304{
4305 hub: &'a CloudResourceManager<C>,
4306 _request: Lien,
4307 _delegate: Option<&'a mut dyn common::Delegate>,
4308 _additional_params: HashMap<String, String>,
4309 _scopes: BTreeSet<String>,
4310}
4311
4312impl<'a, C> common::CallBuilder for LienCreateCall<'a, C> {}
4313
4314impl<'a, C> LienCreateCall<'a, C>
4315where
4316 C: common::Connector,
4317{
4318 /// Perform the operation you have build so far.
4319 pub async fn doit(mut self) -> common::Result<(common::Response, Lien)> {
4320 use std::borrow::Cow;
4321 use std::io::{Read, Seek};
4322
4323 use common::{url::Params, ToParts};
4324 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4325
4326 let mut dd = common::DefaultDelegate;
4327 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4328 dlg.begin(common::MethodInfo {
4329 id: "cloudresourcemanager.liens.create",
4330 http_method: hyper::Method::POST,
4331 });
4332
4333 for &field in ["alt"].iter() {
4334 if self._additional_params.contains_key(field) {
4335 dlg.finished(false);
4336 return Err(common::Error::FieldClash(field));
4337 }
4338 }
4339
4340 let mut params = Params::with_capacity(3 + self._additional_params.len());
4341
4342 params.extend(self._additional_params.iter());
4343
4344 params.push("alt", "json");
4345 let mut url = self.hub._base_url.clone() + "v1/liens";
4346 if self._scopes.is_empty() {
4347 self._scopes
4348 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
4349 }
4350
4351 let url = params.parse_with_url(&url);
4352
4353 let mut json_mime_type = mime::APPLICATION_JSON;
4354 let mut request_value_reader = {
4355 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4356 common::remove_json_null_values(&mut value);
4357 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4358 serde_json::to_writer(&mut dst, &value).unwrap();
4359 dst
4360 };
4361 let request_size = request_value_reader
4362 .seek(std::io::SeekFrom::End(0))
4363 .unwrap();
4364 request_value_reader
4365 .seek(std::io::SeekFrom::Start(0))
4366 .unwrap();
4367
4368 loop {
4369 let token = match self
4370 .hub
4371 .auth
4372 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4373 .await
4374 {
4375 Ok(token) => token,
4376 Err(e) => match dlg.token(e) {
4377 Ok(token) => token,
4378 Err(e) => {
4379 dlg.finished(false);
4380 return Err(common::Error::MissingToken(e));
4381 }
4382 },
4383 };
4384 request_value_reader
4385 .seek(std::io::SeekFrom::Start(0))
4386 .unwrap();
4387 let mut req_result = {
4388 let client = &self.hub.client;
4389 dlg.pre_request();
4390 let mut req_builder = hyper::Request::builder()
4391 .method(hyper::Method::POST)
4392 .uri(url.as_str())
4393 .header(USER_AGENT, self.hub._user_agent.clone());
4394
4395 if let Some(token) = token.as_ref() {
4396 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4397 }
4398
4399 let request = req_builder
4400 .header(CONTENT_TYPE, json_mime_type.to_string())
4401 .header(CONTENT_LENGTH, request_size as u64)
4402 .body(common::to_body(
4403 request_value_reader.get_ref().clone().into(),
4404 ));
4405
4406 client.request(request.unwrap()).await
4407 };
4408
4409 match req_result {
4410 Err(err) => {
4411 if let common::Retry::After(d) = dlg.http_error(&err) {
4412 sleep(d).await;
4413 continue;
4414 }
4415 dlg.finished(false);
4416 return Err(common::Error::HttpError(err));
4417 }
4418 Ok(res) => {
4419 let (mut parts, body) = res.into_parts();
4420 let mut body = common::Body::new(body);
4421 if !parts.status.is_success() {
4422 let bytes = common::to_bytes(body).await.unwrap_or_default();
4423 let error = serde_json::from_str(&common::to_string(&bytes));
4424 let response = common::to_response(parts, bytes.into());
4425
4426 if let common::Retry::After(d) =
4427 dlg.http_failure(&response, error.as_ref().ok())
4428 {
4429 sleep(d).await;
4430 continue;
4431 }
4432
4433 dlg.finished(false);
4434
4435 return Err(match error {
4436 Ok(value) => common::Error::BadRequest(value),
4437 _ => common::Error::Failure(response),
4438 });
4439 }
4440 let response = {
4441 let bytes = common::to_bytes(body).await.unwrap_or_default();
4442 let encoded = common::to_string(&bytes);
4443 match serde_json::from_str(&encoded) {
4444 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4445 Err(error) => {
4446 dlg.response_json_decode_error(&encoded, &error);
4447 return Err(common::Error::JsonDecodeError(
4448 encoded.to_string(),
4449 error,
4450 ));
4451 }
4452 }
4453 };
4454
4455 dlg.finished(true);
4456 return Ok(response);
4457 }
4458 }
4459 }
4460 }
4461
4462 ///
4463 /// Sets the *request* property to the given value.
4464 ///
4465 /// Even though the property as already been set when instantiating this call,
4466 /// we provide this method for API completeness.
4467 pub fn request(mut self, new_value: Lien) -> LienCreateCall<'a, C> {
4468 self._request = new_value;
4469 self
4470 }
4471 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4472 /// while executing the actual API request.
4473 ///
4474 /// ````text
4475 /// It should be used to handle progress information, and to implement a certain level of resilience.
4476 /// ````
4477 ///
4478 /// Sets the *delegate* property to the given value.
4479 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienCreateCall<'a, C> {
4480 self._delegate = Some(new_value);
4481 self
4482 }
4483
4484 /// Set any additional parameter of the query string used in the request.
4485 /// It should be used to set parameters which are not yet available through their own
4486 /// setters.
4487 ///
4488 /// Please note that this method must not be used to set any of the known parameters
4489 /// which have their own setter method. If done anyway, the request will fail.
4490 ///
4491 /// # Additional Parameters
4492 ///
4493 /// * *$.xgafv* (query-string) - V1 error format.
4494 /// * *access_token* (query-string) - OAuth access token.
4495 /// * *alt* (query-string) - Data format for response.
4496 /// * *callback* (query-string) - JSONP
4497 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4498 /// * *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.
4499 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4500 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4501 /// * *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.
4502 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4503 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4504 pub fn param<T>(mut self, name: T, value: T) -> LienCreateCall<'a, C>
4505 where
4506 T: AsRef<str>,
4507 {
4508 self._additional_params
4509 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4510 self
4511 }
4512
4513 /// Identifies the authorization scope for the method you are building.
4514 ///
4515 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4516 /// [`Scope::CloudPlatformReadOnly`].
4517 ///
4518 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4519 /// tokens for more than one scope.
4520 ///
4521 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4522 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4523 /// sufficient, a read-write scope will do as well.
4524 pub fn add_scope<St>(mut self, scope: St) -> LienCreateCall<'a, C>
4525 where
4526 St: AsRef<str>,
4527 {
4528 self._scopes.insert(String::from(scope.as_ref()));
4529 self
4530 }
4531 /// Identifies the authorization scope(s) for the method you are building.
4532 ///
4533 /// See [`Self::add_scope()`] for details.
4534 pub fn add_scopes<I, St>(mut self, scopes: I) -> LienCreateCall<'a, C>
4535 where
4536 I: IntoIterator<Item = St>,
4537 St: AsRef<str>,
4538 {
4539 self._scopes
4540 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4541 self
4542 }
4543
4544 /// Removes all scopes, and no default scope will be used either.
4545 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4546 /// for details).
4547 pub fn clear_scopes(mut self) -> LienCreateCall<'a, C> {
4548 self._scopes.clear();
4549 self
4550 }
4551}
4552
4553/// Delete a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.updateLiens`.
4554///
4555/// A builder for the *delete* method supported by a *lien* resource.
4556/// It is not used directly, but through a [`LienMethods`] instance.
4557///
4558/// # Example
4559///
4560/// Instantiate a resource method builder
4561///
4562/// ```test_harness,no_run
4563/// # extern crate hyper;
4564/// # extern crate hyper_rustls;
4565/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
4566/// # async fn dox() {
4567/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4568///
4569/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4570/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4571/// # .with_native_roots()
4572/// # .unwrap()
4573/// # .https_only()
4574/// # .enable_http2()
4575/// # .build();
4576///
4577/// # let executor = hyper_util::rt::TokioExecutor::new();
4578/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4579/// # secret,
4580/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4581/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4582/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4583/// # ),
4584/// # ).build().await.unwrap();
4585///
4586/// # let client = hyper_util::client::legacy::Client::builder(
4587/// # hyper_util::rt::TokioExecutor::new()
4588/// # )
4589/// # .build(
4590/// # hyper_rustls::HttpsConnectorBuilder::new()
4591/// # .with_native_roots()
4592/// # .unwrap()
4593/// # .https_or_http()
4594/// # .enable_http2()
4595/// # .build()
4596/// # );
4597/// # let mut hub = CloudResourceManager::new(client, auth);
4598/// // You can configure optional parameters by calling the respective setters at will, and
4599/// // execute the final call using `doit()`.
4600/// // Values shown here are possibly random and not representative !
4601/// let result = hub.liens().delete("name")
4602/// .doit().await;
4603/// # }
4604/// ```
4605pub struct LienDeleteCall<'a, C>
4606where
4607 C: 'a,
4608{
4609 hub: &'a CloudResourceManager<C>,
4610 _name: String,
4611 _delegate: Option<&'a mut dyn common::Delegate>,
4612 _additional_params: HashMap<String, String>,
4613 _scopes: BTreeSet<String>,
4614}
4615
4616impl<'a, C> common::CallBuilder for LienDeleteCall<'a, C> {}
4617
4618impl<'a, C> LienDeleteCall<'a, C>
4619where
4620 C: common::Connector,
4621{
4622 /// Perform the operation you have build so far.
4623 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4624 use std::borrow::Cow;
4625 use std::io::{Read, Seek};
4626
4627 use common::{url::Params, ToParts};
4628 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4629
4630 let mut dd = common::DefaultDelegate;
4631 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4632 dlg.begin(common::MethodInfo {
4633 id: "cloudresourcemanager.liens.delete",
4634 http_method: hyper::Method::DELETE,
4635 });
4636
4637 for &field in ["alt", "name"].iter() {
4638 if self._additional_params.contains_key(field) {
4639 dlg.finished(false);
4640 return Err(common::Error::FieldClash(field));
4641 }
4642 }
4643
4644 let mut params = Params::with_capacity(3 + self._additional_params.len());
4645 params.push("name", self._name);
4646
4647 params.extend(self._additional_params.iter());
4648
4649 params.push("alt", "json");
4650 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4651 if self._scopes.is_empty() {
4652 self._scopes
4653 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
4654 }
4655
4656 #[allow(clippy::single_element_loop)]
4657 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4658 url = params.uri_replacement(url, param_name, find_this, true);
4659 }
4660 {
4661 let to_remove = ["name"];
4662 params.remove_params(&to_remove);
4663 }
4664
4665 let url = params.parse_with_url(&url);
4666
4667 loop {
4668 let token = match self
4669 .hub
4670 .auth
4671 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4672 .await
4673 {
4674 Ok(token) => token,
4675 Err(e) => match dlg.token(e) {
4676 Ok(token) => token,
4677 Err(e) => {
4678 dlg.finished(false);
4679 return Err(common::Error::MissingToken(e));
4680 }
4681 },
4682 };
4683 let mut req_result = {
4684 let client = &self.hub.client;
4685 dlg.pre_request();
4686 let mut req_builder = hyper::Request::builder()
4687 .method(hyper::Method::DELETE)
4688 .uri(url.as_str())
4689 .header(USER_AGENT, self.hub._user_agent.clone());
4690
4691 if let Some(token) = token.as_ref() {
4692 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4693 }
4694
4695 let request = req_builder
4696 .header(CONTENT_LENGTH, 0_u64)
4697 .body(common::to_body::<String>(None));
4698
4699 client.request(request.unwrap()).await
4700 };
4701
4702 match req_result {
4703 Err(err) => {
4704 if let common::Retry::After(d) = dlg.http_error(&err) {
4705 sleep(d).await;
4706 continue;
4707 }
4708 dlg.finished(false);
4709 return Err(common::Error::HttpError(err));
4710 }
4711 Ok(res) => {
4712 let (mut parts, body) = res.into_parts();
4713 let mut body = common::Body::new(body);
4714 if !parts.status.is_success() {
4715 let bytes = common::to_bytes(body).await.unwrap_or_default();
4716 let error = serde_json::from_str(&common::to_string(&bytes));
4717 let response = common::to_response(parts, bytes.into());
4718
4719 if let common::Retry::After(d) =
4720 dlg.http_failure(&response, error.as_ref().ok())
4721 {
4722 sleep(d).await;
4723 continue;
4724 }
4725
4726 dlg.finished(false);
4727
4728 return Err(match error {
4729 Ok(value) => common::Error::BadRequest(value),
4730 _ => common::Error::Failure(response),
4731 });
4732 }
4733 let response = {
4734 let bytes = common::to_bytes(body).await.unwrap_or_default();
4735 let encoded = common::to_string(&bytes);
4736 match serde_json::from_str(&encoded) {
4737 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4738 Err(error) => {
4739 dlg.response_json_decode_error(&encoded, &error);
4740 return Err(common::Error::JsonDecodeError(
4741 encoded.to_string(),
4742 error,
4743 ));
4744 }
4745 }
4746 };
4747
4748 dlg.finished(true);
4749 return Ok(response);
4750 }
4751 }
4752 }
4753 }
4754
4755 /// Required. The name/identifier of the Lien to delete.
4756 ///
4757 /// Sets the *name* path property to the given value.
4758 ///
4759 /// Even though the property as already been set when instantiating this call,
4760 /// we provide this method for API completeness.
4761 pub fn name(mut self, new_value: &str) -> LienDeleteCall<'a, C> {
4762 self._name = new_value.to_string();
4763 self
4764 }
4765 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4766 /// while executing the actual API request.
4767 ///
4768 /// ````text
4769 /// It should be used to handle progress information, and to implement a certain level of resilience.
4770 /// ````
4771 ///
4772 /// Sets the *delegate* property to the given value.
4773 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienDeleteCall<'a, C> {
4774 self._delegate = Some(new_value);
4775 self
4776 }
4777
4778 /// Set any additional parameter of the query string used in the request.
4779 /// It should be used to set parameters which are not yet available through their own
4780 /// setters.
4781 ///
4782 /// Please note that this method must not be used to set any of the known parameters
4783 /// which have their own setter method. If done anyway, the request will fail.
4784 ///
4785 /// # Additional Parameters
4786 ///
4787 /// * *$.xgafv* (query-string) - V1 error format.
4788 /// * *access_token* (query-string) - OAuth access token.
4789 /// * *alt* (query-string) - Data format for response.
4790 /// * *callback* (query-string) - JSONP
4791 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4792 /// * *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.
4793 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4794 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4795 /// * *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.
4796 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4797 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4798 pub fn param<T>(mut self, name: T, value: T) -> LienDeleteCall<'a, C>
4799 where
4800 T: AsRef<str>,
4801 {
4802 self._additional_params
4803 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4804 self
4805 }
4806
4807 /// Identifies the authorization scope for the method you are building.
4808 ///
4809 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4810 /// [`Scope::CloudPlatformReadOnly`].
4811 ///
4812 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4813 /// tokens for more than one scope.
4814 ///
4815 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4816 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4817 /// sufficient, a read-write scope will do as well.
4818 pub fn add_scope<St>(mut self, scope: St) -> LienDeleteCall<'a, C>
4819 where
4820 St: AsRef<str>,
4821 {
4822 self._scopes.insert(String::from(scope.as_ref()));
4823 self
4824 }
4825 /// Identifies the authorization scope(s) for the method you are building.
4826 ///
4827 /// See [`Self::add_scope()`] for details.
4828 pub fn add_scopes<I, St>(mut self, scopes: I) -> LienDeleteCall<'a, C>
4829 where
4830 I: IntoIterator<Item = St>,
4831 St: AsRef<str>,
4832 {
4833 self._scopes
4834 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4835 self
4836 }
4837
4838 /// Removes all scopes, and no default scope will be used either.
4839 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4840 /// for details).
4841 pub fn clear_scopes(mut self) -> LienDeleteCall<'a, C> {
4842 self._scopes.clear();
4843 self
4844 }
4845}
4846
4847/// Retrieve a Lien by `name`. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`
4848///
4849/// A builder for the *get* method supported by a *lien* resource.
4850/// It is not used directly, but through a [`LienMethods`] instance.
4851///
4852/// # Example
4853///
4854/// Instantiate a resource method builder
4855///
4856/// ```test_harness,no_run
4857/// # extern crate hyper;
4858/// # extern crate hyper_rustls;
4859/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
4860/// # async fn dox() {
4861/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4862///
4863/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4864/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4865/// # .with_native_roots()
4866/// # .unwrap()
4867/// # .https_only()
4868/// # .enable_http2()
4869/// # .build();
4870///
4871/// # let executor = hyper_util::rt::TokioExecutor::new();
4872/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4873/// # secret,
4874/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4875/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4876/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4877/// # ),
4878/// # ).build().await.unwrap();
4879///
4880/// # let client = hyper_util::client::legacy::Client::builder(
4881/// # hyper_util::rt::TokioExecutor::new()
4882/// # )
4883/// # .build(
4884/// # hyper_rustls::HttpsConnectorBuilder::new()
4885/// # .with_native_roots()
4886/// # .unwrap()
4887/// # .https_or_http()
4888/// # .enable_http2()
4889/// # .build()
4890/// # );
4891/// # let mut hub = CloudResourceManager::new(client, auth);
4892/// // You can configure optional parameters by calling the respective setters at will, and
4893/// // execute the final call using `doit()`.
4894/// // Values shown here are possibly random and not representative !
4895/// let result = hub.liens().get("name")
4896/// .doit().await;
4897/// # }
4898/// ```
4899pub struct LienGetCall<'a, C>
4900where
4901 C: 'a,
4902{
4903 hub: &'a CloudResourceManager<C>,
4904 _name: String,
4905 _delegate: Option<&'a mut dyn common::Delegate>,
4906 _additional_params: HashMap<String, String>,
4907 _scopes: BTreeSet<String>,
4908}
4909
4910impl<'a, C> common::CallBuilder for LienGetCall<'a, C> {}
4911
4912impl<'a, C> LienGetCall<'a, C>
4913where
4914 C: common::Connector,
4915{
4916 /// Perform the operation you have build so far.
4917 pub async fn doit(mut self) -> common::Result<(common::Response, Lien)> {
4918 use std::borrow::Cow;
4919 use std::io::{Read, Seek};
4920
4921 use common::{url::Params, ToParts};
4922 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4923
4924 let mut dd = common::DefaultDelegate;
4925 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4926 dlg.begin(common::MethodInfo {
4927 id: "cloudresourcemanager.liens.get",
4928 http_method: hyper::Method::GET,
4929 });
4930
4931 for &field in ["alt", "name"].iter() {
4932 if self._additional_params.contains_key(field) {
4933 dlg.finished(false);
4934 return Err(common::Error::FieldClash(field));
4935 }
4936 }
4937
4938 let mut params = Params::with_capacity(3 + self._additional_params.len());
4939 params.push("name", self._name);
4940
4941 params.extend(self._additional_params.iter());
4942
4943 params.push("alt", "json");
4944 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4945 if self._scopes.is_empty() {
4946 self._scopes
4947 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
4948 }
4949
4950 #[allow(clippy::single_element_loop)]
4951 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4952 url = params.uri_replacement(url, param_name, find_this, true);
4953 }
4954 {
4955 let to_remove = ["name"];
4956 params.remove_params(&to_remove);
4957 }
4958
4959 let url = params.parse_with_url(&url);
4960
4961 loop {
4962 let token = match self
4963 .hub
4964 .auth
4965 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4966 .await
4967 {
4968 Ok(token) => token,
4969 Err(e) => match dlg.token(e) {
4970 Ok(token) => token,
4971 Err(e) => {
4972 dlg.finished(false);
4973 return Err(common::Error::MissingToken(e));
4974 }
4975 },
4976 };
4977 let mut req_result = {
4978 let client = &self.hub.client;
4979 dlg.pre_request();
4980 let mut req_builder = hyper::Request::builder()
4981 .method(hyper::Method::GET)
4982 .uri(url.as_str())
4983 .header(USER_AGENT, self.hub._user_agent.clone());
4984
4985 if let Some(token) = token.as_ref() {
4986 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4987 }
4988
4989 let request = req_builder
4990 .header(CONTENT_LENGTH, 0_u64)
4991 .body(common::to_body::<String>(None));
4992
4993 client.request(request.unwrap()).await
4994 };
4995
4996 match req_result {
4997 Err(err) => {
4998 if let common::Retry::After(d) = dlg.http_error(&err) {
4999 sleep(d).await;
5000 continue;
5001 }
5002 dlg.finished(false);
5003 return Err(common::Error::HttpError(err));
5004 }
5005 Ok(res) => {
5006 let (mut parts, body) = res.into_parts();
5007 let mut body = common::Body::new(body);
5008 if !parts.status.is_success() {
5009 let bytes = common::to_bytes(body).await.unwrap_or_default();
5010 let error = serde_json::from_str(&common::to_string(&bytes));
5011 let response = common::to_response(parts, bytes.into());
5012
5013 if let common::Retry::After(d) =
5014 dlg.http_failure(&response, error.as_ref().ok())
5015 {
5016 sleep(d).await;
5017 continue;
5018 }
5019
5020 dlg.finished(false);
5021
5022 return Err(match error {
5023 Ok(value) => common::Error::BadRequest(value),
5024 _ => common::Error::Failure(response),
5025 });
5026 }
5027 let response = {
5028 let bytes = common::to_bytes(body).await.unwrap_or_default();
5029 let encoded = common::to_string(&bytes);
5030 match serde_json::from_str(&encoded) {
5031 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5032 Err(error) => {
5033 dlg.response_json_decode_error(&encoded, &error);
5034 return Err(common::Error::JsonDecodeError(
5035 encoded.to_string(),
5036 error,
5037 ));
5038 }
5039 }
5040 };
5041
5042 dlg.finished(true);
5043 return Ok(response);
5044 }
5045 }
5046 }
5047 }
5048
5049 /// Required. The name/identifier of the Lien.
5050 ///
5051 /// Sets the *name* path property to the given value.
5052 ///
5053 /// Even though the property as already been set when instantiating this call,
5054 /// we provide this method for API completeness.
5055 pub fn name(mut self, new_value: &str) -> LienGetCall<'a, C> {
5056 self._name = new_value.to_string();
5057 self
5058 }
5059 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5060 /// while executing the actual API request.
5061 ///
5062 /// ````text
5063 /// It should be used to handle progress information, and to implement a certain level of resilience.
5064 /// ````
5065 ///
5066 /// Sets the *delegate* property to the given value.
5067 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienGetCall<'a, C> {
5068 self._delegate = Some(new_value);
5069 self
5070 }
5071
5072 /// Set any additional parameter of the query string used in the request.
5073 /// It should be used to set parameters which are not yet available through their own
5074 /// setters.
5075 ///
5076 /// Please note that this method must not be used to set any of the known parameters
5077 /// which have their own setter method. If done anyway, the request will fail.
5078 ///
5079 /// # Additional Parameters
5080 ///
5081 /// * *$.xgafv* (query-string) - V1 error format.
5082 /// * *access_token* (query-string) - OAuth access token.
5083 /// * *alt* (query-string) - Data format for response.
5084 /// * *callback* (query-string) - JSONP
5085 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5086 /// * *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.
5087 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5088 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5089 /// * *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.
5090 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5091 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5092 pub fn param<T>(mut self, name: T, value: T) -> LienGetCall<'a, C>
5093 where
5094 T: AsRef<str>,
5095 {
5096 self._additional_params
5097 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5098 self
5099 }
5100
5101 /// Identifies the authorization scope for the method you are building.
5102 ///
5103 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5104 /// [`Scope::CloudPlatformReadOnly`].
5105 ///
5106 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5107 /// tokens for more than one scope.
5108 ///
5109 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5110 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5111 /// sufficient, a read-write scope will do as well.
5112 pub fn add_scope<St>(mut self, scope: St) -> LienGetCall<'a, C>
5113 where
5114 St: AsRef<str>,
5115 {
5116 self._scopes.insert(String::from(scope.as_ref()));
5117 self
5118 }
5119 /// Identifies the authorization scope(s) for the method you are building.
5120 ///
5121 /// See [`Self::add_scope()`] for details.
5122 pub fn add_scopes<I, St>(mut self, scopes: I) -> LienGetCall<'a, C>
5123 where
5124 I: IntoIterator<Item = St>,
5125 St: AsRef<str>,
5126 {
5127 self._scopes
5128 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5129 self
5130 }
5131
5132 /// Removes all scopes, and no default scope will be used either.
5133 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5134 /// for details).
5135 pub fn clear_scopes(mut self) -> LienGetCall<'a, C> {
5136 self._scopes.clear();
5137 self
5138 }
5139}
5140
5141/// List all Liens applied to the `parent` resource. Callers of this method will require permission on the `parent` resource. For example, a Lien with a `parent` of `projects/1234` requires permission `resourcemanager.projects.get`.
5142///
5143/// A builder for the *list* method supported by a *lien* resource.
5144/// It is not used directly, but through a [`LienMethods`] instance.
5145///
5146/// # Example
5147///
5148/// Instantiate a resource method builder
5149///
5150/// ```test_harness,no_run
5151/// # extern crate hyper;
5152/// # extern crate hyper_rustls;
5153/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
5154/// # async fn dox() {
5155/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5156///
5157/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5158/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5159/// # .with_native_roots()
5160/// # .unwrap()
5161/// # .https_only()
5162/// # .enable_http2()
5163/// # .build();
5164///
5165/// # let executor = hyper_util::rt::TokioExecutor::new();
5166/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5167/// # secret,
5168/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5169/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5170/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5171/// # ),
5172/// # ).build().await.unwrap();
5173///
5174/// # let client = hyper_util::client::legacy::Client::builder(
5175/// # hyper_util::rt::TokioExecutor::new()
5176/// # )
5177/// # .build(
5178/// # hyper_rustls::HttpsConnectorBuilder::new()
5179/// # .with_native_roots()
5180/// # .unwrap()
5181/// # .https_or_http()
5182/// # .enable_http2()
5183/// # .build()
5184/// # );
5185/// # let mut hub = CloudResourceManager::new(client, auth);
5186/// // You can configure optional parameters by calling the respective setters at will, and
5187/// // execute the final call using `doit()`.
5188/// // Values shown here are possibly random and not representative !
5189/// let result = hub.liens().list()
5190/// .parent("dolor")
5191/// .page_token("ea")
5192/// .page_size(-55)
5193/// .doit().await;
5194/// # }
5195/// ```
5196pub struct LienListCall<'a, C>
5197where
5198 C: 'a,
5199{
5200 hub: &'a CloudResourceManager<C>,
5201 _parent: Option<String>,
5202 _page_token: Option<String>,
5203 _page_size: Option<i32>,
5204 _delegate: Option<&'a mut dyn common::Delegate>,
5205 _additional_params: HashMap<String, String>,
5206 _scopes: BTreeSet<String>,
5207}
5208
5209impl<'a, C> common::CallBuilder for LienListCall<'a, C> {}
5210
5211impl<'a, C> LienListCall<'a, C>
5212where
5213 C: common::Connector,
5214{
5215 /// Perform the operation you have build so far.
5216 pub async fn doit(mut self) -> common::Result<(common::Response, ListLiensResponse)> {
5217 use std::borrow::Cow;
5218 use std::io::{Read, Seek};
5219
5220 use common::{url::Params, ToParts};
5221 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5222
5223 let mut dd = common::DefaultDelegate;
5224 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5225 dlg.begin(common::MethodInfo {
5226 id: "cloudresourcemanager.liens.list",
5227 http_method: hyper::Method::GET,
5228 });
5229
5230 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5231 if self._additional_params.contains_key(field) {
5232 dlg.finished(false);
5233 return Err(common::Error::FieldClash(field));
5234 }
5235 }
5236
5237 let mut params = Params::with_capacity(5 + self._additional_params.len());
5238 if let Some(value) = self._parent.as_ref() {
5239 params.push("parent", value);
5240 }
5241 if let Some(value) = self._page_token.as_ref() {
5242 params.push("pageToken", value);
5243 }
5244 if let Some(value) = self._page_size.as_ref() {
5245 params.push("pageSize", value.to_string());
5246 }
5247
5248 params.extend(self._additional_params.iter());
5249
5250 params.push("alt", "json");
5251 let mut url = self.hub._base_url.clone() + "v1/liens";
5252 if self._scopes.is_empty() {
5253 self._scopes
5254 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
5255 }
5256
5257 let url = params.parse_with_url(&url);
5258
5259 loop {
5260 let token = match self
5261 .hub
5262 .auth
5263 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5264 .await
5265 {
5266 Ok(token) => token,
5267 Err(e) => match dlg.token(e) {
5268 Ok(token) => token,
5269 Err(e) => {
5270 dlg.finished(false);
5271 return Err(common::Error::MissingToken(e));
5272 }
5273 },
5274 };
5275 let mut req_result = {
5276 let client = &self.hub.client;
5277 dlg.pre_request();
5278 let mut req_builder = hyper::Request::builder()
5279 .method(hyper::Method::GET)
5280 .uri(url.as_str())
5281 .header(USER_AGENT, self.hub._user_agent.clone());
5282
5283 if let Some(token) = token.as_ref() {
5284 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5285 }
5286
5287 let request = req_builder
5288 .header(CONTENT_LENGTH, 0_u64)
5289 .body(common::to_body::<String>(None));
5290
5291 client.request(request.unwrap()).await
5292 };
5293
5294 match req_result {
5295 Err(err) => {
5296 if let common::Retry::After(d) = dlg.http_error(&err) {
5297 sleep(d).await;
5298 continue;
5299 }
5300 dlg.finished(false);
5301 return Err(common::Error::HttpError(err));
5302 }
5303 Ok(res) => {
5304 let (mut parts, body) = res.into_parts();
5305 let mut body = common::Body::new(body);
5306 if !parts.status.is_success() {
5307 let bytes = common::to_bytes(body).await.unwrap_or_default();
5308 let error = serde_json::from_str(&common::to_string(&bytes));
5309 let response = common::to_response(parts, bytes.into());
5310
5311 if let common::Retry::After(d) =
5312 dlg.http_failure(&response, error.as_ref().ok())
5313 {
5314 sleep(d).await;
5315 continue;
5316 }
5317
5318 dlg.finished(false);
5319
5320 return Err(match error {
5321 Ok(value) => common::Error::BadRequest(value),
5322 _ => common::Error::Failure(response),
5323 });
5324 }
5325 let response = {
5326 let bytes = common::to_bytes(body).await.unwrap_or_default();
5327 let encoded = common::to_string(&bytes);
5328 match serde_json::from_str(&encoded) {
5329 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5330 Err(error) => {
5331 dlg.response_json_decode_error(&encoded, &error);
5332 return Err(common::Error::JsonDecodeError(
5333 encoded.to_string(),
5334 error,
5335 ));
5336 }
5337 }
5338 };
5339
5340 dlg.finished(true);
5341 return Ok(response);
5342 }
5343 }
5344 }
5345 }
5346
5347 /// Required. The name of the resource to list all attached Liens. For example, `projects/1234`. (google.api.field_policy).resource_type annotation is not set since the parent depends on the meta api implementation. This field could be a project or other sub project resources.
5348 ///
5349 /// Sets the *parent* query property to the given value.
5350 pub fn parent(mut self, new_value: &str) -> LienListCall<'a, C> {
5351 self._parent = Some(new_value.to_string());
5352 self
5353 }
5354 /// The `next_page_token` value returned from a previous List request, if any.
5355 ///
5356 /// Sets the *page token* query property to the given value.
5357 pub fn page_token(mut self, new_value: &str) -> LienListCall<'a, C> {
5358 self._page_token = Some(new_value.to_string());
5359 self
5360 }
5361 /// The maximum number of items to return. This is a suggestion for the server. The server can return fewer liens than requested. If unspecified, server picks an appropriate default.
5362 ///
5363 /// Sets the *page size* query property to the given value.
5364 pub fn page_size(mut self, new_value: i32) -> LienListCall<'a, C> {
5365 self._page_size = Some(new_value);
5366 self
5367 }
5368 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5369 /// while executing the actual API request.
5370 ///
5371 /// ````text
5372 /// It should be used to handle progress information, and to implement a certain level of resilience.
5373 /// ````
5374 ///
5375 /// Sets the *delegate* property to the given value.
5376 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> LienListCall<'a, C> {
5377 self._delegate = Some(new_value);
5378 self
5379 }
5380
5381 /// Set any additional parameter of the query string used in the request.
5382 /// It should be used to set parameters which are not yet available through their own
5383 /// setters.
5384 ///
5385 /// Please note that this method must not be used to set any of the known parameters
5386 /// which have their own setter method. If done anyway, the request will fail.
5387 ///
5388 /// # Additional Parameters
5389 ///
5390 /// * *$.xgafv* (query-string) - V1 error format.
5391 /// * *access_token* (query-string) - OAuth access token.
5392 /// * *alt* (query-string) - Data format for response.
5393 /// * *callback* (query-string) - JSONP
5394 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5395 /// * *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.
5396 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5397 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5398 /// * *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.
5399 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5400 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5401 pub fn param<T>(mut self, name: T, value: T) -> LienListCall<'a, C>
5402 where
5403 T: AsRef<str>,
5404 {
5405 self._additional_params
5406 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5407 self
5408 }
5409
5410 /// Identifies the authorization scope for the method you are building.
5411 ///
5412 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5413 /// [`Scope::CloudPlatformReadOnly`].
5414 ///
5415 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5416 /// tokens for more than one scope.
5417 ///
5418 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5419 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5420 /// sufficient, a read-write scope will do as well.
5421 pub fn add_scope<St>(mut self, scope: St) -> LienListCall<'a, C>
5422 where
5423 St: AsRef<str>,
5424 {
5425 self._scopes.insert(String::from(scope.as_ref()));
5426 self
5427 }
5428 /// Identifies the authorization scope(s) for the method you are building.
5429 ///
5430 /// See [`Self::add_scope()`] for details.
5431 pub fn add_scopes<I, St>(mut self, scopes: I) -> LienListCall<'a, C>
5432 where
5433 I: IntoIterator<Item = St>,
5434 St: AsRef<str>,
5435 {
5436 self._scopes
5437 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5438 self
5439 }
5440
5441 /// Removes all scopes, and no default scope will be used either.
5442 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5443 /// for details).
5444 pub fn clear_scopes(mut self) -> LienListCall<'a, C> {
5445 self._scopes.clear();
5446 self
5447 }
5448}
5449
5450/// 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.
5451///
5452/// A builder for the *get* method supported by a *operation* resource.
5453/// It is not used directly, but through a [`OperationMethods`] instance.
5454///
5455/// # Example
5456///
5457/// Instantiate a resource method builder
5458///
5459/// ```test_harness,no_run
5460/// # extern crate hyper;
5461/// # extern crate hyper_rustls;
5462/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
5463/// # async fn dox() {
5464/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5465///
5466/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5467/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5468/// # .with_native_roots()
5469/// # .unwrap()
5470/// # .https_only()
5471/// # .enable_http2()
5472/// # .build();
5473///
5474/// # let executor = hyper_util::rt::TokioExecutor::new();
5475/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5476/// # secret,
5477/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5478/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5479/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5480/// # ),
5481/// # ).build().await.unwrap();
5482///
5483/// # let client = hyper_util::client::legacy::Client::builder(
5484/// # hyper_util::rt::TokioExecutor::new()
5485/// # )
5486/// # .build(
5487/// # hyper_rustls::HttpsConnectorBuilder::new()
5488/// # .with_native_roots()
5489/// # .unwrap()
5490/// # .https_or_http()
5491/// # .enable_http2()
5492/// # .build()
5493/// # );
5494/// # let mut hub = CloudResourceManager::new(client, auth);
5495/// // You can configure optional parameters by calling the respective setters at will, and
5496/// // execute the final call using `doit()`.
5497/// // Values shown here are possibly random and not representative !
5498/// let result = hub.operations().get("name")
5499/// .doit().await;
5500/// # }
5501/// ```
5502pub struct OperationGetCall<'a, C>
5503where
5504 C: 'a,
5505{
5506 hub: &'a CloudResourceManager<C>,
5507 _name: String,
5508 _delegate: Option<&'a mut dyn common::Delegate>,
5509 _additional_params: HashMap<String, String>,
5510 _scopes: BTreeSet<String>,
5511}
5512
5513impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
5514
5515impl<'a, C> OperationGetCall<'a, C>
5516where
5517 C: common::Connector,
5518{
5519 /// Perform the operation you have build so far.
5520 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5521 use std::borrow::Cow;
5522 use std::io::{Read, Seek};
5523
5524 use common::{url::Params, ToParts};
5525 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5526
5527 let mut dd = common::DefaultDelegate;
5528 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5529 dlg.begin(common::MethodInfo {
5530 id: "cloudresourcemanager.operations.get",
5531 http_method: hyper::Method::GET,
5532 });
5533
5534 for &field in ["alt", "name"].iter() {
5535 if self._additional_params.contains_key(field) {
5536 dlg.finished(false);
5537 return Err(common::Error::FieldClash(field));
5538 }
5539 }
5540
5541 let mut params = Params::with_capacity(3 + self._additional_params.len());
5542 params.push("name", self._name);
5543
5544 params.extend(self._additional_params.iter());
5545
5546 params.push("alt", "json");
5547 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5548 if self._scopes.is_empty() {
5549 self._scopes
5550 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
5551 }
5552
5553 #[allow(clippy::single_element_loop)]
5554 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5555 url = params.uri_replacement(url, param_name, find_this, true);
5556 }
5557 {
5558 let to_remove = ["name"];
5559 params.remove_params(&to_remove);
5560 }
5561
5562 let url = params.parse_with_url(&url);
5563
5564 loop {
5565 let token = match self
5566 .hub
5567 .auth
5568 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5569 .await
5570 {
5571 Ok(token) => token,
5572 Err(e) => match dlg.token(e) {
5573 Ok(token) => token,
5574 Err(e) => {
5575 dlg.finished(false);
5576 return Err(common::Error::MissingToken(e));
5577 }
5578 },
5579 };
5580 let mut req_result = {
5581 let client = &self.hub.client;
5582 dlg.pre_request();
5583 let mut req_builder = hyper::Request::builder()
5584 .method(hyper::Method::GET)
5585 .uri(url.as_str())
5586 .header(USER_AGENT, self.hub._user_agent.clone());
5587
5588 if let Some(token) = token.as_ref() {
5589 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5590 }
5591
5592 let request = req_builder
5593 .header(CONTENT_LENGTH, 0_u64)
5594 .body(common::to_body::<String>(None));
5595
5596 client.request(request.unwrap()).await
5597 };
5598
5599 match req_result {
5600 Err(err) => {
5601 if let common::Retry::After(d) = dlg.http_error(&err) {
5602 sleep(d).await;
5603 continue;
5604 }
5605 dlg.finished(false);
5606 return Err(common::Error::HttpError(err));
5607 }
5608 Ok(res) => {
5609 let (mut parts, body) = res.into_parts();
5610 let mut body = common::Body::new(body);
5611 if !parts.status.is_success() {
5612 let bytes = common::to_bytes(body).await.unwrap_or_default();
5613 let error = serde_json::from_str(&common::to_string(&bytes));
5614 let response = common::to_response(parts, bytes.into());
5615
5616 if let common::Retry::After(d) =
5617 dlg.http_failure(&response, error.as_ref().ok())
5618 {
5619 sleep(d).await;
5620 continue;
5621 }
5622
5623 dlg.finished(false);
5624
5625 return Err(match error {
5626 Ok(value) => common::Error::BadRequest(value),
5627 _ => common::Error::Failure(response),
5628 });
5629 }
5630 let response = {
5631 let bytes = common::to_bytes(body).await.unwrap_or_default();
5632 let encoded = common::to_string(&bytes);
5633 match serde_json::from_str(&encoded) {
5634 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5635 Err(error) => {
5636 dlg.response_json_decode_error(&encoded, &error);
5637 return Err(common::Error::JsonDecodeError(
5638 encoded.to_string(),
5639 error,
5640 ));
5641 }
5642 }
5643 };
5644
5645 dlg.finished(true);
5646 return Ok(response);
5647 }
5648 }
5649 }
5650 }
5651
5652 /// The name of the operation resource.
5653 ///
5654 /// Sets the *name* path property to the given value.
5655 ///
5656 /// Even though the property as already been set when instantiating this call,
5657 /// we provide this method for API completeness.
5658 pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
5659 self._name = new_value.to_string();
5660 self
5661 }
5662 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5663 /// while executing the actual API request.
5664 ///
5665 /// ````text
5666 /// It should be used to handle progress information, and to implement a certain level of resilience.
5667 /// ````
5668 ///
5669 /// Sets the *delegate* property to the given value.
5670 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
5671 self._delegate = Some(new_value);
5672 self
5673 }
5674
5675 /// Set any additional parameter of the query string used in the request.
5676 /// It should be used to set parameters which are not yet available through their own
5677 /// setters.
5678 ///
5679 /// Please note that this method must not be used to set any of the known parameters
5680 /// which have their own setter method. If done anyway, the request will fail.
5681 ///
5682 /// # Additional Parameters
5683 ///
5684 /// * *$.xgafv* (query-string) - V1 error format.
5685 /// * *access_token* (query-string) - OAuth access token.
5686 /// * *alt* (query-string) - Data format for response.
5687 /// * *callback* (query-string) - JSONP
5688 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5689 /// * *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.
5690 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5691 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5692 /// * *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.
5693 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5694 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5695 pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
5696 where
5697 T: AsRef<str>,
5698 {
5699 self._additional_params
5700 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5701 self
5702 }
5703
5704 /// Identifies the authorization scope for the method you are building.
5705 ///
5706 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5707 /// [`Scope::CloudPlatformReadOnly`].
5708 ///
5709 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5710 /// tokens for more than one scope.
5711 ///
5712 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5713 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5714 /// sufficient, a read-write scope will do as well.
5715 pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
5716 where
5717 St: AsRef<str>,
5718 {
5719 self._scopes.insert(String::from(scope.as_ref()));
5720 self
5721 }
5722 /// Identifies the authorization scope(s) for the method you are building.
5723 ///
5724 /// See [`Self::add_scope()`] for details.
5725 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
5726 where
5727 I: IntoIterator<Item = St>,
5728 St: AsRef<str>,
5729 {
5730 self._scopes
5731 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5732 self
5733 }
5734
5735 /// Removes all scopes, and no default scope will be used either.
5736 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5737 /// for details).
5738 pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
5739 self._scopes.clear();
5740 self
5741 }
5742}
5743
5744/// Clears a `Policy` from a resource.
5745///
5746/// A builder for the *clearOrgPolicy* method supported by a *organization* resource.
5747/// It is not used directly, but through a [`OrganizationMethods`] instance.
5748///
5749/// # Example
5750///
5751/// Instantiate a resource method builder
5752///
5753/// ```test_harness,no_run
5754/// # extern crate hyper;
5755/// # extern crate hyper_rustls;
5756/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
5757/// use cloudresourcemanager1::api::ClearOrgPolicyRequest;
5758/// # async fn dox() {
5759/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5760///
5761/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5762/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5763/// # .with_native_roots()
5764/// # .unwrap()
5765/// # .https_only()
5766/// # .enable_http2()
5767/// # .build();
5768///
5769/// # let executor = hyper_util::rt::TokioExecutor::new();
5770/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5771/// # secret,
5772/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5773/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5774/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5775/// # ),
5776/// # ).build().await.unwrap();
5777///
5778/// # let client = hyper_util::client::legacy::Client::builder(
5779/// # hyper_util::rt::TokioExecutor::new()
5780/// # )
5781/// # .build(
5782/// # hyper_rustls::HttpsConnectorBuilder::new()
5783/// # .with_native_roots()
5784/// # .unwrap()
5785/// # .https_or_http()
5786/// # .enable_http2()
5787/// # .build()
5788/// # );
5789/// # let mut hub = CloudResourceManager::new(client, auth);
5790/// // As the method needs a request, you would usually fill it with the desired information
5791/// // into the respective structure. Some of the parts shown here might not be applicable !
5792/// // Values shown here are possibly random and not representative !
5793/// let mut req = ClearOrgPolicyRequest::default();
5794///
5795/// // You can configure optional parameters by calling the respective setters at will, and
5796/// // execute the final call using `doit()`.
5797/// // Values shown here are possibly random and not representative !
5798/// let result = hub.organizations().clear_org_policy(req, "resource")
5799/// .doit().await;
5800/// # }
5801/// ```
5802pub struct OrganizationClearOrgPolicyCall<'a, C>
5803where
5804 C: 'a,
5805{
5806 hub: &'a CloudResourceManager<C>,
5807 _request: ClearOrgPolicyRequest,
5808 _resource: String,
5809 _delegate: Option<&'a mut dyn common::Delegate>,
5810 _additional_params: HashMap<String, String>,
5811 _scopes: BTreeSet<String>,
5812}
5813
5814impl<'a, C> common::CallBuilder for OrganizationClearOrgPolicyCall<'a, C> {}
5815
5816impl<'a, C> OrganizationClearOrgPolicyCall<'a, C>
5817where
5818 C: common::Connector,
5819{
5820 /// Perform the operation you have build so far.
5821 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5822 use std::borrow::Cow;
5823 use std::io::{Read, Seek};
5824
5825 use common::{url::Params, ToParts};
5826 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5827
5828 let mut dd = common::DefaultDelegate;
5829 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5830 dlg.begin(common::MethodInfo {
5831 id: "cloudresourcemanager.organizations.clearOrgPolicy",
5832 http_method: hyper::Method::POST,
5833 });
5834
5835 for &field in ["alt", "resource"].iter() {
5836 if self._additional_params.contains_key(field) {
5837 dlg.finished(false);
5838 return Err(common::Error::FieldClash(field));
5839 }
5840 }
5841
5842 let mut params = Params::with_capacity(4 + self._additional_params.len());
5843 params.push("resource", self._resource);
5844
5845 params.extend(self._additional_params.iter());
5846
5847 params.push("alt", "json");
5848 let mut url = self.hub._base_url.clone() + "v1/{+resource}:clearOrgPolicy";
5849 if self._scopes.is_empty() {
5850 self._scopes
5851 .insert(Scope::CloudPlatform.as_ref().to_string());
5852 }
5853
5854 #[allow(clippy::single_element_loop)]
5855 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5856 url = params.uri_replacement(url, param_name, find_this, true);
5857 }
5858 {
5859 let to_remove = ["resource"];
5860 params.remove_params(&to_remove);
5861 }
5862
5863 let url = params.parse_with_url(&url);
5864
5865 let mut json_mime_type = mime::APPLICATION_JSON;
5866 let mut request_value_reader = {
5867 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5868 common::remove_json_null_values(&mut value);
5869 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5870 serde_json::to_writer(&mut dst, &value).unwrap();
5871 dst
5872 };
5873 let request_size = request_value_reader
5874 .seek(std::io::SeekFrom::End(0))
5875 .unwrap();
5876 request_value_reader
5877 .seek(std::io::SeekFrom::Start(0))
5878 .unwrap();
5879
5880 loop {
5881 let token = match self
5882 .hub
5883 .auth
5884 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5885 .await
5886 {
5887 Ok(token) => token,
5888 Err(e) => match dlg.token(e) {
5889 Ok(token) => token,
5890 Err(e) => {
5891 dlg.finished(false);
5892 return Err(common::Error::MissingToken(e));
5893 }
5894 },
5895 };
5896 request_value_reader
5897 .seek(std::io::SeekFrom::Start(0))
5898 .unwrap();
5899 let mut req_result = {
5900 let client = &self.hub.client;
5901 dlg.pre_request();
5902 let mut req_builder = hyper::Request::builder()
5903 .method(hyper::Method::POST)
5904 .uri(url.as_str())
5905 .header(USER_AGENT, self.hub._user_agent.clone());
5906
5907 if let Some(token) = token.as_ref() {
5908 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5909 }
5910
5911 let request = req_builder
5912 .header(CONTENT_TYPE, json_mime_type.to_string())
5913 .header(CONTENT_LENGTH, request_size as u64)
5914 .body(common::to_body(
5915 request_value_reader.get_ref().clone().into(),
5916 ));
5917
5918 client.request(request.unwrap()).await
5919 };
5920
5921 match req_result {
5922 Err(err) => {
5923 if let common::Retry::After(d) = dlg.http_error(&err) {
5924 sleep(d).await;
5925 continue;
5926 }
5927 dlg.finished(false);
5928 return Err(common::Error::HttpError(err));
5929 }
5930 Ok(res) => {
5931 let (mut parts, body) = res.into_parts();
5932 let mut body = common::Body::new(body);
5933 if !parts.status.is_success() {
5934 let bytes = common::to_bytes(body).await.unwrap_or_default();
5935 let error = serde_json::from_str(&common::to_string(&bytes));
5936 let response = common::to_response(parts, bytes.into());
5937
5938 if let common::Retry::After(d) =
5939 dlg.http_failure(&response, error.as_ref().ok())
5940 {
5941 sleep(d).await;
5942 continue;
5943 }
5944
5945 dlg.finished(false);
5946
5947 return Err(match error {
5948 Ok(value) => common::Error::BadRequest(value),
5949 _ => common::Error::Failure(response),
5950 });
5951 }
5952 let response = {
5953 let bytes = common::to_bytes(body).await.unwrap_or_default();
5954 let encoded = common::to_string(&bytes);
5955 match serde_json::from_str(&encoded) {
5956 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5957 Err(error) => {
5958 dlg.response_json_decode_error(&encoded, &error);
5959 return Err(common::Error::JsonDecodeError(
5960 encoded.to_string(),
5961 error,
5962 ));
5963 }
5964 }
5965 };
5966
5967 dlg.finished(true);
5968 return Ok(response);
5969 }
5970 }
5971 }
5972 }
5973
5974 ///
5975 /// Sets the *request* property to the given value.
5976 ///
5977 /// Even though the property as already been set when instantiating this call,
5978 /// we provide this method for API completeness.
5979 pub fn request(
5980 mut self,
5981 new_value: ClearOrgPolicyRequest,
5982 ) -> OrganizationClearOrgPolicyCall<'a, C> {
5983 self._request = new_value;
5984 self
5985 }
5986 /// Name of the resource for the `Policy` to clear.
5987 ///
5988 /// Sets the *resource* path property to the given value.
5989 ///
5990 /// Even though the property as already been set when instantiating this call,
5991 /// we provide this method for API completeness.
5992 pub fn resource(mut self, new_value: &str) -> OrganizationClearOrgPolicyCall<'a, C> {
5993 self._resource = new_value.to_string();
5994 self
5995 }
5996 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5997 /// while executing the actual API request.
5998 ///
5999 /// ````text
6000 /// It should be used to handle progress information, and to implement a certain level of resilience.
6001 /// ````
6002 ///
6003 /// Sets the *delegate* property to the given value.
6004 pub fn delegate(
6005 mut self,
6006 new_value: &'a mut dyn common::Delegate,
6007 ) -> OrganizationClearOrgPolicyCall<'a, C> {
6008 self._delegate = Some(new_value);
6009 self
6010 }
6011
6012 /// Set any additional parameter of the query string used in the request.
6013 /// It should be used to set parameters which are not yet available through their own
6014 /// setters.
6015 ///
6016 /// Please note that this method must not be used to set any of the known parameters
6017 /// which have their own setter method. If done anyway, the request will fail.
6018 ///
6019 /// # Additional Parameters
6020 ///
6021 /// * *$.xgafv* (query-string) - V1 error format.
6022 /// * *access_token* (query-string) - OAuth access token.
6023 /// * *alt* (query-string) - Data format for response.
6024 /// * *callback* (query-string) - JSONP
6025 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6026 /// * *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.
6027 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6028 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6029 /// * *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.
6030 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6031 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6032 pub fn param<T>(mut self, name: T, value: T) -> OrganizationClearOrgPolicyCall<'a, C>
6033 where
6034 T: AsRef<str>,
6035 {
6036 self._additional_params
6037 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6038 self
6039 }
6040
6041 /// Identifies the authorization scope for the method you are building.
6042 ///
6043 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6044 /// [`Scope::CloudPlatform`].
6045 ///
6046 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6047 /// tokens for more than one scope.
6048 ///
6049 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6050 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6051 /// sufficient, a read-write scope will do as well.
6052 pub fn add_scope<St>(mut self, scope: St) -> OrganizationClearOrgPolicyCall<'a, C>
6053 where
6054 St: AsRef<str>,
6055 {
6056 self._scopes.insert(String::from(scope.as_ref()));
6057 self
6058 }
6059 /// Identifies the authorization scope(s) for the method you are building.
6060 ///
6061 /// See [`Self::add_scope()`] for details.
6062 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationClearOrgPolicyCall<'a, C>
6063 where
6064 I: IntoIterator<Item = St>,
6065 St: AsRef<str>,
6066 {
6067 self._scopes
6068 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6069 self
6070 }
6071
6072 /// Removes all scopes, and no default scope will be used either.
6073 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6074 /// for details).
6075 pub fn clear_scopes(mut self) -> OrganizationClearOrgPolicyCall<'a, C> {
6076 self._scopes.clear();
6077 self
6078 }
6079}
6080
6081/// Fetches an Organization resource identified by the specified resource name.
6082///
6083/// A builder for the *get* method supported by a *organization* resource.
6084/// It is not used directly, but through a [`OrganizationMethods`] instance.
6085///
6086/// # Example
6087///
6088/// Instantiate a resource method builder
6089///
6090/// ```test_harness,no_run
6091/// # extern crate hyper;
6092/// # extern crate hyper_rustls;
6093/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
6094/// # async fn dox() {
6095/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6096///
6097/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6098/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6099/// # .with_native_roots()
6100/// # .unwrap()
6101/// # .https_only()
6102/// # .enable_http2()
6103/// # .build();
6104///
6105/// # let executor = hyper_util::rt::TokioExecutor::new();
6106/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6107/// # secret,
6108/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6109/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6110/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6111/// # ),
6112/// # ).build().await.unwrap();
6113///
6114/// # let client = hyper_util::client::legacy::Client::builder(
6115/// # hyper_util::rt::TokioExecutor::new()
6116/// # )
6117/// # .build(
6118/// # hyper_rustls::HttpsConnectorBuilder::new()
6119/// # .with_native_roots()
6120/// # .unwrap()
6121/// # .https_or_http()
6122/// # .enable_http2()
6123/// # .build()
6124/// # );
6125/// # let mut hub = CloudResourceManager::new(client, auth);
6126/// // You can configure optional parameters by calling the respective setters at will, and
6127/// // execute the final call using `doit()`.
6128/// // Values shown here are possibly random and not representative !
6129/// let result = hub.organizations().get("name")
6130/// .doit().await;
6131/// # }
6132/// ```
6133pub struct OrganizationGetCall<'a, C>
6134where
6135 C: 'a,
6136{
6137 hub: &'a CloudResourceManager<C>,
6138 _name: String,
6139 _delegate: Option<&'a mut dyn common::Delegate>,
6140 _additional_params: HashMap<String, String>,
6141 _scopes: BTreeSet<String>,
6142}
6143
6144impl<'a, C> common::CallBuilder for OrganizationGetCall<'a, C> {}
6145
6146impl<'a, C> OrganizationGetCall<'a, C>
6147where
6148 C: common::Connector,
6149{
6150 /// Perform the operation you have build so far.
6151 pub async fn doit(mut self) -> common::Result<(common::Response, Organization)> {
6152 use std::borrow::Cow;
6153 use std::io::{Read, Seek};
6154
6155 use common::{url::Params, ToParts};
6156 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6157
6158 let mut dd = common::DefaultDelegate;
6159 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6160 dlg.begin(common::MethodInfo {
6161 id: "cloudresourcemanager.organizations.get",
6162 http_method: hyper::Method::GET,
6163 });
6164
6165 for &field in ["alt", "name"].iter() {
6166 if self._additional_params.contains_key(field) {
6167 dlg.finished(false);
6168 return Err(common::Error::FieldClash(field));
6169 }
6170 }
6171
6172 let mut params = Params::with_capacity(3 + self._additional_params.len());
6173 params.push("name", self._name);
6174
6175 params.extend(self._additional_params.iter());
6176
6177 params.push("alt", "json");
6178 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6179 if self._scopes.is_empty() {
6180 self._scopes
6181 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
6182 }
6183
6184 #[allow(clippy::single_element_loop)]
6185 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6186 url = params.uri_replacement(url, param_name, find_this, true);
6187 }
6188 {
6189 let to_remove = ["name"];
6190 params.remove_params(&to_remove);
6191 }
6192
6193 let url = params.parse_with_url(&url);
6194
6195 loop {
6196 let token = match self
6197 .hub
6198 .auth
6199 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6200 .await
6201 {
6202 Ok(token) => token,
6203 Err(e) => match dlg.token(e) {
6204 Ok(token) => token,
6205 Err(e) => {
6206 dlg.finished(false);
6207 return Err(common::Error::MissingToken(e));
6208 }
6209 },
6210 };
6211 let mut req_result = {
6212 let client = &self.hub.client;
6213 dlg.pre_request();
6214 let mut req_builder = hyper::Request::builder()
6215 .method(hyper::Method::GET)
6216 .uri(url.as_str())
6217 .header(USER_AGENT, self.hub._user_agent.clone());
6218
6219 if let Some(token) = token.as_ref() {
6220 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6221 }
6222
6223 let request = req_builder
6224 .header(CONTENT_LENGTH, 0_u64)
6225 .body(common::to_body::<String>(None));
6226
6227 client.request(request.unwrap()).await
6228 };
6229
6230 match req_result {
6231 Err(err) => {
6232 if let common::Retry::After(d) = dlg.http_error(&err) {
6233 sleep(d).await;
6234 continue;
6235 }
6236 dlg.finished(false);
6237 return Err(common::Error::HttpError(err));
6238 }
6239 Ok(res) => {
6240 let (mut parts, body) = res.into_parts();
6241 let mut body = common::Body::new(body);
6242 if !parts.status.is_success() {
6243 let bytes = common::to_bytes(body).await.unwrap_or_default();
6244 let error = serde_json::from_str(&common::to_string(&bytes));
6245 let response = common::to_response(parts, bytes.into());
6246
6247 if let common::Retry::After(d) =
6248 dlg.http_failure(&response, error.as_ref().ok())
6249 {
6250 sleep(d).await;
6251 continue;
6252 }
6253
6254 dlg.finished(false);
6255
6256 return Err(match error {
6257 Ok(value) => common::Error::BadRequest(value),
6258 _ => common::Error::Failure(response),
6259 });
6260 }
6261 let response = {
6262 let bytes = common::to_bytes(body).await.unwrap_or_default();
6263 let encoded = common::to_string(&bytes);
6264 match serde_json::from_str(&encoded) {
6265 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6266 Err(error) => {
6267 dlg.response_json_decode_error(&encoded, &error);
6268 return Err(common::Error::JsonDecodeError(
6269 encoded.to_string(),
6270 error,
6271 ));
6272 }
6273 }
6274 };
6275
6276 dlg.finished(true);
6277 return Ok(response);
6278 }
6279 }
6280 }
6281 }
6282
6283 /// The resource name of the Organization to fetch. This is the organization's relative path in the API, formatted as "organizations/[organizationId]". For example, "organizations/1234".
6284 ///
6285 /// Sets the *name* path property to the given value.
6286 ///
6287 /// Even though the property as already been set when instantiating this call,
6288 /// we provide this method for API completeness.
6289 pub fn name(mut self, new_value: &str) -> OrganizationGetCall<'a, C> {
6290 self._name = new_value.to_string();
6291 self
6292 }
6293 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6294 /// while executing the actual API request.
6295 ///
6296 /// ````text
6297 /// It should be used to handle progress information, and to implement a certain level of resilience.
6298 /// ````
6299 ///
6300 /// Sets the *delegate* property to the given value.
6301 pub fn delegate(
6302 mut self,
6303 new_value: &'a mut dyn common::Delegate,
6304 ) -> OrganizationGetCall<'a, C> {
6305 self._delegate = Some(new_value);
6306 self
6307 }
6308
6309 /// Set any additional parameter of the query string used in the request.
6310 /// It should be used to set parameters which are not yet available through their own
6311 /// setters.
6312 ///
6313 /// Please note that this method must not be used to set any of the known parameters
6314 /// which have their own setter method. If done anyway, the request will fail.
6315 ///
6316 /// # Additional Parameters
6317 ///
6318 /// * *$.xgafv* (query-string) - V1 error format.
6319 /// * *access_token* (query-string) - OAuth access token.
6320 /// * *alt* (query-string) - Data format for response.
6321 /// * *callback* (query-string) - JSONP
6322 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6323 /// * *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.
6324 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6325 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6326 /// * *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.
6327 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6328 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6329 pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetCall<'a, C>
6330 where
6331 T: AsRef<str>,
6332 {
6333 self._additional_params
6334 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6335 self
6336 }
6337
6338 /// Identifies the authorization scope for the method you are building.
6339 ///
6340 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6341 /// [`Scope::CloudPlatformReadOnly`].
6342 ///
6343 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6344 /// tokens for more than one scope.
6345 ///
6346 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6347 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6348 /// sufficient, a read-write scope will do as well.
6349 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetCall<'a, C>
6350 where
6351 St: AsRef<str>,
6352 {
6353 self._scopes.insert(String::from(scope.as_ref()));
6354 self
6355 }
6356 /// Identifies the authorization scope(s) for the method you are building.
6357 ///
6358 /// See [`Self::add_scope()`] for details.
6359 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetCall<'a, C>
6360 where
6361 I: IntoIterator<Item = St>,
6362 St: AsRef<str>,
6363 {
6364 self._scopes
6365 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6366 self
6367 }
6368
6369 /// Removes all scopes, and no default scope will be used either.
6370 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6371 /// for details).
6372 pub fn clear_scopes(mut self) -> OrganizationGetCall<'a, C> {
6373 self._scopes.clear();
6374 self
6375 }
6376}
6377
6378/// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
6379///
6380/// A builder for the *getEffectiveOrgPolicy* method supported by a *organization* resource.
6381/// It is not used directly, but through a [`OrganizationMethods`] instance.
6382///
6383/// # Example
6384///
6385/// Instantiate a resource method builder
6386///
6387/// ```test_harness,no_run
6388/// # extern crate hyper;
6389/// # extern crate hyper_rustls;
6390/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
6391/// use cloudresourcemanager1::api::GetEffectiveOrgPolicyRequest;
6392/// # async fn dox() {
6393/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6394///
6395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6396/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6397/// # .with_native_roots()
6398/// # .unwrap()
6399/// # .https_only()
6400/// # .enable_http2()
6401/// # .build();
6402///
6403/// # let executor = hyper_util::rt::TokioExecutor::new();
6404/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6405/// # secret,
6406/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6407/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6408/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6409/// # ),
6410/// # ).build().await.unwrap();
6411///
6412/// # let client = hyper_util::client::legacy::Client::builder(
6413/// # hyper_util::rt::TokioExecutor::new()
6414/// # )
6415/// # .build(
6416/// # hyper_rustls::HttpsConnectorBuilder::new()
6417/// # .with_native_roots()
6418/// # .unwrap()
6419/// # .https_or_http()
6420/// # .enable_http2()
6421/// # .build()
6422/// # );
6423/// # let mut hub = CloudResourceManager::new(client, auth);
6424/// // As the method needs a request, you would usually fill it with the desired information
6425/// // into the respective structure. Some of the parts shown here might not be applicable !
6426/// // Values shown here are possibly random and not representative !
6427/// let mut req = GetEffectiveOrgPolicyRequest::default();
6428///
6429/// // You can configure optional parameters by calling the respective setters at will, and
6430/// // execute the final call using `doit()`.
6431/// // Values shown here are possibly random and not representative !
6432/// let result = hub.organizations().get_effective_org_policy(req, "resource")
6433/// .doit().await;
6434/// # }
6435/// ```
6436pub struct OrganizationGetEffectiveOrgPolicyCall<'a, C>
6437where
6438 C: 'a,
6439{
6440 hub: &'a CloudResourceManager<C>,
6441 _request: GetEffectiveOrgPolicyRequest,
6442 _resource: String,
6443 _delegate: Option<&'a mut dyn common::Delegate>,
6444 _additional_params: HashMap<String, String>,
6445 _scopes: BTreeSet<String>,
6446}
6447
6448impl<'a, C> common::CallBuilder for OrganizationGetEffectiveOrgPolicyCall<'a, C> {}
6449
6450impl<'a, C> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6451where
6452 C: common::Connector,
6453{
6454 /// Perform the operation you have build so far.
6455 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
6456 use std::borrow::Cow;
6457 use std::io::{Read, Seek};
6458
6459 use common::{url::Params, ToParts};
6460 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6461
6462 let mut dd = common::DefaultDelegate;
6463 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6464 dlg.begin(common::MethodInfo {
6465 id: "cloudresourcemanager.organizations.getEffectiveOrgPolicy",
6466 http_method: hyper::Method::POST,
6467 });
6468
6469 for &field in ["alt", "resource"].iter() {
6470 if self._additional_params.contains_key(field) {
6471 dlg.finished(false);
6472 return Err(common::Error::FieldClash(field));
6473 }
6474 }
6475
6476 let mut params = Params::with_capacity(4 + self._additional_params.len());
6477 params.push("resource", self._resource);
6478
6479 params.extend(self._additional_params.iter());
6480
6481 params.push("alt", "json");
6482 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getEffectiveOrgPolicy";
6483 if self._scopes.is_empty() {
6484 self._scopes
6485 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
6486 }
6487
6488 #[allow(clippy::single_element_loop)]
6489 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6490 url = params.uri_replacement(url, param_name, find_this, true);
6491 }
6492 {
6493 let to_remove = ["resource"];
6494 params.remove_params(&to_remove);
6495 }
6496
6497 let url = params.parse_with_url(&url);
6498
6499 let mut json_mime_type = mime::APPLICATION_JSON;
6500 let mut request_value_reader = {
6501 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6502 common::remove_json_null_values(&mut value);
6503 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6504 serde_json::to_writer(&mut dst, &value).unwrap();
6505 dst
6506 };
6507 let request_size = request_value_reader
6508 .seek(std::io::SeekFrom::End(0))
6509 .unwrap();
6510 request_value_reader
6511 .seek(std::io::SeekFrom::Start(0))
6512 .unwrap();
6513
6514 loop {
6515 let token = match self
6516 .hub
6517 .auth
6518 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6519 .await
6520 {
6521 Ok(token) => token,
6522 Err(e) => match dlg.token(e) {
6523 Ok(token) => token,
6524 Err(e) => {
6525 dlg.finished(false);
6526 return Err(common::Error::MissingToken(e));
6527 }
6528 },
6529 };
6530 request_value_reader
6531 .seek(std::io::SeekFrom::Start(0))
6532 .unwrap();
6533 let mut req_result = {
6534 let client = &self.hub.client;
6535 dlg.pre_request();
6536 let mut req_builder = hyper::Request::builder()
6537 .method(hyper::Method::POST)
6538 .uri(url.as_str())
6539 .header(USER_AGENT, self.hub._user_agent.clone());
6540
6541 if let Some(token) = token.as_ref() {
6542 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6543 }
6544
6545 let request = req_builder
6546 .header(CONTENT_TYPE, json_mime_type.to_string())
6547 .header(CONTENT_LENGTH, request_size as u64)
6548 .body(common::to_body(
6549 request_value_reader.get_ref().clone().into(),
6550 ));
6551
6552 client.request(request.unwrap()).await
6553 };
6554
6555 match req_result {
6556 Err(err) => {
6557 if let common::Retry::After(d) = dlg.http_error(&err) {
6558 sleep(d).await;
6559 continue;
6560 }
6561 dlg.finished(false);
6562 return Err(common::Error::HttpError(err));
6563 }
6564 Ok(res) => {
6565 let (mut parts, body) = res.into_parts();
6566 let mut body = common::Body::new(body);
6567 if !parts.status.is_success() {
6568 let bytes = common::to_bytes(body).await.unwrap_or_default();
6569 let error = serde_json::from_str(&common::to_string(&bytes));
6570 let response = common::to_response(parts, bytes.into());
6571
6572 if let common::Retry::After(d) =
6573 dlg.http_failure(&response, error.as_ref().ok())
6574 {
6575 sleep(d).await;
6576 continue;
6577 }
6578
6579 dlg.finished(false);
6580
6581 return Err(match error {
6582 Ok(value) => common::Error::BadRequest(value),
6583 _ => common::Error::Failure(response),
6584 });
6585 }
6586 let response = {
6587 let bytes = common::to_bytes(body).await.unwrap_or_default();
6588 let encoded = common::to_string(&bytes);
6589 match serde_json::from_str(&encoded) {
6590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6591 Err(error) => {
6592 dlg.response_json_decode_error(&encoded, &error);
6593 return Err(common::Error::JsonDecodeError(
6594 encoded.to_string(),
6595 error,
6596 ));
6597 }
6598 }
6599 };
6600
6601 dlg.finished(true);
6602 return Ok(response);
6603 }
6604 }
6605 }
6606 }
6607
6608 ///
6609 /// Sets the *request* property to the given value.
6610 ///
6611 /// Even though the property as already been set when instantiating this call,
6612 /// we provide this method for API completeness.
6613 pub fn request(
6614 mut self,
6615 new_value: GetEffectiveOrgPolicyRequest,
6616 ) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6617 self._request = new_value;
6618 self
6619 }
6620 /// The name of the resource to start computing the effective `Policy`.
6621 ///
6622 /// Sets the *resource* path property to the given value.
6623 ///
6624 /// Even though the property as already been set when instantiating this call,
6625 /// we provide this method for API completeness.
6626 pub fn resource(mut self, new_value: &str) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6627 self._resource = new_value.to_string();
6628 self
6629 }
6630 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6631 /// while executing the actual API request.
6632 ///
6633 /// ````text
6634 /// It should be used to handle progress information, and to implement a certain level of resilience.
6635 /// ````
6636 ///
6637 /// Sets the *delegate* property to the given value.
6638 pub fn delegate(
6639 mut self,
6640 new_value: &'a mut dyn common::Delegate,
6641 ) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6642 self._delegate = Some(new_value);
6643 self
6644 }
6645
6646 /// Set any additional parameter of the query string used in the request.
6647 /// It should be used to set parameters which are not yet available through their own
6648 /// setters.
6649 ///
6650 /// Please note that this method must not be used to set any of the known parameters
6651 /// which have their own setter method. If done anyway, the request will fail.
6652 ///
6653 /// # Additional Parameters
6654 ///
6655 /// * *$.xgafv* (query-string) - V1 error format.
6656 /// * *access_token* (query-string) - OAuth access token.
6657 /// * *alt* (query-string) - Data format for response.
6658 /// * *callback* (query-string) - JSONP
6659 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6660 /// * *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.
6661 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6662 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6663 /// * *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.
6664 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6665 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6666 pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6667 where
6668 T: AsRef<str>,
6669 {
6670 self._additional_params
6671 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6672 self
6673 }
6674
6675 /// Identifies the authorization scope for the method you are building.
6676 ///
6677 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6678 /// [`Scope::CloudPlatformReadOnly`].
6679 ///
6680 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6681 /// tokens for more than one scope.
6682 ///
6683 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6684 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6685 /// sufficient, a read-write scope will do as well.
6686 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6687 where
6688 St: AsRef<str>,
6689 {
6690 self._scopes.insert(String::from(scope.as_ref()));
6691 self
6692 }
6693 /// Identifies the authorization scope(s) for the method you are building.
6694 ///
6695 /// See [`Self::add_scope()`] for details.
6696 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetEffectiveOrgPolicyCall<'a, C>
6697 where
6698 I: IntoIterator<Item = St>,
6699 St: AsRef<str>,
6700 {
6701 self._scopes
6702 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6703 self
6704 }
6705
6706 /// Removes all scopes, and no default scope will be used either.
6707 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6708 /// for details).
6709 pub fn clear_scopes(mut self) -> OrganizationGetEffectiveOrgPolicyCall<'a, C> {
6710 self._scopes.clear();
6711 self
6712 }
6713}
6714
6715/// Gets the access control policy for an Organization resource. May be empty if no such policy or resource exists. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.getIamPolicy` on the specified organization
6716///
6717/// A builder for the *getIamPolicy* method supported by a *organization* resource.
6718/// It is not used directly, but through a [`OrganizationMethods`] instance.
6719///
6720/// # Example
6721///
6722/// Instantiate a resource method builder
6723///
6724/// ```test_harness,no_run
6725/// # extern crate hyper;
6726/// # extern crate hyper_rustls;
6727/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
6728/// use cloudresourcemanager1::api::GetIamPolicyRequest;
6729/// # async fn dox() {
6730/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6731///
6732/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6733/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6734/// # .with_native_roots()
6735/// # .unwrap()
6736/// # .https_only()
6737/// # .enable_http2()
6738/// # .build();
6739///
6740/// # let executor = hyper_util::rt::TokioExecutor::new();
6741/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6742/// # secret,
6743/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6744/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6745/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6746/// # ),
6747/// # ).build().await.unwrap();
6748///
6749/// # let client = hyper_util::client::legacy::Client::builder(
6750/// # hyper_util::rt::TokioExecutor::new()
6751/// # )
6752/// # .build(
6753/// # hyper_rustls::HttpsConnectorBuilder::new()
6754/// # .with_native_roots()
6755/// # .unwrap()
6756/// # .https_or_http()
6757/// # .enable_http2()
6758/// # .build()
6759/// # );
6760/// # let mut hub = CloudResourceManager::new(client, auth);
6761/// // As the method needs a request, you would usually fill it with the desired information
6762/// // into the respective structure. Some of the parts shown here might not be applicable !
6763/// // Values shown here are possibly random and not representative !
6764/// let mut req = GetIamPolicyRequest::default();
6765///
6766/// // You can configure optional parameters by calling the respective setters at will, and
6767/// // execute the final call using `doit()`.
6768/// // Values shown here are possibly random and not representative !
6769/// let result = hub.organizations().get_iam_policy(req, "resource")
6770/// .doit().await;
6771/// # }
6772/// ```
6773pub struct OrganizationGetIamPolicyCall<'a, C>
6774where
6775 C: 'a,
6776{
6777 hub: &'a CloudResourceManager<C>,
6778 _request: GetIamPolicyRequest,
6779 _resource: String,
6780 _delegate: Option<&'a mut dyn common::Delegate>,
6781 _additional_params: HashMap<String, String>,
6782 _scopes: BTreeSet<String>,
6783}
6784
6785impl<'a, C> common::CallBuilder for OrganizationGetIamPolicyCall<'a, C> {}
6786
6787impl<'a, C> OrganizationGetIamPolicyCall<'a, C>
6788where
6789 C: common::Connector,
6790{
6791 /// Perform the operation you have build so far.
6792 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6793 use std::borrow::Cow;
6794 use std::io::{Read, Seek};
6795
6796 use common::{url::Params, ToParts};
6797 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6798
6799 let mut dd = common::DefaultDelegate;
6800 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6801 dlg.begin(common::MethodInfo {
6802 id: "cloudresourcemanager.organizations.getIamPolicy",
6803 http_method: hyper::Method::POST,
6804 });
6805
6806 for &field in ["alt", "resource"].iter() {
6807 if self._additional_params.contains_key(field) {
6808 dlg.finished(false);
6809 return Err(common::Error::FieldClash(field));
6810 }
6811 }
6812
6813 let mut params = Params::with_capacity(4 + self._additional_params.len());
6814 params.push("resource", self._resource);
6815
6816 params.extend(self._additional_params.iter());
6817
6818 params.push("alt", "json");
6819 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
6820 if self._scopes.is_empty() {
6821 self._scopes
6822 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
6823 }
6824
6825 #[allow(clippy::single_element_loop)]
6826 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6827 url = params.uri_replacement(url, param_name, find_this, true);
6828 }
6829 {
6830 let to_remove = ["resource"];
6831 params.remove_params(&to_remove);
6832 }
6833
6834 let url = params.parse_with_url(&url);
6835
6836 let mut json_mime_type = mime::APPLICATION_JSON;
6837 let mut request_value_reader = {
6838 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6839 common::remove_json_null_values(&mut value);
6840 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6841 serde_json::to_writer(&mut dst, &value).unwrap();
6842 dst
6843 };
6844 let request_size = request_value_reader
6845 .seek(std::io::SeekFrom::End(0))
6846 .unwrap();
6847 request_value_reader
6848 .seek(std::io::SeekFrom::Start(0))
6849 .unwrap();
6850
6851 loop {
6852 let token = match self
6853 .hub
6854 .auth
6855 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6856 .await
6857 {
6858 Ok(token) => token,
6859 Err(e) => match dlg.token(e) {
6860 Ok(token) => token,
6861 Err(e) => {
6862 dlg.finished(false);
6863 return Err(common::Error::MissingToken(e));
6864 }
6865 },
6866 };
6867 request_value_reader
6868 .seek(std::io::SeekFrom::Start(0))
6869 .unwrap();
6870 let mut req_result = {
6871 let client = &self.hub.client;
6872 dlg.pre_request();
6873 let mut req_builder = hyper::Request::builder()
6874 .method(hyper::Method::POST)
6875 .uri(url.as_str())
6876 .header(USER_AGENT, self.hub._user_agent.clone());
6877
6878 if let Some(token) = token.as_ref() {
6879 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6880 }
6881
6882 let request = req_builder
6883 .header(CONTENT_TYPE, json_mime_type.to_string())
6884 .header(CONTENT_LENGTH, request_size as u64)
6885 .body(common::to_body(
6886 request_value_reader.get_ref().clone().into(),
6887 ));
6888
6889 client.request(request.unwrap()).await
6890 };
6891
6892 match req_result {
6893 Err(err) => {
6894 if let common::Retry::After(d) = dlg.http_error(&err) {
6895 sleep(d).await;
6896 continue;
6897 }
6898 dlg.finished(false);
6899 return Err(common::Error::HttpError(err));
6900 }
6901 Ok(res) => {
6902 let (mut parts, body) = res.into_parts();
6903 let mut body = common::Body::new(body);
6904 if !parts.status.is_success() {
6905 let bytes = common::to_bytes(body).await.unwrap_or_default();
6906 let error = serde_json::from_str(&common::to_string(&bytes));
6907 let response = common::to_response(parts, bytes.into());
6908
6909 if let common::Retry::After(d) =
6910 dlg.http_failure(&response, error.as_ref().ok())
6911 {
6912 sleep(d).await;
6913 continue;
6914 }
6915
6916 dlg.finished(false);
6917
6918 return Err(match error {
6919 Ok(value) => common::Error::BadRequest(value),
6920 _ => common::Error::Failure(response),
6921 });
6922 }
6923 let response = {
6924 let bytes = common::to_bytes(body).await.unwrap_or_default();
6925 let encoded = common::to_string(&bytes);
6926 match serde_json::from_str(&encoded) {
6927 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6928 Err(error) => {
6929 dlg.response_json_decode_error(&encoded, &error);
6930 return Err(common::Error::JsonDecodeError(
6931 encoded.to_string(),
6932 error,
6933 ));
6934 }
6935 }
6936 };
6937
6938 dlg.finished(true);
6939 return Ok(response);
6940 }
6941 }
6942 }
6943 }
6944
6945 ///
6946 /// Sets the *request* property to the given value.
6947 ///
6948 /// Even though the property as already been set when instantiating this call,
6949 /// we provide this method for API completeness.
6950 pub fn request(
6951 mut self,
6952 new_value: GetIamPolicyRequest,
6953 ) -> OrganizationGetIamPolicyCall<'a, C> {
6954 self._request = new_value;
6955 self
6956 }
6957 /// 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.
6958 ///
6959 /// Sets the *resource* path property to the given value.
6960 ///
6961 /// Even though the property as already been set when instantiating this call,
6962 /// we provide this method for API completeness.
6963 pub fn resource(mut self, new_value: &str) -> OrganizationGetIamPolicyCall<'a, C> {
6964 self._resource = new_value.to_string();
6965 self
6966 }
6967 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6968 /// while executing the actual API request.
6969 ///
6970 /// ````text
6971 /// It should be used to handle progress information, and to implement a certain level of resilience.
6972 /// ````
6973 ///
6974 /// Sets the *delegate* property to the given value.
6975 pub fn delegate(
6976 mut self,
6977 new_value: &'a mut dyn common::Delegate,
6978 ) -> OrganizationGetIamPolicyCall<'a, C> {
6979 self._delegate = Some(new_value);
6980 self
6981 }
6982
6983 /// Set any additional parameter of the query string used in the request.
6984 /// It should be used to set parameters which are not yet available through their own
6985 /// setters.
6986 ///
6987 /// Please note that this method must not be used to set any of the known parameters
6988 /// which have their own setter method. If done anyway, the request will fail.
6989 ///
6990 /// # Additional Parameters
6991 ///
6992 /// * *$.xgafv* (query-string) - V1 error format.
6993 /// * *access_token* (query-string) - OAuth access token.
6994 /// * *alt* (query-string) - Data format for response.
6995 /// * *callback* (query-string) - JSONP
6996 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6997 /// * *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.
6998 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6999 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7000 /// * *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.
7001 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7002 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7003 pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetIamPolicyCall<'a, C>
7004 where
7005 T: AsRef<str>,
7006 {
7007 self._additional_params
7008 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7009 self
7010 }
7011
7012 /// Identifies the authorization scope for the method you are building.
7013 ///
7014 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7015 /// [`Scope::CloudPlatformReadOnly`].
7016 ///
7017 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7018 /// tokens for more than one scope.
7019 ///
7020 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7021 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7022 /// sufficient, a read-write scope will do as well.
7023 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetIamPolicyCall<'a, C>
7024 where
7025 St: AsRef<str>,
7026 {
7027 self._scopes.insert(String::from(scope.as_ref()));
7028 self
7029 }
7030 /// Identifies the authorization scope(s) for the method you are building.
7031 ///
7032 /// See [`Self::add_scope()`] for details.
7033 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetIamPolicyCall<'a, C>
7034 where
7035 I: IntoIterator<Item = St>,
7036 St: AsRef<str>,
7037 {
7038 self._scopes
7039 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7040 self
7041 }
7042
7043 /// Removes all scopes, and no default scope will be used either.
7044 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7045 /// for details).
7046 pub fn clear_scopes(mut self) -> OrganizationGetIamPolicyCall<'a, C> {
7047 self._scopes.clear();
7048 self
7049 }
7050}
7051
7052/// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
7053///
7054/// A builder for the *getOrgPolicy* method supported by a *organization* resource.
7055/// It is not used directly, but through a [`OrganizationMethods`] instance.
7056///
7057/// # Example
7058///
7059/// Instantiate a resource method builder
7060///
7061/// ```test_harness,no_run
7062/// # extern crate hyper;
7063/// # extern crate hyper_rustls;
7064/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
7065/// use cloudresourcemanager1::api::GetOrgPolicyRequest;
7066/// # async fn dox() {
7067/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7068///
7069/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7070/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7071/// # .with_native_roots()
7072/// # .unwrap()
7073/// # .https_only()
7074/// # .enable_http2()
7075/// # .build();
7076///
7077/// # let executor = hyper_util::rt::TokioExecutor::new();
7078/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7079/// # secret,
7080/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7081/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7082/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7083/// # ),
7084/// # ).build().await.unwrap();
7085///
7086/// # let client = hyper_util::client::legacy::Client::builder(
7087/// # hyper_util::rt::TokioExecutor::new()
7088/// # )
7089/// # .build(
7090/// # hyper_rustls::HttpsConnectorBuilder::new()
7091/// # .with_native_roots()
7092/// # .unwrap()
7093/// # .https_or_http()
7094/// # .enable_http2()
7095/// # .build()
7096/// # );
7097/// # let mut hub = CloudResourceManager::new(client, auth);
7098/// // As the method needs a request, you would usually fill it with the desired information
7099/// // into the respective structure. Some of the parts shown here might not be applicable !
7100/// // Values shown here are possibly random and not representative !
7101/// let mut req = GetOrgPolicyRequest::default();
7102///
7103/// // You can configure optional parameters by calling the respective setters at will, and
7104/// // execute the final call using `doit()`.
7105/// // Values shown here are possibly random and not representative !
7106/// let result = hub.organizations().get_org_policy(req, "resource")
7107/// .doit().await;
7108/// # }
7109/// ```
7110pub struct OrganizationGetOrgPolicyCall<'a, C>
7111where
7112 C: 'a,
7113{
7114 hub: &'a CloudResourceManager<C>,
7115 _request: GetOrgPolicyRequest,
7116 _resource: String,
7117 _delegate: Option<&'a mut dyn common::Delegate>,
7118 _additional_params: HashMap<String, String>,
7119 _scopes: BTreeSet<String>,
7120}
7121
7122impl<'a, C> common::CallBuilder for OrganizationGetOrgPolicyCall<'a, C> {}
7123
7124impl<'a, C> OrganizationGetOrgPolicyCall<'a, C>
7125where
7126 C: common::Connector,
7127{
7128 /// Perform the operation you have build so far.
7129 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
7130 use std::borrow::Cow;
7131 use std::io::{Read, Seek};
7132
7133 use common::{url::Params, ToParts};
7134 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7135
7136 let mut dd = common::DefaultDelegate;
7137 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7138 dlg.begin(common::MethodInfo {
7139 id: "cloudresourcemanager.organizations.getOrgPolicy",
7140 http_method: hyper::Method::POST,
7141 });
7142
7143 for &field in ["alt", "resource"].iter() {
7144 if self._additional_params.contains_key(field) {
7145 dlg.finished(false);
7146 return Err(common::Error::FieldClash(field));
7147 }
7148 }
7149
7150 let mut params = Params::with_capacity(4 + self._additional_params.len());
7151 params.push("resource", self._resource);
7152
7153 params.extend(self._additional_params.iter());
7154
7155 params.push("alt", "json");
7156 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getOrgPolicy";
7157 if self._scopes.is_empty() {
7158 self._scopes
7159 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
7160 }
7161
7162 #[allow(clippy::single_element_loop)]
7163 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7164 url = params.uri_replacement(url, param_name, find_this, true);
7165 }
7166 {
7167 let to_remove = ["resource"];
7168 params.remove_params(&to_remove);
7169 }
7170
7171 let url = params.parse_with_url(&url);
7172
7173 let mut json_mime_type = mime::APPLICATION_JSON;
7174 let mut request_value_reader = {
7175 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7176 common::remove_json_null_values(&mut value);
7177 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7178 serde_json::to_writer(&mut dst, &value).unwrap();
7179 dst
7180 };
7181 let request_size = request_value_reader
7182 .seek(std::io::SeekFrom::End(0))
7183 .unwrap();
7184 request_value_reader
7185 .seek(std::io::SeekFrom::Start(0))
7186 .unwrap();
7187
7188 loop {
7189 let token = match self
7190 .hub
7191 .auth
7192 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7193 .await
7194 {
7195 Ok(token) => token,
7196 Err(e) => match dlg.token(e) {
7197 Ok(token) => token,
7198 Err(e) => {
7199 dlg.finished(false);
7200 return Err(common::Error::MissingToken(e));
7201 }
7202 },
7203 };
7204 request_value_reader
7205 .seek(std::io::SeekFrom::Start(0))
7206 .unwrap();
7207 let mut req_result = {
7208 let client = &self.hub.client;
7209 dlg.pre_request();
7210 let mut req_builder = hyper::Request::builder()
7211 .method(hyper::Method::POST)
7212 .uri(url.as_str())
7213 .header(USER_AGENT, self.hub._user_agent.clone());
7214
7215 if let Some(token) = token.as_ref() {
7216 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7217 }
7218
7219 let request = req_builder
7220 .header(CONTENT_TYPE, json_mime_type.to_string())
7221 .header(CONTENT_LENGTH, request_size as u64)
7222 .body(common::to_body(
7223 request_value_reader.get_ref().clone().into(),
7224 ));
7225
7226 client.request(request.unwrap()).await
7227 };
7228
7229 match req_result {
7230 Err(err) => {
7231 if let common::Retry::After(d) = dlg.http_error(&err) {
7232 sleep(d).await;
7233 continue;
7234 }
7235 dlg.finished(false);
7236 return Err(common::Error::HttpError(err));
7237 }
7238 Ok(res) => {
7239 let (mut parts, body) = res.into_parts();
7240 let mut body = common::Body::new(body);
7241 if !parts.status.is_success() {
7242 let bytes = common::to_bytes(body).await.unwrap_or_default();
7243 let error = serde_json::from_str(&common::to_string(&bytes));
7244 let response = common::to_response(parts, bytes.into());
7245
7246 if let common::Retry::After(d) =
7247 dlg.http_failure(&response, error.as_ref().ok())
7248 {
7249 sleep(d).await;
7250 continue;
7251 }
7252
7253 dlg.finished(false);
7254
7255 return Err(match error {
7256 Ok(value) => common::Error::BadRequest(value),
7257 _ => common::Error::Failure(response),
7258 });
7259 }
7260 let response = {
7261 let bytes = common::to_bytes(body).await.unwrap_or_default();
7262 let encoded = common::to_string(&bytes);
7263 match serde_json::from_str(&encoded) {
7264 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7265 Err(error) => {
7266 dlg.response_json_decode_error(&encoded, &error);
7267 return Err(common::Error::JsonDecodeError(
7268 encoded.to_string(),
7269 error,
7270 ));
7271 }
7272 }
7273 };
7274
7275 dlg.finished(true);
7276 return Ok(response);
7277 }
7278 }
7279 }
7280 }
7281
7282 ///
7283 /// Sets the *request* property to the given value.
7284 ///
7285 /// Even though the property as already been set when instantiating this call,
7286 /// we provide this method for API completeness.
7287 pub fn request(
7288 mut self,
7289 new_value: GetOrgPolicyRequest,
7290 ) -> OrganizationGetOrgPolicyCall<'a, C> {
7291 self._request = new_value;
7292 self
7293 }
7294 /// Name of the resource the `Policy` is set on.
7295 ///
7296 /// Sets the *resource* path property to the given value.
7297 ///
7298 /// Even though the property as already been set when instantiating this call,
7299 /// we provide this method for API completeness.
7300 pub fn resource(mut self, new_value: &str) -> OrganizationGetOrgPolicyCall<'a, C> {
7301 self._resource = new_value.to_string();
7302 self
7303 }
7304 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7305 /// while executing the actual API request.
7306 ///
7307 /// ````text
7308 /// It should be used to handle progress information, and to implement a certain level of resilience.
7309 /// ````
7310 ///
7311 /// Sets the *delegate* property to the given value.
7312 pub fn delegate(
7313 mut self,
7314 new_value: &'a mut dyn common::Delegate,
7315 ) -> OrganizationGetOrgPolicyCall<'a, C> {
7316 self._delegate = Some(new_value);
7317 self
7318 }
7319
7320 /// Set any additional parameter of the query string used in the request.
7321 /// It should be used to set parameters which are not yet available through their own
7322 /// setters.
7323 ///
7324 /// Please note that this method must not be used to set any of the known parameters
7325 /// which have their own setter method. If done anyway, the request will fail.
7326 ///
7327 /// # Additional Parameters
7328 ///
7329 /// * *$.xgafv* (query-string) - V1 error format.
7330 /// * *access_token* (query-string) - OAuth access token.
7331 /// * *alt* (query-string) - Data format for response.
7332 /// * *callback* (query-string) - JSONP
7333 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7334 /// * *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.
7335 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7336 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7337 /// * *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.
7338 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7339 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7340 pub fn param<T>(mut self, name: T, value: T) -> OrganizationGetOrgPolicyCall<'a, C>
7341 where
7342 T: AsRef<str>,
7343 {
7344 self._additional_params
7345 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7346 self
7347 }
7348
7349 /// Identifies the authorization scope for the method you are building.
7350 ///
7351 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7352 /// [`Scope::CloudPlatformReadOnly`].
7353 ///
7354 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7355 /// tokens for more than one scope.
7356 ///
7357 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7358 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7359 /// sufficient, a read-write scope will do as well.
7360 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGetOrgPolicyCall<'a, C>
7361 where
7362 St: AsRef<str>,
7363 {
7364 self._scopes.insert(String::from(scope.as_ref()));
7365 self
7366 }
7367 /// Identifies the authorization scope(s) for the method you are building.
7368 ///
7369 /// See [`Self::add_scope()`] for details.
7370 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGetOrgPolicyCall<'a, C>
7371 where
7372 I: IntoIterator<Item = St>,
7373 St: AsRef<str>,
7374 {
7375 self._scopes
7376 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7377 self
7378 }
7379
7380 /// Removes all scopes, and no default scope will be used either.
7381 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7382 /// for details).
7383 pub fn clear_scopes(mut self) -> OrganizationGetOrgPolicyCall<'a, C> {
7384 self._scopes.clear();
7385 self
7386 }
7387}
7388
7389/// Lists `Constraints` that could be applied on the specified resource.
7390///
7391/// A builder for the *listAvailableOrgPolicyConstraints* method supported by a *organization* resource.
7392/// It is not used directly, but through a [`OrganizationMethods`] instance.
7393///
7394/// # Example
7395///
7396/// Instantiate a resource method builder
7397///
7398/// ```test_harness,no_run
7399/// # extern crate hyper;
7400/// # extern crate hyper_rustls;
7401/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
7402/// use cloudresourcemanager1::api::ListAvailableOrgPolicyConstraintsRequest;
7403/// # async fn dox() {
7404/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7405///
7406/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7407/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7408/// # .with_native_roots()
7409/// # .unwrap()
7410/// # .https_only()
7411/// # .enable_http2()
7412/// # .build();
7413///
7414/// # let executor = hyper_util::rt::TokioExecutor::new();
7415/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7416/// # secret,
7417/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7418/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7419/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7420/// # ),
7421/// # ).build().await.unwrap();
7422///
7423/// # let client = hyper_util::client::legacy::Client::builder(
7424/// # hyper_util::rt::TokioExecutor::new()
7425/// # )
7426/// # .build(
7427/// # hyper_rustls::HttpsConnectorBuilder::new()
7428/// # .with_native_roots()
7429/// # .unwrap()
7430/// # .https_or_http()
7431/// # .enable_http2()
7432/// # .build()
7433/// # );
7434/// # let mut hub = CloudResourceManager::new(client, auth);
7435/// // As the method needs a request, you would usually fill it with the desired information
7436/// // into the respective structure. Some of the parts shown here might not be applicable !
7437/// // Values shown here are possibly random and not representative !
7438/// let mut req = ListAvailableOrgPolicyConstraintsRequest::default();
7439///
7440/// // You can configure optional parameters by calling the respective setters at will, and
7441/// // execute the final call using `doit()`.
7442/// // Values shown here are possibly random and not representative !
7443/// let result = hub.organizations().list_available_org_policy_constraints(req, "resource")
7444/// .doit().await;
7445/// # }
7446/// ```
7447pub struct OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7448where
7449 C: 'a,
7450{
7451 hub: &'a CloudResourceManager<C>,
7452 _request: ListAvailableOrgPolicyConstraintsRequest,
7453 _resource: String,
7454 _delegate: Option<&'a mut dyn common::Delegate>,
7455 _additional_params: HashMap<String, String>,
7456 _scopes: BTreeSet<String>,
7457}
7458
7459impl<'a, C> common::CallBuilder for OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {}
7460
7461impl<'a, C> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7462where
7463 C: common::Connector,
7464{
7465 /// Perform the operation you have build so far.
7466 pub async fn doit(
7467 mut self,
7468 ) -> common::Result<(common::Response, ListAvailableOrgPolicyConstraintsResponse)> {
7469 use std::borrow::Cow;
7470 use std::io::{Read, Seek};
7471
7472 use common::{url::Params, ToParts};
7473 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7474
7475 let mut dd = common::DefaultDelegate;
7476 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7477 dlg.begin(common::MethodInfo {
7478 id: "cloudresourcemanager.organizations.listAvailableOrgPolicyConstraints",
7479 http_method: hyper::Method::POST,
7480 });
7481
7482 for &field in ["alt", "resource"].iter() {
7483 if self._additional_params.contains_key(field) {
7484 dlg.finished(false);
7485 return Err(common::Error::FieldClash(field));
7486 }
7487 }
7488
7489 let mut params = Params::with_capacity(4 + self._additional_params.len());
7490 params.push("resource", self._resource);
7491
7492 params.extend(self._additional_params.iter());
7493
7494 params.push("alt", "json");
7495 let mut url =
7496 self.hub._base_url.clone() + "v1/{+resource}:listAvailableOrgPolicyConstraints";
7497 if self._scopes.is_empty() {
7498 self._scopes
7499 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
7500 }
7501
7502 #[allow(clippy::single_element_loop)]
7503 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7504 url = params.uri_replacement(url, param_name, find_this, true);
7505 }
7506 {
7507 let to_remove = ["resource"];
7508 params.remove_params(&to_remove);
7509 }
7510
7511 let url = params.parse_with_url(&url);
7512
7513 let mut json_mime_type = mime::APPLICATION_JSON;
7514 let mut request_value_reader = {
7515 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7516 common::remove_json_null_values(&mut value);
7517 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7518 serde_json::to_writer(&mut dst, &value).unwrap();
7519 dst
7520 };
7521 let request_size = request_value_reader
7522 .seek(std::io::SeekFrom::End(0))
7523 .unwrap();
7524 request_value_reader
7525 .seek(std::io::SeekFrom::Start(0))
7526 .unwrap();
7527
7528 loop {
7529 let token = match self
7530 .hub
7531 .auth
7532 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7533 .await
7534 {
7535 Ok(token) => token,
7536 Err(e) => match dlg.token(e) {
7537 Ok(token) => token,
7538 Err(e) => {
7539 dlg.finished(false);
7540 return Err(common::Error::MissingToken(e));
7541 }
7542 },
7543 };
7544 request_value_reader
7545 .seek(std::io::SeekFrom::Start(0))
7546 .unwrap();
7547 let mut req_result = {
7548 let client = &self.hub.client;
7549 dlg.pre_request();
7550 let mut req_builder = hyper::Request::builder()
7551 .method(hyper::Method::POST)
7552 .uri(url.as_str())
7553 .header(USER_AGENT, self.hub._user_agent.clone());
7554
7555 if let Some(token) = token.as_ref() {
7556 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7557 }
7558
7559 let request = req_builder
7560 .header(CONTENT_TYPE, json_mime_type.to_string())
7561 .header(CONTENT_LENGTH, request_size as u64)
7562 .body(common::to_body(
7563 request_value_reader.get_ref().clone().into(),
7564 ));
7565
7566 client.request(request.unwrap()).await
7567 };
7568
7569 match req_result {
7570 Err(err) => {
7571 if let common::Retry::After(d) = dlg.http_error(&err) {
7572 sleep(d).await;
7573 continue;
7574 }
7575 dlg.finished(false);
7576 return Err(common::Error::HttpError(err));
7577 }
7578 Ok(res) => {
7579 let (mut parts, body) = res.into_parts();
7580 let mut body = common::Body::new(body);
7581 if !parts.status.is_success() {
7582 let bytes = common::to_bytes(body).await.unwrap_or_default();
7583 let error = serde_json::from_str(&common::to_string(&bytes));
7584 let response = common::to_response(parts, bytes.into());
7585
7586 if let common::Retry::After(d) =
7587 dlg.http_failure(&response, error.as_ref().ok())
7588 {
7589 sleep(d).await;
7590 continue;
7591 }
7592
7593 dlg.finished(false);
7594
7595 return Err(match error {
7596 Ok(value) => common::Error::BadRequest(value),
7597 _ => common::Error::Failure(response),
7598 });
7599 }
7600 let response = {
7601 let bytes = common::to_bytes(body).await.unwrap_or_default();
7602 let encoded = common::to_string(&bytes);
7603 match serde_json::from_str(&encoded) {
7604 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7605 Err(error) => {
7606 dlg.response_json_decode_error(&encoded, &error);
7607 return Err(common::Error::JsonDecodeError(
7608 encoded.to_string(),
7609 error,
7610 ));
7611 }
7612 }
7613 };
7614
7615 dlg.finished(true);
7616 return Ok(response);
7617 }
7618 }
7619 }
7620 }
7621
7622 ///
7623 /// Sets the *request* property to the given value.
7624 ///
7625 /// Even though the property as already been set when instantiating this call,
7626 /// we provide this method for API completeness.
7627 pub fn request(
7628 mut self,
7629 new_value: ListAvailableOrgPolicyConstraintsRequest,
7630 ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7631 self._request = new_value;
7632 self
7633 }
7634 /// Name of the resource to list `Constraints` for.
7635 ///
7636 /// Sets the *resource* path property to the given value.
7637 ///
7638 /// Even though the property as already been set when instantiating this call,
7639 /// we provide this method for API completeness.
7640 pub fn resource(
7641 mut self,
7642 new_value: &str,
7643 ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7644 self._resource = new_value.to_string();
7645 self
7646 }
7647 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7648 /// while executing the actual API request.
7649 ///
7650 /// ````text
7651 /// It should be used to handle progress information, and to implement a certain level of resilience.
7652 /// ````
7653 ///
7654 /// Sets the *delegate* property to the given value.
7655 pub fn delegate(
7656 mut self,
7657 new_value: &'a mut dyn common::Delegate,
7658 ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7659 self._delegate = Some(new_value);
7660 self
7661 }
7662
7663 /// Set any additional parameter of the query string used in the request.
7664 /// It should be used to set parameters which are not yet available through their own
7665 /// setters.
7666 ///
7667 /// Please note that this method must not be used to set any of the known parameters
7668 /// which have their own setter method. If done anyway, the request will fail.
7669 ///
7670 /// # Additional Parameters
7671 ///
7672 /// * *$.xgafv* (query-string) - V1 error format.
7673 /// * *access_token* (query-string) - OAuth access token.
7674 /// * *alt* (query-string) - Data format for response.
7675 /// * *callback* (query-string) - JSONP
7676 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7677 /// * *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.
7678 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7679 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7680 /// * *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.
7681 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7682 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7683 pub fn param<T>(
7684 mut self,
7685 name: T,
7686 value: T,
7687 ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7688 where
7689 T: AsRef<str>,
7690 {
7691 self._additional_params
7692 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7693 self
7694 }
7695
7696 /// Identifies the authorization scope for the method you are building.
7697 ///
7698 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7699 /// [`Scope::CloudPlatformReadOnly`].
7700 ///
7701 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7702 /// tokens for more than one scope.
7703 ///
7704 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7705 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7706 /// sufficient, a read-write scope will do as well.
7707 pub fn add_scope<St>(
7708 mut self,
7709 scope: St,
7710 ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7711 where
7712 St: AsRef<str>,
7713 {
7714 self._scopes.insert(String::from(scope.as_ref()));
7715 self
7716 }
7717 /// Identifies the authorization scope(s) for the method you are building.
7718 ///
7719 /// See [`Self::add_scope()`] for details.
7720 pub fn add_scopes<I, St>(
7721 mut self,
7722 scopes: I,
7723 ) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C>
7724 where
7725 I: IntoIterator<Item = St>,
7726 St: AsRef<str>,
7727 {
7728 self._scopes
7729 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7730 self
7731 }
7732
7733 /// Removes all scopes, and no default scope will be used either.
7734 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7735 /// for details).
7736 pub fn clear_scopes(mut self) -> OrganizationListAvailableOrgPolicyConstraintCall<'a, C> {
7737 self._scopes.clear();
7738 self
7739 }
7740}
7741
7742/// Lists all the `Policies` set for a particular resource.
7743///
7744/// A builder for the *listOrgPolicies* method supported by a *organization* resource.
7745/// It is not used directly, but through a [`OrganizationMethods`] instance.
7746///
7747/// # Example
7748///
7749/// Instantiate a resource method builder
7750///
7751/// ```test_harness,no_run
7752/// # extern crate hyper;
7753/// # extern crate hyper_rustls;
7754/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
7755/// use cloudresourcemanager1::api::ListOrgPoliciesRequest;
7756/// # async fn dox() {
7757/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7758///
7759/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7760/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7761/// # .with_native_roots()
7762/// # .unwrap()
7763/// # .https_only()
7764/// # .enable_http2()
7765/// # .build();
7766///
7767/// # let executor = hyper_util::rt::TokioExecutor::new();
7768/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7769/// # secret,
7770/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7771/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7772/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7773/// # ),
7774/// # ).build().await.unwrap();
7775///
7776/// # let client = hyper_util::client::legacy::Client::builder(
7777/// # hyper_util::rt::TokioExecutor::new()
7778/// # )
7779/// # .build(
7780/// # hyper_rustls::HttpsConnectorBuilder::new()
7781/// # .with_native_roots()
7782/// # .unwrap()
7783/// # .https_or_http()
7784/// # .enable_http2()
7785/// # .build()
7786/// # );
7787/// # let mut hub = CloudResourceManager::new(client, auth);
7788/// // As the method needs a request, you would usually fill it with the desired information
7789/// // into the respective structure. Some of the parts shown here might not be applicable !
7790/// // Values shown here are possibly random and not representative !
7791/// let mut req = ListOrgPoliciesRequest::default();
7792///
7793/// // You can configure optional parameters by calling the respective setters at will, and
7794/// // execute the final call using `doit()`.
7795/// // Values shown here are possibly random and not representative !
7796/// let result = hub.organizations().list_org_policies(req, "resource")
7797/// .doit().await;
7798/// # }
7799/// ```
7800pub struct OrganizationListOrgPolicyCall<'a, C>
7801where
7802 C: 'a,
7803{
7804 hub: &'a CloudResourceManager<C>,
7805 _request: ListOrgPoliciesRequest,
7806 _resource: String,
7807 _delegate: Option<&'a mut dyn common::Delegate>,
7808 _additional_params: HashMap<String, String>,
7809 _scopes: BTreeSet<String>,
7810}
7811
7812impl<'a, C> common::CallBuilder for OrganizationListOrgPolicyCall<'a, C> {}
7813
7814impl<'a, C> OrganizationListOrgPolicyCall<'a, C>
7815where
7816 C: common::Connector,
7817{
7818 /// Perform the operation you have build so far.
7819 pub async fn doit(mut self) -> common::Result<(common::Response, ListOrgPoliciesResponse)> {
7820 use std::borrow::Cow;
7821 use std::io::{Read, Seek};
7822
7823 use common::{url::Params, ToParts};
7824 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7825
7826 let mut dd = common::DefaultDelegate;
7827 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7828 dlg.begin(common::MethodInfo {
7829 id: "cloudresourcemanager.organizations.listOrgPolicies",
7830 http_method: hyper::Method::POST,
7831 });
7832
7833 for &field in ["alt", "resource"].iter() {
7834 if self._additional_params.contains_key(field) {
7835 dlg.finished(false);
7836 return Err(common::Error::FieldClash(field));
7837 }
7838 }
7839
7840 let mut params = Params::with_capacity(4 + self._additional_params.len());
7841 params.push("resource", self._resource);
7842
7843 params.extend(self._additional_params.iter());
7844
7845 params.push("alt", "json");
7846 let mut url = self.hub._base_url.clone() + "v1/{+resource}:listOrgPolicies";
7847 if self._scopes.is_empty() {
7848 self._scopes
7849 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
7850 }
7851
7852 #[allow(clippy::single_element_loop)]
7853 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7854 url = params.uri_replacement(url, param_name, find_this, true);
7855 }
7856 {
7857 let to_remove = ["resource"];
7858 params.remove_params(&to_remove);
7859 }
7860
7861 let url = params.parse_with_url(&url);
7862
7863 let mut json_mime_type = mime::APPLICATION_JSON;
7864 let mut request_value_reader = {
7865 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7866 common::remove_json_null_values(&mut value);
7867 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7868 serde_json::to_writer(&mut dst, &value).unwrap();
7869 dst
7870 };
7871 let request_size = request_value_reader
7872 .seek(std::io::SeekFrom::End(0))
7873 .unwrap();
7874 request_value_reader
7875 .seek(std::io::SeekFrom::Start(0))
7876 .unwrap();
7877
7878 loop {
7879 let token = match self
7880 .hub
7881 .auth
7882 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7883 .await
7884 {
7885 Ok(token) => token,
7886 Err(e) => match dlg.token(e) {
7887 Ok(token) => token,
7888 Err(e) => {
7889 dlg.finished(false);
7890 return Err(common::Error::MissingToken(e));
7891 }
7892 },
7893 };
7894 request_value_reader
7895 .seek(std::io::SeekFrom::Start(0))
7896 .unwrap();
7897 let mut req_result = {
7898 let client = &self.hub.client;
7899 dlg.pre_request();
7900 let mut req_builder = hyper::Request::builder()
7901 .method(hyper::Method::POST)
7902 .uri(url.as_str())
7903 .header(USER_AGENT, self.hub._user_agent.clone());
7904
7905 if let Some(token) = token.as_ref() {
7906 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7907 }
7908
7909 let request = req_builder
7910 .header(CONTENT_TYPE, json_mime_type.to_string())
7911 .header(CONTENT_LENGTH, request_size as u64)
7912 .body(common::to_body(
7913 request_value_reader.get_ref().clone().into(),
7914 ));
7915
7916 client.request(request.unwrap()).await
7917 };
7918
7919 match req_result {
7920 Err(err) => {
7921 if let common::Retry::After(d) = dlg.http_error(&err) {
7922 sleep(d).await;
7923 continue;
7924 }
7925 dlg.finished(false);
7926 return Err(common::Error::HttpError(err));
7927 }
7928 Ok(res) => {
7929 let (mut parts, body) = res.into_parts();
7930 let mut body = common::Body::new(body);
7931 if !parts.status.is_success() {
7932 let bytes = common::to_bytes(body).await.unwrap_or_default();
7933 let error = serde_json::from_str(&common::to_string(&bytes));
7934 let response = common::to_response(parts, bytes.into());
7935
7936 if let common::Retry::After(d) =
7937 dlg.http_failure(&response, error.as_ref().ok())
7938 {
7939 sleep(d).await;
7940 continue;
7941 }
7942
7943 dlg.finished(false);
7944
7945 return Err(match error {
7946 Ok(value) => common::Error::BadRequest(value),
7947 _ => common::Error::Failure(response),
7948 });
7949 }
7950 let response = {
7951 let bytes = common::to_bytes(body).await.unwrap_or_default();
7952 let encoded = common::to_string(&bytes);
7953 match serde_json::from_str(&encoded) {
7954 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7955 Err(error) => {
7956 dlg.response_json_decode_error(&encoded, &error);
7957 return Err(common::Error::JsonDecodeError(
7958 encoded.to_string(),
7959 error,
7960 ));
7961 }
7962 }
7963 };
7964
7965 dlg.finished(true);
7966 return Ok(response);
7967 }
7968 }
7969 }
7970 }
7971
7972 ///
7973 /// Sets the *request* property to the given value.
7974 ///
7975 /// Even though the property as already been set when instantiating this call,
7976 /// we provide this method for API completeness.
7977 pub fn request(
7978 mut self,
7979 new_value: ListOrgPoliciesRequest,
7980 ) -> OrganizationListOrgPolicyCall<'a, C> {
7981 self._request = new_value;
7982 self
7983 }
7984 /// Name of the resource to list Policies for.
7985 ///
7986 /// Sets the *resource* path property to the given value.
7987 ///
7988 /// Even though the property as already been set when instantiating this call,
7989 /// we provide this method for API completeness.
7990 pub fn resource(mut self, new_value: &str) -> OrganizationListOrgPolicyCall<'a, C> {
7991 self._resource = new_value.to_string();
7992 self
7993 }
7994 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7995 /// while executing the actual API request.
7996 ///
7997 /// ````text
7998 /// It should be used to handle progress information, and to implement a certain level of resilience.
7999 /// ````
8000 ///
8001 /// Sets the *delegate* property to the given value.
8002 pub fn delegate(
8003 mut self,
8004 new_value: &'a mut dyn common::Delegate,
8005 ) -> OrganizationListOrgPolicyCall<'a, C> {
8006 self._delegate = Some(new_value);
8007 self
8008 }
8009
8010 /// Set any additional parameter of the query string used in the request.
8011 /// It should be used to set parameters which are not yet available through their own
8012 /// setters.
8013 ///
8014 /// Please note that this method must not be used to set any of the known parameters
8015 /// which have their own setter method. If done anyway, the request will fail.
8016 ///
8017 /// # Additional Parameters
8018 ///
8019 /// * *$.xgafv* (query-string) - V1 error format.
8020 /// * *access_token* (query-string) - OAuth access token.
8021 /// * *alt* (query-string) - Data format for response.
8022 /// * *callback* (query-string) - JSONP
8023 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8024 /// * *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.
8025 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8026 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8027 /// * *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.
8028 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8029 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8030 pub fn param<T>(mut self, name: T, value: T) -> OrganizationListOrgPolicyCall<'a, C>
8031 where
8032 T: AsRef<str>,
8033 {
8034 self._additional_params
8035 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8036 self
8037 }
8038
8039 /// Identifies the authorization scope for the method you are building.
8040 ///
8041 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8042 /// [`Scope::CloudPlatformReadOnly`].
8043 ///
8044 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8045 /// tokens for more than one scope.
8046 ///
8047 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8048 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8049 /// sufficient, a read-write scope will do as well.
8050 pub fn add_scope<St>(mut self, scope: St) -> OrganizationListOrgPolicyCall<'a, C>
8051 where
8052 St: AsRef<str>,
8053 {
8054 self._scopes.insert(String::from(scope.as_ref()));
8055 self
8056 }
8057 /// Identifies the authorization scope(s) for the method you are building.
8058 ///
8059 /// See [`Self::add_scope()`] for details.
8060 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationListOrgPolicyCall<'a, C>
8061 where
8062 I: IntoIterator<Item = St>,
8063 St: AsRef<str>,
8064 {
8065 self._scopes
8066 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8067 self
8068 }
8069
8070 /// Removes all scopes, and no default scope will be used either.
8071 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8072 /// for details).
8073 pub fn clear_scopes(mut self) -> OrganizationListOrgPolicyCall<'a, C> {
8074 self._scopes.clear();
8075 self
8076 }
8077}
8078
8079/// Searches Organization resources that are visible to the user and satisfy the specified filter. This method returns Organizations in an unspecified order. New Organizations do not necessarily appear at the end of the results. Search will only return organizations on which the user has the permission `resourcemanager.organizations.get` or has super admin privileges.
8080///
8081/// A builder for the *search* method supported by a *organization* resource.
8082/// It is not used directly, but through a [`OrganizationMethods`] instance.
8083///
8084/// # Example
8085///
8086/// Instantiate a resource method builder
8087///
8088/// ```test_harness,no_run
8089/// # extern crate hyper;
8090/// # extern crate hyper_rustls;
8091/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
8092/// use cloudresourcemanager1::api::SearchOrganizationsRequest;
8093/// # async fn dox() {
8094/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8095///
8096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8097/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8098/// # .with_native_roots()
8099/// # .unwrap()
8100/// # .https_only()
8101/// # .enable_http2()
8102/// # .build();
8103///
8104/// # let executor = hyper_util::rt::TokioExecutor::new();
8105/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8106/// # secret,
8107/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8108/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8109/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8110/// # ),
8111/// # ).build().await.unwrap();
8112///
8113/// # let client = hyper_util::client::legacy::Client::builder(
8114/// # hyper_util::rt::TokioExecutor::new()
8115/// # )
8116/// # .build(
8117/// # hyper_rustls::HttpsConnectorBuilder::new()
8118/// # .with_native_roots()
8119/// # .unwrap()
8120/// # .https_or_http()
8121/// # .enable_http2()
8122/// # .build()
8123/// # );
8124/// # let mut hub = CloudResourceManager::new(client, auth);
8125/// // As the method needs a request, you would usually fill it with the desired information
8126/// // into the respective structure. Some of the parts shown here might not be applicable !
8127/// // Values shown here are possibly random and not representative !
8128/// let mut req = SearchOrganizationsRequest::default();
8129///
8130/// // You can configure optional parameters by calling the respective setters at will, and
8131/// // execute the final call using `doit()`.
8132/// // Values shown here are possibly random and not representative !
8133/// let result = hub.organizations().search(req)
8134/// .doit().await;
8135/// # }
8136/// ```
8137pub struct OrganizationSearchCall<'a, C>
8138where
8139 C: 'a,
8140{
8141 hub: &'a CloudResourceManager<C>,
8142 _request: SearchOrganizationsRequest,
8143 _delegate: Option<&'a mut dyn common::Delegate>,
8144 _additional_params: HashMap<String, String>,
8145 _scopes: BTreeSet<String>,
8146}
8147
8148impl<'a, C> common::CallBuilder for OrganizationSearchCall<'a, C> {}
8149
8150impl<'a, C> OrganizationSearchCall<'a, C>
8151where
8152 C: common::Connector,
8153{
8154 /// Perform the operation you have build so far.
8155 pub async fn doit(mut self) -> common::Result<(common::Response, SearchOrganizationsResponse)> {
8156 use std::borrow::Cow;
8157 use std::io::{Read, Seek};
8158
8159 use common::{url::Params, ToParts};
8160 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8161
8162 let mut dd = common::DefaultDelegate;
8163 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8164 dlg.begin(common::MethodInfo {
8165 id: "cloudresourcemanager.organizations.search",
8166 http_method: hyper::Method::POST,
8167 });
8168
8169 for &field in ["alt"].iter() {
8170 if self._additional_params.contains_key(field) {
8171 dlg.finished(false);
8172 return Err(common::Error::FieldClash(field));
8173 }
8174 }
8175
8176 let mut params = Params::with_capacity(3 + self._additional_params.len());
8177
8178 params.extend(self._additional_params.iter());
8179
8180 params.push("alt", "json");
8181 let mut url = self.hub._base_url.clone() + "v1/organizations:search";
8182 if self._scopes.is_empty() {
8183 self._scopes
8184 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
8185 }
8186
8187 let url = params.parse_with_url(&url);
8188
8189 let mut json_mime_type = mime::APPLICATION_JSON;
8190 let mut request_value_reader = {
8191 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8192 common::remove_json_null_values(&mut value);
8193 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8194 serde_json::to_writer(&mut dst, &value).unwrap();
8195 dst
8196 };
8197 let request_size = request_value_reader
8198 .seek(std::io::SeekFrom::End(0))
8199 .unwrap();
8200 request_value_reader
8201 .seek(std::io::SeekFrom::Start(0))
8202 .unwrap();
8203
8204 loop {
8205 let token = match self
8206 .hub
8207 .auth
8208 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8209 .await
8210 {
8211 Ok(token) => token,
8212 Err(e) => match dlg.token(e) {
8213 Ok(token) => token,
8214 Err(e) => {
8215 dlg.finished(false);
8216 return Err(common::Error::MissingToken(e));
8217 }
8218 },
8219 };
8220 request_value_reader
8221 .seek(std::io::SeekFrom::Start(0))
8222 .unwrap();
8223 let mut req_result = {
8224 let client = &self.hub.client;
8225 dlg.pre_request();
8226 let mut req_builder = hyper::Request::builder()
8227 .method(hyper::Method::POST)
8228 .uri(url.as_str())
8229 .header(USER_AGENT, self.hub._user_agent.clone());
8230
8231 if let Some(token) = token.as_ref() {
8232 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8233 }
8234
8235 let request = req_builder
8236 .header(CONTENT_TYPE, json_mime_type.to_string())
8237 .header(CONTENT_LENGTH, request_size as u64)
8238 .body(common::to_body(
8239 request_value_reader.get_ref().clone().into(),
8240 ));
8241
8242 client.request(request.unwrap()).await
8243 };
8244
8245 match req_result {
8246 Err(err) => {
8247 if let common::Retry::After(d) = dlg.http_error(&err) {
8248 sleep(d).await;
8249 continue;
8250 }
8251 dlg.finished(false);
8252 return Err(common::Error::HttpError(err));
8253 }
8254 Ok(res) => {
8255 let (mut parts, body) = res.into_parts();
8256 let mut body = common::Body::new(body);
8257 if !parts.status.is_success() {
8258 let bytes = common::to_bytes(body).await.unwrap_or_default();
8259 let error = serde_json::from_str(&common::to_string(&bytes));
8260 let response = common::to_response(parts, bytes.into());
8261
8262 if let common::Retry::After(d) =
8263 dlg.http_failure(&response, error.as_ref().ok())
8264 {
8265 sleep(d).await;
8266 continue;
8267 }
8268
8269 dlg.finished(false);
8270
8271 return Err(match error {
8272 Ok(value) => common::Error::BadRequest(value),
8273 _ => common::Error::Failure(response),
8274 });
8275 }
8276 let response = {
8277 let bytes = common::to_bytes(body).await.unwrap_or_default();
8278 let encoded = common::to_string(&bytes);
8279 match serde_json::from_str(&encoded) {
8280 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8281 Err(error) => {
8282 dlg.response_json_decode_error(&encoded, &error);
8283 return Err(common::Error::JsonDecodeError(
8284 encoded.to_string(),
8285 error,
8286 ));
8287 }
8288 }
8289 };
8290
8291 dlg.finished(true);
8292 return Ok(response);
8293 }
8294 }
8295 }
8296 }
8297
8298 ///
8299 /// Sets the *request* property to the given value.
8300 ///
8301 /// Even though the property as already been set when instantiating this call,
8302 /// we provide this method for API completeness.
8303 pub fn request(
8304 mut self,
8305 new_value: SearchOrganizationsRequest,
8306 ) -> OrganizationSearchCall<'a, C> {
8307 self._request = new_value;
8308 self
8309 }
8310 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8311 /// while executing the actual API request.
8312 ///
8313 /// ````text
8314 /// It should be used to handle progress information, and to implement a certain level of resilience.
8315 /// ````
8316 ///
8317 /// Sets the *delegate* property to the given value.
8318 pub fn delegate(
8319 mut self,
8320 new_value: &'a mut dyn common::Delegate,
8321 ) -> OrganizationSearchCall<'a, C> {
8322 self._delegate = Some(new_value);
8323 self
8324 }
8325
8326 /// Set any additional parameter of the query string used in the request.
8327 /// It should be used to set parameters which are not yet available through their own
8328 /// setters.
8329 ///
8330 /// Please note that this method must not be used to set any of the known parameters
8331 /// which have their own setter method. If done anyway, the request will fail.
8332 ///
8333 /// # Additional Parameters
8334 ///
8335 /// * *$.xgafv* (query-string) - V1 error format.
8336 /// * *access_token* (query-string) - OAuth access token.
8337 /// * *alt* (query-string) - Data format for response.
8338 /// * *callback* (query-string) - JSONP
8339 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8340 /// * *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.
8341 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8342 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8343 /// * *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.
8344 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8345 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8346 pub fn param<T>(mut self, name: T, value: T) -> OrganizationSearchCall<'a, C>
8347 where
8348 T: AsRef<str>,
8349 {
8350 self._additional_params
8351 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8352 self
8353 }
8354
8355 /// Identifies the authorization scope for the method you are building.
8356 ///
8357 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8358 /// [`Scope::CloudPlatformReadOnly`].
8359 ///
8360 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8361 /// tokens for more than one scope.
8362 ///
8363 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8364 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8365 /// sufficient, a read-write scope will do as well.
8366 pub fn add_scope<St>(mut self, scope: St) -> OrganizationSearchCall<'a, C>
8367 where
8368 St: AsRef<str>,
8369 {
8370 self._scopes.insert(String::from(scope.as_ref()));
8371 self
8372 }
8373 /// Identifies the authorization scope(s) for the method you are building.
8374 ///
8375 /// See [`Self::add_scope()`] for details.
8376 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationSearchCall<'a, C>
8377 where
8378 I: IntoIterator<Item = St>,
8379 St: AsRef<str>,
8380 {
8381 self._scopes
8382 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8383 self
8384 }
8385
8386 /// Removes all scopes, and no default scope will be used either.
8387 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8388 /// for details).
8389 pub fn clear_scopes(mut self) -> OrganizationSearchCall<'a, C> {
8390 self._scopes.clear();
8391 self
8392 }
8393}
8394
8395/// Sets the access control policy on an Organization resource. Replaces any existing policy. The `resource` field should be the organization's resource name, e.g. "organizations/123". Authorization requires the Google IAM permission `resourcemanager.organizations.setIamPolicy` on the specified organization
8396///
8397/// A builder for the *setIamPolicy* method supported by a *organization* resource.
8398/// It is not used directly, but through a [`OrganizationMethods`] instance.
8399///
8400/// # Example
8401///
8402/// Instantiate a resource method builder
8403///
8404/// ```test_harness,no_run
8405/// # extern crate hyper;
8406/// # extern crate hyper_rustls;
8407/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
8408/// use cloudresourcemanager1::api::SetIamPolicyRequest;
8409/// # async fn dox() {
8410/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8411///
8412/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8413/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8414/// # .with_native_roots()
8415/// # .unwrap()
8416/// # .https_only()
8417/// # .enable_http2()
8418/// # .build();
8419///
8420/// # let executor = hyper_util::rt::TokioExecutor::new();
8421/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8422/// # secret,
8423/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8424/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8425/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8426/// # ),
8427/// # ).build().await.unwrap();
8428///
8429/// # let client = hyper_util::client::legacy::Client::builder(
8430/// # hyper_util::rt::TokioExecutor::new()
8431/// # )
8432/// # .build(
8433/// # hyper_rustls::HttpsConnectorBuilder::new()
8434/// # .with_native_roots()
8435/// # .unwrap()
8436/// # .https_or_http()
8437/// # .enable_http2()
8438/// # .build()
8439/// # );
8440/// # let mut hub = CloudResourceManager::new(client, auth);
8441/// // As the method needs a request, you would usually fill it with the desired information
8442/// // into the respective structure. Some of the parts shown here might not be applicable !
8443/// // Values shown here are possibly random and not representative !
8444/// let mut req = SetIamPolicyRequest::default();
8445///
8446/// // You can configure optional parameters by calling the respective setters at will, and
8447/// // execute the final call using `doit()`.
8448/// // Values shown here are possibly random and not representative !
8449/// let result = hub.organizations().set_iam_policy(req, "resource")
8450/// .doit().await;
8451/// # }
8452/// ```
8453pub struct OrganizationSetIamPolicyCall<'a, C>
8454where
8455 C: 'a,
8456{
8457 hub: &'a CloudResourceManager<C>,
8458 _request: SetIamPolicyRequest,
8459 _resource: String,
8460 _delegate: Option<&'a mut dyn common::Delegate>,
8461 _additional_params: HashMap<String, String>,
8462 _scopes: BTreeSet<String>,
8463}
8464
8465impl<'a, C> common::CallBuilder for OrganizationSetIamPolicyCall<'a, C> {}
8466
8467impl<'a, C> OrganizationSetIamPolicyCall<'a, C>
8468where
8469 C: common::Connector,
8470{
8471 /// Perform the operation you have build so far.
8472 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8473 use std::borrow::Cow;
8474 use std::io::{Read, Seek};
8475
8476 use common::{url::Params, ToParts};
8477 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8478
8479 let mut dd = common::DefaultDelegate;
8480 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8481 dlg.begin(common::MethodInfo {
8482 id: "cloudresourcemanager.organizations.setIamPolicy",
8483 http_method: hyper::Method::POST,
8484 });
8485
8486 for &field in ["alt", "resource"].iter() {
8487 if self._additional_params.contains_key(field) {
8488 dlg.finished(false);
8489 return Err(common::Error::FieldClash(field));
8490 }
8491 }
8492
8493 let mut params = Params::with_capacity(4 + self._additional_params.len());
8494 params.push("resource", self._resource);
8495
8496 params.extend(self._additional_params.iter());
8497
8498 params.push("alt", "json");
8499 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8500 if self._scopes.is_empty() {
8501 self._scopes
8502 .insert(Scope::CloudPlatform.as_ref().to_string());
8503 }
8504
8505 #[allow(clippy::single_element_loop)]
8506 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8507 url = params.uri_replacement(url, param_name, find_this, true);
8508 }
8509 {
8510 let to_remove = ["resource"];
8511 params.remove_params(&to_remove);
8512 }
8513
8514 let url = params.parse_with_url(&url);
8515
8516 let mut json_mime_type = mime::APPLICATION_JSON;
8517 let mut request_value_reader = {
8518 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8519 common::remove_json_null_values(&mut value);
8520 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8521 serde_json::to_writer(&mut dst, &value).unwrap();
8522 dst
8523 };
8524 let request_size = request_value_reader
8525 .seek(std::io::SeekFrom::End(0))
8526 .unwrap();
8527 request_value_reader
8528 .seek(std::io::SeekFrom::Start(0))
8529 .unwrap();
8530
8531 loop {
8532 let token = match self
8533 .hub
8534 .auth
8535 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8536 .await
8537 {
8538 Ok(token) => token,
8539 Err(e) => match dlg.token(e) {
8540 Ok(token) => token,
8541 Err(e) => {
8542 dlg.finished(false);
8543 return Err(common::Error::MissingToken(e));
8544 }
8545 },
8546 };
8547 request_value_reader
8548 .seek(std::io::SeekFrom::Start(0))
8549 .unwrap();
8550 let mut req_result = {
8551 let client = &self.hub.client;
8552 dlg.pre_request();
8553 let mut req_builder = hyper::Request::builder()
8554 .method(hyper::Method::POST)
8555 .uri(url.as_str())
8556 .header(USER_AGENT, self.hub._user_agent.clone());
8557
8558 if let Some(token) = token.as_ref() {
8559 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8560 }
8561
8562 let request = req_builder
8563 .header(CONTENT_TYPE, json_mime_type.to_string())
8564 .header(CONTENT_LENGTH, request_size as u64)
8565 .body(common::to_body(
8566 request_value_reader.get_ref().clone().into(),
8567 ));
8568
8569 client.request(request.unwrap()).await
8570 };
8571
8572 match req_result {
8573 Err(err) => {
8574 if let common::Retry::After(d) = dlg.http_error(&err) {
8575 sleep(d).await;
8576 continue;
8577 }
8578 dlg.finished(false);
8579 return Err(common::Error::HttpError(err));
8580 }
8581 Ok(res) => {
8582 let (mut parts, body) = res.into_parts();
8583 let mut body = common::Body::new(body);
8584 if !parts.status.is_success() {
8585 let bytes = common::to_bytes(body).await.unwrap_or_default();
8586 let error = serde_json::from_str(&common::to_string(&bytes));
8587 let response = common::to_response(parts, bytes.into());
8588
8589 if let common::Retry::After(d) =
8590 dlg.http_failure(&response, error.as_ref().ok())
8591 {
8592 sleep(d).await;
8593 continue;
8594 }
8595
8596 dlg.finished(false);
8597
8598 return Err(match error {
8599 Ok(value) => common::Error::BadRequest(value),
8600 _ => common::Error::Failure(response),
8601 });
8602 }
8603 let response = {
8604 let bytes = common::to_bytes(body).await.unwrap_or_default();
8605 let encoded = common::to_string(&bytes);
8606 match serde_json::from_str(&encoded) {
8607 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8608 Err(error) => {
8609 dlg.response_json_decode_error(&encoded, &error);
8610 return Err(common::Error::JsonDecodeError(
8611 encoded.to_string(),
8612 error,
8613 ));
8614 }
8615 }
8616 };
8617
8618 dlg.finished(true);
8619 return Ok(response);
8620 }
8621 }
8622 }
8623 }
8624
8625 ///
8626 /// Sets the *request* property to the given value.
8627 ///
8628 /// Even though the property as already been set when instantiating this call,
8629 /// we provide this method for API completeness.
8630 pub fn request(
8631 mut self,
8632 new_value: SetIamPolicyRequest,
8633 ) -> OrganizationSetIamPolicyCall<'a, C> {
8634 self._request = new_value;
8635 self
8636 }
8637 /// 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.
8638 ///
8639 /// Sets the *resource* path property to the given value.
8640 ///
8641 /// Even though the property as already been set when instantiating this call,
8642 /// we provide this method for API completeness.
8643 pub fn resource(mut self, new_value: &str) -> OrganizationSetIamPolicyCall<'a, C> {
8644 self._resource = new_value.to_string();
8645 self
8646 }
8647 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8648 /// while executing the actual API request.
8649 ///
8650 /// ````text
8651 /// It should be used to handle progress information, and to implement a certain level of resilience.
8652 /// ````
8653 ///
8654 /// Sets the *delegate* property to the given value.
8655 pub fn delegate(
8656 mut self,
8657 new_value: &'a mut dyn common::Delegate,
8658 ) -> OrganizationSetIamPolicyCall<'a, C> {
8659 self._delegate = Some(new_value);
8660 self
8661 }
8662
8663 /// Set any additional parameter of the query string used in the request.
8664 /// It should be used to set parameters which are not yet available through their own
8665 /// setters.
8666 ///
8667 /// Please note that this method must not be used to set any of the known parameters
8668 /// which have their own setter method. If done anyway, the request will fail.
8669 ///
8670 /// # Additional Parameters
8671 ///
8672 /// * *$.xgafv* (query-string) - V1 error format.
8673 /// * *access_token* (query-string) - OAuth access token.
8674 /// * *alt* (query-string) - Data format for response.
8675 /// * *callback* (query-string) - JSONP
8676 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8677 /// * *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.
8678 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8679 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8680 /// * *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.
8681 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8682 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8683 pub fn param<T>(mut self, name: T, value: T) -> OrganizationSetIamPolicyCall<'a, C>
8684 where
8685 T: AsRef<str>,
8686 {
8687 self._additional_params
8688 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8689 self
8690 }
8691
8692 /// Identifies the authorization scope for the method you are building.
8693 ///
8694 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8695 /// [`Scope::CloudPlatform`].
8696 ///
8697 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8698 /// tokens for more than one scope.
8699 ///
8700 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8701 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8702 /// sufficient, a read-write scope will do as well.
8703 pub fn add_scope<St>(mut self, scope: St) -> OrganizationSetIamPolicyCall<'a, C>
8704 where
8705 St: AsRef<str>,
8706 {
8707 self._scopes.insert(String::from(scope.as_ref()));
8708 self
8709 }
8710 /// Identifies the authorization scope(s) for the method you are building.
8711 ///
8712 /// See [`Self::add_scope()`] for details.
8713 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationSetIamPolicyCall<'a, C>
8714 where
8715 I: IntoIterator<Item = St>,
8716 St: AsRef<str>,
8717 {
8718 self._scopes
8719 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8720 self
8721 }
8722
8723 /// Removes all scopes, and no default scope will be used either.
8724 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8725 /// for details).
8726 pub fn clear_scopes(mut self) -> OrganizationSetIamPolicyCall<'a, C> {
8727 self._scopes.clear();
8728 self
8729 }
8730}
8731
8732/// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
8733///
8734/// A builder for the *setOrgPolicy* method supported by a *organization* resource.
8735/// It is not used directly, but through a [`OrganizationMethods`] instance.
8736///
8737/// # Example
8738///
8739/// Instantiate a resource method builder
8740///
8741/// ```test_harness,no_run
8742/// # extern crate hyper;
8743/// # extern crate hyper_rustls;
8744/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
8745/// use cloudresourcemanager1::api::SetOrgPolicyRequest;
8746/// # async fn dox() {
8747/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8748///
8749/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8750/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8751/// # .with_native_roots()
8752/// # .unwrap()
8753/// # .https_only()
8754/// # .enable_http2()
8755/// # .build();
8756///
8757/// # let executor = hyper_util::rt::TokioExecutor::new();
8758/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8759/// # secret,
8760/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8761/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8762/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8763/// # ),
8764/// # ).build().await.unwrap();
8765///
8766/// # let client = hyper_util::client::legacy::Client::builder(
8767/// # hyper_util::rt::TokioExecutor::new()
8768/// # )
8769/// # .build(
8770/// # hyper_rustls::HttpsConnectorBuilder::new()
8771/// # .with_native_roots()
8772/// # .unwrap()
8773/// # .https_or_http()
8774/// # .enable_http2()
8775/// # .build()
8776/// # );
8777/// # let mut hub = CloudResourceManager::new(client, auth);
8778/// // As the method needs a request, you would usually fill it with the desired information
8779/// // into the respective structure. Some of the parts shown here might not be applicable !
8780/// // Values shown here are possibly random and not representative !
8781/// let mut req = SetOrgPolicyRequest::default();
8782///
8783/// // You can configure optional parameters by calling the respective setters at will, and
8784/// // execute the final call using `doit()`.
8785/// // Values shown here are possibly random and not representative !
8786/// let result = hub.organizations().set_org_policy(req, "resource")
8787/// .doit().await;
8788/// # }
8789/// ```
8790pub struct OrganizationSetOrgPolicyCall<'a, C>
8791where
8792 C: 'a,
8793{
8794 hub: &'a CloudResourceManager<C>,
8795 _request: SetOrgPolicyRequest,
8796 _resource: String,
8797 _delegate: Option<&'a mut dyn common::Delegate>,
8798 _additional_params: HashMap<String, String>,
8799 _scopes: BTreeSet<String>,
8800}
8801
8802impl<'a, C> common::CallBuilder for OrganizationSetOrgPolicyCall<'a, C> {}
8803
8804impl<'a, C> OrganizationSetOrgPolicyCall<'a, C>
8805where
8806 C: common::Connector,
8807{
8808 /// Perform the operation you have build so far.
8809 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
8810 use std::borrow::Cow;
8811 use std::io::{Read, Seek};
8812
8813 use common::{url::Params, ToParts};
8814 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8815
8816 let mut dd = common::DefaultDelegate;
8817 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8818 dlg.begin(common::MethodInfo {
8819 id: "cloudresourcemanager.organizations.setOrgPolicy",
8820 http_method: hyper::Method::POST,
8821 });
8822
8823 for &field in ["alt", "resource"].iter() {
8824 if self._additional_params.contains_key(field) {
8825 dlg.finished(false);
8826 return Err(common::Error::FieldClash(field));
8827 }
8828 }
8829
8830 let mut params = Params::with_capacity(4 + self._additional_params.len());
8831 params.push("resource", self._resource);
8832
8833 params.extend(self._additional_params.iter());
8834
8835 params.push("alt", "json");
8836 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setOrgPolicy";
8837 if self._scopes.is_empty() {
8838 self._scopes
8839 .insert(Scope::CloudPlatform.as_ref().to_string());
8840 }
8841
8842 #[allow(clippy::single_element_loop)]
8843 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8844 url = params.uri_replacement(url, param_name, find_this, true);
8845 }
8846 {
8847 let to_remove = ["resource"];
8848 params.remove_params(&to_remove);
8849 }
8850
8851 let url = params.parse_with_url(&url);
8852
8853 let mut json_mime_type = mime::APPLICATION_JSON;
8854 let mut request_value_reader = {
8855 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8856 common::remove_json_null_values(&mut value);
8857 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8858 serde_json::to_writer(&mut dst, &value).unwrap();
8859 dst
8860 };
8861 let request_size = request_value_reader
8862 .seek(std::io::SeekFrom::End(0))
8863 .unwrap();
8864 request_value_reader
8865 .seek(std::io::SeekFrom::Start(0))
8866 .unwrap();
8867
8868 loop {
8869 let token = match self
8870 .hub
8871 .auth
8872 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8873 .await
8874 {
8875 Ok(token) => token,
8876 Err(e) => match dlg.token(e) {
8877 Ok(token) => token,
8878 Err(e) => {
8879 dlg.finished(false);
8880 return Err(common::Error::MissingToken(e));
8881 }
8882 },
8883 };
8884 request_value_reader
8885 .seek(std::io::SeekFrom::Start(0))
8886 .unwrap();
8887 let mut req_result = {
8888 let client = &self.hub.client;
8889 dlg.pre_request();
8890 let mut req_builder = hyper::Request::builder()
8891 .method(hyper::Method::POST)
8892 .uri(url.as_str())
8893 .header(USER_AGENT, self.hub._user_agent.clone());
8894
8895 if let Some(token) = token.as_ref() {
8896 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8897 }
8898
8899 let request = req_builder
8900 .header(CONTENT_TYPE, json_mime_type.to_string())
8901 .header(CONTENT_LENGTH, request_size as u64)
8902 .body(common::to_body(
8903 request_value_reader.get_ref().clone().into(),
8904 ));
8905
8906 client.request(request.unwrap()).await
8907 };
8908
8909 match req_result {
8910 Err(err) => {
8911 if let common::Retry::After(d) = dlg.http_error(&err) {
8912 sleep(d).await;
8913 continue;
8914 }
8915 dlg.finished(false);
8916 return Err(common::Error::HttpError(err));
8917 }
8918 Ok(res) => {
8919 let (mut parts, body) = res.into_parts();
8920 let mut body = common::Body::new(body);
8921 if !parts.status.is_success() {
8922 let bytes = common::to_bytes(body).await.unwrap_or_default();
8923 let error = serde_json::from_str(&common::to_string(&bytes));
8924 let response = common::to_response(parts, bytes.into());
8925
8926 if let common::Retry::After(d) =
8927 dlg.http_failure(&response, error.as_ref().ok())
8928 {
8929 sleep(d).await;
8930 continue;
8931 }
8932
8933 dlg.finished(false);
8934
8935 return Err(match error {
8936 Ok(value) => common::Error::BadRequest(value),
8937 _ => common::Error::Failure(response),
8938 });
8939 }
8940 let response = {
8941 let bytes = common::to_bytes(body).await.unwrap_or_default();
8942 let encoded = common::to_string(&bytes);
8943 match serde_json::from_str(&encoded) {
8944 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8945 Err(error) => {
8946 dlg.response_json_decode_error(&encoded, &error);
8947 return Err(common::Error::JsonDecodeError(
8948 encoded.to_string(),
8949 error,
8950 ));
8951 }
8952 }
8953 };
8954
8955 dlg.finished(true);
8956 return Ok(response);
8957 }
8958 }
8959 }
8960 }
8961
8962 ///
8963 /// Sets the *request* property to the given value.
8964 ///
8965 /// Even though the property as already been set when instantiating this call,
8966 /// we provide this method for API completeness.
8967 pub fn request(
8968 mut self,
8969 new_value: SetOrgPolicyRequest,
8970 ) -> OrganizationSetOrgPolicyCall<'a, C> {
8971 self._request = new_value;
8972 self
8973 }
8974 /// Resource name of the resource to attach the `Policy`.
8975 ///
8976 /// Sets the *resource* path property to the given value.
8977 ///
8978 /// Even though the property as already been set when instantiating this call,
8979 /// we provide this method for API completeness.
8980 pub fn resource(mut self, new_value: &str) -> OrganizationSetOrgPolicyCall<'a, C> {
8981 self._resource = new_value.to_string();
8982 self
8983 }
8984 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8985 /// while executing the actual API request.
8986 ///
8987 /// ````text
8988 /// It should be used to handle progress information, and to implement a certain level of resilience.
8989 /// ````
8990 ///
8991 /// Sets the *delegate* property to the given value.
8992 pub fn delegate(
8993 mut self,
8994 new_value: &'a mut dyn common::Delegate,
8995 ) -> OrganizationSetOrgPolicyCall<'a, C> {
8996 self._delegate = Some(new_value);
8997 self
8998 }
8999
9000 /// Set any additional parameter of the query string used in the request.
9001 /// It should be used to set parameters which are not yet available through their own
9002 /// setters.
9003 ///
9004 /// Please note that this method must not be used to set any of the known parameters
9005 /// which have their own setter method. If done anyway, the request will fail.
9006 ///
9007 /// # Additional Parameters
9008 ///
9009 /// * *$.xgafv* (query-string) - V1 error format.
9010 /// * *access_token* (query-string) - OAuth access token.
9011 /// * *alt* (query-string) - Data format for response.
9012 /// * *callback* (query-string) - JSONP
9013 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9014 /// * *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.
9015 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9016 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9017 /// * *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.
9018 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9019 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9020 pub fn param<T>(mut self, name: T, value: T) -> OrganizationSetOrgPolicyCall<'a, C>
9021 where
9022 T: AsRef<str>,
9023 {
9024 self._additional_params
9025 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9026 self
9027 }
9028
9029 /// Identifies the authorization scope for the method you are building.
9030 ///
9031 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9032 /// [`Scope::CloudPlatform`].
9033 ///
9034 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9035 /// tokens for more than one scope.
9036 ///
9037 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9038 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9039 /// sufficient, a read-write scope will do as well.
9040 pub fn add_scope<St>(mut self, scope: St) -> OrganizationSetOrgPolicyCall<'a, C>
9041 where
9042 St: AsRef<str>,
9043 {
9044 self._scopes.insert(String::from(scope.as_ref()));
9045 self
9046 }
9047 /// Identifies the authorization scope(s) for the method you are building.
9048 ///
9049 /// See [`Self::add_scope()`] for details.
9050 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationSetOrgPolicyCall<'a, C>
9051 where
9052 I: IntoIterator<Item = St>,
9053 St: AsRef<str>,
9054 {
9055 self._scopes
9056 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9057 self
9058 }
9059
9060 /// Removes all scopes, and no default scope will be used either.
9061 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9062 /// for details).
9063 pub fn clear_scopes(mut self) -> OrganizationSetOrgPolicyCall<'a, C> {
9064 self._scopes.clear();
9065 self
9066 }
9067}
9068
9069/// Returns permissions that a caller has on the specified Organization. The `resource` field should be the organization's resource name, e.g. "organizations/123". There are no permissions required for making this API call.
9070///
9071/// A builder for the *testIamPermissions* method supported by a *organization* resource.
9072/// It is not used directly, but through a [`OrganizationMethods`] instance.
9073///
9074/// # Example
9075///
9076/// Instantiate a resource method builder
9077///
9078/// ```test_harness,no_run
9079/// # extern crate hyper;
9080/// # extern crate hyper_rustls;
9081/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
9082/// use cloudresourcemanager1::api::TestIamPermissionsRequest;
9083/// # async fn dox() {
9084/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9085///
9086/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9087/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9088/// # .with_native_roots()
9089/// # .unwrap()
9090/// # .https_only()
9091/// # .enable_http2()
9092/// # .build();
9093///
9094/// # let executor = hyper_util::rt::TokioExecutor::new();
9095/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9096/// # secret,
9097/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9098/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9099/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9100/// # ),
9101/// # ).build().await.unwrap();
9102///
9103/// # let client = hyper_util::client::legacy::Client::builder(
9104/// # hyper_util::rt::TokioExecutor::new()
9105/// # )
9106/// # .build(
9107/// # hyper_rustls::HttpsConnectorBuilder::new()
9108/// # .with_native_roots()
9109/// # .unwrap()
9110/// # .https_or_http()
9111/// # .enable_http2()
9112/// # .build()
9113/// # );
9114/// # let mut hub = CloudResourceManager::new(client, auth);
9115/// // As the method needs a request, you would usually fill it with the desired information
9116/// // into the respective structure. Some of the parts shown here might not be applicable !
9117/// // Values shown here are possibly random and not representative !
9118/// let mut req = TestIamPermissionsRequest::default();
9119///
9120/// // You can configure optional parameters by calling the respective setters at will, and
9121/// // execute the final call using `doit()`.
9122/// // Values shown here are possibly random and not representative !
9123/// let result = hub.organizations().test_iam_permissions(req, "resource")
9124/// .doit().await;
9125/// # }
9126/// ```
9127pub struct OrganizationTestIamPermissionCall<'a, C>
9128where
9129 C: 'a,
9130{
9131 hub: &'a CloudResourceManager<C>,
9132 _request: TestIamPermissionsRequest,
9133 _resource: String,
9134 _delegate: Option<&'a mut dyn common::Delegate>,
9135 _additional_params: HashMap<String, String>,
9136 _scopes: BTreeSet<String>,
9137}
9138
9139impl<'a, C> common::CallBuilder for OrganizationTestIamPermissionCall<'a, C> {}
9140
9141impl<'a, C> OrganizationTestIamPermissionCall<'a, C>
9142where
9143 C: common::Connector,
9144{
9145 /// Perform the operation you have build so far.
9146 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
9147 use std::borrow::Cow;
9148 use std::io::{Read, Seek};
9149
9150 use common::{url::Params, ToParts};
9151 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9152
9153 let mut dd = common::DefaultDelegate;
9154 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9155 dlg.begin(common::MethodInfo {
9156 id: "cloudresourcemanager.organizations.testIamPermissions",
9157 http_method: hyper::Method::POST,
9158 });
9159
9160 for &field in ["alt", "resource"].iter() {
9161 if self._additional_params.contains_key(field) {
9162 dlg.finished(false);
9163 return Err(common::Error::FieldClash(field));
9164 }
9165 }
9166
9167 let mut params = Params::with_capacity(4 + self._additional_params.len());
9168 params.push("resource", self._resource);
9169
9170 params.extend(self._additional_params.iter());
9171
9172 params.push("alt", "json");
9173 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
9174 if self._scopes.is_empty() {
9175 self._scopes
9176 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
9177 }
9178
9179 #[allow(clippy::single_element_loop)]
9180 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9181 url = params.uri_replacement(url, param_name, find_this, true);
9182 }
9183 {
9184 let to_remove = ["resource"];
9185 params.remove_params(&to_remove);
9186 }
9187
9188 let url = params.parse_with_url(&url);
9189
9190 let mut json_mime_type = mime::APPLICATION_JSON;
9191 let mut request_value_reader = {
9192 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9193 common::remove_json_null_values(&mut value);
9194 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9195 serde_json::to_writer(&mut dst, &value).unwrap();
9196 dst
9197 };
9198 let request_size = request_value_reader
9199 .seek(std::io::SeekFrom::End(0))
9200 .unwrap();
9201 request_value_reader
9202 .seek(std::io::SeekFrom::Start(0))
9203 .unwrap();
9204
9205 loop {
9206 let token = match self
9207 .hub
9208 .auth
9209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9210 .await
9211 {
9212 Ok(token) => token,
9213 Err(e) => match dlg.token(e) {
9214 Ok(token) => token,
9215 Err(e) => {
9216 dlg.finished(false);
9217 return Err(common::Error::MissingToken(e));
9218 }
9219 },
9220 };
9221 request_value_reader
9222 .seek(std::io::SeekFrom::Start(0))
9223 .unwrap();
9224 let mut req_result = {
9225 let client = &self.hub.client;
9226 dlg.pre_request();
9227 let mut req_builder = hyper::Request::builder()
9228 .method(hyper::Method::POST)
9229 .uri(url.as_str())
9230 .header(USER_AGENT, self.hub._user_agent.clone());
9231
9232 if let Some(token) = token.as_ref() {
9233 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9234 }
9235
9236 let request = req_builder
9237 .header(CONTENT_TYPE, json_mime_type.to_string())
9238 .header(CONTENT_LENGTH, request_size as u64)
9239 .body(common::to_body(
9240 request_value_reader.get_ref().clone().into(),
9241 ));
9242
9243 client.request(request.unwrap()).await
9244 };
9245
9246 match req_result {
9247 Err(err) => {
9248 if let common::Retry::After(d) = dlg.http_error(&err) {
9249 sleep(d).await;
9250 continue;
9251 }
9252 dlg.finished(false);
9253 return Err(common::Error::HttpError(err));
9254 }
9255 Ok(res) => {
9256 let (mut parts, body) = res.into_parts();
9257 let mut body = common::Body::new(body);
9258 if !parts.status.is_success() {
9259 let bytes = common::to_bytes(body).await.unwrap_or_default();
9260 let error = serde_json::from_str(&common::to_string(&bytes));
9261 let response = common::to_response(parts, bytes.into());
9262
9263 if let common::Retry::After(d) =
9264 dlg.http_failure(&response, error.as_ref().ok())
9265 {
9266 sleep(d).await;
9267 continue;
9268 }
9269
9270 dlg.finished(false);
9271
9272 return Err(match error {
9273 Ok(value) => common::Error::BadRequest(value),
9274 _ => common::Error::Failure(response),
9275 });
9276 }
9277 let response = {
9278 let bytes = common::to_bytes(body).await.unwrap_or_default();
9279 let encoded = common::to_string(&bytes);
9280 match serde_json::from_str(&encoded) {
9281 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9282 Err(error) => {
9283 dlg.response_json_decode_error(&encoded, &error);
9284 return Err(common::Error::JsonDecodeError(
9285 encoded.to_string(),
9286 error,
9287 ));
9288 }
9289 }
9290 };
9291
9292 dlg.finished(true);
9293 return Ok(response);
9294 }
9295 }
9296 }
9297 }
9298
9299 ///
9300 /// Sets the *request* property to the given value.
9301 ///
9302 /// Even though the property as already been set when instantiating this call,
9303 /// we provide this method for API completeness.
9304 pub fn request(
9305 mut self,
9306 new_value: TestIamPermissionsRequest,
9307 ) -> OrganizationTestIamPermissionCall<'a, C> {
9308 self._request = new_value;
9309 self
9310 }
9311 /// 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.
9312 ///
9313 /// Sets the *resource* path property to the given value.
9314 ///
9315 /// Even though the property as already been set when instantiating this call,
9316 /// we provide this method for API completeness.
9317 pub fn resource(mut self, new_value: &str) -> OrganizationTestIamPermissionCall<'a, C> {
9318 self._resource = new_value.to_string();
9319 self
9320 }
9321 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9322 /// while executing the actual API request.
9323 ///
9324 /// ````text
9325 /// It should be used to handle progress information, and to implement a certain level of resilience.
9326 /// ````
9327 ///
9328 /// Sets the *delegate* property to the given value.
9329 pub fn delegate(
9330 mut self,
9331 new_value: &'a mut dyn common::Delegate,
9332 ) -> OrganizationTestIamPermissionCall<'a, C> {
9333 self._delegate = Some(new_value);
9334 self
9335 }
9336
9337 /// Set any additional parameter of the query string used in the request.
9338 /// It should be used to set parameters which are not yet available through their own
9339 /// setters.
9340 ///
9341 /// Please note that this method must not be used to set any of the known parameters
9342 /// which have their own setter method. If done anyway, the request will fail.
9343 ///
9344 /// # Additional Parameters
9345 ///
9346 /// * *$.xgafv* (query-string) - V1 error format.
9347 /// * *access_token* (query-string) - OAuth access token.
9348 /// * *alt* (query-string) - Data format for response.
9349 /// * *callback* (query-string) - JSONP
9350 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9351 /// * *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.
9352 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9353 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9354 /// * *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.
9355 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9356 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9357 pub fn param<T>(mut self, name: T, value: T) -> OrganizationTestIamPermissionCall<'a, C>
9358 where
9359 T: AsRef<str>,
9360 {
9361 self._additional_params
9362 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9363 self
9364 }
9365
9366 /// Identifies the authorization scope for the method you are building.
9367 ///
9368 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9369 /// [`Scope::CloudPlatformReadOnly`].
9370 ///
9371 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9372 /// tokens for more than one scope.
9373 ///
9374 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9375 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9376 /// sufficient, a read-write scope will do as well.
9377 pub fn add_scope<St>(mut self, scope: St) -> OrganizationTestIamPermissionCall<'a, C>
9378 where
9379 St: AsRef<str>,
9380 {
9381 self._scopes.insert(String::from(scope.as_ref()));
9382 self
9383 }
9384 /// Identifies the authorization scope(s) for the method you are building.
9385 ///
9386 /// See [`Self::add_scope()`] for details.
9387 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationTestIamPermissionCall<'a, C>
9388 where
9389 I: IntoIterator<Item = St>,
9390 St: AsRef<str>,
9391 {
9392 self._scopes
9393 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9394 self
9395 }
9396
9397 /// Removes all scopes, and no default scope will be used either.
9398 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9399 /// for details).
9400 pub fn clear_scopes(mut self) -> OrganizationTestIamPermissionCall<'a, C> {
9401 self._scopes.clear();
9402 self
9403 }
9404}
9405
9406/// Clears a `Policy` from a resource.
9407///
9408/// A builder for the *clearOrgPolicy* method supported by a *project* resource.
9409/// It is not used directly, but through a [`ProjectMethods`] instance.
9410///
9411/// # Example
9412///
9413/// Instantiate a resource method builder
9414///
9415/// ```test_harness,no_run
9416/// # extern crate hyper;
9417/// # extern crate hyper_rustls;
9418/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
9419/// use cloudresourcemanager1::api::ClearOrgPolicyRequest;
9420/// # async fn dox() {
9421/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9422///
9423/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9424/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9425/// # .with_native_roots()
9426/// # .unwrap()
9427/// # .https_only()
9428/// # .enable_http2()
9429/// # .build();
9430///
9431/// # let executor = hyper_util::rt::TokioExecutor::new();
9432/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9433/// # secret,
9434/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9435/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9436/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9437/// # ),
9438/// # ).build().await.unwrap();
9439///
9440/// # let client = hyper_util::client::legacy::Client::builder(
9441/// # hyper_util::rt::TokioExecutor::new()
9442/// # )
9443/// # .build(
9444/// # hyper_rustls::HttpsConnectorBuilder::new()
9445/// # .with_native_roots()
9446/// # .unwrap()
9447/// # .https_or_http()
9448/// # .enable_http2()
9449/// # .build()
9450/// # );
9451/// # let mut hub = CloudResourceManager::new(client, auth);
9452/// // As the method needs a request, you would usually fill it with the desired information
9453/// // into the respective structure. Some of the parts shown here might not be applicable !
9454/// // Values shown here are possibly random and not representative !
9455/// let mut req = ClearOrgPolicyRequest::default();
9456///
9457/// // You can configure optional parameters by calling the respective setters at will, and
9458/// // execute the final call using `doit()`.
9459/// // Values shown here are possibly random and not representative !
9460/// let result = hub.projects().clear_org_policy(req, "resource")
9461/// .doit().await;
9462/// # }
9463/// ```
9464pub struct ProjectClearOrgPolicyCall<'a, C>
9465where
9466 C: 'a,
9467{
9468 hub: &'a CloudResourceManager<C>,
9469 _request: ClearOrgPolicyRequest,
9470 _resource: String,
9471 _delegate: Option<&'a mut dyn common::Delegate>,
9472 _additional_params: HashMap<String, String>,
9473 _scopes: BTreeSet<String>,
9474}
9475
9476impl<'a, C> common::CallBuilder for ProjectClearOrgPolicyCall<'a, C> {}
9477
9478impl<'a, C> ProjectClearOrgPolicyCall<'a, C>
9479where
9480 C: common::Connector,
9481{
9482 /// Perform the operation you have build so far.
9483 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9484 use std::borrow::Cow;
9485 use std::io::{Read, Seek};
9486
9487 use common::{url::Params, ToParts};
9488 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9489
9490 let mut dd = common::DefaultDelegate;
9491 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9492 dlg.begin(common::MethodInfo {
9493 id: "cloudresourcemanager.projects.clearOrgPolicy",
9494 http_method: hyper::Method::POST,
9495 });
9496
9497 for &field in ["alt", "resource"].iter() {
9498 if self._additional_params.contains_key(field) {
9499 dlg.finished(false);
9500 return Err(common::Error::FieldClash(field));
9501 }
9502 }
9503
9504 let mut params = Params::with_capacity(4 + self._additional_params.len());
9505 params.push("resource", self._resource);
9506
9507 params.extend(self._additional_params.iter());
9508
9509 params.push("alt", "json");
9510 let mut url = self.hub._base_url.clone() + "v1/{+resource}:clearOrgPolicy";
9511 if self._scopes.is_empty() {
9512 self._scopes
9513 .insert(Scope::CloudPlatform.as_ref().to_string());
9514 }
9515
9516 #[allow(clippy::single_element_loop)]
9517 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9518 url = params.uri_replacement(url, param_name, find_this, true);
9519 }
9520 {
9521 let to_remove = ["resource"];
9522 params.remove_params(&to_remove);
9523 }
9524
9525 let url = params.parse_with_url(&url);
9526
9527 let mut json_mime_type = mime::APPLICATION_JSON;
9528 let mut request_value_reader = {
9529 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9530 common::remove_json_null_values(&mut value);
9531 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9532 serde_json::to_writer(&mut dst, &value).unwrap();
9533 dst
9534 };
9535 let request_size = request_value_reader
9536 .seek(std::io::SeekFrom::End(0))
9537 .unwrap();
9538 request_value_reader
9539 .seek(std::io::SeekFrom::Start(0))
9540 .unwrap();
9541
9542 loop {
9543 let token = match self
9544 .hub
9545 .auth
9546 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9547 .await
9548 {
9549 Ok(token) => token,
9550 Err(e) => match dlg.token(e) {
9551 Ok(token) => token,
9552 Err(e) => {
9553 dlg.finished(false);
9554 return Err(common::Error::MissingToken(e));
9555 }
9556 },
9557 };
9558 request_value_reader
9559 .seek(std::io::SeekFrom::Start(0))
9560 .unwrap();
9561 let mut req_result = {
9562 let client = &self.hub.client;
9563 dlg.pre_request();
9564 let mut req_builder = hyper::Request::builder()
9565 .method(hyper::Method::POST)
9566 .uri(url.as_str())
9567 .header(USER_AGENT, self.hub._user_agent.clone());
9568
9569 if let Some(token) = token.as_ref() {
9570 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9571 }
9572
9573 let request = req_builder
9574 .header(CONTENT_TYPE, json_mime_type.to_string())
9575 .header(CONTENT_LENGTH, request_size as u64)
9576 .body(common::to_body(
9577 request_value_reader.get_ref().clone().into(),
9578 ));
9579
9580 client.request(request.unwrap()).await
9581 };
9582
9583 match req_result {
9584 Err(err) => {
9585 if let common::Retry::After(d) = dlg.http_error(&err) {
9586 sleep(d).await;
9587 continue;
9588 }
9589 dlg.finished(false);
9590 return Err(common::Error::HttpError(err));
9591 }
9592 Ok(res) => {
9593 let (mut parts, body) = res.into_parts();
9594 let mut body = common::Body::new(body);
9595 if !parts.status.is_success() {
9596 let bytes = common::to_bytes(body).await.unwrap_or_default();
9597 let error = serde_json::from_str(&common::to_string(&bytes));
9598 let response = common::to_response(parts, bytes.into());
9599
9600 if let common::Retry::After(d) =
9601 dlg.http_failure(&response, error.as_ref().ok())
9602 {
9603 sleep(d).await;
9604 continue;
9605 }
9606
9607 dlg.finished(false);
9608
9609 return Err(match error {
9610 Ok(value) => common::Error::BadRequest(value),
9611 _ => common::Error::Failure(response),
9612 });
9613 }
9614 let response = {
9615 let bytes = common::to_bytes(body).await.unwrap_or_default();
9616 let encoded = common::to_string(&bytes);
9617 match serde_json::from_str(&encoded) {
9618 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9619 Err(error) => {
9620 dlg.response_json_decode_error(&encoded, &error);
9621 return Err(common::Error::JsonDecodeError(
9622 encoded.to_string(),
9623 error,
9624 ));
9625 }
9626 }
9627 };
9628
9629 dlg.finished(true);
9630 return Ok(response);
9631 }
9632 }
9633 }
9634 }
9635
9636 ///
9637 /// Sets the *request* property to the given value.
9638 ///
9639 /// Even though the property as already been set when instantiating this call,
9640 /// we provide this method for API completeness.
9641 pub fn request(mut self, new_value: ClearOrgPolicyRequest) -> ProjectClearOrgPolicyCall<'a, C> {
9642 self._request = new_value;
9643 self
9644 }
9645 /// Name of the resource for the `Policy` to clear.
9646 ///
9647 /// Sets the *resource* path property to the given value.
9648 ///
9649 /// Even though the property as already been set when instantiating this call,
9650 /// we provide this method for API completeness.
9651 pub fn resource(mut self, new_value: &str) -> ProjectClearOrgPolicyCall<'a, C> {
9652 self._resource = new_value.to_string();
9653 self
9654 }
9655 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9656 /// while executing the actual API request.
9657 ///
9658 /// ````text
9659 /// It should be used to handle progress information, and to implement a certain level of resilience.
9660 /// ````
9661 ///
9662 /// Sets the *delegate* property to the given value.
9663 pub fn delegate(
9664 mut self,
9665 new_value: &'a mut dyn common::Delegate,
9666 ) -> ProjectClearOrgPolicyCall<'a, C> {
9667 self._delegate = Some(new_value);
9668 self
9669 }
9670
9671 /// Set any additional parameter of the query string used in the request.
9672 /// It should be used to set parameters which are not yet available through their own
9673 /// setters.
9674 ///
9675 /// Please note that this method must not be used to set any of the known parameters
9676 /// which have their own setter method. If done anyway, the request will fail.
9677 ///
9678 /// # Additional Parameters
9679 ///
9680 /// * *$.xgafv* (query-string) - V1 error format.
9681 /// * *access_token* (query-string) - OAuth access token.
9682 /// * *alt* (query-string) - Data format for response.
9683 /// * *callback* (query-string) - JSONP
9684 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9685 /// * *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.
9686 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9687 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9688 /// * *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.
9689 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9690 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9691 pub fn param<T>(mut self, name: T, value: T) -> ProjectClearOrgPolicyCall<'a, C>
9692 where
9693 T: AsRef<str>,
9694 {
9695 self._additional_params
9696 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9697 self
9698 }
9699
9700 /// Identifies the authorization scope for the method you are building.
9701 ///
9702 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9703 /// [`Scope::CloudPlatform`].
9704 ///
9705 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9706 /// tokens for more than one scope.
9707 ///
9708 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9709 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9710 /// sufficient, a read-write scope will do as well.
9711 pub fn add_scope<St>(mut self, scope: St) -> ProjectClearOrgPolicyCall<'a, C>
9712 where
9713 St: AsRef<str>,
9714 {
9715 self._scopes.insert(String::from(scope.as_ref()));
9716 self
9717 }
9718 /// Identifies the authorization scope(s) for the method you are building.
9719 ///
9720 /// See [`Self::add_scope()`] for details.
9721 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectClearOrgPolicyCall<'a, C>
9722 where
9723 I: IntoIterator<Item = St>,
9724 St: AsRef<str>,
9725 {
9726 self._scopes
9727 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9728 self
9729 }
9730
9731 /// Removes all scopes, and no default scope will be used either.
9732 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9733 /// for details).
9734 pub fn clear_scopes(mut self) -> ProjectClearOrgPolicyCall<'a, C> {
9735 self._scopes.clear();
9736 self
9737 }
9738}
9739
9740/// Request that a new Project be created. The result is an Operation which can be used to track the creation process. This process usually takes a few seconds, but can sometimes take much longer. The tracking Operation is automatically deleted after a few hours, so there is no need to call DeleteOperation. Authorization requires the Google IAM permission `resourcemanager.projects.create` on the specified parent for the new project. The parent is identified by a specified ResourceId, which must include both an ID and a type, such as organization. This method does not associate the new project with a billing account. You can set or update the billing account associated with a project using the \[`projects.updateBillingInfo`\] (/billing/reference/rest/v1/projects/updateBillingInfo) method.
9741///
9742/// A builder for the *create* method supported by a *project* resource.
9743/// It is not used directly, but through a [`ProjectMethods`] instance.
9744///
9745/// # Example
9746///
9747/// Instantiate a resource method builder
9748///
9749/// ```test_harness,no_run
9750/// # extern crate hyper;
9751/// # extern crate hyper_rustls;
9752/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
9753/// use cloudresourcemanager1::api::Project;
9754/// # async fn dox() {
9755/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9756///
9757/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9758/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9759/// # .with_native_roots()
9760/// # .unwrap()
9761/// # .https_only()
9762/// # .enable_http2()
9763/// # .build();
9764///
9765/// # let executor = hyper_util::rt::TokioExecutor::new();
9766/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9767/// # secret,
9768/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9769/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9770/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9771/// # ),
9772/// # ).build().await.unwrap();
9773///
9774/// # let client = hyper_util::client::legacy::Client::builder(
9775/// # hyper_util::rt::TokioExecutor::new()
9776/// # )
9777/// # .build(
9778/// # hyper_rustls::HttpsConnectorBuilder::new()
9779/// # .with_native_roots()
9780/// # .unwrap()
9781/// # .https_or_http()
9782/// # .enable_http2()
9783/// # .build()
9784/// # );
9785/// # let mut hub = CloudResourceManager::new(client, auth);
9786/// // As the method needs a request, you would usually fill it with the desired information
9787/// // into the respective structure. Some of the parts shown here might not be applicable !
9788/// // Values shown here are possibly random and not representative !
9789/// let mut req = Project::default();
9790///
9791/// // You can configure optional parameters by calling the respective setters at will, and
9792/// // execute the final call using `doit()`.
9793/// // Values shown here are possibly random and not representative !
9794/// let result = hub.projects().create(req)
9795/// .doit().await;
9796/// # }
9797/// ```
9798pub struct ProjectCreateCall<'a, C>
9799where
9800 C: 'a,
9801{
9802 hub: &'a CloudResourceManager<C>,
9803 _request: Project,
9804 _delegate: Option<&'a mut dyn common::Delegate>,
9805 _additional_params: HashMap<String, String>,
9806 _scopes: BTreeSet<String>,
9807}
9808
9809impl<'a, C> common::CallBuilder for ProjectCreateCall<'a, C> {}
9810
9811impl<'a, C> ProjectCreateCall<'a, C>
9812where
9813 C: common::Connector,
9814{
9815 /// Perform the operation you have build so far.
9816 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9817 use std::borrow::Cow;
9818 use std::io::{Read, Seek};
9819
9820 use common::{url::Params, ToParts};
9821 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9822
9823 let mut dd = common::DefaultDelegate;
9824 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9825 dlg.begin(common::MethodInfo {
9826 id: "cloudresourcemanager.projects.create",
9827 http_method: hyper::Method::POST,
9828 });
9829
9830 for &field in ["alt"].iter() {
9831 if self._additional_params.contains_key(field) {
9832 dlg.finished(false);
9833 return Err(common::Error::FieldClash(field));
9834 }
9835 }
9836
9837 let mut params = Params::with_capacity(3 + self._additional_params.len());
9838
9839 params.extend(self._additional_params.iter());
9840
9841 params.push("alt", "json");
9842 let mut url = self.hub._base_url.clone() + "v1/projects";
9843 if self._scopes.is_empty() {
9844 self._scopes
9845 .insert(Scope::CloudPlatform.as_ref().to_string());
9846 }
9847
9848 let url = params.parse_with_url(&url);
9849
9850 let mut json_mime_type = mime::APPLICATION_JSON;
9851 let mut request_value_reader = {
9852 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9853 common::remove_json_null_values(&mut value);
9854 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9855 serde_json::to_writer(&mut dst, &value).unwrap();
9856 dst
9857 };
9858 let request_size = request_value_reader
9859 .seek(std::io::SeekFrom::End(0))
9860 .unwrap();
9861 request_value_reader
9862 .seek(std::io::SeekFrom::Start(0))
9863 .unwrap();
9864
9865 loop {
9866 let token = match self
9867 .hub
9868 .auth
9869 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9870 .await
9871 {
9872 Ok(token) => token,
9873 Err(e) => match dlg.token(e) {
9874 Ok(token) => token,
9875 Err(e) => {
9876 dlg.finished(false);
9877 return Err(common::Error::MissingToken(e));
9878 }
9879 },
9880 };
9881 request_value_reader
9882 .seek(std::io::SeekFrom::Start(0))
9883 .unwrap();
9884 let mut req_result = {
9885 let client = &self.hub.client;
9886 dlg.pre_request();
9887 let mut req_builder = hyper::Request::builder()
9888 .method(hyper::Method::POST)
9889 .uri(url.as_str())
9890 .header(USER_AGENT, self.hub._user_agent.clone());
9891
9892 if let Some(token) = token.as_ref() {
9893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9894 }
9895
9896 let request = req_builder
9897 .header(CONTENT_TYPE, json_mime_type.to_string())
9898 .header(CONTENT_LENGTH, request_size as u64)
9899 .body(common::to_body(
9900 request_value_reader.get_ref().clone().into(),
9901 ));
9902
9903 client.request(request.unwrap()).await
9904 };
9905
9906 match req_result {
9907 Err(err) => {
9908 if let common::Retry::After(d) = dlg.http_error(&err) {
9909 sleep(d).await;
9910 continue;
9911 }
9912 dlg.finished(false);
9913 return Err(common::Error::HttpError(err));
9914 }
9915 Ok(res) => {
9916 let (mut parts, body) = res.into_parts();
9917 let mut body = common::Body::new(body);
9918 if !parts.status.is_success() {
9919 let bytes = common::to_bytes(body).await.unwrap_or_default();
9920 let error = serde_json::from_str(&common::to_string(&bytes));
9921 let response = common::to_response(parts, bytes.into());
9922
9923 if let common::Retry::After(d) =
9924 dlg.http_failure(&response, error.as_ref().ok())
9925 {
9926 sleep(d).await;
9927 continue;
9928 }
9929
9930 dlg.finished(false);
9931
9932 return Err(match error {
9933 Ok(value) => common::Error::BadRequest(value),
9934 _ => common::Error::Failure(response),
9935 });
9936 }
9937 let response = {
9938 let bytes = common::to_bytes(body).await.unwrap_or_default();
9939 let encoded = common::to_string(&bytes);
9940 match serde_json::from_str(&encoded) {
9941 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9942 Err(error) => {
9943 dlg.response_json_decode_error(&encoded, &error);
9944 return Err(common::Error::JsonDecodeError(
9945 encoded.to_string(),
9946 error,
9947 ));
9948 }
9949 }
9950 };
9951
9952 dlg.finished(true);
9953 return Ok(response);
9954 }
9955 }
9956 }
9957 }
9958
9959 ///
9960 /// Sets the *request* property to the given value.
9961 ///
9962 /// Even though the property as already been set when instantiating this call,
9963 /// we provide this method for API completeness.
9964 pub fn request(mut self, new_value: Project) -> ProjectCreateCall<'a, C> {
9965 self._request = new_value;
9966 self
9967 }
9968 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9969 /// while executing the actual API request.
9970 ///
9971 /// ````text
9972 /// It should be used to handle progress information, and to implement a certain level of resilience.
9973 /// ````
9974 ///
9975 /// Sets the *delegate* property to the given value.
9976 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectCreateCall<'a, C> {
9977 self._delegate = Some(new_value);
9978 self
9979 }
9980
9981 /// Set any additional parameter of the query string used in the request.
9982 /// It should be used to set parameters which are not yet available through their own
9983 /// setters.
9984 ///
9985 /// Please note that this method must not be used to set any of the known parameters
9986 /// which have their own setter method. If done anyway, the request will fail.
9987 ///
9988 /// # Additional Parameters
9989 ///
9990 /// * *$.xgafv* (query-string) - V1 error format.
9991 /// * *access_token* (query-string) - OAuth access token.
9992 /// * *alt* (query-string) - Data format for response.
9993 /// * *callback* (query-string) - JSONP
9994 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9995 /// * *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.
9996 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9997 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9998 /// * *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.
9999 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10000 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10001 pub fn param<T>(mut self, name: T, value: T) -> ProjectCreateCall<'a, C>
10002 where
10003 T: AsRef<str>,
10004 {
10005 self._additional_params
10006 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10007 self
10008 }
10009
10010 /// Identifies the authorization scope for the method you are building.
10011 ///
10012 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10013 /// [`Scope::CloudPlatform`].
10014 ///
10015 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10016 /// tokens for more than one scope.
10017 ///
10018 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10019 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10020 /// sufficient, a read-write scope will do as well.
10021 pub fn add_scope<St>(mut self, scope: St) -> ProjectCreateCall<'a, C>
10022 where
10023 St: AsRef<str>,
10024 {
10025 self._scopes.insert(String::from(scope.as_ref()));
10026 self
10027 }
10028 /// Identifies the authorization scope(s) for the method you are building.
10029 ///
10030 /// See [`Self::add_scope()`] for details.
10031 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectCreateCall<'a, C>
10032 where
10033 I: IntoIterator<Item = St>,
10034 St: AsRef<str>,
10035 {
10036 self._scopes
10037 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10038 self
10039 }
10040
10041 /// Removes all scopes, and no default scope will be used either.
10042 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10043 /// for details).
10044 pub fn clear_scopes(mut self) -> ProjectCreateCall<'a, C> {
10045 self._scopes.clear();
10046 self
10047 }
10048}
10049
10050/// Marks the Project identified by the specified `project_id` (for example, `my-project-123`) for deletion. This method will only affect the Project if it has a lifecycle state of ACTIVE. This method changes the Project's lifecycle state from ACTIVE to DELETE_REQUESTED. The deletion starts at an unspecified time, at which point the Project is no longer accessible. Until the deletion completes, you can check the lifecycle state checked by retrieving the Project with GetProject, and the Project remains visible to ListProjects. However, you cannot update the project. After the deletion completes, the Project is not retrievable by the GetProject and ListProjects methods. The caller must have delete permissions for this Project.
10051///
10052/// A builder for the *delete* method supported by a *project* resource.
10053/// It is not used directly, but through a [`ProjectMethods`] instance.
10054///
10055/// # Example
10056///
10057/// Instantiate a resource method builder
10058///
10059/// ```test_harness,no_run
10060/// # extern crate hyper;
10061/// # extern crate hyper_rustls;
10062/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10063/// # async fn dox() {
10064/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10065///
10066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10068/// # .with_native_roots()
10069/// # .unwrap()
10070/// # .https_only()
10071/// # .enable_http2()
10072/// # .build();
10073///
10074/// # let executor = hyper_util::rt::TokioExecutor::new();
10075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10076/// # secret,
10077/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10078/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10079/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10080/// # ),
10081/// # ).build().await.unwrap();
10082///
10083/// # let client = hyper_util::client::legacy::Client::builder(
10084/// # hyper_util::rt::TokioExecutor::new()
10085/// # )
10086/// # .build(
10087/// # hyper_rustls::HttpsConnectorBuilder::new()
10088/// # .with_native_roots()
10089/// # .unwrap()
10090/// # .https_or_http()
10091/// # .enable_http2()
10092/// # .build()
10093/// # );
10094/// # let mut hub = CloudResourceManager::new(client, auth);
10095/// // You can configure optional parameters by calling the respective setters at will, and
10096/// // execute the final call using `doit()`.
10097/// // Values shown here are possibly random and not representative !
10098/// let result = hub.projects().delete("projectId")
10099/// .doit().await;
10100/// # }
10101/// ```
10102pub struct ProjectDeleteCall<'a, C>
10103where
10104 C: 'a,
10105{
10106 hub: &'a CloudResourceManager<C>,
10107 _project_id: String,
10108 _delegate: Option<&'a mut dyn common::Delegate>,
10109 _additional_params: HashMap<String, String>,
10110 _scopes: BTreeSet<String>,
10111}
10112
10113impl<'a, C> common::CallBuilder for ProjectDeleteCall<'a, C> {}
10114
10115impl<'a, C> ProjectDeleteCall<'a, C>
10116where
10117 C: common::Connector,
10118{
10119 /// Perform the operation you have build so far.
10120 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
10121 use std::borrow::Cow;
10122 use std::io::{Read, Seek};
10123
10124 use common::{url::Params, ToParts};
10125 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10126
10127 let mut dd = common::DefaultDelegate;
10128 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10129 dlg.begin(common::MethodInfo {
10130 id: "cloudresourcemanager.projects.delete",
10131 http_method: hyper::Method::DELETE,
10132 });
10133
10134 for &field in ["alt", "projectId"].iter() {
10135 if self._additional_params.contains_key(field) {
10136 dlg.finished(false);
10137 return Err(common::Error::FieldClash(field));
10138 }
10139 }
10140
10141 let mut params = Params::with_capacity(3 + self._additional_params.len());
10142 params.push("projectId", self._project_id);
10143
10144 params.extend(self._additional_params.iter());
10145
10146 params.push("alt", "json");
10147 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}";
10148 if self._scopes.is_empty() {
10149 self._scopes
10150 .insert(Scope::CloudPlatform.as_ref().to_string());
10151 }
10152
10153 #[allow(clippy::single_element_loop)]
10154 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
10155 url = params.uri_replacement(url, param_name, find_this, false);
10156 }
10157 {
10158 let to_remove = ["projectId"];
10159 params.remove_params(&to_remove);
10160 }
10161
10162 let url = params.parse_with_url(&url);
10163
10164 loop {
10165 let token = match self
10166 .hub
10167 .auth
10168 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10169 .await
10170 {
10171 Ok(token) => token,
10172 Err(e) => match dlg.token(e) {
10173 Ok(token) => token,
10174 Err(e) => {
10175 dlg.finished(false);
10176 return Err(common::Error::MissingToken(e));
10177 }
10178 },
10179 };
10180 let mut req_result = {
10181 let client = &self.hub.client;
10182 dlg.pre_request();
10183 let mut req_builder = hyper::Request::builder()
10184 .method(hyper::Method::DELETE)
10185 .uri(url.as_str())
10186 .header(USER_AGENT, self.hub._user_agent.clone());
10187
10188 if let Some(token) = token.as_ref() {
10189 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10190 }
10191
10192 let request = req_builder
10193 .header(CONTENT_LENGTH, 0_u64)
10194 .body(common::to_body::<String>(None));
10195
10196 client.request(request.unwrap()).await
10197 };
10198
10199 match req_result {
10200 Err(err) => {
10201 if let common::Retry::After(d) = dlg.http_error(&err) {
10202 sleep(d).await;
10203 continue;
10204 }
10205 dlg.finished(false);
10206 return Err(common::Error::HttpError(err));
10207 }
10208 Ok(res) => {
10209 let (mut parts, body) = res.into_parts();
10210 let mut body = common::Body::new(body);
10211 if !parts.status.is_success() {
10212 let bytes = common::to_bytes(body).await.unwrap_or_default();
10213 let error = serde_json::from_str(&common::to_string(&bytes));
10214 let response = common::to_response(parts, bytes.into());
10215
10216 if let common::Retry::After(d) =
10217 dlg.http_failure(&response, error.as_ref().ok())
10218 {
10219 sleep(d).await;
10220 continue;
10221 }
10222
10223 dlg.finished(false);
10224
10225 return Err(match error {
10226 Ok(value) => common::Error::BadRequest(value),
10227 _ => common::Error::Failure(response),
10228 });
10229 }
10230 let response = {
10231 let bytes = common::to_bytes(body).await.unwrap_or_default();
10232 let encoded = common::to_string(&bytes);
10233 match serde_json::from_str(&encoded) {
10234 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10235 Err(error) => {
10236 dlg.response_json_decode_error(&encoded, &error);
10237 return Err(common::Error::JsonDecodeError(
10238 encoded.to_string(),
10239 error,
10240 ));
10241 }
10242 }
10243 };
10244
10245 dlg.finished(true);
10246 return Ok(response);
10247 }
10248 }
10249 }
10250 }
10251
10252 /// The Project ID (for example, `foo-bar-123`). Required.
10253 ///
10254 /// Sets the *project id* path property to the given value.
10255 ///
10256 /// Even though the property as already been set when instantiating this call,
10257 /// we provide this method for API completeness.
10258 pub fn project_id(mut self, new_value: &str) -> ProjectDeleteCall<'a, C> {
10259 self._project_id = new_value.to_string();
10260 self
10261 }
10262 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10263 /// while executing the actual API request.
10264 ///
10265 /// ````text
10266 /// It should be used to handle progress information, and to implement a certain level of resilience.
10267 /// ````
10268 ///
10269 /// Sets the *delegate* property to the given value.
10270 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectDeleteCall<'a, C> {
10271 self._delegate = Some(new_value);
10272 self
10273 }
10274
10275 /// Set any additional parameter of the query string used in the request.
10276 /// It should be used to set parameters which are not yet available through their own
10277 /// setters.
10278 ///
10279 /// Please note that this method must not be used to set any of the known parameters
10280 /// which have their own setter method. If done anyway, the request will fail.
10281 ///
10282 /// # Additional Parameters
10283 ///
10284 /// * *$.xgafv* (query-string) - V1 error format.
10285 /// * *access_token* (query-string) - OAuth access token.
10286 /// * *alt* (query-string) - Data format for response.
10287 /// * *callback* (query-string) - JSONP
10288 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10289 /// * *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.
10290 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10291 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10292 /// * *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.
10293 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10294 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10295 pub fn param<T>(mut self, name: T, value: T) -> ProjectDeleteCall<'a, C>
10296 where
10297 T: AsRef<str>,
10298 {
10299 self._additional_params
10300 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10301 self
10302 }
10303
10304 /// Identifies the authorization scope for the method you are building.
10305 ///
10306 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10307 /// [`Scope::CloudPlatform`].
10308 ///
10309 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10310 /// tokens for more than one scope.
10311 ///
10312 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10313 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10314 /// sufficient, a read-write scope will do as well.
10315 pub fn add_scope<St>(mut self, scope: St) -> ProjectDeleteCall<'a, C>
10316 where
10317 St: AsRef<str>,
10318 {
10319 self._scopes.insert(String::from(scope.as_ref()));
10320 self
10321 }
10322 /// Identifies the authorization scope(s) for the method you are building.
10323 ///
10324 /// See [`Self::add_scope()`] for details.
10325 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectDeleteCall<'a, C>
10326 where
10327 I: IntoIterator<Item = St>,
10328 St: AsRef<str>,
10329 {
10330 self._scopes
10331 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10332 self
10333 }
10334
10335 /// Removes all scopes, and no default scope will be used either.
10336 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10337 /// for details).
10338 pub fn clear_scopes(mut self) -> ProjectDeleteCall<'a, C> {
10339 self._scopes.clear();
10340 self
10341 }
10342}
10343
10344/// Retrieves the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
10345///
10346/// A builder for the *get* method supported by a *project* resource.
10347/// It is not used directly, but through a [`ProjectMethods`] instance.
10348///
10349/// # Example
10350///
10351/// Instantiate a resource method builder
10352///
10353/// ```test_harness,no_run
10354/// # extern crate hyper;
10355/// # extern crate hyper_rustls;
10356/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10357/// # async fn dox() {
10358/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10359///
10360/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10361/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10362/// # .with_native_roots()
10363/// # .unwrap()
10364/// # .https_only()
10365/// # .enable_http2()
10366/// # .build();
10367///
10368/// # let executor = hyper_util::rt::TokioExecutor::new();
10369/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10370/// # secret,
10371/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10372/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10373/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10374/// # ),
10375/// # ).build().await.unwrap();
10376///
10377/// # let client = hyper_util::client::legacy::Client::builder(
10378/// # hyper_util::rt::TokioExecutor::new()
10379/// # )
10380/// # .build(
10381/// # hyper_rustls::HttpsConnectorBuilder::new()
10382/// # .with_native_roots()
10383/// # .unwrap()
10384/// # .https_or_http()
10385/// # .enable_http2()
10386/// # .build()
10387/// # );
10388/// # let mut hub = CloudResourceManager::new(client, auth);
10389/// // You can configure optional parameters by calling the respective setters at will, and
10390/// // execute the final call using `doit()`.
10391/// // Values shown here are possibly random and not representative !
10392/// let result = hub.projects().get("projectId")
10393/// .doit().await;
10394/// # }
10395/// ```
10396pub struct ProjectGetCall<'a, C>
10397where
10398 C: 'a,
10399{
10400 hub: &'a CloudResourceManager<C>,
10401 _project_id: String,
10402 _delegate: Option<&'a mut dyn common::Delegate>,
10403 _additional_params: HashMap<String, String>,
10404 _scopes: BTreeSet<String>,
10405}
10406
10407impl<'a, C> common::CallBuilder for ProjectGetCall<'a, C> {}
10408
10409impl<'a, C> ProjectGetCall<'a, C>
10410where
10411 C: common::Connector,
10412{
10413 /// Perform the operation you have build so far.
10414 pub async fn doit(mut self) -> common::Result<(common::Response, Project)> {
10415 use std::borrow::Cow;
10416 use std::io::{Read, Seek};
10417
10418 use common::{url::Params, ToParts};
10419 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10420
10421 let mut dd = common::DefaultDelegate;
10422 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10423 dlg.begin(common::MethodInfo {
10424 id: "cloudresourcemanager.projects.get",
10425 http_method: hyper::Method::GET,
10426 });
10427
10428 for &field in ["alt", "projectId"].iter() {
10429 if self._additional_params.contains_key(field) {
10430 dlg.finished(false);
10431 return Err(common::Error::FieldClash(field));
10432 }
10433 }
10434
10435 let mut params = Params::with_capacity(3 + self._additional_params.len());
10436 params.push("projectId", self._project_id);
10437
10438 params.extend(self._additional_params.iter());
10439
10440 params.push("alt", "json");
10441 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}";
10442 if self._scopes.is_empty() {
10443 self._scopes
10444 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
10445 }
10446
10447 #[allow(clippy::single_element_loop)]
10448 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
10449 url = params.uri_replacement(url, param_name, find_this, false);
10450 }
10451 {
10452 let to_remove = ["projectId"];
10453 params.remove_params(&to_remove);
10454 }
10455
10456 let url = params.parse_with_url(&url);
10457
10458 loop {
10459 let token = match self
10460 .hub
10461 .auth
10462 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10463 .await
10464 {
10465 Ok(token) => token,
10466 Err(e) => match dlg.token(e) {
10467 Ok(token) => token,
10468 Err(e) => {
10469 dlg.finished(false);
10470 return Err(common::Error::MissingToken(e));
10471 }
10472 },
10473 };
10474 let mut req_result = {
10475 let client = &self.hub.client;
10476 dlg.pre_request();
10477 let mut req_builder = hyper::Request::builder()
10478 .method(hyper::Method::GET)
10479 .uri(url.as_str())
10480 .header(USER_AGENT, self.hub._user_agent.clone());
10481
10482 if let Some(token) = token.as_ref() {
10483 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10484 }
10485
10486 let request = req_builder
10487 .header(CONTENT_LENGTH, 0_u64)
10488 .body(common::to_body::<String>(None));
10489
10490 client.request(request.unwrap()).await
10491 };
10492
10493 match req_result {
10494 Err(err) => {
10495 if let common::Retry::After(d) = dlg.http_error(&err) {
10496 sleep(d).await;
10497 continue;
10498 }
10499 dlg.finished(false);
10500 return Err(common::Error::HttpError(err));
10501 }
10502 Ok(res) => {
10503 let (mut parts, body) = res.into_parts();
10504 let mut body = common::Body::new(body);
10505 if !parts.status.is_success() {
10506 let bytes = common::to_bytes(body).await.unwrap_or_default();
10507 let error = serde_json::from_str(&common::to_string(&bytes));
10508 let response = common::to_response(parts, bytes.into());
10509
10510 if let common::Retry::After(d) =
10511 dlg.http_failure(&response, error.as_ref().ok())
10512 {
10513 sleep(d).await;
10514 continue;
10515 }
10516
10517 dlg.finished(false);
10518
10519 return Err(match error {
10520 Ok(value) => common::Error::BadRequest(value),
10521 _ => common::Error::Failure(response),
10522 });
10523 }
10524 let response = {
10525 let bytes = common::to_bytes(body).await.unwrap_or_default();
10526 let encoded = common::to_string(&bytes);
10527 match serde_json::from_str(&encoded) {
10528 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10529 Err(error) => {
10530 dlg.response_json_decode_error(&encoded, &error);
10531 return Err(common::Error::JsonDecodeError(
10532 encoded.to_string(),
10533 error,
10534 ));
10535 }
10536 }
10537 };
10538
10539 dlg.finished(true);
10540 return Ok(response);
10541 }
10542 }
10543 }
10544 }
10545
10546 /// Required. The Project ID (for example, `my-project-123`).
10547 ///
10548 /// Sets the *project id* path property to the given value.
10549 ///
10550 /// Even though the property as already been set when instantiating this call,
10551 /// we provide this method for API completeness.
10552 pub fn project_id(mut self, new_value: &str) -> ProjectGetCall<'a, C> {
10553 self._project_id = new_value.to_string();
10554 self
10555 }
10556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10557 /// while executing the actual API request.
10558 ///
10559 /// ````text
10560 /// It should be used to handle progress information, and to implement a certain level of resilience.
10561 /// ````
10562 ///
10563 /// Sets the *delegate* property to the given value.
10564 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectGetCall<'a, C> {
10565 self._delegate = Some(new_value);
10566 self
10567 }
10568
10569 /// Set any additional parameter of the query string used in the request.
10570 /// It should be used to set parameters which are not yet available through their own
10571 /// setters.
10572 ///
10573 /// Please note that this method must not be used to set any of the known parameters
10574 /// which have their own setter method. If done anyway, the request will fail.
10575 ///
10576 /// # Additional Parameters
10577 ///
10578 /// * *$.xgafv* (query-string) - V1 error format.
10579 /// * *access_token* (query-string) - OAuth access token.
10580 /// * *alt* (query-string) - Data format for response.
10581 /// * *callback* (query-string) - JSONP
10582 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10583 /// * *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.
10584 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10585 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10586 /// * *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.
10587 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10588 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10589 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetCall<'a, C>
10590 where
10591 T: AsRef<str>,
10592 {
10593 self._additional_params
10594 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10595 self
10596 }
10597
10598 /// Identifies the authorization scope for the method you are building.
10599 ///
10600 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10601 /// [`Scope::CloudPlatformReadOnly`].
10602 ///
10603 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10604 /// tokens for more than one scope.
10605 ///
10606 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10607 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10608 /// sufficient, a read-write scope will do as well.
10609 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetCall<'a, C>
10610 where
10611 St: AsRef<str>,
10612 {
10613 self._scopes.insert(String::from(scope.as_ref()));
10614 self
10615 }
10616 /// Identifies the authorization scope(s) for the method you are building.
10617 ///
10618 /// See [`Self::add_scope()`] for details.
10619 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetCall<'a, C>
10620 where
10621 I: IntoIterator<Item = St>,
10622 St: AsRef<str>,
10623 {
10624 self._scopes
10625 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10626 self
10627 }
10628
10629 /// Removes all scopes, and no default scope will be used either.
10630 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10631 /// for details).
10632 pub fn clear_scopes(mut self) -> ProjectGetCall<'a, C> {
10633 self._scopes.clear();
10634 self
10635 }
10636}
10637
10638/// Gets a list of ancestors in the resource hierarchy for the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have read permissions for this Project.
10639///
10640/// A builder for the *getAncestry* method supported by a *project* resource.
10641/// It is not used directly, but through a [`ProjectMethods`] instance.
10642///
10643/// # Example
10644///
10645/// Instantiate a resource method builder
10646///
10647/// ```test_harness,no_run
10648/// # extern crate hyper;
10649/// # extern crate hyper_rustls;
10650/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10651/// use cloudresourcemanager1::api::GetAncestryRequest;
10652/// # async fn dox() {
10653/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10654///
10655/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10656/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10657/// # .with_native_roots()
10658/// # .unwrap()
10659/// # .https_only()
10660/// # .enable_http2()
10661/// # .build();
10662///
10663/// # let executor = hyper_util::rt::TokioExecutor::new();
10664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10665/// # secret,
10666/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10667/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10668/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10669/// # ),
10670/// # ).build().await.unwrap();
10671///
10672/// # let client = hyper_util::client::legacy::Client::builder(
10673/// # hyper_util::rt::TokioExecutor::new()
10674/// # )
10675/// # .build(
10676/// # hyper_rustls::HttpsConnectorBuilder::new()
10677/// # .with_native_roots()
10678/// # .unwrap()
10679/// # .https_or_http()
10680/// # .enable_http2()
10681/// # .build()
10682/// # );
10683/// # let mut hub = CloudResourceManager::new(client, auth);
10684/// // As the method needs a request, you would usually fill it with the desired information
10685/// // into the respective structure. Some of the parts shown here might not be applicable !
10686/// // Values shown here are possibly random and not representative !
10687/// let mut req = GetAncestryRequest::default();
10688///
10689/// // You can configure optional parameters by calling the respective setters at will, and
10690/// // execute the final call using `doit()`.
10691/// // Values shown here are possibly random and not representative !
10692/// let result = hub.projects().get_ancestry(req, "projectId")
10693/// .doit().await;
10694/// # }
10695/// ```
10696pub struct ProjectGetAncestryCall<'a, C>
10697where
10698 C: 'a,
10699{
10700 hub: &'a CloudResourceManager<C>,
10701 _request: GetAncestryRequest,
10702 _project_id: String,
10703 _delegate: Option<&'a mut dyn common::Delegate>,
10704 _additional_params: HashMap<String, String>,
10705 _scopes: BTreeSet<String>,
10706}
10707
10708impl<'a, C> common::CallBuilder for ProjectGetAncestryCall<'a, C> {}
10709
10710impl<'a, C> ProjectGetAncestryCall<'a, C>
10711where
10712 C: common::Connector,
10713{
10714 /// Perform the operation you have build so far.
10715 pub async fn doit(mut self) -> common::Result<(common::Response, GetAncestryResponse)> {
10716 use std::borrow::Cow;
10717 use std::io::{Read, Seek};
10718
10719 use common::{url::Params, ToParts};
10720 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10721
10722 let mut dd = common::DefaultDelegate;
10723 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10724 dlg.begin(common::MethodInfo {
10725 id: "cloudresourcemanager.projects.getAncestry",
10726 http_method: hyper::Method::POST,
10727 });
10728
10729 for &field in ["alt", "projectId"].iter() {
10730 if self._additional_params.contains_key(field) {
10731 dlg.finished(false);
10732 return Err(common::Error::FieldClash(field));
10733 }
10734 }
10735
10736 let mut params = Params::with_capacity(4 + self._additional_params.len());
10737 params.push("projectId", self._project_id);
10738
10739 params.extend(self._additional_params.iter());
10740
10741 params.push("alt", "json");
10742 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:getAncestry";
10743 if self._scopes.is_empty() {
10744 self._scopes
10745 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
10746 }
10747
10748 #[allow(clippy::single_element_loop)]
10749 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
10750 url = params.uri_replacement(url, param_name, find_this, false);
10751 }
10752 {
10753 let to_remove = ["projectId"];
10754 params.remove_params(&to_remove);
10755 }
10756
10757 let url = params.parse_with_url(&url);
10758
10759 let mut json_mime_type = mime::APPLICATION_JSON;
10760 let mut request_value_reader = {
10761 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10762 common::remove_json_null_values(&mut value);
10763 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10764 serde_json::to_writer(&mut dst, &value).unwrap();
10765 dst
10766 };
10767 let request_size = request_value_reader
10768 .seek(std::io::SeekFrom::End(0))
10769 .unwrap();
10770 request_value_reader
10771 .seek(std::io::SeekFrom::Start(0))
10772 .unwrap();
10773
10774 loop {
10775 let token = match self
10776 .hub
10777 .auth
10778 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10779 .await
10780 {
10781 Ok(token) => token,
10782 Err(e) => match dlg.token(e) {
10783 Ok(token) => token,
10784 Err(e) => {
10785 dlg.finished(false);
10786 return Err(common::Error::MissingToken(e));
10787 }
10788 },
10789 };
10790 request_value_reader
10791 .seek(std::io::SeekFrom::Start(0))
10792 .unwrap();
10793 let mut req_result = {
10794 let client = &self.hub.client;
10795 dlg.pre_request();
10796 let mut req_builder = hyper::Request::builder()
10797 .method(hyper::Method::POST)
10798 .uri(url.as_str())
10799 .header(USER_AGENT, self.hub._user_agent.clone());
10800
10801 if let Some(token) = token.as_ref() {
10802 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10803 }
10804
10805 let request = req_builder
10806 .header(CONTENT_TYPE, json_mime_type.to_string())
10807 .header(CONTENT_LENGTH, request_size as u64)
10808 .body(common::to_body(
10809 request_value_reader.get_ref().clone().into(),
10810 ));
10811
10812 client.request(request.unwrap()).await
10813 };
10814
10815 match req_result {
10816 Err(err) => {
10817 if let common::Retry::After(d) = dlg.http_error(&err) {
10818 sleep(d).await;
10819 continue;
10820 }
10821 dlg.finished(false);
10822 return Err(common::Error::HttpError(err));
10823 }
10824 Ok(res) => {
10825 let (mut parts, body) = res.into_parts();
10826 let mut body = common::Body::new(body);
10827 if !parts.status.is_success() {
10828 let bytes = common::to_bytes(body).await.unwrap_or_default();
10829 let error = serde_json::from_str(&common::to_string(&bytes));
10830 let response = common::to_response(parts, bytes.into());
10831
10832 if let common::Retry::After(d) =
10833 dlg.http_failure(&response, error.as_ref().ok())
10834 {
10835 sleep(d).await;
10836 continue;
10837 }
10838
10839 dlg.finished(false);
10840
10841 return Err(match error {
10842 Ok(value) => common::Error::BadRequest(value),
10843 _ => common::Error::Failure(response),
10844 });
10845 }
10846 let response = {
10847 let bytes = common::to_bytes(body).await.unwrap_or_default();
10848 let encoded = common::to_string(&bytes);
10849 match serde_json::from_str(&encoded) {
10850 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10851 Err(error) => {
10852 dlg.response_json_decode_error(&encoded, &error);
10853 return Err(common::Error::JsonDecodeError(
10854 encoded.to_string(),
10855 error,
10856 ));
10857 }
10858 }
10859 };
10860
10861 dlg.finished(true);
10862 return Ok(response);
10863 }
10864 }
10865 }
10866 }
10867
10868 ///
10869 /// Sets the *request* property to the given value.
10870 ///
10871 /// Even though the property as already been set when instantiating this call,
10872 /// we provide this method for API completeness.
10873 pub fn request(mut self, new_value: GetAncestryRequest) -> ProjectGetAncestryCall<'a, C> {
10874 self._request = new_value;
10875 self
10876 }
10877 /// Required. The Project ID (for example, `my-project-123`).
10878 ///
10879 /// Sets the *project id* path property to the given value.
10880 ///
10881 /// Even though the property as already been set when instantiating this call,
10882 /// we provide this method for API completeness.
10883 pub fn project_id(mut self, new_value: &str) -> ProjectGetAncestryCall<'a, C> {
10884 self._project_id = new_value.to_string();
10885 self
10886 }
10887 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10888 /// while executing the actual API request.
10889 ///
10890 /// ````text
10891 /// It should be used to handle progress information, and to implement a certain level of resilience.
10892 /// ````
10893 ///
10894 /// Sets the *delegate* property to the given value.
10895 pub fn delegate(
10896 mut self,
10897 new_value: &'a mut dyn common::Delegate,
10898 ) -> ProjectGetAncestryCall<'a, C> {
10899 self._delegate = Some(new_value);
10900 self
10901 }
10902
10903 /// Set any additional parameter of the query string used in the request.
10904 /// It should be used to set parameters which are not yet available through their own
10905 /// setters.
10906 ///
10907 /// Please note that this method must not be used to set any of the known parameters
10908 /// which have their own setter method. If done anyway, the request will fail.
10909 ///
10910 /// # Additional Parameters
10911 ///
10912 /// * *$.xgafv* (query-string) - V1 error format.
10913 /// * *access_token* (query-string) - OAuth access token.
10914 /// * *alt* (query-string) - Data format for response.
10915 /// * *callback* (query-string) - JSONP
10916 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10917 /// * *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.
10918 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10919 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10920 /// * *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.
10921 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10922 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10923 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetAncestryCall<'a, C>
10924 where
10925 T: AsRef<str>,
10926 {
10927 self._additional_params
10928 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10929 self
10930 }
10931
10932 /// Identifies the authorization scope for the method you are building.
10933 ///
10934 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10935 /// [`Scope::CloudPlatformReadOnly`].
10936 ///
10937 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10938 /// tokens for more than one scope.
10939 ///
10940 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10941 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10942 /// sufficient, a read-write scope will do as well.
10943 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetAncestryCall<'a, C>
10944 where
10945 St: AsRef<str>,
10946 {
10947 self._scopes.insert(String::from(scope.as_ref()));
10948 self
10949 }
10950 /// Identifies the authorization scope(s) for the method you are building.
10951 ///
10952 /// See [`Self::add_scope()`] for details.
10953 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetAncestryCall<'a, C>
10954 where
10955 I: IntoIterator<Item = St>,
10956 St: AsRef<str>,
10957 {
10958 self._scopes
10959 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10960 self
10961 }
10962
10963 /// Removes all scopes, and no default scope will be used either.
10964 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10965 /// for details).
10966 pub fn clear_scopes(mut self) -> ProjectGetAncestryCall<'a, C> {
10967 self._scopes.clear();
10968 self
10969 }
10970}
10971
10972/// Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the resource hierarchy. The returned `Policy` will not have an `etag`set because it is a computed `Policy` across multiple resources. Subtrees of Resource Manager resource hierarchy with 'under:' prefix will not be expanded.
10973///
10974/// A builder for the *getEffectiveOrgPolicy* method supported by a *project* resource.
10975/// It is not used directly, but through a [`ProjectMethods`] instance.
10976///
10977/// # Example
10978///
10979/// Instantiate a resource method builder
10980///
10981/// ```test_harness,no_run
10982/// # extern crate hyper;
10983/// # extern crate hyper_rustls;
10984/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
10985/// use cloudresourcemanager1::api::GetEffectiveOrgPolicyRequest;
10986/// # async fn dox() {
10987/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10988///
10989/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10990/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10991/// # .with_native_roots()
10992/// # .unwrap()
10993/// # .https_only()
10994/// # .enable_http2()
10995/// # .build();
10996///
10997/// # let executor = hyper_util::rt::TokioExecutor::new();
10998/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10999/// # secret,
11000/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11001/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11002/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11003/// # ),
11004/// # ).build().await.unwrap();
11005///
11006/// # let client = hyper_util::client::legacy::Client::builder(
11007/// # hyper_util::rt::TokioExecutor::new()
11008/// # )
11009/// # .build(
11010/// # hyper_rustls::HttpsConnectorBuilder::new()
11011/// # .with_native_roots()
11012/// # .unwrap()
11013/// # .https_or_http()
11014/// # .enable_http2()
11015/// # .build()
11016/// # );
11017/// # let mut hub = CloudResourceManager::new(client, auth);
11018/// // As the method needs a request, you would usually fill it with the desired information
11019/// // into the respective structure. Some of the parts shown here might not be applicable !
11020/// // Values shown here are possibly random and not representative !
11021/// let mut req = GetEffectiveOrgPolicyRequest::default();
11022///
11023/// // You can configure optional parameters by calling the respective setters at will, and
11024/// // execute the final call using `doit()`.
11025/// // Values shown here are possibly random and not representative !
11026/// let result = hub.projects().get_effective_org_policy(req, "resource")
11027/// .doit().await;
11028/// # }
11029/// ```
11030pub struct ProjectGetEffectiveOrgPolicyCall<'a, C>
11031where
11032 C: 'a,
11033{
11034 hub: &'a CloudResourceManager<C>,
11035 _request: GetEffectiveOrgPolicyRequest,
11036 _resource: String,
11037 _delegate: Option<&'a mut dyn common::Delegate>,
11038 _additional_params: HashMap<String, String>,
11039 _scopes: BTreeSet<String>,
11040}
11041
11042impl<'a, C> common::CallBuilder for ProjectGetEffectiveOrgPolicyCall<'a, C> {}
11043
11044impl<'a, C> ProjectGetEffectiveOrgPolicyCall<'a, C>
11045where
11046 C: common::Connector,
11047{
11048 /// Perform the operation you have build so far.
11049 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
11050 use std::borrow::Cow;
11051 use std::io::{Read, Seek};
11052
11053 use common::{url::Params, ToParts};
11054 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11055
11056 let mut dd = common::DefaultDelegate;
11057 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11058 dlg.begin(common::MethodInfo {
11059 id: "cloudresourcemanager.projects.getEffectiveOrgPolicy",
11060 http_method: hyper::Method::POST,
11061 });
11062
11063 for &field in ["alt", "resource"].iter() {
11064 if self._additional_params.contains_key(field) {
11065 dlg.finished(false);
11066 return Err(common::Error::FieldClash(field));
11067 }
11068 }
11069
11070 let mut params = Params::with_capacity(4 + self._additional_params.len());
11071 params.push("resource", self._resource);
11072
11073 params.extend(self._additional_params.iter());
11074
11075 params.push("alt", "json");
11076 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getEffectiveOrgPolicy";
11077 if self._scopes.is_empty() {
11078 self._scopes
11079 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
11080 }
11081
11082 #[allow(clippy::single_element_loop)]
11083 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11084 url = params.uri_replacement(url, param_name, find_this, true);
11085 }
11086 {
11087 let to_remove = ["resource"];
11088 params.remove_params(&to_remove);
11089 }
11090
11091 let url = params.parse_with_url(&url);
11092
11093 let mut json_mime_type = mime::APPLICATION_JSON;
11094 let mut request_value_reader = {
11095 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11096 common::remove_json_null_values(&mut value);
11097 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11098 serde_json::to_writer(&mut dst, &value).unwrap();
11099 dst
11100 };
11101 let request_size = request_value_reader
11102 .seek(std::io::SeekFrom::End(0))
11103 .unwrap();
11104 request_value_reader
11105 .seek(std::io::SeekFrom::Start(0))
11106 .unwrap();
11107
11108 loop {
11109 let token = match self
11110 .hub
11111 .auth
11112 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11113 .await
11114 {
11115 Ok(token) => token,
11116 Err(e) => match dlg.token(e) {
11117 Ok(token) => token,
11118 Err(e) => {
11119 dlg.finished(false);
11120 return Err(common::Error::MissingToken(e));
11121 }
11122 },
11123 };
11124 request_value_reader
11125 .seek(std::io::SeekFrom::Start(0))
11126 .unwrap();
11127 let mut req_result = {
11128 let client = &self.hub.client;
11129 dlg.pre_request();
11130 let mut req_builder = hyper::Request::builder()
11131 .method(hyper::Method::POST)
11132 .uri(url.as_str())
11133 .header(USER_AGENT, self.hub._user_agent.clone());
11134
11135 if let Some(token) = token.as_ref() {
11136 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11137 }
11138
11139 let request = req_builder
11140 .header(CONTENT_TYPE, json_mime_type.to_string())
11141 .header(CONTENT_LENGTH, request_size as u64)
11142 .body(common::to_body(
11143 request_value_reader.get_ref().clone().into(),
11144 ));
11145
11146 client.request(request.unwrap()).await
11147 };
11148
11149 match req_result {
11150 Err(err) => {
11151 if let common::Retry::After(d) = dlg.http_error(&err) {
11152 sleep(d).await;
11153 continue;
11154 }
11155 dlg.finished(false);
11156 return Err(common::Error::HttpError(err));
11157 }
11158 Ok(res) => {
11159 let (mut parts, body) = res.into_parts();
11160 let mut body = common::Body::new(body);
11161 if !parts.status.is_success() {
11162 let bytes = common::to_bytes(body).await.unwrap_or_default();
11163 let error = serde_json::from_str(&common::to_string(&bytes));
11164 let response = common::to_response(parts, bytes.into());
11165
11166 if let common::Retry::After(d) =
11167 dlg.http_failure(&response, error.as_ref().ok())
11168 {
11169 sleep(d).await;
11170 continue;
11171 }
11172
11173 dlg.finished(false);
11174
11175 return Err(match error {
11176 Ok(value) => common::Error::BadRequest(value),
11177 _ => common::Error::Failure(response),
11178 });
11179 }
11180 let response = {
11181 let bytes = common::to_bytes(body).await.unwrap_or_default();
11182 let encoded = common::to_string(&bytes);
11183 match serde_json::from_str(&encoded) {
11184 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11185 Err(error) => {
11186 dlg.response_json_decode_error(&encoded, &error);
11187 return Err(common::Error::JsonDecodeError(
11188 encoded.to_string(),
11189 error,
11190 ));
11191 }
11192 }
11193 };
11194
11195 dlg.finished(true);
11196 return Ok(response);
11197 }
11198 }
11199 }
11200 }
11201
11202 ///
11203 /// Sets the *request* property to the given value.
11204 ///
11205 /// Even though the property as already been set when instantiating this call,
11206 /// we provide this method for API completeness.
11207 pub fn request(
11208 mut self,
11209 new_value: GetEffectiveOrgPolicyRequest,
11210 ) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
11211 self._request = new_value;
11212 self
11213 }
11214 /// The name of the resource to start computing the effective `Policy`.
11215 ///
11216 /// Sets the *resource* path property to the given value.
11217 ///
11218 /// Even though the property as already been set when instantiating this call,
11219 /// we provide this method for API completeness.
11220 pub fn resource(mut self, new_value: &str) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
11221 self._resource = new_value.to_string();
11222 self
11223 }
11224 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11225 /// while executing the actual API request.
11226 ///
11227 /// ````text
11228 /// It should be used to handle progress information, and to implement a certain level of resilience.
11229 /// ````
11230 ///
11231 /// Sets the *delegate* property to the given value.
11232 pub fn delegate(
11233 mut self,
11234 new_value: &'a mut dyn common::Delegate,
11235 ) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
11236 self._delegate = Some(new_value);
11237 self
11238 }
11239
11240 /// Set any additional parameter of the query string used in the request.
11241 /// It should be used to set parameters which are not yet available through their own
11242 /// setters.
11243 ///
11244 /// Please note that this method must not be used to set any of the known parameters
11245 /// which have their own setter method. If done anyway, the request will fail.
11246 ///
11247 /// # Additional Parameters
11248 ///
11249 /// * *$.xgafv* (query-string) - V1 error format.
11250 /// * *access_token* (query-string) - OAuth access token.
11251 /// * *alt* (query-string) - Data format for response.
11252 /// * *callback* (query-string) - JSONP
11253 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11254 /// * *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.
11255 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11256 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11257 /// * *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.
11258 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11259 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11260 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetEffectiveOrgPolicyCall<'a, C>
11261 where
11262 T: AsRef<str>,
11263 {
11264 self._additional_params
11265 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11266 self
11267 }
11268
11269 /// Identifies the authorization scope for the method you are building.
11270 ///
11271 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11272 /// [`Scope::CloudPlatformReadOnly`].
11273 ///
11274 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11275 /// tokens for more than one scope.
11276 ///
11277 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11278 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11279 /// sufficient, a read-write scope will do as well.
11280 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetEffectiveOrgPolicyCall<'a, C>
11281 where
11282 St: AsRef<str>,
11283 {
11284 self._scopes.insert(String::from(scope.as_ref()));
11285 self
11286 }
11287 /// Identifies the authorization scope(s) for the method you are building.
11288 ///
11289 /// See [`Self::add_scope()`] for details.
11290 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetEffectiveOrgPolicyCall<'a, C>
11291 where
11292 I: IntoIterator<Item = St>,
11293 St: AsRef<str>,
11294 {
11295 self._scopes
11296 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11297 self
11298 }
11299
11300 /// Removes all scopes, and no default scope will be used either.
11301 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11302 /// for details).
11303 pub fn clear_scopes(mut self) -> ProjectGetEffectiveOrgPolicyCall<'a, C> {
11304 self._scopes.clear();
11305 self
11306 }
11307}
11308
11309/// Returns the IAM access control policy for the specified Project. Permission is denied if the policy or the resource does not exist. Authorization requires the Google IAM permission `resourcemanager.projects.getIamPolicy` on the project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names).
11310///
11311/// A builder for the *getIamPolicy* method supported by a *project* resource.
11312/// It is not used directly, but through a [`ProjectMethods`] instance.
11313///
11314/// # Example
11315///
11316/// Instantiate a resource method builder
11317///
11318/// ```test_harness,no_run
11319/// # extern crate hyper;
11320/// # extern crate hyper_rustls;
11321/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
11322/// use cloudresourcemanager1::api::GetIamPolicyRequest;
11323/// # async fn dox() {
11324/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11325///
11326/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11327/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11328/// # .with_native_roots()
11329/// # .unwrap()
11330/// # .https_only()
11331/// # .enable_http2()
11332/// # .build();
11333///
11334/// # let executor = hyper_util::rt::TokioExecutor::new();
11335/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11336/// # secret,
11337/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11338/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11339/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11340/// # ),
11341/// # ).build().await.unwrap();
11342///
11343/// # let client = hyper_util::client::legacy::Client::builder(
11344/// # hyper_util::rt::TokioExecutor::new()
11345/// # )
11346/// # .build(
11347/// # hyper_rustls::HttpsConnectorBuilder::new()
11348/// # .with_native_roots()
11349/// # .unwrap()
11350/// # .https_or_http()
11351/// # .enable_http2()
11352/// # .build()
11353/// # );
11354/// # let mut hub = CloudResourceManager::new(client, auth);
11355/// // As the method needs a request, you would usually fill it with the desired information
11356/// // into the respective structure. Some of the parts shown here might not be applicable !
11357/// // Values shown here are possibly random and not representative !
11358/// let mut req = GetIamPolicyRequest::default();
11359///
11360/// // You can configure optional parameters by calling the respective setters at will, and
11361/// // execute the final call using `doit()`.
11362/// // Values shown here are possibly random and not representative !
11363/// let result = hub.projects().get_iam_policy(req, "resource")
11364/// .doit().await;
11365/// # }
11366/// ```
11367pub struct ProjectGetIamPolicyCall<'a, C>
11368where
11369 C: 'a,
11370{
11371 hub: &'a CloudResourceManager<C>,
11372 _request: GetIamPolicyRequest,
11373 _resource: String,
11374 _delegate: Option<&'a mut dyn common::Delegate>,
11375 _additional_params: HashMap<String, String>,
11376 _scopes: BTreeSet<String>,
11377}
11378
11379impl<'a, C> common::CallBuilder for ProjectGetIamPolicyCall<'a, C> {}
11380
11381impl<'a, C> ProjectGetIamPolicyCall<'a, C>
11382where
11383 C: common::Connector,
11384{
11385 /// Perform the operation you have build so far.
11386 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
11387 use std::borrow::Cow;
11388 use std::io::{Read, Seek};
11389
11390 use common::{url::Params, ToParts};
11391 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11392
11393 let mut dd = common::DefaultDelegate;
11394 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11395 dlg.begin(common::MethodInfo {
11396 id: "cloudresourcemanager.projects.getIamPolicy",
11397 http_method: hyper::Method::POST,
11398 });
11399
11400 for &field in ["alt", "resource"].iter() {
11401 if self._additional_params.contains_key(field) {
11402 dlg.finished(false);
11403 return Err(common::Error::FieldClash(field));
11404 }
11405 }
11406
11407 let mut params = Params::with_capacity(4 + self._additional_params.len());
11408 params.push("resource", self._resource);
11409
11410 params.extend(self._additional_params.iter());
11411
11412 params.push("alt", "json");
11413 let mut url = self.hub._base_url.clone() + "v1/projects/{resource}:getIamPolicy";
11414 if self._scopes.is_empty() {
11415 self._scopes
11416 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
11417 }
11418
11419 #[allow(clippy::single_element_loop)]
11420 for &(find_this, param_name) in [("{resource}", "resource")].iter() {
11421 url = params.uri_replacement(url, param_name, find_this, false);
11422 }
11423 {
11424 let to_remove = ["resource"];
11425 params.remove_params(&to_remove);
11426 }
11427
11428 let url = params.parse_with_url(&url);
11429
11430 let mut json_mime_type = mime::APPLICATION_JSON;
11431 let mut request_value_reader = {
11432 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11433 common::remove_json_null_values(&mut value);
11434 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11435 serde_json::to_writer(&mut dst, &value).unwrap();
11436 dst
11437 };
11438 let request_size = request_value_reader
11439 .seek(std::io::SeekFrom::End(0))
11440 .unwrap();
11441 request_value_reader
11442 .seek(std::io::SeekFrom::Start(0))
11443 .unwrap();
11444
11445 loop {
11446 let token = match self
11447 .hub
11448 .auth
11449 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11450 .await
11451 {
11452 Ok(token) => token,
11453 Err(e) => match dlg.token(e) {
11454 Ok(token) => token,
11455 Err(e) => {
11456 dlg.finished(false);
11457 return Err(common::Error::MissingToken(e));
11458 }
11459 },
11460 };
11461 request_value_reader
11462 .seek(std::io::SeekFrom::Start(0))
11463 .unwrap();
11464 let mut req_result = {
11465 let client = &self.hub.client;
11466 dlg.pre_request();
11467 let mut req_builder = hyper::Request::builder()
11468 .method(hyper::Method::POST)
11469 .uri(url.as_str())
11470 .header(USER_AGENT, self.hub._user_agent.clone());
11471
11472 if let Some(token) = token.as_ref() {
11473 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11474 }
11475
11476 let request = req_builder
11477 .header(CONTENT_TYPE, json_mime_type.to_string())
11478 .header(CONTENT_LENGTH, request_size as u64)
11479 .body(common::to_body(
11480 request_value_reader.get_ref().clone().into(),
11481 ));
11482
11483 client.request(request.unwrap()).await
11484 };
11485
11486 match req_result {
11487 Err(err) => {
11488 if let common::Retry::After(d) = dlg.http_error(&err) {
11489 sleep(d).await;
11490 continue;
11491 }
11492 dlg.finished(false);
11493 return Err(common::Error::HttpError(err));
11494 }
11495 Ok(res) => {
11496 let (mut parts, body) = res.into_parts();
11497 let mut body = common::Body::new(body);
11498 if !parts.status.is_success() {
11499 let bytes = common::to_bytes(body).await.unwrap_or_default();
11500 let error = serde_json::from_str(&common::to_string(&bytes));
11501 let response = common::to_response(parts, bytes.into());
11502
11503 if let common::Retry::After(d) =
11504 dlg.http_failure(&response, error.as_ref().ok())
11505 {
11506 sleep(d).await;
11507 continue;
11508 }
11509
11510 dlg.finished(false);
11511
11512 return Err(match error {
11513 Ok(value) => common::Error::BadRequest(value),
11514 _ => common::Error::Failure(response),
11515 });
11516 }
11517 let response = {
11518 let bytes = common::to_bytes(body).await.unwrap_or_default();
11519 let encoded = common::to_string(&bytes);
11520 match serde_json::from_str(&encoded) {
11521 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11522 Err(error) => {
11523 dlg.response_json_decode_error(&encoded, &error);
11524 return Err(common::Error::JsonDecodeError(
11525 encoded.to_string(),
11526 error,
11527 ));
11528 }
11529 }
11530 };
11531
11532 dlg.finished(true);
11533 return Ok(response);
11534 }
11535 }
11536 }
11537 }
11538
11539 ///
11540 /// Sets the *request* property to the given value.
11541 ///
11542 /// Even though the property as already been set when instantiating this call,
11543 /// we provide this method for API completeness.
11544 pub fn request(mut self, new_value: GetIamPolicyRequest) -> ProjectGetIamPolicyCall<'a, C> {
11545 self._request = new_value;
11546 self
11547 }
11548 /// 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.
11549 ///
11550 /// Sets the *resource* path property to the given value.
11551 ///
11552 /// Even though the property as already been set when instantiating this call,
11553 /// we provide this method for API completeness.
11554 pub fn resource(mut self, new_value: &str) -> ProjectGetIamPolicyCall<'a, C> {
11555 self._resource = new_value.to_string();
11556 self
11557 }
11558 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11559 /// while executing the actual API request.
11560 ///
11561 /// ````text
11562 /// It should be used to handle progress information, and to implement a certain level of resilience.
11563 /// ````
11564 ///
11565 /// Sets the *delegate* property to the given value.
11566 pub fn delegate(
11567 mut self,
11568 new_value: &'a mut dyn common::Delegate,
11569 ) -> ProjectGetIamPolicyCall<'a, C> {
11570 self._delegate = Some(new_value);
11571 self
11572 }
11573
11574 /// Set any additional parameter of the query string used in the request.
11575 /// It should be used to set parameters which are not yet available through their own
11576 /// setters.
11577 ///
11578 /// Please note that this method must not be used to set any of the known parameters
11579 /// which have their own setter method. If done anyway, the request will fail.
11580 ///
11581 /// # Additional Parameters
11582 ///
11583 /// * *$.xgafv* (query-string) - V1 error format.
11584 /// * *access_token* (query-string) - OAuth access token.
11585 /// * *alt* (query-string) - Data format for response.
11586 /// * *callback* (query-string) - JSONP
11587 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11588 /// * *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.
11589 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11590 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11591 /// * *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.
11592 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11593 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11594 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetIamPolicyCall<'a, C>
11595 where
11596 T: AsRef<str>,
11597 {
11598 self._additional_params
11599 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11600 self
11601 }
11602
11603 /// Identifies the authorization scope for the method you are building.
11604 ///
11605 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11606 /// [`Scope::CloudPlatformReadOnly`].
11607 ///
11608 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11609 /// tokens for more than one scope.
11610 ///
11611 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11612 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11613 /// sufficient, a read-write scope will do as well.
11614 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetIamPolicyCall<'a, C>
11615 where
11616 St: AsRef<str>,
11617 {
11618 self._scopes.insert(String::from(scope.as_ref()));
11619 self
11620 }
11621 /// Identifies the authorization scope(s) for the method you are building.
11622 ///
11623 /// See [`Self::add_scope()`] for details.
11624 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetIamPolicyCall<'a, C>
11625 where
11626 I: IntoIterator<Item = St>,
11627 St: AsRef<str>,
11628 {
11629 self._scopes
11630 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11631 self
11632 }
11633
11634 /// Removes all scopes, and no default scope will be used either.
11635 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11636 /// for details).
11637 pub fn clear_scopes(mut self) -> ProjectGetIamPolicyCall<'a, C> {
11638 self._scopes.clear();
11639 self
11640 }
11641}
11642
11643/// Gets a `Policy` on a resource. If no `Policy` is set on the resource, a `Policy` is returned with default values including `POLICY_TYPE_NOT_SET` for the `policy_type oneof`. The `etag` value can be used with `SetOrgPolicy()` to create or update a `Policy` during read-modify-write.
11644///
11645/// A builder for the *getOrgPolicy* method supported by a *project* resource.
11646/// It is not used directly, but through a [`ProjectMethods`] instance.
11647///
11648/// # Example
11649///
11650/// Instantiate a resource method builder
11651///
11652/// ```test_harness,no_run
11653/// # extern crate hyper;
11654/// # extern crate hyper_rustls;
11655/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
11656/// use cloudresourcemanager1::api::GetOrgPolicyRequest;
11657/// # async fn dox() {
11658/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11659///
11660/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11661/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11662/// # .with_native_roots()
11663/// # .unwrap()
11664/// # .https_only()
11665/// # .enable_http2()
11666/// # .build();
11667///
11668/// # let executor = hyper_util::rt::TokioExecutor::new();
11669/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11670/// # secret,
11671/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11672/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11673/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11674/// # ),
11675/// # ).build().await.unwrap();
11676///
11677/// # let client = hyper_util::client::legacy::Client::builder(
11678/// # hyper_util::rt::TokioExecutor::new()
11679/// # )
11680/// # .build(
11681/// # hyper_rustls::HttpsConnectorBuilder::new()
11682/// # .with_native_roots()
11683/// # .unwrap()
11684/// # .https_or_http()
11685/// # .enable_http2()
11686/// # .build()
11687/// # );
11688/// # let mut hub = CloudResourceManager::new(client, auth);
11689/// // As the method needs a request, you would usually fill it with the desired information
11690/// // into the respective structure. Some of the parts shown here might not be applicable !
11691/// // Values shown here are possibly random and not representative !
11692/// let mut req = GetOrgPolicyRequest::default();
11693///
11694/// // You can configure optional parameters by calling the respective setters at will, and
11695/// // execute the final call using `doit()`.
11696/// // Values shown here are possibly random and not representative !
11697/// let result = hub.projects().get_org_policy(req, "resource")
11698/// .doit().await;
11699/// # }
11700/// ```
11701pub struct ProjectGetOrgPolicyCall<'a, C>
11702where
11703 C: 'a,
11704{
11705 hub: &'a CloudResourceManager<C>,
11706 _request: GetOrgPolicyRequest,
11707 _resource: String,
11708 _delegate: Option<&'a mut dyn common::Delegate>,
11709 _additional_params: HashMap<String, String>,
11710 _scopes: BTreeSet<String>,
11711}
11712
11713impl<'a, C> common::CallBuilder for ProjectGetOrgPolicyCall<'a, C> {}
11714
11715impl<'a, C> ProjectGetOrgPolicyCall<'a, C>
11716where
11717 C: common::Connector,
11718{
11719 /// Perform the operation you have build so far.
11720 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
11721 use std::borrow::Cow;
11722 use std::io::{Read, Seek};
11723
11724 use common::{url::Params, ToParts};
11725 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11726
11727 let mut dd = common::DefaultDelegate;
11728 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11729 dlg.begin(common::MethodInfo {
11730 id: "cloudresourcemanager.projects.getOrgPolicy",
11731 http_method: hyper::Method::POST,
11732 });
11733
11734 for &field in ["alt", "resource"].iter() {
11735 if self._additional_params.contains_key(field) {
11736 dlg.finished(false);
11737 return Err(common::Error::FieldClash(field));
11738 }
11739 }
11740
11741 let mut params = Params::with_capacity(4 + self._additional_params.len());
11742 params.push("resource", self._resource);
11743
11744 params.extend(self._additional_params.iter());
11745
11746 params.push("alt", "json");
11747 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getOrgPolicy";
11748 if self._scopes.is_empty() {
11749 self._scopes
11750 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
11751 }
11752
11753 #[allow(clippy::single_element_loop)]
11754 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11755 url = params.uri_replacement(url, param_name, find_this, true);
11756 }
11757 {
11758 let to_remove = ["resource"];
11759 params.remove_params(&to_remove);
11760 }
11761
11762 let url = params.parse_with_url(&url);
11763
11764 let mut json_mime_type = mime::APPLICATION_JSON;
11765 let mut request_value_reader = {
11766 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11767 common::remove_json_null_values(&mut value);
11768 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11769 serde_json::to_writer(&mut dst, &value).unwrap();
11770 dst
11771 };
11772 let request_size = request_value_reader
11773 .seek(std::io::SeekFrom::End(0))
11774 .unwrap();
11775 request_value_reader
11776 .seek(std::io::SeekFrom::Start(0))
11777 .unwrap();
11778
11779 loop {
11780 let token = match self
11781 .hub
11782 .auth
11783 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11784 .await
11785 {
11786 Ok(token) => token,
11787 Err(e) => match dlg.token(e) {
11788 Ok(token) => token,
11789 Err(e) => {
11790 dlg.finished(false);
11791 return Err(common::Error::MissingToken(e));
11792 }
11793 },
11794 };
11795 request_value_reader
11796 .seek(std::io::SeekFrom::Start(0))
11797 .unwrap();
11798 let mut req_result = {
11799 let client = &self.hub.client;
11800 dlg.pre_request();
11801 let mut req_builder = hyper::Request::builder()
11802 .method(hyper::Method::POST)
11803 .uri(url.as_str())
11804 .header(USER_AGENT, self.hub._user_agent.clone());
11805
11806 if let Some(token) = token.as_ref() {
11807 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11808 }
11809
11810 let request = req_builder
11811 .header(CONTENT_TYPE, json_mime_type.to_string())
11812 .header(CONTENT_LENGTH, request_size as u64)
11813 .body(common::to_body(
11814 request_value_reader.get_ref().clone().into(),
11815 ));
11816
11817 client.request(request.unwrap()).await
11818 };
11819
11820 match req_result {
11821 Err(err) => {
11822 if let common::Retry::After(d) = dlg.http_error(&err) {
11823 sleep(d).await;
11824 continue;
11825 }
11826 dlg.finished(false);
11827 return Err(common::Error::HttpError(err));
11828 }
11829 Ok(res) => {
11830 let (mut parts, body) = res.into_parts();
11831 let mut body = common::Body::new(body);
11832 if !parts.status.is_success() {
11833 let bytes = common::to_bytes(body).await.unwrap_or_default();
11834 let error = serde_json::from_str(&common::to_string(&bytes));
11835 let response = common::to_response(parts, bytes.into());
11836
11837 if let common::Retry::After(d) =
11838 dlg.http_failure(&response, error.as_ref().ok())
11839 {
11840 sleep(d).await;
11841 continue;
11842 }
11843
11844 dlg.finished(false);
11845
11846 return Err(match error {
11847 Ok(value) => common::Error::BadRequest(value),
11848 _ => common::Error::Failure(response),
11849 });
11850 }
11851 let response = {
11852 let bytes = common::to_bytes(body).await.unwrap_or_default();
11853 let encoded = common::to_string(&bytes);
11854 match serde_json::from_str(&encoded) {
11855 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11856 Err(error) => {
11857 dlg.response_json_decode_error(&encoded, &error);
11858 return Err(common::Error::JsonDecodeError(
11859 encoded.to_string(),
11860 error,
11861 ));
11862 }
11863 }
11864 };
11865
11866 dlg.finished(true);
11867 return Ok(response);
11868 }
11869 }
11870 }
11871 }
11872
11873 ///
11874 /// Sets the *request* property to the given value.
11875 ///
11876 /// Even though the property as already been set when instantiating this call,
11877 /// we provide this method for API completeness.
11878 pub fn request(mut self, new_value: GetOrgPolicyRequest) -> ProjectGetOrgPolicyCall<'a, C> {
11879 self._request = new_value;
11880 self
11881 }
11882 /// Name of the resource the `Policy` is set on.
11883 ///
11884 /// Sets the *resource* path property to the given value.
11885 ///
11886 /// Even though the property as already been set when instantiating this call,
11887 /// we provide this method for API completeness.
11888 pub fn resource(mut self, new_value: &str) -> ProjectGetOrgPolicyCall<'a, C> {
11889 self._resource = new_value.to_string();
11890 self
11891 }
11892 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11893 /// while executing the actual API request.
11894 ///
11895 /// ````text
11896 /// It should be used to handle progress information, and to implement a certain level of resilience.
11897 /// ````
11898 ///
11899 /// Sets the *delegate* property to the given value.
11900 pub fn delegate(
11901 mut self,
11902 new_value: &'a mut dyn common::Delegate,
11903 ) -> ProjectGetOrgPolicyCall<'a, C> {
11904 self._delegate = Some(new_value);
11905 self
11906 }
11907
11908 /// Set any additional parameter of the query string used in the request.
11909 /// It should be used to set parameters which are not yet available through their own
11910 /// setters.
11911 ///
11912 /// Please note that this method must not be used to set any of the known parameters
11913 /// which have their own setter method. If done anyway, the request will fail.
11914 ///
11915 /// # Additional Parameters
11916 ///
11917 /// * *$.xgafv* (query-string) - V1 error format.
11918 /// * *access_token* (query-string) - OAuth access token.
11919 /// * *alt* (query-string) - Data format for response.
11920 /// * *callback* (query-string) - JSONP
11921 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11922 /// * *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.
11923 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11924 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11925 /// * *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.
11926 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11927 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11928 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetOrgPolicyCall<'a, C>
11929 where
11930 T: AsRef<str>,
11931 {
11932 self._additional_params
11933 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11934 self
11935 }
11936
11937 /// Identifies the authorization scope for the method you are building.
11938 ///
11939 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11940 /// [`Scope::CloudPlatformReadOnly`].
11941 ///
11942 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11943 /// tokens for more than one scope.
11944 ///
11945 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11946 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11947 /// sufficient, a read-write scope will do as well.
11948 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetOrgPolicyCall<'a, C>
11949 where
11950 St: AsRef<str>,
11951 {
11952 self._scopes.insert(String::from(scope.as_ref()));
11953 self
11954 }
11955 /// Identifies the authorization scope(s) for the method you are building.
11956 ///
11957 /// See [`Self::add_scope()`] for details.
11958 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetOrgPolicyCall<'a, C>
11959 where
11960 I: IntoIterator<Item = St>,
11961 St: AsRef<str>,
11962 {
11963 self._scopes
11964 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11965 self
11966 }
11967
11968 /// Removes all scopes, and no default scope will be used either.
11969 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11970 /// for details).
11971 pub fn clear_scopes(mut self) -> ProjectGetOrgPolicyCall<'a, C> {
11972 self._scopes.clear();
11973 self
11974 }
11975}
11976
11977/// Lists Projects that the caller has the `resourcemanager.projects.get` permission on and satisfy the specified filter. This method returns Projects in an unspecified order. This method is eventually consistent with project mutations; this means that a newly created project may not appear in the results or recent updates to an existing project may not be reflected in the results. To retrieve the latest state of a project, use the GetProject method. NOTE: If the request filter contains a `parent.type` and `parent.id` and the caller has the `resourcemanager.projects.list` permission on the parent, the results will be drawn from an alternate index which provides more consistent results. In future versions of this API, this List method will be split into List and Search to properly capture the behavioral difference.
11978///
11979/// A builder for the *list* method supported by a *project* resource.
11980/// It is not used directly, but through a [`ProjectMethods`] instance.
11981///
11982/// # Example
11983///
11984/// Instantiate a resource method builder
11985///
11986/// ```test_harness,no_run
11987/// # extern crate hyper;
11988/// # extern crate hyper_rustls;
11989/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
11990/// # async fn dox() {
11991/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11992///
11993/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11994/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11995/// # .with_native_roots()
11996/// # .unwrap()
11997/// # .https_only()
11998/// # .enable_http2()
11999/// # .build();
12000///
12001/// # let executor = hyper_util::rt::TokioExecutor::new();
12002/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12003/// # secret,
12004/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12005/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12006/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12007/// # ),
12008/// # ).build().await.unwrap();
12009///
12010/// # let client = hyper_util::client::legacy::Client::builder(
12011/// # hyper_util::rt::TokioExecutor::new()
12012/// # )
12013/// # .build(
12014/// # hyper_rustls::HttpsConnectorBuilder::new()
12015/// # .with_native_roots()
12016/// # .unwrap()
12017/// # .https_or_http()
12018/// # .enable_http2()
12019/// # .build()
12020/// # );
12021/// # let mut hub = CloudResourceManager::new(client, auth);
12022/// // You can configure optional parameters by calling the respective setters at will, and
12023/// // execute the final call using `doit()`.
12024/// // Values shown here are possibly random and not representative !
12025/// let result = hub.projects().list()
12026/// .page_token("sed")
12027/// .page_size(-70)
12028/// .filter("sed")
12029/// .doit().await;
12030/// # }
12031/// ```
12032pub struct ProjectListCall<'a, C>
12033where
12034 C: 'a,
12035{
12036 hub: &'a CloudResourceManager<C>,
12037 _page_token: Option<String>,
12038 _page_size: Option<i32>,
12039 _filter: Option<String>,
12040 _delegate: Option<&'a mut dyn common::Delegate>,
12041 _additional_params: HashMap<String, String>,
12042 _scopes: BTreeSet<String>,
12043}
12044
12045impl<'a, C> common::CallBuilder for ProjectListCall<'a, C> {}
12046
12047impl<'a, C> ProjectListCall<'a, C>
12048where
12049 C: common::Connector,
12050{
12051 /// Perform the operation you have build so far.
12052 pub async fn doit(mut self) -> common::Result<(common::Response, ListProjectsResponse)> {
12053 use std::borrow::Cow;
12054 use std::io::{Read, Seek};
12055
12056 use common::{url::Params, ToParts};
12057 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12058
12059 let mut dd = common::DefaultDelegate;
12060 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12061 dlg.begin(common::MethodInfo {
12062 id: "cloudresourcemanager.projects.list",
12063 http_method: hyper::Method::GET,
12064 });
12065
12066 for &field in ["alt", "pageToken", "pageSize", "filter"].iter() {
12067 if self._additional_params.contains_key(field) {
12068 dlg.finished(false);
12069 return Err(common::Error::FieldClash(field));
12070 }
12071 }
12072
12073 let mut params = Params::with_capacity(5 + self._additional_params.len());
12074 if let Some(value) = self._page_token.as_ref() {
12075 params.push("pageToken", value);
12076 }
12077 if let Some(value) = self._page_size.as_ref() {
12078 params.push("pageSize", value.to_string());
12079 }
12080 if let Some(value) = self._filter.as_ref() {
12081 params.push("filter", value);
12082 }
12083
12084 params.extend(self._additional_params.iter());
12085
12086 params.push("alt", "json");
12087 let mut url = self.hub._base_url.clone() + "v1/projects";
12088 if self._scopes.is_empty() {
12089 self._scopes
12090 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
12091 }
12092
12093 let url = params.parse_with_url(&url);
12094
12095 loop {
12096 let token = match self
12097 .hub
12098 .auth
12099 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12100 .await
12101 {
12102 Ok(token) => token,
12103 Err(e) => match dlg.token(e) {
12104 Ok(token) => token,
12105 Err(e) => {
12106 dlg.finished(false);
12107 return Err(common::Error::MissingToken(e));
12108 }
12109 },
12110 };
12111 let mut req_result = {
12112 let client = &self.hub.client;
12113 dlg.pre_request();
12114 let mut req_builder = hyper::Request::builder()
12115 .method(hyper::Method::GET)
12116 .uri(url.as_str())
12117 .header(USER_AGENT, self.hub._user_agent.clone());
12118
12119 if let Some(token) = token.as_ref() {
12120 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12121 }
12122
12123 let request = req_builder
12124 .header(CONTENT_LENGTH, 0_u64)
12125 .body(common::to_body::<String>(None));
12126
12127 client.request(request.unwrap()).await
12128 };
12129
12130 match req_result {
12131 Err(err) => {
12132 if let common::Retry::After(d) = dlg.http_error(&err) {
12133 sleep(d).await;
12134 continue;
12135 }
12136 dlg.finished(false);
12137 return Err(common::Error::HttpError(err));
12138 }
12139 Ok(res) => {
12140 let (mut parts, body) = res.into_parts();
12141 let mut body = common::Body::new(body);
12142 if !parts.status.is_success() {
12143 let bytes = common::to_bytes(body).await.unwrap_or_default();
12144 let error = serde_json::from_str(&common::to_string(&bytes));
12145 let response = common::to_response(parts, bytes.into());
12146
12147 if let common::Retry::After(d) =
12148 dlg.http_failure(&response, error.as_ref().ok())
12149 {
12150 sleep(d).await;
12151 continue;
12152 }
12153
12154 dlg.finished(false);
12155
12156 return Err(match error {
12157 Ok(value) => common::Error::BadRequest(value),
12158 _ => common::Error::Failure(response),
12159 });
12160 }
12161 let response = {
12162 let bytes = common::to_bytes(body).await.unwrap_or_default();
12163 let encoded = common::to_string(&bytes);
12164 match serde_json::from_str(&encoded) {
12165 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12166 Err(error) => {
12167 dlg.response_json_decode_error(&encoded, &error);
12168 return Err(common::Error::JsonDecodeError(
12169 encoded.to_string(),
12170 error,
12171 ));
12172 }
12173 }
12174 };
12175
12176 dlg.finished(true);
12177 return Ok(response);
12178 }
12179 }
12180 }
12181 }
12182
12183 /// Optional. A pagination token returned from a previous call to ListProjects that indicates from where listing should continue.
12184 ///
12185 /// Sets the *page token* query property to the given value.
12186 pub fn page_token(mut self, new_value: &str) -> ProjectListCall<'a, C> {
12187 self._page_token = Some(new_value.to_string());
12188 self
12189 }
12190 /// Optional. The maximum number of Projects to return in the response. The server can return fewer Projects than requested. If unspecified, server picks an appropriate default.
12191 ///
12192 /// Sets the *page size* query property to the given value.
12193 pub fn page_size(mut self, new_value: i32) -> ProjectListCall<'a, C> {
12194 self._page_size = Some(new_value);
12195 self
12196 }
12197 /// Optional. An expression for filtering the results of the request. Filter rules are case insensitive. If multiple fields are included in a filter query, the query will return results that match any of the fields. Some eligible fields for filtering are: + `name` + `id` + `labels.` (where *key* is the name of a label) + `parent.type` + `parent.id` + `lifecycleState` Some examples of filter queries: | Query | Description | |------------------|-----------------------------------------------------| | name:how* | The project's name starts with "how". | | name:Howl | The project's name is `Howl` or `howl`. | | name:HOWL | Equivalent to above. | | NAME:howl | Equivalent to above. | | labels.color:* | The project has the label `color`. | | labels.color:red | The project's label `color` has the value `red`. | | labels.color:red labels.size:big | The project's label `color` has the value `red` or its label `size` has the value `big`. | | lifecycleState:DELETE_REQUESTED | Only show projects that are pending deletion.| If no filter is specified, the call will return projects for which the user has the `resourcemanager.projects.get` permission. NOTE: To perform a by-parent query (eg., what projects are directly in a Folder), the caller must have the `resourcemanager.projects.list` permission on the parent and the filter must contain both a `parent.type` and a `parent.id` restriction (example: "parent.type:folder parent.id:123"). In this case an alternate search index is used which provides more consistent results.
12198 ///
12199 /// Sets the *filter* query property to the given value.
12200 pub fn filter(mut self, new_value: &str) -> ProjectListCall<'a, C> {
12201 self._filter = Some(new_value.to_string());
12202 self
12203 }
12204 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12205 /// while executing the actual API request.
12206 ///
12207 /// ````text
12208 /// It should be used to handle progress information, and to implement a certain level of resilience.
12209 /// ````
12210 ///
12211 /// Sets the *delegate* property to the given value.
12212 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectListCall<'a, C> {
12213 self._delegate = Some(new_value);
12214 self
12215 }
12216
12217 /// Set any additional parameter of the query string used in the request.
12218 /// It should be used to set parameters which are not yet available through their own
12219 /// setters.
12220 ///
12221 /// Please note that this method must not be used to set any of the known parameters
12222 /// which have their own setter method. If done anyway, the request will fail.
12223 ///
12224 /// # Additional Parameters
12225 ///
12226 /// * *$.xgafv* (query-string) - V1 error format.
12227 /// * *access_token* (query-string) - OAuth access token.
12228 /// * *alt* (query-string) - Data format for response.
12229 /// * *callback* (query-string) - JSONP
12230 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12231 /// * *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.
12232 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12233 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12234 /// * *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.
12235 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12236 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12237 pub fn param<T>(mut self, name: T, value: T) -> ProjectListCall<'a, C>
12238 where
12239 T: AsRef<str>,
12240 {
12241 self._additional_params
12242 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12243 self
12244 }
12245
12246 /// Identifies the authorization scope for the method you are building.
12247 ///
12248 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12249 /// [`Scope::CloudPlatformReadOnly`].
12250 ///
12251 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12252 /// tokens for more than one scope.
12253 ///
12254 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12255 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12256 /// sufficient, a read-write scope will do as well.
12257 pub fn add_scope<St>(mut self, scope: St) -> ProjectListCall<'a, C>
12258 where
12259 St: AsRef<str>,
12260 {
12261 self._scopes.insert(String::from(scope.as_ref()));
12262 self
12263 }
12264 /// Identifies the authorization scope(s) for the method you are building.
12265 ///
12266 /// See [`Self::add_scope()`] for details.
12267 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectListCall<'a, C>
12268 where
12269 I: IntoIterator<Item = St>,
12270 St: AsRef<str>,
12271 {
12272 self._scopes
12273 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12274 self
12275 }
12276
12277 /// Removes all scopes, and no default scope will be used either.
12278 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12279 /// for details).
12280 pub fn clear_scopes(mut self) -> ProjectListCall<'a, C> {
12281 self._scopes.clear();
12282 self
12283 }
12284}
12285
12286/// Lists `Constraints` that could be applied on the specified resource.
12287///
12288/// A builder for the *listAvailableOrgPolicyConstraints* method supported by a *project* resource.
12289/// It is not used directly, but through a [`ProjectMethods`] instance.
12290///
12291/// # Example
12292///
12293/// Instantiate a resource method builder
12294///
12295/// ```test_harness,no_run
12296/// # extern crate hyper;
12297/// # extern crate hyper_rustls;
12298/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
12299/// use cloudresourcemanager1::api::ListAvailableOrgPolicyConstraintsRequest;
12300/// # async fn dox() {
12301/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12302///
12303/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12304/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12305/// # .with_native_roots()
12306/// # .unwrap()
12307/// # .https_only()
12308/// # .enable_http2()
12309/// # .build();
12310///
12311/// # let executor = hyper_util::rt::TokioExecutor::new();
12312/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12313/// # secret,
12314/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12315/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12316/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12317/// # ),
12318/// # ).build().await.unwrap();
12319///
12320/// # let client = hyper_util::client::legacy::Client::builder(
12321/// # hyper_util::rt::TokioExecutor::new()
12322/// # )
12323/// # .build(
12324/// # hyper_rustls::HttpsConnectorBuilder::new()
12325/// # .with_native_roots()
12326/// # .unwrap()
12327/// # .https_or_http()
12328/// # .enable_http2()
12329/// # .build()
12330/// # );
12331/// # let mut hub = CloudResourceManager::new(client, auth);
12332/// // As the method needs a request, you would usually fill it with the desired information
12333/// // into the respective structure. Some of the parts shown here might not be applicable !
12334/// // Values shown here are possibly random and not representative !
12335/// let mut req = ListAvailableOrgPolicyConstraintsRequest::default();
12336///
12337/// // You can configure optional parameters by calling the respective setters at will, and
12338/// // execute the final call using `doit()`.
12339/// // Values shown here are possibly random and not representative !
12340/// let result = hub.projects().list_available_org_policy_constraints(req, "resource")
12341/// .doit().await;
12342/// # }
12343/// ```
12344pub struct ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12345where
12346 C: 'a,
12347{
12348 hub: &'a CloudResourceManager<C>,
12349 _request: ListAvailableOrgPolicyConstraintsRequest,
12350 _resource: String,
12351 _delegate: Option<&'a mut dyn common::Delegate>,
12352 _additional_params: HashMap<String, String>,
12353 _scopes: BTreeSet<String>,
12354}
12355
12356impl<'a, C> common::CallBuilder for ProjectListAvailableOrgPolicyConstraintCall<'a, C> {}
12357
12358impl<'a, C> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12359where
12360 C: common::Connector,
12361{
12362 /// Perform the operation you have build so far.
12363 pub async fn doit(
12364 mut self,
12365 ) -> common::Result<(common::Response, ListAvailableOrgPolicyConstraintsResponse)> {
12366 use std::borrow::Cow;
12367 use std::io::{Read, Seek};
12368
12369 use common::{url::Params, ToParts};
12370 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12371
12372 let mut dd = common::DefaultDelegate;
12373 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12374 dlg.begin(common::MethodInfo {
12375 id: "cloudresourcemanager.projects.listAvailableOrgPolicyConstraints",
12376 http_method: hyper::Method::POST,
12377 });
12378
12379 for &field in ["alt", "resource"].iter() {
12380 if self._additional_params.contains_key(field) {
12381 dlg.finished(false);
12382 return Err(common::Error::FieldClash(field));
12383 }
12384 }
12385
12386 let mut params = Params::with_capacity(4 + self._additional_params.len());
12387 params.push("resource", self._resource);
12388
12389 params.extend(self._additional_params.iter());
12390
12391 params.push("alt", "json");
12392 let mut url =
12393 self.hub._base_url.clone() + "v1/{+resource}:listAvailableOrgPolicyConstraints";
12394 if self._scopes.is_empty() {
12395 self._scopes
12396 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
12397 }
12398
12399 #[allow(clippy::single_element_loop)]
12400 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12401 url = params.uri_replacement(url, param_name, find_this, true);
12402 }
12403 {
12404 let to_remove = ["resource"];
12405 params.remove_params(&to_remove);
12406 }
12407
12408 let url = params.parse_with_url(&url);
12409
12410 let mut json_mime_type = mime::APPLICATION_JSON;
12411 let mut request_value_reader = {
12412 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12413 common::remove_json_null_values(&mut value);
12414 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12415 serde_json::to_writer(&mut dst, &value).unwrap();
12416 dst
12417 };
12418 let request_size = request_value_reader
12419 .seek(std::io::SeekFrom::End(0))
12420 .unwrap();
12421 request_value_reader
12422 .seek(std::io::SeekFrom::Start(0))
12423 .unwrap();
12424
12425 loop {
12426 let token = match self
12427 .hub
12428 .auth
12429 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12430 .await
12431 {
12432 Ok(token) => token,
12433 Err(e) => match dlg.token(e) {
12434 Ok(token) => token,
12435 Err(e) => {
12436 dlg.finished(false);
12437 return Err(common::Error::MissingToken(e));
12438 }
12439 },
12440 };
12441 request_value_reader
12442 .seek(std::io::SeekFrom::Start(0))
12443 .unwrap();
12444 let mut req_result = {
12445 let client = &self.hub.client;
12446 dlg.pre_request();
12447 let mut req_builder = hyper::Request::builder()
12448 .method(hyper::Method::POST)
12449 .uri(url.as_str())
12450 .header(USER_AGENT, self.hub._user_agent.clone());
12451
12452 if let Some(token) = token.as_ref() {
12453 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12454 }
12455
12456 let request = req_builder
12457 .header(CONTENT_TYPE, json_mime_type.to_string())
12458 .header(CONTENT_LENGTH, request_size as u64)
12459 .body(common::to_body(
12460 request_value_reader.get_ref().clone().into(),
12461 ));
12462
12463 client.request(request.unwrap()).await
12464 };
12465
12466 match req_result {
12467 Err(err) => {
12468 if let common::Retry::After(d) = dlg.http_error(&err) {
12469 sleep(d).await;
12470 continue;
12471 }
12472 dlg.finished(false);
12473 return Err(common::Error::HttpError(err));
12474 }
12475 Ok(res) => {
12476 let (mut parts, body) = res.into_parts();
12477 let mut body = common::Body::new(body);
12478 if !parts.status.is_success() {
12479 let bytes = common::to_bytes(body).await.unwrap_or_default();
12480 let error = serde_json::from_str(&common::to_string(&bytes));
12481 let response = common::to_response(parts, bytes.into());
12482
12483 if let common::Retry::After(d) =
12484 dlg.http_failure(&response, error.as_ref().ok())
12485 {
12486 sleep(d).await;
12487 continue;
12488 }
12489
12490 dlg.finished(false);
12491
12492 return Err(match error {
12493 Ok(value) => common::Error::BadRequest(value),
12494 _ => common::Error::Failure(response),
12495 });
12496 }
12497 let response = {
12498 let bytes = common::to_bytes(body).await.unwrap_or_default();
12499 let encoded = common::to_string(&bytes);
12500 match serde_json::from_str(&encoded) {
12501 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12502 Err(error) => {
12503 dlg.response_json_decode_error(&encoded, &error);
12504 return Err(common::Error::JsonDecodeError(
12505 encoded.to_string(),
12506 error,
12507 ));
12508 }
12509 }
12510 };
12511
12512 dlg.finished(true);
12513 return Ok(response);
12514 }
12515 }
12516 }
12517 }
12518
12519 ///
12520 /// Sets the *request* property to the given value.
12521 ///
12522 /// Even though the property as already been set when instantiating this call,
12523 /// we provide this method for API completeness.
12524 pub fn request(
12525 mut self,
12526 new_value: ListAvailableOrgPolicyConstraintsRequest,
12527 ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12528 self._request = new_value;
12529 self
12530 }
12531 /// Name of the resource to list `Constraints` for.
12532 ///
12533 /// Sets the *resource* path property to the given value.
12534 ///
12535 /// Even though the property as already been set when instantiating this call,
12536 /// we provide this method for API completeness.
12537 pub fn resource(
12538 mut self,
12539 new_value: &str,
12540 ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12541 self._resource = new_value.to_string();
12542 self
12543 }
12544 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12545 /// while executing the actual API request.
12546 ///
12547 /// ````text
12548 /// It should be used to handle progress information, and to implement a certain level of resilience.
12549 /// ````
12550 ///
12551 /// Sets the *delegate* property to the given value.
12552 pub fn delegate(
12553 mut self,
12554 new_value: &'a mut dyn common::Delegate,
12555 ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12556 self._delegate = Some(new_value);
12557 self
12558 }
12559
12560 /// Set any additional parameter of the query string used in the request.
12561 /// It should be used to set parameters which are not yet available through their own
12562 /// setters.
12563 ///
12564 /// Please note that this method must not be used to set any of the known parameters
12565 /// which have their own setter method. If done anyway, the request will fail.
12566 ///
12567 /// # Additional Parameters
12568 ///
12569 /// * *$.xgafv* (query-string) - V1 error format.
12570 /// * *access_token* (query-string) - OAuth access token.
12571 /// * *alt* (query-string) - Data format for response.
12572 /// * *callback* (query-string) - JSONP
12573 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12574 /// * *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.
12575 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12576 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12577 /// * *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.
12578 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12579 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12580 pub fn param<T>(
12581 mut self,
12582 name: T,
12583 value: T,
12584 ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12585 where
12586 T: AsRef<str>,
12587 {
12588 self._additional_params
12589 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12590 self
12591 }
12592
12593 /// Identifies the authorization scope for the method you are building.
12594 ///
12595 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12596 /// [`Scope::CloudPlatformReadOnly`].
12597 ///
12598 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12599 /// tokens for more than one scope.
12600 ///
12601 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12602 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12603 /// sufficient, a read-write scope will do as well.
12604 pub fn add_scope<St>(mut self, scope: St) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12605 where
12606 St: AsRef<str>,
12607 {
12608 self._scopes.insert(String::from(scope.as_ref()));
12609 self
12610 }
12611 /// Identifies the authorization scope(s) for the method you are building.
12612 ///
12613 /// See [`Self::add_scope()`] for details.
12614 pub fn add_scopes<I, St>(
12615 mut self,
12616 scopes: I,
12617 ) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C>
12618 where
12619 I: IntoIterator<Item = St>,
12620 St: AsRef<str>,
12621 {
12622 self._scopes
12623 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12624 self
12625 }
12626
12627 /// Removes all scopes, and no default scope will be used either.
12628 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12629 /// for details).
12630 pub fn clear_scopes(mut self) -> ProjectListAvailableOrgPolicyConstraintCall<'a, C> {
12631 self._scopes.clear();
12632 self
12633 }
12634}
12635
12636/// Lists all the `Policies` set for a particular resource.
12637///
12638/// A builder for the *listOrgPolicies* method supported by a *project* resource.
12639/// It is not used directly, but through a [`ProjectMethods`] instance.
12640///
12641/// # Example
12642///
12643/// Instantiate a resource method builder
12644///
12645/// ```test_harness,no_run
12646/// # extern crate hyper;
12647/// # extern crate hyper_rustls;
12648/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
12649/// use cloudresourcemanager1::api::ListOrgPoliciesRequest;
12650/// # async fn dox() {
12651/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12652///
12653/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12654/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12655/// # .with_native_roots()
12656/// # .unwrap()
12657/// # .https_only()
12658/// # .enable_http2()
12659/// # .build();
12660///
12661/// # let executor = hyper_util::rt::TokioExecutor::new();
12662/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12663/// # secret,
12664/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12665/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12666/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12667/// # ),
12668/// # ).build().await.unwrap();
12669///
12670/// # let client = hyper_util::client::legacy::Client::builder(
12671/// # hyper_util::rt::TokioExecutor::new()
12672/// # )
12673/// # .build(
12674/// # hyper_rustls::HttpsConnectorBuilder::new()
12675/// # .with_native_roots()
12676/// # .unwrap()
12677/// # .https_or_http()
12678/// # .enable_http2()
12679/// # .build()
12680/// # );
12681/// # let mut hub = CloudResourceManager::new(client, auth);
12682/// // As the method needs a request, you would usually fill it with the desired information
12683/// // into the respective structure. Some of the parts shown here might not be applicable !
12684/// // Values shown here are possibly random and not representative !
12685/// let mut req = ListOrgPoliciesRequest::default();
12686///
12687/// // You can configure optional parameters by calling the respective setters at will, and
12688/// // execute the final call using `doit()`.
12689/// // Values shown here are possibly random and not representative !
12690/// let result = hub.projects().list_org_policies(req, "resource")
12691/// .doit().await;
12692/// # }
12693/// ```
12694pub struct ProjectListOrgPolicyCall<'a, C>
12695where
12696 C: 'a,
12697{
12698 hub: &'a CloudResourceManager<C>,
12699 _request: ListOrgPoliciesRequest,
12700 _resource: String,
12701 _delegate: Option<&'a mut dyn common::Delegate>,
12702 _additional_params: HashMap<String, String>,
12703 _scopes: BTreeSet<String>,
12704}
12705
12706impl<'a, C> common::CallBuilder for ProjectListOrgPolicyCall<'a, C> {}
12707
12708impl<'a, C> ProjectListOrgPolicyCall<'a, C>
12709where
12710 C: common::Connector,
12711{
12712 /// Perform the operation you have build so far.
12713 pub async fn doit(mut self) -> common::Result<(common::Response, ListOrgPoliciesResponse)> {
12714 use std::borrow::Cow;
12715 use std::io::{Read, Seek};
12716
12717 use common::{url::Params, ToParts};
12718 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12719
12720 let mut dd = common::DefaultDelegate;
12721 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12722 dlg.begin(common::MethodInfo {
12723 id: "cloudresourcemanager.projects.listOrgPolicies",
12724 http_method: hyper::Method::POST,
12725 });
12726
12727 for &field in ["alt", "resource"].iter() {
12728 if self._additional_params.contains_key(field) {
12729 dlg.finished(false);
12730 return Err(common::Error::FieldClash(field));
12731 }
12732 }
12733
12734 let mut params = Params::with_capacity(4 + self._additional_params.len());
12735 params.push("resource", self._resource);
12736
12737 params.extend(self._additional_params.iter());
12738
12739 params.push("alt", "json");
12740 let mut url = self.hub._base_url.clone() + "v1/{+resource}:listOrgPolicies";
12741 if self._scopes.is_empty() {
12742 self._scopes
12743 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
12744 }
12745
12746 #[allow(clippy::single_element_loop)]
12747 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12748 url = params.uri_replacement(url, param_name, find_this, true);
12749 }
12750 {
12751 let to_remove = ["resource"];
12752 params.remove_params(&to_remove);
12753 }
12754
12755 let url = params.parse_with_url(&url);
12756
12757 let mut json_mime_type = mime::APPLICATION_JSON;
12758 let mut request_value_reader = {
12759 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12760 common::remove_json_null_values(&mut value);
12761 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12762 serde_json::to_writer(&mut dst, &value).unwrap();
12763 dst
12764 };
12765 let request_size = request_value_reader
12766 .seek(std::io::SeekFrom::End(0))
12767 .unwrap();
12768 request_value_reader
12769 .seek(std::io::SeekFrom::Start(0))
12770 .unwrap();
12771
12772 loop {
12773 let token = match self
12774 .hub
12775 .auth
12776 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12777 .await
12778 {
12779 Ok(token) => token,
12780 Err(e) => match dlg.token(e) {
12781 Ok(token) => token,
12782 Err(e) => {
12783 dlg.finished(false);
12784 return Err(common::Error::MissingToken(e));
12785 }
12786 },
12787 };
12788 request_value_reader
12789 .seek(std::io::SeekFrom::Start(0))
12790 .unwrap();
12791 let mut req_result = {
12792 let client = &self.hub.client;
12793 dlg.pre_request();
12794 let mut req_builder = hyper::Request::builder()
12795 .method(hyper::Method::POST)
12796 .uri(url.as_str())
12797 .header(USER_AGENT, self.hub._user_agent.clone());
12798
12799 if let Some(token) = token.as_ref() {
12800 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12801 }
12802
12803 let request = req_builder
12804 .header(CONTENT_TYPE, json_mime_type.to_string())
12805 .header(CONTENT_LENGTH, request_size as u64)
12806 .body(common::to_body(
12807 request_value_reader.get_ref().clone().into(),
12808 ));
12809
12810 client.request(request.unwrap()).await
12811 };
12812
12813 match req_result {
12814 Err(err) => {
12815 if let common::Retry::After(d) = dlg.http_error(&err) {
12816 sleep(d).await;
12817 continue;
12818 }
12819 dlg.finished(false);
12820 return Err(common::Error::HttpError(err));
12821 }
12822 Ok(res) => {
12823 let (mut parts, body) = res.into_parts();
12824 let mut body = common::Body::new(body);
12825 if !parts.status.is_success() {
12826 let bytes = common::to_bytes(body).await.unwrap_or_default();
12827 let error = serde_json::from_str(&common::to_string(&bytes));
12828 let response = common::to_response(parts, bytes.into());
12829
12830 if let common::Retry::After(d) =
12831 dlg.http_failure(&response, error.as_ref().ok())
12832 {
12833 sleep(d).await;
12834 continue;
12835 }
12836
12837 dlg.finished(false);
12838
12839 return Err(match error {
12840 Ok(value) => common::Error::BadRequest(value),
12841 _ => common::Error::Failure(response),
12842 });
12843 }
12844 let response = {
12845 let bytes = common::to_bytes(body).await.unwrap_or_default();
12846 let encoded = common::to_string(&bytes);
12847 match serde_json::from_str(&encoded) {
12848 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12849 Err(error) => {
12850 dlg.response_json_decode_error(&encoded, &error);
12851 return Err(common::Error::JsonDecodeError(
12852 encoded.to_string(),
12853 error,
12854 ));
12855 }
12856 }
12857 };
12858
12859 dlg.finished(true);
12860 return Ok(response);
12861 }
12862 }
12863 }
12864 }
12865
12866 ///
12867 /// Sets the *request* property to the given value.
12868 ///
12869 /// Even though the property as already been set when instantiating this call,
12870 /// we provide this method for API completeness.
12871 pub fn request(mut self, new_value: ListOrgPoliciesRequest) -> ProjectListOrgPolicyCall<'a, C> {
12872 self._request = new_value;
12873 self
12874 }
12875 /// Name of the resource to list Policies for.
12876 ///
12877 /// Sets the *resource* path property to the given value.
12878 ///
12879 /// Even though the property as already been set when instantiating this call,
12880 /// we provide this method for API completeness.
12881 pub fn resource(mut self, new_value: &str) -> ProjectListOrgPolicyCall<'a, C> {
12882 self._resource = new_value.to_string();
12883 self
12884 }
12885 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12886 /// while executing the actual API request.
12887 ///
12888 /// ````text
12889 /// It should be used to handle progress information, and to implement a certain level of resilience.
12890 /// ````
12891 ///
12892 /// Sets the *delegate* property to the given value.
12893 pub fn delegate(
12894 mut self,
12895 new_value: &'a mut dyn common::Delegate,
12896 ) -> ProjectListOrgPolicyCall<'a, C> {
12897 self._delegate = Some(new_value);
12898 self
12899 }
12900
12901 /// Set any additional parameter of the query string used in the request.
12902 /// It should be used to set parameters which are not yet available through their own
12903 /// setters.
12904 ///
12905 /// Please note that this method must not be used to set any of the known parameters
12906 /// which have their own setter method. If done anyway, the request will fail.
12907 ///
12908 /// # Additional Parameters
12909 ///
12910 /// * *$.xgafv* (query-string) - V1 error format.
12911 /// * *access_token* (query-string) - OAuth access token.
12912 /// * *alt* (query-string) - Data format for response.
12913 /// * *callback* (query-string) - JSONP
12914 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12915 /// * *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.
12916 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12917 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12918 /// * *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.
12919 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12920 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12921 pub fn param<T>(mut self, name: T, value: T) -> ProjectListOrgPolicyCall<'a, C>
12922 where
12923 T: AsRef<str>,
12924 {
12925 self._additional_params
12926 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12927 self
12928 }
12929
12930 /// Identifies the authorization scope for the method you are building.
12931 ///
12932 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12933 /// [`Scope::CloudPlatformReadOnly`].
12934 ///
12935 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12936 /// tokens for more than one scope.
12937 ///
12938 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12939 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12940 /// sufficient, a read-write scope will do as well.
12941 pub fn add_scope<St>(mut self, scope: St) -> ProjectListOrgPolicyCall<'a, C>
12942 where
12943 St: AsRef<str>,
12944 {
12945 self._scopes.insert(String::from(scope.as_ref()));
12946 self
12947 }
12948 /// Identifies the authorization scope(s) for the method you are building.
12949 ///
12950 /// See [`Self::add_scope()`] for details.
12951 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectListOrgPolicyCall<'a, C>
12952 where
12953 I: IntoIterator<Item = St>,
12954 St: AsRef<str>,
12955 {
12956 self._scopes
12957 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12958 self
12959 }
12960
12961 /// Removes all scopes, and no default scope will be used either.
12962 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12963 /// for details).
12964 pub fn clear_scopes(mut self) -> ProjectListOrgPolicyCall<'a, C> {
12965 self._scopes.clear();
12966 self
12967 }
12968}
12969
12970/// Sets the IAM access control policy for the specified Project. CAUTION: This method will replace the existing policy, and cannot be used to append additional IAM settings. NOTE: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). The following constraints apply when using `setIamPolicy()`: + Project does not support `allUsers` and `allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The owner role can be granted to a `user`, `serviceAccount`, or a group that is part of an organization. For example, group@myownpersonaldomain.com could be added as an owner to a project in the myownpersonaldomain.com organization, but not the examplepetstore.com organization. + Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation. + A user cannot be granted the owner role using `setIamPolicy()`. The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation. + You can only grant ownership of a project to a member by using the Google Cloud console. Inviting a member will deliver an invitation email that they must accept. An invitation email is not generated if you are granting a role other than owner, or if both the member you are inviting and the project are part of your organization. + If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling `setIamPolicy()` to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified. If the project is part of an organization, you can remove all owners, potentially making the organization inaccessible. Authorization requires the Google IAM permission `resourcemanager.projects.setIamPolicy` on the project
12971///
12972/// A builder for the *setIamPolicy* method supported by a *project* resource.
12973/// It is not used directly, but through a [`ProjectMethods`] instance.
12974///
12975/// # Example
12976///
12977/// Instantiate a resource method builder
12978///
12979/// ```test_harness,no_run
12980/// # extern crate hyper;
12981/// # extern crate hyper_rustls;
12982/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
12983/// use cloudresourcemanager1::api::SetIamPolicyRequest;
12984/// # async fn dox() {
12985/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12986///
12987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12989/// # .with_native_roots()
12990/// # .unwrap()
12991/// # .https_only()
12992/// # .enable_http2()
12993/// # .build();
12994///
12995/// # let executor = hyper_util::rt::TokioExecutor::new();
12996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12997/// # secret,
12998/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12999/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13000/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13001/// # ),
13002/// # ).build().await.unwrap();
13003///
13004/// # let client = hyper_util::client::legacy::Client::builder(
13005/// # hyper_util::rt::TokioExecutor::new()
13006/// # )
13007/// # .build(
13008/// # hyper_rustls::HttpsConnectorBuilder::new()
13009/// # .with_native_roots()
13010/// # .unwrap()
13011/// # .https_or_http()
13012/// # .enable_http2()
13013/// # .build()
13014/// # );
13015/// # let mut hub = CloudResourceManager::new(client, auth);
13016/// // As the method needs a request, you would usually fill it with the desired information
13017/// // into the respective structure. Some of the parts shown here might not be applicable !
13018/// // Values shown here are possibly random and not representative !
13019/// let mut req = SetIamPolicyRequest::default();
13020///
13021/// // You can configure optional parameters by calling the respective setters at will, and
13022/// // execute the final call using `doit()`.
13023/// // Values shown here are possibly random and not representative !
13024/// let result = hub.projects().set_iam_policy(req, "resource")
13025/// .doit().await;
13026/// # }
13027/// ```
13028pub struct ProjectSetIamPolicyCall<'a, C>
13029where
13030 C: 'a,
13031{
13032 hub: &'a CloudResourceManager<C>,
13033 _request: SetIamPolicyRequest,
13034 _resource: String,
13035 _delegate: Option<&'a mut dyn common::Delegate>,
13036 _additional_params: HashMap<String, String>,
13037 _scopes: BTreeSet<String>,
13038}
13039
13040impl<'a, C> common::CallBuilder for ProjectSetIamPolicyCall<'a, C> {}
13041
13042impl<'a, C> ProjectSetIamPolicyCall<'a, C>
13043where
13044 C: common::Connector,
13045{
13046 /// Perform the operation you have build so far.
13047 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
13048 use std::borrow::Cow;
13049 use std::io::{Read, Seek};
13050
13051 use common::{url::Params, ToParts};
13052 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13053
13054 let mut dd = common::DefaultDelegate;
13055 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13056 dlg.begin(common::MethodInfo {
13057 id: "cloudresourcemanager.projects.setIamPolicy",
13058 http_method: hyper::Method::POST,
13059 });
13060
13061 for &field in ["alt", "resource"].iter() {
13062 if self._additional_params.contains_key(field) {
13063 dlg.finished(false);
13064 return Err(common::Error::FieldClash(field));
13065 }
13066 }
13067
13068 let mut params = Params::with_capacity(4 + self._additional_params.len());
13069 params.push("resource", self._resource);
13070
13071 params.extend(self._additional_params.iter());
13072
13073 params.push("alt", "json");
13074 let mut url = self.hub._base_url.clone() + "v1/projects/{resource}:setIamPolicy";
13075 if self._scopes.is_empty() {
13076 self._scopes
13077 .insert(Scope::CloudPlatform.as_ref().to_string());
13078 }
13079
13080 #[allow(clippy::single_element_loop)]
13081 for &(find_this, param_name) in [("{resource}", "resource")].iter() {
13082 url = params.uri_replacement(url, param_name, find_this, false);
13083 }
13084 {
13085 let to_remove = ["resource"];
13086 params.remove_params(&to_remove);
13087 }
13088
13089 let url = params.parse_with_url(&url);
13090
13091 let mut json_mime_type = mime::APPLICATION_JSON;
13092 let mut request_value_reader = {
13093 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13094 common::remove_json_null_values(&mut value);
13095 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13096 serde_json::to_writer(&mut dst, &value).unwrap();
13097 dst
13098 };
13099 let request_size = request_value_reader
13100 .seek(std::io::SeekFrom::End(0))
13101 .unwrap();
13102 request_value_reader
13103 .seek(std::io::SeekFrom::Start(0))
13104 .unwrap();
13105
13106 loop {
13107 let token = match self
13108 .hub
13109 .auth
13110 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13111 .await
13112 {
13113 Ok(token) => token,
13114 Err(e) => match dlg.token(e) {
13115 Ok(token) => token,
13116 Err(e) => {
13117 dlg.finished(false);
13118 return Err(common::Error::MissingToken(e));
13119 }
13120 },
13121 };
13122 request_value_reader
13123 .seek(std::io::SeekFrom::Start(0))
13124 .unwrap();
13125 let mut req_result = {
13126 let client = &self.hub.client;
13127 dlg.pre_request();
13128 let mut req_builder = hyper::Request::builder()
13129 .method(hyper::Method::POST)
13130 .uri(url.as_str())
13131 .header(USER_AGENT, self.hub._user_agent.clone());
13132
13133 if let Some(token) = token.as_ref() {
13134 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13135 }
13136
13137 let request = req_builder
13138 .header(CONTENT_TYPE, json_mime_type.to_string())
13139 .header(CONTENT_LENGTH, request_size as u64)
13140 .body(common::to_body(
13141 request_value_reader.get_ref().clone().into(),
13142 ));
13143
13144 client.request(request.unwrap()).await
13145 };
13146
13147 match req_result {
13148 Err(err) => {
13149 if let common::Retry::After(d) = dlg.http_error(&err) {
13150 sleep(d).await;
13151 continue;
13152 }
13153 dlg.finished(false);
13154 return Err(common::Error::HttpError(err));
13155 }
13156 Ok(res) => {
13157 let (mut parts, body) = res.into_parts();
13158 let mut body = common::Body::new(body);
13159 if !parts.status.is_success() {
13160 let bytes = common::to_bytes(body).await.unwrap_or_default();
13161 let error = serde_json::from_str(&common::to_string(&bytes));
13162 let response = common::to_response(parts, bytes.into());
13163
13164 if let common::Retry::After(d) =
13165 dlg.http_failure(&response, error.as_ref().ok())
13166 {
13167 sleep(d).await;
13168 continue;
13169 }
13170
13171 dlg.finished(false);
13172
13173 return Err(match error {
13174 Ok(value) => common::Error::BadRequest(value),
13175 _ => common::Error::Failure(response),
13176 });
13177 }
13178 let response = {
13179 let bytes = common::to_bytes(body).await.unwrap_or_default();
13180 let encoded = common::to_string(&bytes);
13181 match serde_json::from_str(&encoded) {
13182 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13183 Err(error) => {
13184 dlg.response_json_decode_error(&encoded, &error);
13185 return Err(common::Error::JsonDecodeError(
13186 encoded.to_string(),
13187 error,
13188 ));
13189 }
13190 }
13191 };
13192
13193 dlg.finished(true);
13194 return Ok(response);
13195 }
13196 }
13197 }
13198 }
13199
13200 ///
13201 /// Sets the *request* property to the given value.
13202 ///
13203 /// Even though the property as already been set when instantiating this call,
13204 /// we provide this method for API completeness.
13205 pub fn request(mut self, new_value: SetIamPolicyRequest) -> ProjectSetIamPolicyCall<'a, C> {
13206 self._request = new_value;
13207 self
13208 }
13209 /// 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.
13210 ///
13211 /// Sets the *resource* path property to the given value.
13212 ///
13213 /// Even though the property as already been set when instantiating this call,
13214 /// we provide this method for API completeness.
13215 pub fn resource(mut self, new_value: &str) -> ProjectSetIamPolicyCall<'a, C> {
13216 self._resource = new_value.to_string();
13217 self
13218 }
13219 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13220 /// while executing the actual API request.
13221 ///
13222 /// ````text
13223 /// It should be used to handle progress information, and to implement a certain level of resilience.
13224 /// ````
13225 ///
13226 /// Sets the *delegate* property to the given value.
13227 pub fn delegate(
13228 mut self,
13229 new_value: &'a mut dyn common::Delegate,
13230 ) -> ProjectSetIamPolicyCall<'a, C> {
13231 self._delegate = Some(new_value);
13232 self
13233 }
13234
13235 /// Set any additional parameter of the query string used in the request.
13236 /// It should be used to set parameters which are not yet available through their own
13237 /// setters.
13238 ///
13239 /// Please note that this method must not be used to set any of the known parameters
13240 /// which have their own setter method. If done anyway, the request will fail.
13241 ///
13242 /// # Additional Parameters
13243 ///
13244 /// * *$.xgafv* (query-string) - V1 error format.
13245 /// * *access_token* (query-string) - OAuth access token.
13246 /// * *alt* (query-string) - Data format for response.
13247 /// * *callback* (query-string) - JSONP
13248 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13249 /// * *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.
13250 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13251 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13252 /// * *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.
13253 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13254 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13255 pub fn param<T>(mut self, name: T, value: T) -> ProjectSetIamPolicyCall<'a, C>
13256 where
13257 T: AsRef<str>,
13258 {
13259 self._additional_params
13260 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13261 self
13262 }
13263
13264 /// Identifies the authorization scope for the method you are building.
13265 ///
13266 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13267 /// [`Scope::CloudPlatform`].
13268 ///
13269 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13270 /// tokens for more than one scope.
13271 ///
13272 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13273 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13274 /// sufficient, a read-write scope will do as well.
13275 pub fn add_scope<St>(mut self, scope: St) -> ProjectSetIamPolicyCall<'a, C>
13276 where
13277 St: AsRef<str>,
13278 {
13279 self._scopes.insert(String::from(scope.as_ref()));
13280 self
13281 }
13282 /// Identifies the authorization scope(s) for the method you are building.
13283 ///
13284 /// See [`Self::add_scope()`] for details.
13285 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSetIamPolicyCall<'a, C>
13286 where
13287 I: IntoIterator<Item = St>,
13288 St: AsRef<str>,
13289 {
13290 self._scopes
13291 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13292 self
13293 }
13294
13295 /// Removes all scopes, and no default scope will be used either.
13296 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13297 /// for details).
13298 pub fn clear_scopes(mut self) -> ProjectSetIamPolicyCall<'a, C> {
13299 self._scopes.clear();
13300 self
13301 }
13302}
13303
13304/// Updates the specified `Policy` on the resource. Creates a new `Policy` for that `Constraint` on the resource if one does not exist. Not supplying an `etag` on the request `Policy` results in an unconditional write of the `Policy`.
13305///
13306/// A builder for the *setOrgPolicy* method supported by a *project* resource.
13307/// It is not used directly, but through a [`ProjectMethods`] instance.
13308///
13309/// # Example
13310///
13311/// Instantiate a resource method builder
13312///
13313/// ```test_harness,no_run
13314/// # extern crate hyper;
13315/// # extern crate hyper_rustls;
13316/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
13317/// use cloudresourcemanager1::api::SetOrgPolicyRequest;
13318/// # async fn dox() {
13319/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13320///
13321/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13322/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13323/// # .with_native_roots()
13324/// # .unwrap()
13325/// # .https_only()
13326/// # .enable_http2()
13327/// # .build();
13328///
13329/// # let executor = hyper_util::rt::TokioExecutor::new();
13330/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13331/// # secret,
13332/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13333/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13334/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13335/// # ),
13336/// # ).build().await.unwrap();
13337///
13338/// # let client = hyper_util::client::legacy::Client::builder(
13339/// # hyper_util::rt::TokioExecutor::new()
13340/// # )
13341/// # .build(
13342/// # hyper_rustls::HttpsConnectorBuilder::new()
13343/// # .with_native_roots()
13344/// # .unwrap()
13345/// # .https_or_http()
13346/// # .enable_http2()
13347/// # .build()
13348/// # );
13349/// # let mut hub = CloudResourceManager::new(client, auth);
13350/// // As the method needs a request, you would usually fill it with the desired information
13351/// // into the respective structure. Some of the parts shown here might not be applicable !
13352/// // Values shown here are possibly random and not representative !
13353/// let mut req = SetOrgPolicyRequest::default();
13354///
13355/// // You can configure optional parameters by calling the respective setters at will, and
13356/// // execute the final call using `doit()`.
13357/// // Values shown here are possibly random and not representative !
13358/// let result = hub.projects().set_org_policy(req, "resource")
13359/// .doit().await;
13360/// # }
13361/// ```
13362pub struct ProjectSetOrgPolicyCall<'a, C>
13363where
13364 C: 'a,
13365{
13366 hub: &'a CloudResourceManager<C>,
13367 _request: SetOrgPolicyRequest,
13368 _resource: String,
13369 _delegate: Option<&'a mut dyn common::Delegate>,
13370 _additional_params: HashMap<String, String>,
13371 _scopes: BTreeSet<String>,
13372}
13373
13374impl<'a, C> common::CallBuilder for ProjectSetOrgPolicyCall<'a, C> {}
13375
13376impl<'a, C> ProjectSetOrgPolicyCall<'a, C>
13377where
13378 C: common::Connector,
13379{
13380 /// Perform the operation you have build so far.
13381 pub async fn doit(mut self) -> common::Result<(common::Response, OrgPolicy)> {
13382 use std::borrow::Cow;
13383 use std::io::{Read, Seek};
13384
13385 use common::{url::Params, ToParts};
13386 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13387
13388 let mut dd = common::DefaultDelegate;
13389 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13390 dlg.begin(common::MethodInfo {
13391 id: "cloudresourcemanager.projects.setOrgPolicy",
13392 http_method: hyper::Method::POST,
13393 });
13394
13395 for &field in ["alt", "resource"].iter() {
13396 if self._additional_params.contains_key(field) {
13397 dlg.finished(false);
13398 return Err(common::Error::FieldClash(field));
13399 }
13400 }
13401
13402 let mut params = Params::with_capacity(4 + self._additional_params.len());
13403 params.push("resource", self._resource);
13404
13405 params.extend(self._additional_params.iter());
13406
13407 params.push("alt", "json");
13408 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setOrgPolicy";
13409 if self._scopes.is_empty() {
13410 self._scopes
13411 .insert(Scope::CloudPlatform.as_ref().to_string());
13412 }
13413
13414 #[allow(clippy::single_element_loop)]
13415 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
13416 url = params.uri_replacement(url, param_name, find_this, true);
13417 }
13418 {
13419 let to_remove = ["resource"];
13420 params.remove_params(&to_remove);
13421 }
13422
13423 let url = params.parse_with_url(&url);
13424
13425 let mut json_mime_type = mime::APPLICATION_JSON;
13426 let mut request_value_reader = {
13427 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13428 common::remove_json_null_values(&mut value);
13429 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13430 serde_json::to_writer(&mut dst, &value).unwrap();
13431 dst
13432 };
13433 let request_size = request_value_reader
13434 .seek(std::io::SeekFrom::End(0))
13435 .unwrap();
13436 request_value_reader
13437 .seek(std::io::SeekFrom::Start(0))
13438 .unwrap();
13439
13440 loop {
13441 let token = match self
13442 .hub
13443 .auth
13444 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13445 .await
13446 {
13447 Ok(token) => token,
13448 Err(e) => match dlg.token(e) {
13449 Ok(token) => token,
13450 Err(e) => {
13451 dlg.finished(false);
13452 return Err(common::Error::MissingToken(e));
13453 }
13454 },
13455 };
13456 request_value_reader
13457 .seek(std::io::SeekFrom::Start(0))
13458 .unwrap();
13459 let mut req_result = {
13460 let client = &self.hub.client;
13461 dlg.pre_request();
13462 let mut req_builder = hyper::Request::builder()
13463 .method(hyper::Method::POST)
13464 .uri(url.as_str())
13465 .header(USER_AGENT, self.hub._user_agent.clone());
13466
13467 if let Some(token) = token.as_ref() {
13468 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13469 }
13470
13471 let request = req_builder
13472 .header(CONTENT_TYPE, json_mime_type.to_string())
13473 .header(CONTENT_LENGTH, request_size as u64)
13474 .body(common::to_body(
13475 request_value_reader.get_ref().clone().into(),
13476 ));
13477
13478 client.request(request.unwrap()).await
13479 };
13480
13481 match req_result {
13482 Err(err) => {
13483 if let common::Retry::After(d) = dlg.http_error(&err) {
13484 sleep(d).await;
13485 continue;
13486 }
13487 dlg.finished(false);
13488 return Err(common::Error::HttpError(err));
13489 }
13490 Ok(res) => {
13491 let (mut parts, body) = res.into_parts();
13492 let mut body = common::Body::new(body);
13493 if !parts.status.is_success() {
13494 let bytes = common::to_bytes(body).await.unwrap_or_default();
13495 let error = serde_json::from_str(&common::to_string(&bytes));
13496 let response = common::to_response(parts, bytes.into());
13497
13498 if let common::Retry::After(d) =
13499 dlg.http_failure(&response, error.as_ref().ok())
13500 {
13501 sleep(d).await;
13502 continue;
13503 }
13504
13505 dlg.finished(false);
13506
13507 return Err(match error {
13508 Ok(value) => common::Error::BadRequest(value),
13509 _ => common::Error::Failure(response),
13510 });
13511 }
13512 let response = {
13513 let bytes = common::to_bytes(body).await.unwrap_or_default();
13514 let encoded = common::to_string(&bytes);
13515 match serde_json::from_str(&encoded) {
13516 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13517 Err(error) => {
13518 dlg.response_json_decode_error(&encoded, &error);
13519 return Err(common::Error::JsonDecodeError(
13520 encoded.to_string(),
13521 error,
13522 ));
13523 }
13524 }
13525 };
13526
13527 dlg.finished(true);
13528 return Ok(response);
13529 }
13530 }
13531 }
13532 }
13533
13534 ///
13535 /// Sets the *request* property to the given value.
13536 ///
13537 /// Even though the property as already been set when instantiating this call,
13538 /// we provide this method for API completeness.
13539 pub fn request(mut self, new_value: SetOrgPolicyRequest) -> ProjectSetOrgPolicyCall<'a, C> {
13540 self._request = new_value;
13541 self
13542 }
13543 /// Resource name of the resource to attach the `Policy`.
13544 ///
13545 /// Sets the *resource* path property to the given value.
13546 ///
13547 /// Even though the property as already been set when instantiating this call,
13548 /// we provide this method for API completeness.
13549 pub fn resource(mut self, new_value: &str) -> ProjectSetOrgPolicyCall<'a, C> {
13550 self._resource = new_value.to_string();
13551 self
13552 }
13553 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13554 /// while executing the actual API request.
13555 ///
13556 /// ````text
13557 /// It should be used to handle progress information, and to implement a certain level of resilience.
13558 /// ````
13559 ///
13560 /// Sets the *delegate* property to the given value.
13561 pub fn delegate(
13562 mut self,
13563 new_value: &'a mut dyn common::Delegate,
13564 ) -> ProjectSetOrgPolicyCall<'a, C> {
13565 self._delegate = Some(new_value);
13566 self
13567 }
13568
13569 /// Set any additional parameter of the query string used in the request.
13570 /// It should be used to set parameters which are not yet available through their own
13571 /// setters.
13572 ///
13573 /// Please note that this method must not be used to set any of the known parameters
13574 /// which have their own setter method. If done anyway, the request will fail.
13575 ///
13576 /// # Additional Parameters
13577 ///
13578 /// * *$.xgafv* (query-string) - V1 error format.
13579 /// * *access_token* (query-string) - OAuth access token.
13580 /// * *alt* (query-string) - Data format for response.
13581 /// * *callback* (query-string) - JSONP
13582 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13583 /// * *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.
13584 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13585 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13586 /// * *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.
13587 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13588 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13589 pub fn param<T>(mut self, name: T, value: T) -> ProjectSetOrgPolicyCall<'a, C>
13590 where
13591 T: AsRef<str>,
13592 {
13593 self._additional_params
13594 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13595 self
13596 }
13597
13598 /// Identifies the authorization scope for the method you are building.
13599 ///
13600 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13601 /// [`Scope::CloudPlatform`].
13602 ///
13603 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13604 /// tokens for more than one scope.
13605 ///
13606 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13607 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13608 /// sufficient, a read-write scope will do as well.
13609 pub fn add_scope<St>(mut self, scope: St) -> ProjectSetOrgPolicyCall<'a, C>
13610 where
13611 St: AsRef<str>,
13612 {
13613 self._scopes.insert(String::from(scope.as_ref()));
13614 self
13615 }
13616 /// Identifies the authorization scope(s) for the method you are building.
13617 ///
13618 /// See [`Self::add_scope()`] for details.
13619 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectSetOrgPolicyCall<'a, C>
13620 where
13621 I: IntoIterator<Item = St>,
13622 St: AsRef<str>,
13623 {
13624 self._scopes
13625 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13626 self
13627 }
13628
13629 /// Removes all scopes, and no default scope will be used either.
13630 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13631 /// for details).
13632 pub fn clear_scopes(mut self) -> ProjectSetOrgPolicyCall<'a, C> {
13633 self._scopes.clear();
13634 self
13635 }
13636}
13637
13638/// Returns permissions that a caller has on the specified Project. For additional information about `resource` (e.g. my-project-id) structure and identification, see [Resource Names](https://cloud.google.com/apis/design/resource_names). There are no permissions required for making this API call.
13639///
13640/// A builder for the *testIamPermissions* method supported by a *project* resource.
13641/// It is not used directly, but through a [`ProjectMethods`] instance.
13642///
13643/// # Example
13644///
13645/// Instantiate a resource method builder
13646///
13647/// ```test_harness,no_run
13648/// # extern crate hyper;
13649/// # extern crate hyper_rustls;
13650/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
13651/// use cloudresourcemanager1::api::TestIamPermissionsRequest;
13652/// # async fn dox() {
13653/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13654///
13655/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13656/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13657/// # .with_native_roots()
13658/// # .unwrap()
13659/// # .https_only()
13660/// # .enable_http2()
13661/// # .build();
13662///
13663/// # let executor = hyper_util::rt::TokioExecutor::new();
13664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13665/// # secret,
13666/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13667/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13668/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13669/// # ),
13670/// # ).build().await.unwrap();
13671///
13672/// # let client = hyper_util::client::legacy::Client::builder(
13673/// # hyper_util::rt::TokioExecutor::new()
13674/// # )
13675/// # .build(
13676/// # hyper_rustls::HttpsConnectorBuilder::new()
13677/// # .with_native_roots()
13678/// # .unwrap()
13679/// # .https_or_http()
13680/// # .enable_http2()
13681/// # .build()
13682/// # );
13683/// # let mut hub = CloudResourceManager::new(client, auth);
13684/// // As the method needs a request, you would usually fill it with the desired information
13685/// // into the respective structure. Some of the parts shown here might not be applicable !
13686/// // Values shown here are possibly random and not representative !
13687/// let mut req = TestIamPermissionsRequest::default();
13688///
13689/// // You can configure optional parameters by calling the respective setters at will, and
13690/// // execute the final call using `doit()`.
13691/// // Values shown here are possibly random and not representative !
13692/// let result = hub.projects().test_iam_permissions(req, "resource")
13693/// .doit().await;
13694/// # }
13695/// ```
13696pub struct ProjectTestIamPermissionCall<'a, C>
13697where
13698 C: 'a,
13699{
13700 hub: &'a CloudResourceManager<C>,
13701 _request: TestIamPermissionsRequest,
13702 _resource: String,
13703 _delegate: Option<&'a mut dyn common::Delegate>,
13704 _additional_params: HashMap<String, String>,
13705 _scopes: BTreeSet<String>,
13706}
13707
13708impl<'a, C> common::CallBuilder for ProjectTestIamPermissionCall<'a, C> {}
13709
13710impl<'a, C> ProjectTestIamPermissionCall<'a, C>
13711where
13712 C: common::Connector,
13713{
13714 /// Perform the operation you have build so far.
13715 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
13716 use std::borrow::Cow;
13717 use std::io::{Read, Seek};
13718
13719 use common::{url::Params, ToParts};
13720 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13721
13722 let mut dd = common::DefaultDelegate;
13723 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13724 dlg.begin(common::MethodInfo {
13725 id: "cloudresourcemanager.projects.testIamPermissions",
13726 http_method: hyper::Method::POST,
13727 });
13728
13729 for &field in ["alt", "resource"].iter() {
13730 if self._additional_params.contains_key(field) {
13731 dlg.finished(false);
13732 return Err(common::Error::FieldClash(field));
13733 }
13734 }
13735
13736 let mut params = Params::with_capacity(4 + self._additional_params.len());
13737 params.push("resource", self._resource);
13738
13739 params.extend(self._additional_params.iter());
13740
13741 params.push("alt", "json");
13742 let mut url = self.hub._base_url.clone() + "v1/projects/{resource}:testIamPermissions";
13743 if self._scopes.is_empty() {
13744 self._scopes
13745 .insert(Scope::CloudPlatformReadOnly.as_ref().to_string());
13746 }
13747
13748 #[allow(clippy::single_element_loop)]
13749 for &(find_this, param_name) in [("{resource}", "resource")].iter() {
13750 url = params.uri_replacement(url, param_name, find_this, false);
13751 }
13752 {
13753 let to_remove = ["resource"];
13754 params.remove_params(&to_remove);
13755 }
13756
13757 let url = params.parse_with_url(&url);
13758
13759 let mut json_mime_type = mime::APPLICATION_JSON;
13760 let mut request_value_reader = {
13761 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13762 common::remove_json_null_values(&mut value);
13763 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13764 serde_json::to_writer(&mut dst, &value).unwrap();
13765 dst
13766 };
13767 let request_size = request_value_reader
13768 .seek(std::io::SeekFrom::End(0))
13769 .unwrap();
13770 request_value_reader
13771 .seek(std::io::SeekFrom::Start(0))
13772 .unwrap();
13773
13774 loop {
13775 let token = match self
13776 .hub
13777 .auth
13778 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13779 .await
13780 {
13781 Ok(token) => token,
13782 Err(e) => match dlg.token(e) {
13783 Ok(token) => token,
13784 Err(e) => {
13785 dlg.finished(false);
13786 return Err(common::Error::MissingToken(e));
13787 }
13788 },
13789 };
13790 request_value_reader
13791 .seek(std::io::SeekFrom::Start(0))
13792 .unwrap();
13793 let mut req_result = {
13794 let client = &self.hub.client;
13795 dlg.pre_request();
13796 let mut req_builder = hyper::Request::builder()
13797 .method(hyper::Method::POST)
13798 .uri(url.as_str())
13799 .header(USER_AGENT, self.hub._user_agent.clone());
13800
13801 if let Some(token) = token.as_ref() {
13802 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13803 }
13804
13805 let request = req_builder
13806 .header(CONTENT_TYPE, json_mime_type.to_string())
13807 .header(CONTENT_LENGTH, request_size as u64)
13808 .body(common::to_body(
13809 request_value_reader.get_ref().clone().into(),
13810 ));
13811
13812 client.request(request.unwrap()).await
13813 };
13814
13815 match req_result {
13816 Err(err) => {
13817 if let common::Retry::After(d) = dlg.http_error(&err) {
13818 sleep(d).await;
13819 continue;
13820 }
13821 dlg.finished(false);
13822 return Err(common::Error::HttpError(err));
13823 }
13824 Ok(res) => {
13825 let (mut parts, body) = res.into_parts();
13826 let mut body = common::Body::new(body);
13827 if !parts.status.is_success() {
13828 let bytes = common::to_bytes(body).await.unwrap_or_default();
13829 let error = serde_json::from_str(&common::to_string(&bytes));
13830 let response = common::to_response(parts, bytes.into());
13831
13832 if let common::Retry::After(d) =
13833 dlg.http_failure(&response, error.as_ref().ok())
13834 {
13835 sleep(d).await;
13836 continue;
13837 }
13838
13839 dlg.finished(false);
13840
13841 return Err(match error {
13842 Ok(value) => common::Error::BadRequest(value),
13843 _ => common::Error::Failure(response),
13844 });
13845 }
13846 let response = {
13847 let bytes = common::to_bytes(body).await.unwrap_or_default();
13848 let encoded = common::to_string(&bytes);
13849 match serde_json::from_str(&encoded) {
13850 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13851 Err(error) => {
13852 dlg.response_json_decode_error(&encoded, &error);
13853 return Err(common::Error::JsonDecodeError(
13854 encoded.to_string(),
13855 error,
13856 ));
13857 }
13858 }
13859 };
13860
13861 dlg.finished(true);
13862 return Ok(response);
13863 }
13864 }
13865 }
13866 }
13867
13868 ///
13869 /// Sets the *request* property to the given value.
13870 ///
13871 /// Even though the property as already been set when instantiating this call,
13872 /// we provide this method for API completeness.
13873 pub fn request(
13874 mut self,
13875 new_value: TestIamPermissionsRequest,
13876 ) -> ProjectTestIamPermissionCall<'a, C> {
13877 self._request = new_value;
13878 self
13879 }
13880 /// 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.
13881 ///
13882 /// Sets the *resource* path property to the given value.
13883 ///
13884 /// Even though the property as already been set when instantiating this call,
13885 /// we provide this method for API completeness.
13886 pub fn resource(mut self, new_value: &str) -> ProjectTestIamPermissionCall<'a, C> {
13887 self._resource = new_value.to_string();
13888 self
13889 }
13890 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13891 /// while executing the actual API request.
13892 ///
13893 /// ````text
13894 /// It should be used to handle progress information, and to implement a certain level of resilience.
13895 /// ````
13896 ///
13897 /// Sets the *delegate* property to the given value.
13898 pub fn delegate(
13899 mut self,
13900 new_value: &'a mut dyn common::Delegate,
13901 ) -> ProjectTestIamPermissionCall<'a, C> {
13902 self._delegate = Some(new_value);
13903 self
13904 }
13905
13906 /// Set any additional parameter of the query string used in the request.
13907 /// It should be used to set parameters which are not yet available through their own
13908 /// setters.
13909 ///
13910 /// Please note that this method must not be used to set any of the known parameters
13911 /// which have their own setter method. If done anyway, the request will fail.
13912 ///
13913 /// # Additional Parameters
13914 ///
13915 /// * *$.xgafv* (query-string) - V1 error format.
13916 /// * *access_token* (query-string) - OAuth access token.
13917 /// * *alt* (query-string) - Data format for response.
13918 /// * *callback* (query-string) - JSONP
13919 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13920 /// * *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.
13921 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13922 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13923 /// * *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.
13924 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13925 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13926 pub fn param<T>(mut self, name: T, value: T) -> ProjectTestIamPermissionCall<'a, C>
13927 where
13928 T: AsRef<str>,
13929 {
13930 self._additional_params
13931 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13932 self
13933 }
13934
13935 /// Identifies the authorization scope for the method you are building.
13936 ///
13937 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13938 /// [`Scope::CloudPlatformReadOnly`].
13939 ///
13940 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13941 /// tokens for more than one scope.
13942 ///
13943 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13944 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13945 /// sufficient, a read-write scope will do as well.
13946 pub fn add_scope<St>(mut self, scope: St) -> ProjectTestIamPermissionCall<'a, C>
13947 where
13948 St: AsRef<str>,
13949 {
13950 self._scopes.insert(String::from(scope.as_ref()));
13951 self
13952 }
13953 /// Identifies the authorization scope(s) for the method you are building.
13954 ///
13955 /// See [`Self::add_scope()`] for details.
13956 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTestIamPermissionCall<'a, C>
13957 where
13958 I: IntoIterator<Item = St>,
13959 St: AsRef<str>,
13960 {
13961 self._scopes
13962 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13963 self
13964 }
13965
13966 /// Removes all scopes, and no default scope will be used either.
13967 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13968 /// for details).
13969 pub fn clear_scopes(mut self) -> ProjectTestIamPermissionCall<'a, C> {
13970 self._scopes.clear();
13971 self
13972 }
13973}
13974
13975/// Restores the Project identified by the specified `project_id` (for example, `my-project-123`). You can only use this method for a Project that has a lifecycle state of DELETE_REQUESTED. After deletion starts, the Project cannot be restored. The caller must have undelete permissions for this Project.
13976///
13977/// A builder for the *undelete* method supported by a *project* resource.
13978/// It is not used directly, but through a [`ProjectMethods`] instance.
13979///
13980/// # Example
13981///
13982/// Instantiate a resource method builder
13983///
13984/// ```test_harness,no_run
13985/// # extern crate hyper;
13986/// # extern crate hyper_rustls;
13987/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
13988/// use cloudresourcemanager1::api::UndeleteProjectRequest;
13989/// # async fn dox() {
13990/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13991///
13992/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13993/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13994/// # .with_native_roots()
13995/// # .unwrap()
13996/// # .https_only()
13997/// # .enable_http2()
13998/// # .build();
13999///
14000/// # let executor = hyper_util::rt::TokioExecutor::new();
14001/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14002/// # secret,
14003/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14004/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14005/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14006/// # ),
14007/// # ).build().await.unwrap();
14008///
14009/// # let client = hyper_util::client::legacy::Client::builder(
14010/// # hyper_util::rt::TokioExecutor::new()
14011/// # )
14012/// # .build(
14013/// # hyper_rustls::HttpsConnectorBuilder::new()
14014/// # .with_native_roots()
14015/// # .unwrap()
14016/// # .https_or_http()
14017/// # .enable_http2()
14018/// # .build()
14019/// # );
14020/// # let mut hub = CloudResourceManager::new(client, auth);
14021/// // As the method needs a request, you would usually fill it with the desired information
14022/// // into the respective structure. Some of the parts shown here might not be applicable !
14023/// // Values shown here are possibly random and not representative !
14024/// let mut req = UndeleteProjectRequest::default();
14025///
14026/// // You can configure optional parameters by calling the respective setters at will, and
14027/// // execute the final call using `doit()`.
14028/// // Values shown here are possibly random and not representative !
14029/// let result = hub.projects().undelete(req, "projectId")
14030/// .doit().await;
14031/// # }
14032/// ```
14033pub struct ProjectUndeleteCall<'a, C>
14034where
14035 C: 'a,
14036{
14037 hub: &'a CloudResourceManager<C>,
14038 _request: UndeleteProjectRequest,
14039 _project_id: String,
14040 _delegate: Option<&'a mut dyn common::Delegate>,
14041 _additional_params: HashMap<String, String>,
14042 _scopes: BTreeSet<String>,
14043}
14044
14045impl<'a, C> common::CallBuilder for ProjectUndeleteCall<'a, C> {}
14046
14047impl<'a, C> ProjectUndeleteCall<'a, C>
14048where
14049 C: common::Connector,
14050{
14051 /// Perform the operation you have build so far.
14052 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
14053 use std::borrow::Cow;
14054 use std::io::{Read, Seek};
14055
14056 use common::{url::Params, ToParts};
14057 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14058
14059 let mut dd = common::DefaultDelegate;
14060 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14061 dlg.begin(common::MethodInfo {
14062 id: "cloudresourcemanager.projects.undelete",
14063 http_method: hyper::Method::POST,
14064 });
14065
14066 for &field in ["alt", "projectId"].iter() {
14067 if self._additional_params.contains_key(field) {
14068 dlg.finished(false);
14069 return Err(common::Error::FieldClash(field));
14070 }
14071 }
14072
14073 let mut params = Params::with_capacity(4 + self._additional_params.len());
14074 params.push("projectId", self._project_id);
14075
14076 params.extend(self._additional_params.iter());
14077
14078 params.push("alt", "json");
14079 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}:undelete";
14080 if self._scopes.is_empty() {
14081 self._scopes
14082 .insert(Scope::CloudPlatform.as_ref().to_string());
14083 }
14084
14085 #[allow(clippy::single_element_loop)]
14086 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
14087 url = params.uri_replacement(url, param_name, find_this, false);
14088 }
14089 {
14090 let to_remove = ["projectId"];
14091 params.remove_params(&to_remove);
14092 }
14093
14094 let url = params.parse_with_url(&url);
14095
14096 let mut json_mime_type = mime::APPLICATION_JSON;
14097 let mut request_value_reader = {
14098 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14099 common::remove_json_null_values(&mut value);
14100 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14101 serde_json::to_writer(&mut dst, &value).unwrap();
14102 dst
14103 };
14104 let request_size = request_value_reader
14105 .seek(std::io::SeekFrom::End(0))
14106 .unwrap();
14107 request_value_reader
14108 .seek(std::io::SeekFrom::Start(0))
14109 .unwrap();
14110
14111 loop {
14112 let token = match self
14113 .hub
14114 .auth
14115 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14116 .await
14117 {
14118 Ok(token) => token,
14119 Err(e) => match dlg.token(e) {
14120 Ok(token) => token,
14121 Err(e) => {
14122 dlg.finished(false);
14123 return Err(common::Error::MissingToken(e));
14124 }
14125 },
14126 };
14127 request_value_reader
14128 .seek(std::io::SeekFrom::Start(0))
14129 .unwrap();
14130 let mut req_result = {
14131 let client = &self.hub.client;
14132 dlg.pre_request();
14133 let mut req_builder = hyper::Request::builder()
14134 .method(hyper::Method::POST)
14135 .uri(url.as_str())
14136 .header(USER_AGENT, self.hub._user_agent.clone());
14137
14138 if let Some(token) = token.as_ref() {
14139 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14140 }
14141
14142 let request = req_builder
14143 .header(CONTENT_TYPE, json_mime_type.to_string())
14144 .header(CONTENT_LENGTH, request_size as u64)
14145 .body(common::to_body(
14146 request_value_reader.get_ref().clone().into(),
14147 ));
14148
14149 client.request(request.unwrap()).await
14150 };
14151
14152 match req_result {
14153 Err(err) => {
14154 if let common::Retry::After(d) = dlg.http_error(&err) {
14155 sleep(d).await;
14156 continue;
14157 }
14158 dlg.finished(false);
14159 return Err(common::Error::HttpError(err));
14160 }
14161 Ok(res) => {
14162 let (mut parts, body) = res.into_parts();
14163 let mut body = common::Body::new(body);
14164 if !parts.status.is_success() {
14165 let bytes = common::to_bytes(body).await.unwrap_or_default();
14166 let error = serde_json::from_str(&common::to_string(&bytes));
14167 let response = common::to_response(parts, bytes.into());
14168
14169 if let common::Retry::After(d) =
14170 dlg.http_failure(&response, error.as_ref().ok())
14171 {
14172 sleep(d).await;
14173 continue;
14174 }
14175
14176 dlg.finished(false);
14177
14178 return Err(match error {
14179 Ok(value) => common::Error::BadRequest(value),
14180 _ => common::Error::Failure(response),
14181 });
14182 }
14183 let response = {
14184 let bytes = common::to_bytes(body).await.unwrap_or_default();
14185 let encoded = common::to_string(&bytes);
14186 match serde_json::from_str(&encoded) {
14187 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14188 Err(error) => {
14189 dlg.response_json_decode_error(&encoded, &error);
14190 return Err(common::Error::JsonDecodeError(
14191 encoded.to_string(),
14192 error,
14193 ));
14194 }
14195 }
14196 };
14197
14198 dlg.finished(true);
14199 return Ok(response);
14200 }
14201 }
14202 }
14203 }
14204
14205 ///
14206 /// Sets the *request* property to the given value.
14207 ///
14208 /// Even though the property as already been set when instantiating this call,
14209 /// we provide this method for API completeness.
14210 pub fn request(mut self, new_value: UndeleteProjectRequest) -> ProjectUndeleteCall<'a, C> {
14211 self._request = new_value;
14212 self
14213 }
14214 /// Required. The project ID (for example, `foo-bar-123`).
14215 ///
14216 /// Sets the *project id* path property to the given value.
14217 ///
14218 /// Even though the property as already been set when instantiating this call,
14219 /// we provide this method for API completeness.
14220 pub fn project_id(mut self, new_value: &str) -> ProjectUndeleteCall<'a, C> {
14221 self._project_id = new_value.to_string();
14222 self
14223 }
14224 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14225 /// while executing the actual API request.
14226 ///
14227 /// ````text
14228 /// It should be used to handle progress information, and to implement a certain level of resilience.
14229 /// ````
14230 ///
14231 /// Sets the *delegate* property to the given value.
14232 pub fn delegate(
14233 mut self,
14234 new_value: &'a mut dyn common::Delegate,
14235 ) -> ProjectUndeleteCall<'a, C> {
14236 self._delegate = Some(new_value);
14237 self
14238 }
14239
14240 /// Set any additional parameter of the query string used in the request.
14241 /// It should be used to set parameters which are not yet available through their own
14242 /// setters.
14243 ///
14244 /// Please note that this method must not be used to set any of the known parameters
14245 /// which have their own setter method. If done anyway, the request will fail.
14246 ///
14247 /// # Additional Parameters
14248 ///
14249 /// * *$.xgafv* (query-string) - V1 error format.
14250 /// * *access_token* (query-string) - OAuth access token.
14251 /// * *alt* (query-string) - Data format for response.
14252 /// * *callback* (query-string) - JSONP
14253 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14254 /// * *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.
14255 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14256 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14257 /// * *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.
14258 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14259 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14260 pub fn param<T>(mut self, name: T, value: T) -> ProjectUndeleteCall<'a, C>
14261 where
14262 T: AsRef<str>,
14263 {
14264 self._additional_params
14265 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14266 self
14267 }
14268
14269 /// Identifies the authorization scope for the method you are building.
14270 ///
14271 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14272 /// [`Scope::CloudPlatform`].
14273 ///
14274 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14275 /// tokens for more than one scope.
14276 ///
14277 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14278 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14279 /// sufficient, a read-write scope will do as well.
14280 pub fn add_scope<St>(mut self, scope: St) -> ProjectUndeleteCall<'a, C>
14281 where
14282 St: AsRef<str>,
14283 {
14284 self._scopes.insert(String::from(scope.as_ref()));
14285 self
14286 }
14287 /// Identifies the authorization scope(s) for the method you are building.
14288 ///
14289 /// See [`Self::add_scope()`] for details.
14290 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUndeleteCall<'a, C>
14291 where
14292 I: IntoIterator<Item = St>,
14293 St: AsRef<str>,
14294 {
14295 self._scopes
14296 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14297 self
14298 }
14299
14300 /// Removes all scopes, and no default scope will be used either.
14301 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14302 /// for details).
14303 pub fn clear_scopes(mut self) -> ProjectUndeleteCall<'a, C> {
14304 self._scopes.clear();
14305 self
14306 }
14307}
14308
14309/// Updates the attributes of the Project identified by the specified `project_id` (for example, `my-project-123`). The caller must have modify permissions for this Project.
14310///
14311/// A builder for the *update* method supported by a *project* resource.
14312/// It is not used directly, but through a [`ProjectMethods`] instance.
14313///
14314/// # Example
14315///
14316/// Instantiate a resource method builder
14317///
14318/// ```test_harness,no_run
14319/// # extern crate hyper;
14320/// # extern crate hyper_rustls;
14321/// # extern crate google_cloudresourcemanager1 as cloudresourcemanager1;
14322/// use cloudresourcemanager1::api::Project;
14323/// # async fn dox() {
14324/// # use cloudresourcemanager1::{CloudResourceManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14325///
14326/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14327/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14328/// # .with_native_roots()
14329/// # .unwrap()
14330/// # .https_only()
14331/// # .enable_http2()
14332/// # .build();
14333///
14334/// # let executor = hyper_util::rt::TokioExecutor::new();
14335/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14336/// # secret,
14337/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14338/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14339/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14340/// # ),
14341/// # ).build().await.unwrap();
14342///
14343/// # let client = hyper_util::client::legacy::Client::builder(
14344/// # hyper_util::rt::TokioExecutor::new()
14345/// # )
14346/// # .build(
14347/// # hyper_rustls::HttpsConnectorBuilder::new()
14348/// # .with_native_roots()
14349/// # .unwrap()
14350/// # .https_or_http()
14351/// # .enable_http2()
14352/// # .build()
14353/// # );
14354/// # let mut hub = CloudResourceManager::new(client, auth);
14355/// // As the method needs a request, you would usually fill it with the desired information
14356/// // into the respective structure. Some of the parts shown here might not be applicable !
14357/// // Values shown here are possibly random and not representative !
14358/// let mut req = Project::default();
14359///
14360/// // You can configure optional parameters by calling the respective setters at will, and
14361/// // execute the final call using `doit()`.
14362/// // Values shown here are possibly random and not representative !
14363/// let result = hub.projects().update(req, "projectId")
14364/// .doit().await;
14365/// # }
14366/// ```
14367pub struct ProjectUpdateCall<'a, C>
14368where
14369 C: 'a,
14370{
14371 hub: &'a CloudResourceManager<C>,
14372 _request: Project,
14373 _project_id: String,
14374 _delegate: Option<&'a mut dyn common::Delegate>,
14375 _additional_params: HashMap<String, String>,
14376 _scopes: BTreeSet<String>,
14377}
14378
14379impl<'a, C> common::CallBuilder for ProjectUpdateCall<'a, C> {}
14380
14381impl<'a, C> ProjectUpdateCall<'a, C>
14382where
14383 C: common::Connector,
14384{
14385 /// Perform the operation you have build so far.
14386 pub async fn doit(mut self) -> common::Result<(common::Response, Project)> {
14387 use std::borrow::Cow;
14388 use std::io::{Read, Seek};
14389
14390 use common::{url::Params, ToParts};
14391 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14392
14393 let mut dd = common::DefaultDelegate;
14394 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14395 dlg.begin(common::MethodInfo {
14396 id: "cloudresourcemanager.projects.update",
14397 http_method: hyper::Method::PUT,
14398 });
14399
14400 for &field in ["alt", "projectId"].iter() {
14401 if self._additional_params.contains_key(field) {
14402 dlg.finished(false);
14403 return Err(common::Error::FieldClash(field));
14404 }
14405 }
14406
14407 let mut params = Params::with_capacity(4 + self._additional_params.len());
14408 params.push("projectId", self._project_id);
14409
14410 params.extend(self._additional_params.iter());
14411
14412 params.push("alt", "json");
14413 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}";
14414 if self._scopes.is_empty() {
14415 self._scopes
14416 .insert(Scope::CloudPlatform.as_ref().to_string());
14417 }
14418
14419 #[allow(clippy::single_element_loop)]
14420 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
14421 url = params.uri_replacement(url, param_name, find_this, false);
14422 }
14423 {
14424 let to_remove = ["projectId"];
14425 params.remove_params(&to_remove);
14426 }
14427
14428 let url = params.parse_with_url(&url);
14429
14430 let mut json_mime_type = mime::APPLICATION_JSON;
14431 let mut request_value_reader = {
14432 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14433 common::remove_json_null_values(&mut value);
14434 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14435 serde_json::to_writer(&mut dst, &value).unwrap();
14436 dst
14437 };
14438 let request_size = request_value_reader
14439 .seek(std::io::SeekFrom::End(0))
14440 .unwrap();
14441 request_value_reader
14442 .seek(std::io::SeekFrom::Start(0))
14443 .unwrap();
14444
14445 loop {
14446 let token = match self
14447 .hub
14448 .auth
14449 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14450 .await
14451 {
14452 Ok(token) => token,
14453 Err(e) => match dlg.token(e) {
14454 Ok(token) => token,
14455 Err(e) => {
14456 dlg.finished(false);
14457 return Err(common::Error::MissingToken(e));
14458 }
14459 },
14460 };
14461 request_value_reader
14462 .seek(std::io::SeekFrom::Start(0))
14463 .unwrap();
14464 let mut req_result = {
14465 let client = &self.hub.client;
14466 dlg.pre_request();
14467 let mut req_builder = hyper::Request::builder()
14468 .method(hyper::Method::PUT)
14469 .uri(url.as_str())
14470 .header(USER_AGENT, self.hub._user_agent.clone());
14471
14472 if let Some(token) = token.as_ref() {
14473 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14474 }
14475
14476 let request = req_builder
14477 .header(CONTENT_TYPE, json_mime_type.to_string())
14478 .header(CONTENT_LENGTH, request_size as u64)
14479 .body(common::to_body(
14480 request_value_reader.get_ref().clone().into(),
14481 ));
14482
14483 client.request(request.unwrap()).await
14484 };
14485
14486 match req_result {
14487 Err(err) => {
14488 if let common::Retry::After(d) = dlg.http_error(&err) {
14489 sleep(d).await;
14490 continue;
14491 }
14492 dlg.finished(false);
14493 return Err(common::Error::HttpError(err));
14494 }
14495 Ok(res) => {
14496 let (mut parts, body) = res.into_parts();
14497 let mut body = common::Body::new(body);
14498 if !parts.status.is_success() {
14499 let bytes = common::to_bytes(body).await.unwrap_or_default();
14500 let error = serde_json::from_str(&common::to_string(&bytes));
14501 let response = common::to_response(parts, bytes.into());
14502
14503 if let common::Retry::After(d) =
14504 dlg.http_failure(&response, error.as_ref().ok())
14505 {
14506 sleep(d).await;
14507 continue;
14508 }
14509
14510 dlg.finished(false);
14511
14512 return Err(match error {
14513 Ok(value) => common::Error::BadRequest(value),
14514 _ => common::Error::Failure(response),
14515 });
14516 }
14517 let response = {
14518 let bytes = common::to_bytes(body).await.unwrap_or_default();
14519 let encoded = common::to_string(&bytes);
14520 match serde_json::from_str(&encoded) {
14521 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14522 Err(error) => {
14523 dlg.response_json_decode_error(&encoded, &error);
14524 return Err(common::Error::JsonDecodeError(
14525 encoded.to_string(),
14526 error,
14527 ));
14528 }
14529 }
14530 };
14531
14532 dlg.finished(true);
14533 return Ok(response);
14534 }
14535 }
14536 }
14537 }
14538
14539 ///
14540 /// Sets the *request* property to the given value.
14541 ///
14542 /// Even though the property as already been set when instantiating this call,
14543 /// we provide this method for API completeness.
14544 pub fn request(mut self, new_value: Project) -> ProjectUpdateCall<'a, C> {
14545 self._request = new_value;
14546 self
14547 }
14548 /// The project ID (for example, `my-project-123`). Required.
14549 ///
14550 /// Sets the *project id* path property to the given value.
14551 ///
14552 /// Even though the property as already been set when instantiating this call,
14553 /// we provide this method for API completeness.
14554 pub fn project_id(mut self, new_value: &str) -> ProjectUpdateCall<'a, C> {
14555 self._project_id = new_value.to_string();
14556 self
14557 }
14558 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14559 /// while executing the actual API request.
14560 ///
14561 /// ````text
14562 /// It should be used to handle progress information, and to implement a certain level of resilience.
14563 /// ````
14564 ///
14565 /// Sets the *delegate* property to the given value.
14566 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ProjectUpdateCall<'a, C> {
14567 self._delegate = Some(new_value);
14568 self
14569 }
14570
14571 /// Set any additional parameter of the query string used in the request.
14572 /// It should be used to set parameters which are not yet available through their own
14573 /// setters.
14574 ///
14575 /// Please note that this method must not be used to set any of the known parameters
14576 /// which have their own setter method. If done anyway, the request will fail.
14577 ///
14578 /// # Additional Parameters
14579 ///
14580 /// * *$.xgafv* (query-string) - V1 error format.
14581 /// * *access_token* (query-string) - OAuth access token.
14582 /// * *alt* (query-string) - Data format for response.
14583 /// * *callback* (query-string) - JSONP
14584 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14585 /// * *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.
14586 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14587 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14588 /// * *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.
14589 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14590 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14591 pub fn param<T>(mut self, name: T, value: T) -> ProjectUpdateCall<'a, C>
14592 where
14593 T: AsRef<str>,
14594 {
14595 self._additional_params
14596 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14597 self
14598 }
14599
14600 /// Identifies the authorization scope for the method you are building.
14601 ///
14602 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14603 /// [`Scope::CloudPlatform`].
14604 ///
14605 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14606 /// tokens for more than one scope.
14607 ///
14608 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14609 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14610 /// sufficient, a read-write scope will do as well.
14611 pub fn add_scope<St>(mut self, scope: St) -> ProjectUpdateCall<'a, C>
14612 where
14613 St: AsRef<str>,
14614 {
14615 self._scopes.insert(String::from(scope.as_ref()));
14616 self
14617 }
14618 /// Identifies the authorization scope(s) for the method you are building.
14619 ///
14620 /// See [`Self::add_scope()`] for details.
14621 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUpdateCall<'a, C>
14622 where
14623 I: IntoIterator<Item = St>,
14624 St: AsRef<str>,
14625 {
14626 self._scopes
14627 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14628 self
14629 }
14630
14631 /// Removes all scopes, and no default scope will be used either.
14632 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14633 /// for details).
14634 pub fn clear_scopes(mut self) -> ProjectUpdateCall<'a, C> {
14635 self._scopes.clear();
14636 self
14637 }
14638}