google_accesscontextmanager1/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all AccessContextManager related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
49/// use accesscontextmanager1::{Result, Error};
50/// # async fn dox() {
51/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace  `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62///     .with_native_roots()
63///     .unwrap()
64///     .https_only()
65///     .enable_http2()
66///     .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70///     secret,
71///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72///     yup_oauth2::client::CustomHyperClientBuilder::from(
73///         hyper_util::client::legacy::Client::builder(executor).build(connector),
74///     ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78///     hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81///     hyper_rustls::HttpsConnectorBuilder::new()
82///         .with_native_roots()
83///         .unwrap()
84///         .https_or_http()
85///         .enable_http2()
86///         .build()
87/// );
88/// let mut hub = AccessContextManager::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.operations().list("name")
93///              .return_partial_success(true)
94///              .page_token("gubergren")
95///              .page_size(-75)
96///              .filter("dolor")
97///              .doit().await;
98///
99/// match result {
100///     Err(e) => match e {
101///         // The Error enum provides details about what exactly happened.
102///         // You can also just use its `Debug`, `Display` or `Error` traits
103///          Error::HttpError(_)
104///         |Error::Io(_)
105///         |Error::MissingAPIKey
106///         |Error::MissingToken(_)
107///         |Error::Cancelled
108///         |Error::UploadSizeLimitExceeded(_, _)
109///         |Error::Failure(_)
110///         |Error::BadRequest(_)
111///         |Error::FieldClash(_)
112///         |Error::JsonDecodeError(_, _) => println!("{}", e),
113///     },
114///     Ok(res) => println!("Success: {:?}", res),
115/// }
116/// # }
117/// ```
118#[derive(Clone)]
119pub struct AccessContextManager<C> {
120    pub client: common::Client<C>,
121    pub auth: Box<dyn common::GetToken>,
122    _user_agent: String,
123    _base_url: String,
124    _root_url: String,
125}
126
127impl<C> common::Hub for AccessContextManager<C> {}
128
129impl<'a, C> AccessContextManager<C> {
130    pub fn new<A: 'static + common::GetToken>(
131        client: common::Client<C>,
132        auth: A,
133    ) -> AccessContextManager<C> {
134        AccessContextManager {
135            client,
136            auth: Box::new(auth),
137            _user_agent: "google-api-rust-client/7.0.0".to_string(),
138            _base_url: "https://accesscontextmanager.googleapis.com/".to_string(),
139            _root_url: "https://accesscontextmanager.googleapis.com/".to_string(),
140        }
141    }
142
143    pub fn access_policies(&'a self) -> AccessPolicyMethods<'a, C> {
144        AccessPolicyMethods { hub: self }
145    }
146    pub fn operations(&'a self) -> OperationMethods<'a, C> {
147        OperationMethods { hub: self }
148    }
149    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
150        OrganizationMethods { hub: self }
151    }
152    pub fn services(&'a self) -> ServiceMethods<'a, C> {
153        ServiceMethods { hub: self }
154    }
155
156    /// Set the user-agent header field to use in all requests to the server.
157    /// It defaults to `google-api-rust-client/7.0.0`.
158    ///
159    /// Returns the previously set user-agent.
160    pub fn user_agent(&mut self, agent_name: String) -> String {
161        std::mem::replace(&mut self._user_agent, agent_name)
162    }
163
164    /// Set the base url to use in all requests to the server.
165    /// It defaults to `https://accesscontextmanager.googleapis.com/`.
166    ///
167    /// Returns the previously set base url.
168    pub fn base_url(&mut self, new_base_url: String) -> String {
169        std::mem::replace(&mut self._base_url, new_base_url)
170    }
171
172    /// Set the root url to use in all requests to the server.
173    /// It defaults to `https://accesscontextmanager.googleapis.com/`.
174    ///
175    /// Returns the previously set root url.
176    pub fn root_url(&mut self, new_root_url: String) -> String {
177        std::mem::replace(&mut self._root_url, new_root_url)
178    }
179}
180
181// ############
182// SCHEMAS ###
183// ##########
184/// An `AccessLevel` is a label that can be applied to requests to Google Cloud services, along with a list of requirements necessary for the label to be applied.
185///
186/// # Activities
187///
188/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
189/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
190///
191/// * [access levels create access policies](AccessPolicyAccessLevelCreateCall) (request)
192/// * [access levels get access policies](AccessPolicyAccessLevelGetCall) (response)
193/// * [access levels patch access policies](AccessPolicyAccessLevelPatchCall) (request)
194#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
195#[serde_with::serde_as]
196#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
197pub struct AccessLevel {
198    /// A `BasicLevel` composed of `Conditions`.
199    pub basic: Option<BasicLevel>,
200    /// A `CustomLevel` written in the Common Expression Language.
201    pub custom: Option<CustomLevel>,
202    /// Description of the `AccessLevel` and its use. Does not affect behavior.
203    pub description: Option<String>,
204    /// Identifier. Resource name for the `AccessLevel`. Format: `accessPolicies/{access_policy}/accessLevels/{access_level}`. The `access_level` component must begin with a letter, followed by alphanumeric characters or `_`. Its maximum length is 50 characters. After you create an `AccessLevel`, you cannot change its `name`.
205    pub name: Option<String>,
206    /// Human readable title. Must be unique within the Policy.
207    pub title: Option<String>,
208}
209
210impl common::RequestValue for AccessLevel {}
211impl common::ResponseResult for AccessLevel {}
212
213/// `AccessPolicy` is a container for `AccessLevels` (which define the necessary attributes to use Google Cloud services) and `ServicePerimeters` (which define regions of services able to freely pass data within a perimeter). An access policy is globally visible within an organization, and the restrictions it specifies apply to all projects within an organization.
214///
215/// # Activities
216///
217/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
218/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
219///
220/// * [create access policies](AccessPolicyCreateCall) (request)
221/// * [get access policies](AccessPolicyGetCall) (response)
222/// * [patch access policies](AccessPolicyPatchCall) (request)
223#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
224#[serde_with::serde_as]
225#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
226pub struct AccessPolicy {
227    /// Output only. An opaque identifier for the current version of the `AccessPolicy`. This will always be a strongly validated etag, meaning that two Access Policies will be identical if and only if their etags are identical. Clients should not expect this to be in any specific format.
228    pub etag: Option<String>,
229    /// Output only. Identifier. Resource name of the `AccessPolicy`. Format: `accessPolicies/{access_policy}`
230    pub name: Option<String>,
231    /// Required. The parent of this `AccessPolicy` in the Cloud Resource Hierarchy. Currently immutable once created. Format: `organizations/{organization_id}`
232    pub parent: Option<String>,
233    /// The scopes of the AccessPolicy. Scopes define which resources a policy can restrict and where its resources can be referenced. For example, policy A with `scopes=["folders/123"]` has the following behavior: - ServicePerimeter can only restrict projects within `folders/123`. - ServicePerimeter within policy A can only reference access levels defined within policy A. - Only one policy can include a given scope; thus, attempting to create a second policy which includes `folders/123` will result in an error. If no scopes are provided, then any resource within the organization can be restricted. Scopes cannot be modified after a policy is created. Policies can only have a single scope. Format: list of `folders/{folder_number}` or `projects/{project_number}`
234    pub scopes: Option<Vec<String>>,
235    /// Required. Human readable title. Does not affect behavior.
236    pub title: Option<String>,
237}
238
239impl common::RequestValue for AccessPolicy {}
240impl common::ResponseResult for AccessPolicy {}
241
242/// Access scope represents the client scope, etc. to which the settings will be applied to.
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 AccessScope {
250    /// Optional. Client scope for this access scope.
251    #[serde(rename = "clientScope")]
252    pub client_scope: Option<ClientScope>,
253}
254
255impl common::Part for AccessScope {}
256
257/// Access settings represent the set of conditions that must be met for access to be granted. At least one of the fields must be set.
258///
259/// This type is not used in any activity, and only used as *part* of another schema.
260///
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct AccessSettings {
265    /// Optional. Access level that a user must have to be granted access. Only one access level is supported, not multiple. This repeated field must have exactly one element. Example: "accessPolicies/9522/accessLevels/device_trusted"
266    #[serde(rename = "accessLevels")]
267    pub access_levels: Option<Vec<String>>,
268    /// Optional. Session settings applied to user access on a given AccessScope.
269    #[serde(rename = "sessionSettings")]
270    pub session_settings: Option<SessionSettings>,
271}
272
273impl common::Part for AccessSettings {}
274
275/// Identification for an API Operation.
276///
277/// This type is not used in any activity, and only used as *part* of another schema.
278///
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct ApiOperation {
283    /// API methods or permissions to allow. Method or permission must belong to the service specified by `service_name` field. A single MethodSelector entry with `*` specified for the `method` field will allow all methods AND permissions for the service specified in `service_name`.
284    #[serde(rename = "methodSelectors")]
285    pub method_selectors: Option<Vec<MethodSelector>>,
286    /// The name of the API whose methods or permissions the IngressPolicy or EgressPolicy want to allow. A single ApiOperation with `service_name` field set to `*` will allow all methods AND permissions for all services.
287    #[serde(rename = "serviceName")]
288    pub service_name: Option<String>,
289}
290
291impl common::Part for ApiOperation {}
292
293/// An application that accesses Google Cloud APIs.
294///
295/// This type is not used in any activity, and only used as *part* of another schema.
296///
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct Application {
301    /// The OAuth client ID of the application.
302    #[serde(rename = "clientId")]
303    pub client_id: Option<String>,
304    /// The name of the application. Example: "Cloud Console"
305    pub name: Option<String>,
306}
307
308impl common::Part for Application {}
309
310/// 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.
311///
312/// This type is not used in any activity, and only used as *part* of another schema.
313///
314#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
315#[serde_with::serde_as]
316#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
317pub struct AuditConfig {
318    /// The configuration for logging of each type of permission.
319    #[serde(rename = "auditLogConfigs")]
320    pub audit_log_configs: Option<Vec<AuditLogConfig>>,
321    /// 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.
322    pub service: Option<String>,
323}
324
325impl common::Part for AuditConfig {}
326
327/// 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.
328///
329/// This type is not used in any activity, and only used as *part* of another schema.
330///
331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
332#[serde_with::serde_as]
333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
334pub struct AuditLogConfig {
335    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
336    #[serde(rename = "exemptedMembers")]
337    pub exempted_members: Option<Vec<String>>,
338    /// The log type that this config enables.
339    #[serde(rename = "logType")]
340    pub log_type: Option<String>,
341}
342
343impl common::Part for AuditLogConfig {}
344
345/// `AuthorizedOrgsDesc` contains data for an organization’s authorization policy.
346///
347/// # Activities
348///
349/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
350/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
351///
352/// * [authorized orgs descs create access policies](AccessPolicyAuthorizedOrgsDescCreateCall) (request)
353/// * [authorized orgs descs get access policies](AccessPolicyAuthorizedOrgsDescGetCall) (response)
354/// * [authorized orgs descs patch access policies](AccessPolicyAuthorizedOrgsDescPatchCall) (request)
355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
356#[serde_with::serde_as]
357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
358pub struct AuthorizedOrgsDesc {
359    /// The asset type of this authorized orgs desc. Valid values are `ASSET_TYPE_DEVICE`, and `ASSET_TYPE_CREDENTIAL_STRENGTH`.
360    #[serde(rename = "assetType")]
361    pub asset_type: Option<String>,
362    /// The direction of the authorization relationship between this organization and the organizations listed in the `orgs` field. The valid values for this field include the following: `AUTHORIZATION_DIRECTION_FROM`: Allows this organization to evaluate traffic in the organizations listed in the `orgs` field. `AUTHORIZATION_DIRECTION_TO`: Allows the organizations listed in the `orgs` field to evaluate the traffic in this organization. For the authorization relationship to take effect, all of the organizations must authorize and specify the appropriate relationship direction. For example, if organization A authorized organization B and C to evaluate its traffic, by specifying `AUTHORIZATION_DIRECTION_TO` as the authorization direction, organizations B and C must specify `AUTHORIZATION_DIRECTION_FROM` as the authorization direction in their `AuthorizedOrgsDesc` resource.
363    #[serde(rename = "authorizationDirection")]
364    pub authorization_direction: Option<String>,
365    /// A granular control type for authorization levels. Valid value is `AUTHORIZATION_TYPE_TRUST`.
366    #[serde(rename = "authorizationType")]
367    pub authorization_type: Option<String>,
368    /// Identifier. Resource name for the `AuthorizedOrgsDesc`. Format: `accessPolicies/{access_policy}/authorizedOrgsDescs/{authorized_orgs_desc}`. The `authorized_orgs_desc` component must begin with a letter, followed by alphanumeric characters or `_`. After you create an `AuthorizedOrgsDesc`, you cannot change its `name`.
369    pub name: Option<String>,
370    /// The list of organization ids in this AuthorizedOrgsDesc. Format: `organizations/` Example: `organizations/123456`
371    pub orgs: Option<Vec<String>>,
372}
373
374impl common::RequestValue for AuthorizedOrgsDesc {}
375impl common::ResponseResult for AuthorizedOrgsDesc {}
376
377/// `BasicLevel` is an `AccessLevel` using a set of recommended features.
378///
379/// This type is not used in any activity, and only used as *part* of another schema.
380///
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct BasicLevel {
385    /// How the `conditions` list should be combined to determine if a request is granted this `AccessLevel`. If AND is used, each `Condition` in `conditions` must be satisfied for the `AccessLevel` to be applied. If OR is used, at least one `Condition` in `conditions` must be satisfied for the `AccessLevel` to be applied. Default behavior is AND.
386    #[serde(rename = "combiningFunction")]
387    pub combining_function: Option<String>,
388    /// Required. A list of requirements for the `AccessLevel` to be granted.
389    pub conditions: Option<Vec<Condition>>,
390}
391
392impl common::Part for BasicLevel {}
393
394/// Associates `members`, or principals, with a `role`.
395///
396/// This type is not used in any activity, and only used as *part* of another schema.
397///
398#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
399#[serde_with::serde_as]
400#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
401pub struct Binding {
402    /// 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).
403    pub condition: Option<Expr>,
404    /// 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`.
405    pub members: Option<Vec<String>>,
406    /// 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).
407    pub role: Option<String>,
408}
409
410impl common::Part for Binding {}
411
412/// The request message for Operations.CancelOperation.
413///
414/// # Activities
415///
416/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
417/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
418///
419/// * [cancel operations](OperationCancelCall) (request)
420#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
421#[serde_with::serde_as]
422#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
423pub struct CancelOperationRequest {
424    _never_set: Option<bool>,
425}
426
427impl common::RequestValue for CancelOperationRequest {}
428
429/// Client scope represents the application, etc. subject to this binding's restrictions.
430///
431/// This type is not used in any activity, and only used as *part* of another schema.
432///
433#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
434#[serde_with::serde_as]
435#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
436pub struct ClientScope {
437    /// Optional. The application that is subject to this binding's scope.
438    #[serde(rename = "restrictedClientApplication")]
439    pub restricted_client_application: Option<Application>,
440}
441
442impl common::Part for ClientScope {}
443
444/// A request to commit dry-run specs in all Service Perimeters belonging to an Access Policy.
445///
446/// # Activities
447///
448/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
449/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
450///
451/// * [service perimeters commit access policies](AccessPolicyServicePerimeterCommitCall) (request)
452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
453#[serde_with::serde_as]
454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
455pub struct CommitServicePerimetersRequest {
456    /// Optional. The etag for the version of the Access Policy that this commit operation is to be performed on. If, at the time of commit, the etag for the Access Policy stored in Access Context Manager is different from the specified etag, then the commit operation will not be performed and the call will fail. This field is not required. If etag is not provided, the operation will be performed as if a valid etag is provided.
457    pub etag: Option<String>,
458}
459
460impl common::RequestValue for CommitServicePerimetersRequest {}
461
462/// A condition necessary for an `AccessLevel` to be granted. The Condition is an AND over its fields. So a Condition is true if: 1) the request IP is from one of the listed subnetworks AND 2) the originating device complies with the listed device policy AND 3) all listed access levels are granted AND 4) the request was sent at a time allowed by the DateTimeRestriction.
463///
464/// This type is not used in any activity, and only used as *part* of another schema.
465///
466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
467#[serde_with::serde_as]
468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
469pub struct Condition {
470    /// Device specific restrictions, all restrictions must hold for the Condition to be true. If not specified, all devices are allowed.
471    #[serde(rename = "devicePolicy")]
472    pub device_policy: Option<DevicePolicy>,
473    /// CIDR block IP subnetwork specification. May be IPv4 or IPv6. Note that for a CIDR IP address block, the specified IP address portion must be properly truncated (i.e. all the host bits must be zero) or the input is considered malformed. For example, "192.0.2.0/24" is accepted but "192.0.2.1/24" is not. Similarly, for IPv6, "2001:db8::/32" is accepted whereas "2001:db8::1/32" is not. The originating IP of a request must be in one of the listed subnets in order for this Condition to be true. If empty, all IP addresses are allowed.
474    #[serde(rename = "ipSubnetworks")]
475    pub ip_subnetworks: Option<Vec<String>>,
476    /// The request must be made by one of the provided user or service accounts. Groups are not supported. Syntax: `user:{emailid}` `serviceAccount:{emailid}` If not specified, a request may come from any user.
477    pub members: Option<Vec<String>>,
478    /// Whether to negate the Condition. If true, the Condition becomes a NAND over its non-empty fields. Any non-empty field criteria evaluating to false will result in the Condition to be satisfied. Defaults to false.
479    pub negate: Option<bool>,
480    /// The request must originate from one of the provided countries/regions. Must be valid ISO 3166-1 alpha-2 codes.
481    pub regions: Option<Vec<String>>,
482    /// A list of other access levels defined in the same `Policy`, referenced by resource name. Referencing an `AccessLevel` which does not exist is an error. All access levels listed must be granted for the Condition to be true. Example: "`accessPolicies/MY_POLICY/accessLevels/LEVEL_NAME"`
483    #[serde(rename = "requiredAccessLevels")]
484    pub required_access_levels: Option<Vec<String>>,
485    /// The request must originate from one of the provided VPC networks in Google Cloud. Cannot specify this field together with `ip_subnetworks`.
486    #[serde(rename = "vpcNetworkSources")]
487    pub vpc_network_sources: Option<Vec<VpcNetworkSource>>,
488}
489
490impl common::Part for Condition {}
491
492/// `CustomLevel` is an `AccessLevel` using the Cloud Common Expression Language to represent the necessary conditions for the level to apply to a request. See CEL spec at: https://github.com/google/cel-spec
493///
494/// This type is not used in any activity, and only used as *part* of another schema.
495///
496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
497#[serde_with::serde_as]
498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
499pub struct CustomLevel {
500    /// Required. A Cloud CEL expression evaluating to a boolean.
501    pub expr: Option<Expr>,
502}
503
504impl common::Part for CustomLevel {}
505
506/// `DevicePolicy` specifies device specific restrictions necessary to acquire a given access level. A `DevicePolicy` specifies requirements for requests from devices to be granted access levels, it does not do any enforcement on the device. `DevicePolicy` acts as an AND over all specified fields, and each repeated field is an OR over its elements. Any unset fields are ignored. For example, if the proto is { os_type : DESKTOP_WINDOWS, os_type : DESKTOP_LINUX, encryption_status: ENCRYPTED}, then the DevicePolicy will be true for requests originating from encrypted Linux desktops and encrypted Windows desktops.
507///
508/// This type is not used in any activity, and only used as *part* of another schema.
509///
510#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
511#[serde_with::serde_as]
512#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
513pub struct DevicePolicy {
514    /// Allowed device management levels, an empty list allows all management levels.
515    #[serde(rename = "allowedDeviceManagementLevels")]
516    pub allowed_device_management_levels: Option<Vec<String>>,
517    /// Allowed encryptions statuses, an empty list allows all statuses.
518    #[serde(rename = "allowedEncryptionStatuses")]
519    pub allowed_encryption_statuses: Option<Vec<String>>,
520    /// Allowed OS versions, an empty list allows all types and all versions.
521    #[serde(rename = "osConstraints")]
522    pub os_constraints: Option<Vec<OsConstraint>>,
523    /// Whether the device needs to be approved by the customer admin.
524    #[serde(rename = "requireAdminApproval")]
525    pub require_admin_approval: Option<bool>,
526    /// Whether the device needs to be corp owned.
527    #[serde(rename = "requireCorpOwned")]
528    pub require_corp_owned: Option<bool>,
529    /// Whether or not screenlock is required for the DevicePolicy to be true. Defaults to `false`.
530    #[serde(rename = "requireScreenlock")]
531    pub require_screenlock: Option<bool>,
532}
533
534impl common::Part for DevicePolicy {}
535
536/// Defines the conditions under which an EgressPolicy matches a request. Conditions based on information about the source of the request. Note that if the destination of the request is also protected by a ServicePerimeter, then that ServicePerimeter must have an IngressPolicy which allows access in order for this request to succeed.
537///
538/// This type is not used in any activity, and only used as *part* of another schema.
539///
540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
541#[serde_with::serde_as]
542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
543pub struct EgressFrom {
544    /// A list of identities that are allowed access through [EgressPolicy]. Identities can be an individual user, service account, Google group, or third-party identity. For third-party identity, only single identities are supported and other identity types are not supported. The `v1` identities that have the prefix `user`, `group`, `serviceAccount`, and `principal` in https://cloud.google.com/iam/docs/principal-identifiers#v1 are supported.
545    pub identities: Option<Vec<String>>,
546    /// Specifies the type of identities that are allowed access to outside the perimeter. If left unspecified, then members of `identities` field will be allowed access.
547    #[serde(rename = "identityType")]
548    pub identity_type: Option<String>,
549    /// Whether to enforce traffic restrictions based on `sources` field. If the `sources` fields is non-empty, then this field must be set to `SOURCE_RESTRICTION_ENABLED`.
550    #[serde(rename = "sourceRestriction")]
551    pub source_restriction: Option<String>,
552    /// Sources that this EgressPolicy authorizes access from. If this field is not empty, then `source_restriction` must be set to `SOURCE_RESTRICTION_ENABLED`.
553    pub sources: Option<Vec<EgressSource>>,
554}
555
556impl common::Part for EgressFrom {}
557
558/// Policy for egress from perimeter. EgressPolicies match requests based on `egress_from` and `egress_to` stanzas. For an EgressPolicy to match, both `egress_from` and `egress_to` stanzas must be matched. If an EgressPolicy matches a request, the request is allowed to span the ServicePerimeter boundary. For example, an EgressPolicy can be used to allow VMs on networks within the ServicePerimeter to access a defined set of projects outside the perimeter in certain contexts (e.g. to read data from a Cloud Storage bucket or query against a BigQuery dataset). EgressPolicies are concerned with the *resources* that a request relates as well as the API services and API actions being used. They do not related to the direction of data movement. More detailed documentation for this concept can be found in the descriptions of EgressFrom and EgressTo.
559///
560/// This type is not used in any activity, and only used as *part* of another schema.
561///
562#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
563#[serde_with::serde_as]
564#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
565pub struct EgressPolicy {
566    /// Defines conditions on the source of a request causing this EgressPolicy to apply.
567    #[serde(rename = "egressFrom")]
568    pub egress_from: Option<EgressFrom>,
569    /// Defines the conditions on the ApiOperation and destination resources that cause this EgressPolicy to apply.
570    #[serde(rename = "egressTo")]
571    pub egress_to: Option<EgressTo>,
572    /// Optional. Human-readable title for the egress rule. The title must be unique within the perimeter and can not exceed 100 characters. Within the access policy, the combined length of all rule titles must not exceed 240,000 characters.
573    pub title: Option<String>,
574}
575
576impl common::Part for EgressPolicy {}
577
578/// The source that EgressPolicy authorizes access from inside the ServicePerimeter to somewhere outside the ServicePerimeter boundaries.
579///
580/// This type is not used in any activity, and only used as *part* of another schema.
581///
582#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
583#[serde_with::serde_as]
584#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
585pub struct EgressSource {
586    /// An AccessLevel resource name that allows protected resources inside the ServicePerimeters to access outside the ServicePerimeter boundaries. AccessLevels listed must be in the same policy as this ServicePerimeter. Referencing a nonexistent AccessLevel will cause an error. If an AccessLevel name is not specified, only resources within the perimeter can be accessed through Google Cloud calls with request origins within the perimeter. Example: `accessPolicies/MY_POLICY/accessLevels/MY_LEVEL`. If a single `*` is specified for `access_level`, then all EgressSources will be allowed.
587    #[serde(rename = "accessLevel")]
588    pub access_level: Option<String>,
589    /// A Google Cloud resource from the service perimeter that you want to allow to access data outside the perimeter. This field supports only projects. The project format is `projects/{project_number}`. You can't use `*` in this field to allow all Google Cloud resources.
590    pub resource: Option<String>,
591}
592
593impl common::Part for EgressSource {}
594
595/// Defines the conditions under which an EgressPolicy matches a request. Conditions are based on information about the ApiOperation intended to be performed on the `resources` specified. Note that if the destination of the request is also protected by a ServicePerimeter, then that ServicePerimeter must have an IngressPolicy which allows access in order for this request to succeed. The request must match `operations` AND `resources` fields in order to be allowed egress out of the perimeter.
596///
597/// This type is not used in any activity, and only used as *part* of another schema.
598///
599#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
600#[serde_with::serde_as]
601#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
602pub struct EgressTo {
603    /// A list of external resources that are allowed to be accessed. Only AWS and Azure resources are supported. For Amazon S3, the supported formats are s3://BUCKET_NAME, s3a://BUCKET_NAME, and s3n://BUCKET_NAME. For Azure Storage, the supported format is azure://myaccount.blob.core.windows.net/CONTAINER_NAME. A request matches if it contains an external resource in this list (Example: s3://bucket/path). Currently '*' is not allowed.
604    #[serde(rename = "externalResources")]
605    pub external_resources: Option<Vec<String>>,
606    /// A list of ApiOperations allowed to be performed by the sources specified in the corresponding EgressFrom. A request matches if it uses an operation/service in this list.
607    pub operations: Option<Vec<ApiOperation>>,
608    /// A list of resources, currently only projects in the form `projects/`, that are allowed to be accessed by sources defined in the corresponding EgressFrom. A request matches if it contains a resource in this list. If `*` is specified for `resources`, then this EgressTo rule will authorize access to all resources outside the perimeter.
609    pub resources: Option<Vec<String>>,
610    /// IAM roles that represent the set of operations that the sources specified in the corresponding EgressFrom. are allowed to perform in this ServicePerimeter.
611    pub roles: Option<Vec<String>>,
612}
613
614impl common::Part for EgressTo {}
615
616/// 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); }
617///
618/// # Activities
619///
620/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
621/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
622///
623/// * [cancel operations](OperationCancelCall) (response)
624/// * [delete operations](OperationDeleteCall) (response)
625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
626#[serde_with::serde_as]
627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
628pub struct Empty {
629    _never_set: Option<bool>,
630}
631
632impl common::ResponseResult for Empty {}
633
634/// 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.
635///
636/// This type is not used in any activity, and only used as *part* of another schema.
637///
638#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
639#[serde_with::serde_as]
640#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
641pub struct Expr {
642    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
643    pub description: Option<String>,
644    /// Textual representation of an expression in Common Expression Language syntax.
645    pub expression: Option<String>,
646    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
647    pub location: Option<String>,
648    /// 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.
649    pub title: Option<String>,
650}
651
652impl common::Part for Expr {}
653
654/// Restricts access to Cloud Console and Google Cloud APIs for a set of users using Context-Aware Access.
655///
656/// # Activities
657///
658/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
659/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
660///
661/// * [gcp user access bindings create organizations](OrganizationGcpUserAccessBindingCreateCall) (request)
662/// * [gcp user access bindings get organizations](OrganizationGcpUserAccessBindingGetCall) (response)
663/// * [gcp user access bindings patch organizations](OrganizationGcpUserAccessBindingPatchCall) (request)
664#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
665#[serde_with::serde_as]
666#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
667pub struct GcpUserAccessBinding {
668    /// Optional. Access level that a user must have to be granted access. Only one access level is supported, not multiple. This repeated field must have exactly one element. Example: "accessPolicies/9522/accessLevels/device_trusted"
669    #[serde(rename = "accessLevels")]
670    pub access_levels: Option<Vec<String>>,
671    /// Optional. Dry run access level that will be evaluated but will not be enforced. The access denial based on dry run policy will be logged. Only one access level is supported, not multiple. This list must have exactly one element. Example: "accessPolicies/9522/accessLevels/device_trusted"
672    #[serde(rename = "dryRunAccessLevels")]
673    pub dry_run_access_levels: Option<Vec<String>>,
674    /// Optional. Immutable. Google Group id whose users are subject to this binding's restrictions. See "id" in the [Google Workspace Directory API's Group Resource] (https://developers.google.com/admin-sdk/directory/v1/reference/groups#resource). If a group's email address/alias is changed, this resource will continue to point at the changed group. This field does not accept group email addresses or aliases. Example: "01d520gv4vjcrht"
675    #[serde(rename = "groupKey")]
676    pub group_key: Option<String>,
677    /// Immutable. Assigned by the server during creation. The last segment has an arbitrary length and has only URI unreserved characters (as defined by [RFC 3986 Section 2.3](https://tools.ietf.org/html/rfc3986#section-2.3)). Should not be specified by the client during creation. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
678    pub name: Option<String>,
679    /// Optional. A list of applications that are subject to this binding's restrictions. If the list is empty, the binding restrictions will universally apply to all applications.
680    #[serde(rename = "restrictedClientApplications")]
681    pub restricted_client_applications: Option<Vec<Application>>,
682    /// Optional. A list of scoped access settings that set this binding's restrictions on a subset of applications. This field cannot be set if restricted_client_applications is set.
683    #[serde(rename = "scopedAccessSettings")]
684    pub scoped_access_settings: Option<Vec<ScopedAccessSettings>>,
685    /// Optional. The Google Cloud session length (GCSL) policy for the group key.
686    #[serde(rename = "sessionSettings")]
687    pub session_settings: Option<SessionSettings>,
688}
689
690impl common::RequestValue for GcpUserAccessBinding {}
691impl common::ResponseResult for GcpUserAccessBinding {}
692
693/// Request message for `GetIamPolicy` method.
694///
695/// # Activities
696///
697/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
698/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
699///
700/// * [get iam policy access policies](AccessPolicyGetIamPolicyCall) (request)
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct GetIamPolicyRequest {
705    /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
706    pub options: Option<GetPolicyOptions>,
707}
708
709impl common::RequestValue for GetIamPolicyRequest {}
710
711/// Encapsulates settings provided to GetIamPolicy.
712///
713/// This type is not used in any activity, and only used as *part* of another schema.
714///
715#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
716#[serde_with::serde_as]
717#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
718pub struct GetPolicyOptions {
719    /// 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).
720    #[serde(rename = "requestedPolicyVersion")]
721    pub requested_policy_version: Option<i32>,
722}
723
724impl common::Part for GetPolicyOptions {}
725
726/// Defines the conditions under which an IngressPolicy matches a request. Conditions are based on information about the source of the request. The request must satisfy what is defined in `sources` AND identity related fields in order to match.
727///
728/// This type is not used in any activity, and only used as *part* of another schema.
729///
730#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
731#[serde_with::serde_as]
732#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
733pub struct IngressFrom {
734    /// A list of identities that are allowed access through [IngressPolicy]. Identities can be an individual user, service account, Google group, or third-party identity. For third-party identity, only single identities are supported and other identity types are not supported. The `v1` identities that have the prefix `user`, `group`, `serviceAccount`, and `principal` in https://cloud.google.com/iam/docs/principal-identifiers#v1 are supported.
735    pub identities: Option<Vec<String>>,
736    /// Specifies the type of identities that are allowed access from outside the perimeter. If left unspecified, then members of `identities` field will be allowed access.
737    #[serde(rename = "identityType")]
738    pub identity_type: Option<String>,
739    /// Sources that this IngressPolicy authorizes access from.
740    pub sources: Option<Vec<IngressSource>>,
741}
742
743impl common::Part for IngressFrom {}
744
745/// Policy for ingress into ServicePerimeter. IngressPolicies match requests based on `ingress_from` and `ingress_to` stanzas. For an ingress policy to match, both the `ingress_from` and `ingress_to` stanzas must be matched. If an IngressPolicy matches a request, the request is allowed through the perimeter boundary from outside the perimeter. For example, access from the internet can be allowed either based on an AccessLevel or, for traffic hosted on Google Cloud, the project of the source network. For access from private networks, using the project of the hosting network is required. Individual ingress policies can be limited by restricting which services and/or actions they match using the `ingress_to` field.
746///
747/// This type is not used in any activity, and only used as *part* of another schema.
748///
749#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
750#[serde_with::serde_as]
751#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
752pub struct IngressPolicy {
753    /// Defines the conditions on the source of a request causing this IngressPolicy to apply.
754    #[serde(rename = "ingressFrom")]
755    pub ingress_from: Option<IngressFrom>,
756    /// Defines the conditions on the ApiOperation and request destination that cause this IngressPolicy to apply.
757    #[serde(rename = "ingressTo")]
758    pub ingress_to: Option<IngressTo>,
759    /// Optional. Human-readable title for the ingress rule. The title must be unique within the perimeter and can not exceed 100 characters. Within the access policy, the combined length of all rule titles must not exceed 240,000 characters.
760    pub title: Option<String>,
761}
762
763impl common::Part for IngressPolicy {}
764
765/// The source that IngressPolicy authorizes access from.
766///
767/// This type is not used in any activity, and only used as *part* of another schema.
768///
769#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
770#[serde_with::serde_as]
771#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
772pub struct IngressSource {
773    /// An AccessLevel resource name that allow resources within the ServicePerimeters to be accessed from the internet. AccessLevels listed must be in the same policy as this ServicePerimeter. Referencing a nonexistent AccessLevel will cause an error. If no AccessLevel names are listed, resources within the perimeter can only be accessed via Google Cloud calls with request origins within the perimeter. Example: `accessPolicies/MY_POLICY/accessLevels/MY_LEVEL`. If a single `*` is specified for `access_level`, then all IngressSources will be allowed.
774    #[serde(rename = "accessLevel")]
775    pub access_level: Option<String>,
776    /// A Google Cloud resource that is allowed to ingress the perimeter. Requests from these resources will be allowed to access perimeter data. Currently only projects and VPCs are allowed. Project format: `projects/{project_number}` VPC network format: `//compute.googleapis.com/projects/{PROJECT_ID}/global/networks/{NAME}`. The project may be in any Google Cloud organization, not just the organization that the perimeter is defined in. `*` is not allowed, the case of allowing all Google Cloud resources only is not supported.
777    pub resource: Option<String>,
778}
779
780impl common::Part for IngressSource {}
781
782/// Defines the conditions under which an IngressPolicy matches a request. Conditions are based on information about the ApiOperation intended to be performed on the target resource of the request. The request must satisfy what is defined in `operations` AND `resources` in order to match.
783///
784/// This type is not used in any activity, and only used as *part* of another schema.
785///
786#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
787#[serde_with::serde_as]
788#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
789pub struct IngressTo {
790    /// A list of ApiOperations allowed to be performed by the sources specified in corresponding IngressFrom in this ServicePerimeter.
791    pub operations: Option<Vec<ApiOperation>>,
792    /// A list of resources, currently only projects in the form `projects/`, protected by this ServicePerimeter that are allowed to be accessed by sources defined in the corresponding IngressFrom. If a single `*` is specified, then access to all resources inside the perimeter are allowed.
793    pub resources: Option<Vec<String>>,
794    /// IAM roles that represent the set of operations that the sources specified in the corresponding IngressFrom are allowed to perform in this ServicePerimeter.
795    pub roles: Option<Vec<String>>,
796}
797
798impl common::Part for IngressTo {}
799
800/// A response to `ListAccessLevelsRequest`.
801///
802/// # Activities
803///
804/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
805/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
806///
807/// * [access levels list access policies](AccessPolicyAccessLevelListCall) (response)
808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
809#[serde_with::serde_as]
810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
811pub struct ListAccessLevelsResponse {
812    /// List of the Access Level instances.
813    #[serde(rename = "accessLevels")]
814    pub access_levels: Option<Vec<AccessLevel>>,
815    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
816    #[serde(rename = "nextPageToken")]
817    pub next_page_token: Option<String>,
818}
819
820impl common::ResponseResult for ListAccessLevelsResponse {}
821
822/// A response to `ListAccessPoliciesRequest`.
823///
824/// # Activities
825///
826/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
827/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
828///
829/// * [list access policies](AccessPolicyListCall) (response)
830#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
831#[serde_with::serde_as]
832#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
833pub struct ListAccessPoliciesResponse {
834    /// List of the AccessPolicy instances.
835    #[serde(rename = "accessPolicies")]
836    pub access_policies: Option<Vec<AccessPolicy>>,
837    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
838    #[serde(rename = "nextPageToken")]
839    pub next_page_token: Option<String>,
840}
841
842impl common::ResponseResult for ListAccessPoliciesResponse {}
843
844/// A response to `ListAuthorizedOrgsDescsRequest`.
845///
846/// # Activities
847///
848/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
849/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
850///
851/// * [authorized orgs descs list access policies](AccessPolicyAuthorizedOrgsDescListCall) (response)
852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
853#[serde_with::serde_as]
854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
855pub struct ListAuthorizedOrgsDescsResponse {
856    /// List of all the Authorized Orgs Desc instances.
857    #[serde(rename = "authorizedOrgsDescs")]
858    pub authorized_orgs_descs: Option<Vec<AuthorizedOrgsDesc>>,
859    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
860    #[serde(rename = "nextPageToken")]
861    pub next_page_token: Option<String>,
862}
863
864impl common::ResponseResult for ListAuthorizedOrgsDescsResponse {}
865
866/// Response of ListGcpUserAccessBindings.
867///
868/// # Activities
869///
870/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
871/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
872///
873/// * [gcp user access bindings list organizations](OrganizationGcpUserAccessBindingListCall) (response)
874#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
875#[serde_with::serde_as]
876#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
877pub struct ListGcpUserAccessBindingsResponse {
878    /// GcpUserAccessBinding
879    #[serde(rename = "gcpUserAccessBindings")]
880    pub gcp_user_access_bindings: Option<Vec<GcpUserAccessBinding>>,
881    /// Token to get the next page of items. If blank, there are no more items.
882    #[serde(rename = "nextPageToken")]
883    pub next_page_token: Option<String>,
884}
885
886impl common::ResponseResult for ListGcpUserAccessBindingsResponse {}
887
888/// The response message for Operations.ListOperations.
889///
890/// # Activities
891///
892/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
893/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
894///
895/// * [list operations](OperationListCall) (response)
896#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
897#[serde_with::serde_as]
898#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
899pub struct ListOperationsResponse {
900    /// The standard List next-page token.
901    #[serde(rename = "nextPageToken")]
902    pub next_page_token: Option<String>,
903    /// A list of operations that matches the specified filter in the request.
904    pub operations: Option<Vec<Operation>>,
905    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
906    pub unreachable: Option<Vec<String>>,
907}
908
909impl common::ResponseResult for ListOperationsResponse {}
910
911/// A response to `ListServicePerimetersRequest`.
912///
913/// # Activities
914///
915/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
916/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
917///
918/// * [service perimeters list access policies](AccessPolicyServicePerimeterListCall) (response)
919#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
920#[serde_with::serde_as]
921#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
922pub struct ListServicePerimetersResponse {
923    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
924    #[serde(rename = "nextPageToken")]
925    pub next_page_token: Option<String>,
926    /// List of the Service Perimeter instances.
927    #[serde(rename = "servicePerimeters")]
928    pub service_perimeters: Option<Vec<ServicePerimeter>>,
929}
930
931impl common::ResponseResult for ListServicePerimetersResponse {}
932
933/// A response to `ListSupportedServicesRequest`.
934///
935/// # Activities
936///
937/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
938/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
939///
940/// * [list services](ServiceListCall) (response)
941#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
942#[serde_with::serde_as]
943#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
944pub struct ListSupportedServicesResponse {
945    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
946    #[serde(rename = "nextPageToken")]
947    pub next_page_token: Option<String>,
948    /// List of services supported by VPC Service Controls instances.
949    #[serde(rename = "supportedServices")]
950    pub supported_services: Option<Vec<SupportedService>>,
951}
952
953impl common::ResponseResult for ListSupportedServicesResponse {}
954
955/// An allowed method or permission of a service specified in ApiOperation.
956///
957/// This type is not used in any activity, and only used as *part* of another schema.
958///
959#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
960#[serde_with::serde_as]
961#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
962pub struct MethodSelector {
963    /// A valid method name for the corresponding `service_name` in ApiOperation. If `*` is used as the value for the `method`, then ALL methods and permissions are allowed.
964    pub method: Option<String>,
965    /// A valid Cloud IAM permission for the corresponding `service_name` in ApiOperation.
966    pub permission: Option<String>,
967}
968
969impl common::Part for MethodSelector {}
970
971/// This resource represents a long-running operation that is the result of a network API call.
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/// * [access levels create access policies](AccessPolicyAccessLevelCreateCall) (response)
979/// * [access levels delete access policies](AccessPolicyAccessLevelDeleteCall) (response)
980/// * [access levels patch access policies](AccessPolicyAccessLevelPatchCall) (response)
981/// * [access levels replace all access policies](AccessPolicyAccessLevelReplaceAllCall) (response)
982/// * [authorized orgs descs create access policies](AccessPolicyAuthorizedOrgsDescCreateCall) (response)
983/// * [authorized orgs descs delete access policies](AccessPolicyAuthorizedOrgsDescDeleteCall) (response)
984/// * [authorized orgs descs patch access policies](AccessPolicyAuthorizedOrgsDescPatchCall) (response)
985/// * [service perimeters commit access policies](AccessPolicyServicePerimeterCommitCall) (response)
986/// * [service perimeters create access policies](AccessPolicyServicePerimeterCreateCall) (response)
987/// * [service perimeters delete access policies](AccessPolicyServicePerimeterDeleteCall) (response)
988/// * [service perimeters patch access policies](AccessPolicyServicePerimeterPatchCall) (response)
989/// * [service perimeters replace all access policies](AccessPolicyServicePerimeterReplaceAllCall) (response)
990/// * [create access policies](AccessPolicyCreateCall) (response)
991/// * [delete access policies](AccessPolicyDeleteCall) (response)
992/// * [patch access policies](AccessPolicyPatchCall) (response)
993/// * [cancel operations](OperationCancelCall) (none)
994/// * [delete operations](OperationDeleteCall) (none)
995/// * [get operations](OperationGetCall) (response)
996/// * [list operations](OperationListCall) (none)
997/// * [gcp user access bindings create organizations](OrganizationGcpUserAccessBindingCreateCall) (response)
998/// * [gcp user access bindings delete organizations](OrganizationGcpUserAccessBindingDeleteCall) (response)
999/// * [gcp user access bindings patch organizations](OrganizationGcpUserAccessBindingPatchCall) (response)
1000#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1001#[serde_with::serde_as]
1002#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1003pub struct Operation {
1004    /// 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.
1005    pub done: Option<bool>,
1006    /// The error result of the operation in case of failure or cancellation.
1007    pub error: Option<Status>,
1008    /// 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.
1009    pub metadata: Option<HashMap<String, serde_json::Value>>,
1010    /// 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}`.
1011    pub name: Option<String>,
1012    /// 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`.
1013    pub response: Option<HashMap<String, serde_json::Value>>,
1014}
1015
1016impl common::Resource for Operation {}
1017impl common::ResponseResult for Operation {}
1018
1019/// A restriction on the OS type and version of devices making requests.
1020///
1021/// This type is not used in any activity, and only used as *part* of another schema.
1022///
1023#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1024#[serde_with::serde_as]
1025#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1026pub struct OsConstraint {
1027    /// The minimum allowed OS version. If not set, any version of this OS satisfies the constraint. Format: `"major.minor.patch"`. Examples: `"10.5.301"`, `"9.2.1"`.
1028    #[serde(rename = "minimumVersion")]
1029    pub minimum_version: Option<String>,
1030    /// Required. The allowed OS type.
1031    #[serde(rename = "osType")]
1032    pub os_type: Option<String>,
1033    /// Only allows requests from devices with a verified Chrome OS. Verifications includes requirements that the device is enterprise-managed, conformant to domain policies, and the caller has permission to call the API targeted by the request.
1034    #[serde(rename = "requireVerifiedChromeOs")]
1035    pub require_verified_chrome_os: Option<bool>,
1036}
1037
1038impl common::Part for OsConstraint {}
1039
1040/// 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/).
1041///
1042/// # Activities
1043///
1044/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1045/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1046///
1047/// * [get iam policy access policies](AccessPolicyGetIamPolicyCall) (response)
1048/// * [set iam policy access policies](AccessPolicySetIamPolicyCall) (response)
1049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1050#[serde_with::serde_as]
1051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1052pub struct Policy {
1053    /// Specifies cloud audit logging configuration for this policy.
1054    #[serde(rename = "auditConfigs")]
1055    pub audit_configs: Option<Vec<AuditConfig>>,
1056    /// 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`.
1057    pub bindings: Option<Vec<Binding>>,
1058    /// `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.
1059    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1060    pub etag: Option<Vec<u8>>,
1061    /// 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).
1062    pub version: Option<i32>,
1063}
1064
1065impl common::ResponseResult for Policy {}
1066
1067/// A request to replace all existing Access Levels in an Access Policy with the Access Levels provided. This is done atomically.
1068///
1069/// # Activities
1070///
1071/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1072/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1073///
1074/// * [access levels replace all access policies](AccessPolicyAccessLevelReplaceAllCall) (request)
1075#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1076#[serde_with::serde_as]
1077#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1078pub struct ReplaceAccessLevelsRequest {
1079    /// Required. The desired Access Levels that should replace all existing Access Levels in the Access Policy.
1080    #[serde(rename = "accessLevels")]
1081    pub access_levels: Option<Vec<AccessLevel>>,
1082    /// Optional. The etag for the version of the Access Policy that this replace operation is to be performed on. If, at the time of replace, the etag for the Access Policy stored in Access Context Manager is different from the specified etag, then the replace operation will not be performed and the call will fail. This field is not required. If etag is not provided, the operation will be performed as if a valid etag is provided.
1083    pub etag: Option<String>,
1084}
1085
1086impl common::RequestValue for ReplaceAccessLevelsRequest {}
1087
1088/// A request to replace all existing Service Perimeters in an Access Policy with the Service Perimeters provided. This is done atomically.
1089///
1090/// # Activities
1091///
1092/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1093/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1094///
1095/// * [service perimeters replace all access policies](AccessPolicyServicePerimeterReplaceAllCall) (request)
1096#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1097#[serde_with::serde_as]
1098#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1099pub struct ReplaceServicePerimetersRequest {
1100    /// Optional. The etag for the version of the Access Policy that this replace operation is to be performed on. If, at the time of replace, the etag for the Access Policy stored in Access Context Manager is different from the specified etag, then the replace operation will not be performed and the call will fail. This field is not required. If etag is not provided, the operation will be performed as if a valid etag is provided.
1101    pub etag: Option<String>,
1102    /// Required. The desired Service Perimeters that should replace all existing Service Perimeters in the Access Policy.
1103    #[serde(rename = "servicePerimeters")]
1104    pub service_perimeters: Option<Vec<ServicePerimeter>>,
1105}
1106
1107impl common::RequestValue for ReplaceServicePerimetersRequest {}
1108
1109/// A relationship between access settings and its scope.
1110///
1111/// This type is not used in any activity, and only used as *part* of another schema.
1112///
1113#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1114#[serde_with::serde_as]
1115#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1116pub struct ScopedAccessSettings {
1117    /// Optional. Access settings for this scoped access settings. This field may be empty if dry_run_settings is set.
1118    #[serde(rename = "activeSettings")]
1119    pub active_settings: Option<AccessSettings>,
1120    /// Optional. Dry-run access settings for this scoped access settings. This field may be empty if active_settings is set.
1121    #[serde(rename = "dryRunSettings")]
1122    pub dry_run_settings: Option<AccessSettings>,
1123    /// Optional. Application, etc. to which the access settings will be applied to. Implicitly, this is the scoped access settings key; as such, it must be unique and non-empty.
1124    pub scope: Option<AccessScope>,
1125}
1126
1127impl common::Part for ScopedAccessSettings {}
1128
1129/// `ServicePerimeter` describes a set of Google Cloud resources which can freely import and export data amongst themselves, but not export outside of the `ServicePerimeter`. If a request with a source within this `ServicePerimeter` has a target outside of the `ServicePerimeter`, the request will be blocked. Otherwise the request is allowed. There are two types of Service Perimeter - Regular and Bridge. Regular Service Perimeters cannot overlap, a single Google Cloud project or VPC network can only belong to a single regular Service Perimeter. Service Perimeter Bridges can contain only Google Cloud projects as members, a single Google Cloud project may belong to multiple Service Perimeter Bridges.
1130///
1131/// # Activities
1132///
1133/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1134/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1135///
1136/// * [service perimeters create access policies](AccessPolicyServicePerimeterCreateCall) (request)
1137/// * [service perimeters get access policies](AccessPolicyServicePerimeterGetCall) (response)
1138/// * [service perimeters patch access policies](AccessPolicyServicePerimeterPatchCall) (request)
1139#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1140#[serde_with::serde_as]
1141#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1142pub struct ServicePerimeter {
1143    /// Description of the `ServicePerimeter` and its use. Does not affect behavior.
1144    pub description: Option<String>,
1145    /// Optional. An opaque identifier for the current version of the `ServicePerimeter`. This identifier does not follow any specific format. If an etag is not provided, the operation will be performed as if a valid etag is provided.
1146    pub etag: Option<String>,
1147    /// Identifier. Resource name for the `ServicePerimeter`. Format: `accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}`. The `service_perimeter` component must begin with a letter, followed by alphanumeric characters or `_`. After you create a `ServicePerimeter`, you cannot change its `name`.
1148    pub name: Option<String>,
1149    /// Perimeter type indicator. A single project or VPC network is allowed to be a member of single regular perimeter, but multiple service perimeter bridges. A project cannot be a included in a perimeter bridge without being included in regular perimeter. For perimeter bridges, the restricted service list as well as access level lists must be empty.
1150    #[serde(rename = "perimeterType")]
1151    pub perimeter_type: Option<String>,
1152    /// Proposed (or dry run) ServicePerimeter configuration. This configuration allows to specify and test ServicePerimeter configuration without enforcing actual access restrictions. Only allowed to be set when the "use_explicit_dry_run_spec" flag is set.
1153    pub spec: Option<ServicePerimeterConfig>,
1154    /// Current ServicePerimeter configuration. Specifies sets of resources, restricted services and access levels that determine perimeter content and boundaries.
1155    pub status: Option<ServicePerimeterConfig>,
1156    /// Human readable title. Must be unique within the Policy.
1157    pub title: Option<String>,
1158    /// Use explicit dry run spec flag. Ordinarily, a dry-run spec implicitly exists for all Service Perimeters, and that spec is identical to the status for those Service Perimeters. When this flag is set, it inhibits the generation of the implicit spec, thereby allowing the user to explicitly provide a configuration ("spec") to use in a dry-run version of the Service Perimeter. This allows the user to test changes to the enforced config ("status") without actually enforcing them. This testing is done through analyzing the differences between currently enforced and suggested restrictions. use_explicit_dry_run_spec must bet set to True if any of the fields in the spec are set to non-default values.
1159    #[serde(rename = "useExplicitDryRunSpec")]
1160    pub use_explicit_dry_run_spec: Option<bool>,
1161}
1162
1163impl common::RequestValue for ServicePerimeter {}
1164impl common::ResponseResult for ServicePerimeter {}
1165
1166/// `ServicePerimeterConfig` specifies a set of Google Cloud resources that describe specific Service Perimeter configuration.
1167///
1168/// This type is not used in any activity, and only used as *part* of another schema.
1169///
1170#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1171#[serde_with::serde_as]
1172#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1173pub struct ServicePerimeterConfig {
1174    /// A list of `AccessLevel` resource names that allow resources within the `ServicePerimeter` to be accessed from the internet. `AccessLevels` listed must be in the same policy as this `ServicePerimeter`. Referencing a nonexistent `AccessLevel` is a syntax error. If no `AccessLevel` names are listed, resources within the perimeter can only be accessed via Google Cloud calls with request origins within the perimeter. Example: `"accessPolicies/MY_POLICY/accessLevels/MY_LEVEL"`. For Service Perimeter Bridge, must be empty.
1175    #[serde(rename = "accessLevels")]
1176    pub access_levels: Option<Vec<String>>,
1177    /// List of EgressPolicies to apply to the perimeter. A perimeter may have multiple EgressPolicies, each of which is evaluated separately. Access is granted if any EgressPolicy grants it. Must be empty for a perimeter bridge.
1178    #[serde(rename = "egressPolicies")]
1179    pub egress_policies: Option<Vec<EgressPolicy>>,
1180    /// List of IngressPolicies to apply to the perimeter. A perimeter may have multiple IngressPolicies, each of which is evaluated separately. Access is granted if any Ingress Policy grants it. Must be empty for a perimeter bridge.
1181    #[serde(rename = "ingressPolicies")]
1182    pub ingress_policies: Option<Vec<IngressPolicy>>,
1183    /// A list of Google Cloud resources that are inside of the service perimeter. Currently only projects and VPCs are allowed. Project format: `projects/{project_number}` VPC network format: `//compute.googleapis.com/projects/{PROJECT_ID}/global/networks/{NAME}`.
1184    pub resources: Option<Vec<String>>,
1185    /// Google Cloud services that are subject to the Service Perimeter restrictions. For example, if `storage.googleapis.com` is specified, access to the storage buckets inside the perimeter must meet the perimeter's access restrictions.
1186    #[serde(rename = "restrictedServices")]
1187    pub restricted_services: Option<Vec<String>>,
1188    /// Configuration for APIs allowed within Perimeter.
1189    #[serde(rename = "vpcAccessibleServices")]
1190    pub vpc_accessible_services: Option<VpcAccessibleServices>,
1191}
1192
1193impl common::Part for ServicePerimeterConfig {}
1194
1195/// Stores settings related to Google Cloud Session Length including session duration, the type of challenge (i.e. method) they should face when their session expires, and other related settings.
1196///
1197/// This type is not used in any activity, and only used as *part* of another schema.
1198///
1199#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1200#[serde_with::serde_as]
1201#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1202pub struct SessionSettings {
1203    /// Optional. How long a user is allowed to take between actions before a new access token must be issued. Only set for Google Cloud apps.
1204    #[serde(rename = "maxInactivity")]
1205    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1206    pub max_inactivity: Option<chrono::Duration>,
1207    /// Optional. The session length. Setting this field to zero is equal to disabling session. Also can set infinite session by flipping the enabled bit to false below. If use_oidc_max_age is true, for OIDC apps, the session length will be the minimum of this field and OIDC max_age param.
1208    #[serde(rename = "sessionLength")]
1209    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1210    pub session_length: Option<chrono::Duration>,
1211    /// Optional. This field enables or disables Google Cloud session length. When false, all fields set above will be disregarded and the session length is basically infinite.
1212    #[serde(rename = "sessionLengthEnabled")]
1213    pub session_length_enabled: Option<bool>,
1214    /// Optional. Session method when user's Google Cloud session is up.
1215    #[serde(rename = "sessionReauthMethod")]
1216    pub session_reauth_method: Option<String>,
1217    /// Optional. Only useful for OIDC apps. When false, the OIDC max_age param, if passed in the authentication request will be ignored. When true, the re-auth period will be the minimum of the session_length field and the max_age OIDC param.
1218    #[serde(rename = "useOidcMaxAge")]
1219    pub use_oidc_max_age: Option<bool>,
1220}
1221
1222impl common::Part for SessionSettings {}
1223
1224/// Request message for `SetIamPolicy` method.
1225///
1226/// # Activities
1227///
1228/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1229/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1230///
1231/// * [set iam policy access policies](AccessPolicySetIamPolicyCall) (request)
1232#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1233#[serde_with::serde_as]
1234#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1235pub struct SetIamPolicyRequest {
1236    /// 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.
1237    pub policy: Option<Policy>,
1238    /// 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"`
1239    #[serde(rename = "updateMask")]
1240    pub update_mask: Option<common::FieldMask>,
1241}
1242
1243impl common::RequestValue for SetIamPolicyRequest {}
1244
1245/// 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).
1246///
1247/// This type is not used in any activity, and only used as *part* of another schema.
1248///
1249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1250#[serde_with::serde_as]
1251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1252pub struct Status {
1253    /// The status code, which should be an enum value of google.rpc.Code.
1254    pub code: Option<i32>,
1255    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1256    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1257    /// 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.
1258    pub message: Option<String>,
1259}
1260
1261impl common::Part for Status {}
1262
1263/// `SupportedService` specifies the VPC Service Controls and its properties.
1264///
1265/// # Activities
1266///
1267/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1268/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1269///
1270/// * [get services](ServiceGetCall) (response)
1271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1272#[serde_with::serde_as]
1273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1274pub struct SupportedService {
1275    /// True if the service is available on the restricted VIP. Services on the restricted VIP typically either support VPC Service Controls or are core infrastructure services required for the functioning of Google Cloud.
1276    #[serde(rename = "availableOnRestrictedVip")]
1277    pub available_on_restricted_vip: Option<bool>,
1278    /// True if the service is supported with some limitations. Check [documentation](https://cloud.google.com/vpc-service-controls/docs/supported-products) for details.
1279    #[serde(rename = "knownLimitations")]
1280    pub known_limitations: Option<bool>,
1281    /// The service name or address of the supported service, such as `service.googleapis.com`.
1282    pub name: Option<String>,
1283    /// The support stage of the service.
1284    #[serde(rename = "serviceSupportStage")]
1285    pub service_support_stage: Option<String>,
1286    /// The support stage of the service.
1287    #[serde(rename = "supportStage")]
1288    pub support_stage: Option<String>,
1289    /// The list of the supported methods. This field exists only in response to GetSupportedService
1290    #[serde(rename = "supportedMethods")]
1291    pub supported_methods: Option<Vec<MethodSelector>>,
1292    /// The name of the supported product, such as 'Cloud Product API'.
1293    pub title: Option<String>,
1294}
1295
1296impl common::ResponseResult for SupportedService {}
1297
1298/// Request message for `TestIamPermissions` method.
1299///
1300/// # Activities
1301///
1302/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1303/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1304///
1305/// * [access levels test iam permissions access policies](AccessPolicyAccessLevelTestIamPermissionCall) (request)
1306/// * [service perimeters test iam permissions access policies](AccessPolicyServicePerimeterTestIamPermissionCall) (request)
1307/// * [test iam permissions access policies](AccessPolicyTestIamPermissionCall) (request)
1308#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1309#[serde_with::serde_as]
1310#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1311pub struct TestIamPermissionsRequest {
1312    /// 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).
1313    pub permissions: Option<Vec<String>>,
1314}
1315
1316impl common::RequestValue for TestIamPermissionsRequest {}
1317
1318/// Response message for `TestIamPermissions` method.
1319///
1320/// # Activities
1321///
1322/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1323/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1324///
1325/// * [access levels test iam permissions access policies](AccessPolicyAccessLevelTestIamPermissionCall) (response)
1326/// * [service perimeters test iam permissions access policies](AccessPolicyServicePerimeterTestIamPermissionCall) (response)
1327/// * [test iam permissions access policies](AccessPolicyTestIamPermissionCall) (response)
1328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1329#[serde_with::serde_as]
1330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1331pub struct TestIamPermissionsResponse {
1332    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1333    pub permissions: Option<Vec<String>>,
1334}
1335
1336impl common::ResponseResult for TestIamPermissionsResponse {}
1337
1338/// Specifies how APIs are allowed to communicate within the Service Perimeter.
1339///
1340/// This type is not used in any activity, and only used as *part* of another schema.
1341///
1342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1343#[serde_with::serde_as]
1344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1345pub struct VpcAccessibleServices {
1346    /// The list of APIs usable within the Service Perimeter. Must be empty unless 'enable_restriction' is True. You can specify a list of individual services, as well as include the 'RESTRICTED-SERVICES' value, which automatically includes all of the services protected by the perimeter.
1347    #[serde(rename = "allowedServices")]
1348    pub allowed_services: Option<Vec<String>>,
1349    /// Whether to restrict API calls within the Service Perimeter to the list of APIs specified in 'allowed_services'.
1350    #[serde(rename = "enableRestriction")]
1351    pub enable_restriction: Option<bool>,
1352}
1353
1354impl common::Part for VpcAccessibleServices {}
1355
1356/// The originating network source in Google Cloud.
1357///
1358/// This type is not used in any activity, and only used as *part* of another schema.
1359///
1360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1361#[serde_with::serde_as]
1362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1363pub struct VpcNetworkSource {
1364    /// Sub-segment ranges of a VPC network.
1365    #[serde(rename = "vpcSubnetwork")]
1366    pub vpc_subnetwork: Option<VpcSubNetwork>,
1367}
1368
1369impl common::Part for VpcNetworkSource {}
1370
1371/// Sub-segment ranges inside of a VPC Network.
1372///
1373/// This type is not used in any activity, and only used as *part* of another schema.
1374///
1375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1376#[serde_with::serde_as]
1377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1378pub struct VpcSubNetwork {
1379    /// Required. Network name. If the network is not part of the organization, the `compute.network.get` permission must be granted to the caller. Format: `//compute.googleapis.com/projects/{PROJECT_ID}/global/networks/{NETWORK_NAME}` Example: `//compute.googleapis.com/projects/my-project/global/networks/network-1`
1380    pub network: Option<String>,
1381    /// CIDR block IP subnetwork specification. The IP address must be an IPv4 address and can be a public or private IP address. Note that for a CIDR IP address block, the specified IP address portion must be properly truncated (i.e. all the host bits must be zero) or the input is considered malformed. For example, "192.0.2.0/24" is accepted but "192.0.2.1/24" is not. If empty, all IP addresses are allowed.
1382    #[serde(rename = "vpcIpSubnetworks")]
1383    pub vpc_ip_subnetworks: Option<Vec<String>>,
1384}
1385
1386impl common::Part for VpcSubNetwork {}
1387
1388// ###################
1389// MethodBuilders ###
1390// #################
1391
1392/// A builder providing access to all methods supported on *accessPolicy* resources.
1393/// It is not used directly, but through the [`AccessContextManager`] hub.
1394///
1395/// # Example
1396///
1397/// Instantiate a resource builder
1398///
1399/// ```test_harness,no_run
1400/// extern crate hyper;
1401/// extern crate hyper_rustls;
1402/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
1403///
1404/// # async fn dox() {
1405/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1406///
1407/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1408/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1409///     .with_native_roots()
1410///     .unwrap()
1411///     .https_only()
1412///     .enable_http2()
1413///     .build();
1414///
1415/// let executor = hyper_util::rt::TokioExecutor::new();
1416/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1417///     secret,
1418///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1419///     yup_oauth2::client::CustomHyperClientBuilder::from(
1420///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1421///     ),
1422/// ).build().await.unwrap();
1423///
1424/// let client = hyper_util::client::legacy::Client::builder(
1425///     hyper_util::rt::TokioExecutor::new()
1426/// )
1427/// .build(
1428///     hyper_rustls::HttpsConnectorBuilder::new()
1429///         .with_native_roots()
1430///         .unwrap()
1431///         .https_or_http()
1432///         .enable_http2()
1433///         .build()
1434/// );
1435/// let mut hub = AccessContextManager::new(client, auth);
1436/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1437/// // like `access_levels_create(...)`, `access_levels_delete(...)`, `access_levels_get(...)`, `access_levels_list(...)`, `access_levels_patch(...)`, `access_levels_replace_all(...)`, `access_levels_test_iam_permissions(...)`, `authorized_orgs_descs_create(...)`, `authorized_orgs_descs_delete(...)`, `authorized_orgs_descs_get(...)`, `authorized_orgs_descs_list(...)`, `authorized_orgs_descs_patch(...)`, `create(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `list(...)`, `patch(...)`, `service_perimeters_commit(...)`, `service_perimeters_create(...)`, `service_perimeters_delete(...)`, `service_perimeters_get(...)`, `service_perimeters_list(...)`, `service_perimeters_patch(...)`, `service_perimeters_replace_all(...)`, `service_perimeters_test_iam_permissions(...)`, `set_iam_policy(...)` and `test_iam_permissions(...)`
1438/// // to build up your call.
1439/// let rb = hub.access_policies();
1440/// # }
1441/// ```
1442pub struct AccessPolicyMethods<'a, C>
1443where
1444    C: 'a,
1445{
1446    hub: &'a AccessContextManager<C>,
1447}
1448
1449impl<'a, C> common::MethodsBuilder for AccessPolicyMethods<'a, C> {}
1450
1451impl<'a, C> AccessPolicyMethods<'a, C> {
1452    /// Create a builder to help you perform the following task:
1453    ///
1454    /// Creates an access level. The long-running operation from this RPC has a successful status after the access level propagates to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
1455    ///
1456    /// # Arguments
1457    ///
1458    /// * `request` - No description provided.
1459    /// * `parent` - Required. Resource name for the access policy which owns this Access Level. Format: `accessPolicies/{policy_id}`
1460    pub fn access_levels_create(
1461        &self,
1462        request: AccessLevel,
1463        parent: &str,
1464    ) -> AccessPolicyAccessLevelCreateCall<'a, C> {
1465        AccessPolicyAccessLevelCreateCall {
1466            hub: self.hub,
1467            _request: request,
1468            _parent: parent.to_string(),
1469            _delegate: Default::default(),
1470            _additional_params: Default::default(),
1471            _scopes: Default::default(),
1472        }
1473    }
1474
1475    /// Create a builder to help you perform the following task:
1476    ///
1477    /// Deletes an access level based on the resource name. The long-running operation from this RPC has a successful status after the access level has been removed from long-lasting storage.
1478    ///
1479    /// # Arguments
1480    ///
1481    /// * `name` - Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
1482    pub fn access_levels_delete(&self, name: &str) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
1483        AccessPolicyAccessLevelDeleteCall {
1484            hub: self.hub,
1485            _name: name.to_string(),
1486            _delegate: Default::default(),
1487            _additional_params: Default::default(),
1488            _scopes: Default::default(),
1489        }
1490    }
1491
1492    /// Create a builder to help you perform the following task:
1493    ///
1494    /// Gets an access level based on the resource name.
1495    ///
1496    /// # Arguments
1497    ///
1498    /// * `name` - Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
1499    pub fn access_levels_get(&self, name: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
1500        AccessPolicyAccessLevelGetCall {
1501            hub: self.hub,
1502            _name: name.to_string(),
1503            _access_level_format: Default::default(),
1504            _delegate: Default::default(),
1505            _additional_params: Default::default(),
1506            _scopes: Default::default(),
1507        }
1508    }
1509
1510    /// Create a builder to help you perform the following task:
1511    ///
1512    /// Lists all access levels for an access policy.
1513    ///
1514    /// # Arguments
1515    ///
1516    /// * `parent` - Required. Resource name for the access policy to list Access Levels from. Format: `accessPolicies/{policy_id}`
1517    pub fn access_levels_list(&self, parent: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
1518        AccessPolicyAccessLevelListCall {
1519            hub: self.hub,
1520            _parent: parent.to_string(),
1521            _page_token: Default::default(),
1522            _page_size: Default::default(),
1523            _access_level_format: Default::default(),
1524            _delegate: Default::default(),
1525            _additional_params: Default::default(),
1526            _scopes: Default::default(),
1527        }
1528    }
1529
1530    /// Create a builder to help you perform the following task:
1531    ///
1532    /// Updates an access level. The long-running operation from this RPC has a successful status after the changes to the access level propagate to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
1533    ///
1534    /// # Arguments
1535    ///
1536    /// * `request` - No description provided.
1537    /// * `name` - Identifier. Resource name for the `AccessLevel`. Format: `accessPolicies/{access_policy}/accessLevels/{access_level}`. The `access_level` component must begin with a letter, followed by alphanumeric characters or `_`. Its maximum length is 50 characters. After you create an `AccessLevel`, you cannot change its `name`.
1538    pub fn access_levels_patch(
1539        &self,
1540        request: AccessLevel,
1541        name: &str,
1542    ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
1543        AccessPolicyAccessLevelPatchCall {
1544            hub: self.hub,
1545            _request: request,
1546            _name: name.to_string(),
1547            _update_mask: Default::default(),
1548            _delegate: Default::default(),
1549            _additional_params: Default::default(),
1550            _scopes: Default::default(),
1551        }
1552    }
1553
1554    /// Create a builder to help you perform the following task:
1555    ///
1556    /// Replaces all existing access levels in an access policy with the access levels provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. If the replacement contains errors, an error response is returned for the first error encountered. Upon error, the replacement is cancelled, and existing access levels are not affected. The Operation.response field contains ReplaceAccessLevelsResponse. Removing access levels contained in existing service perimeters result in an error.
1557    ///
1558    /// # Arguments
1559    ///
1560    /// * `request` - No description provided.
1561    /// * `parent` - Required. Resource name for the access policy which owns these Access Levels. Format: `accessPolicies/{policy_id}`
1562    pub fn access_levels_replace_all(
1563        &self,
1564        request: ReplaceAccessLevelsRequest,
1565        parent: &str,
1566    ) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
1567        AccessPolicyAccessLevelReplaceAllCall {
1568            hub: self.hub,
1569            _request: request,
1570            _parent: parent.to_string(),
1571            _delegate: Default::default(),
1572            _additional_params: Default::default(),
1573            _scopes: Default::default(),
1574        }
1575    }
1576
1577    /// Create a builder to help you perform the following task:
1578    ///
1579    /// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
1580    ///
1581    /// # Arguments
1582    ///
1583    /// * `request` - No description provided.
1584    /// * `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.
1585    pub fn access_levels_test_iam_permissions(
1586        &self,
1587        request: TestIamPermissionsRequest,
1588        resource: &str,
1589    ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
1590        AccessPolicyAccessLevelTestIamPermissionCall {
1591            hub: self.hub,
1592            _request: request,
1593            _resource: resource.to_string(),
1594            _delegate: Default::default(),
1595            _additional_params: Default::default(),
1596            _scopes: Default::default(),
1597        }
1598    }
1599
1600    /// Create a builder to help you perform the following task:
1601    ///
1602    /// Creates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. The name of this `AuthorizedOrgsDesc` will be assigned during creation.
1603    ///
1604    /// # Arguments
1605    ///
1606    /// * `request` - No description provided.
1607    /// * `parent` - Required. Resource name for the access policy which owns this Authorized Orgs Desc. Format: `accessPolicies/{policy_id}`
1608    pub fn authorized_orgs_descs_create(
1609        &self,
1610        request: AuthorizedOrgsDesc,
1611        parent: &str,
1612    ) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
1613        AccessPolicyAuthorizedOrgsDescCreateCall {
1614            hub: self.hub,
1615            _request: request,
1616            _parent: parent.to_string(),
1617            _delegate: Default::default(),
1618            _additional_params: Default::default(),
1619            _scopes: Default::default(),
1620        }
1621    }
1622
1623    /// Create a builder to help you perform the following task:
1624    ///
1625    /// Deletes an authorized orgs desc based on the resource name. The long-running operation from this RPC has a successful status after the authorized orgs desc is removed from long-lasting storage.
1626    ///
1627    /// # Arguments
1628    ///
1629    /// * `name` - Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDesc/{authorized_orgs_desc_id}`
1630    pub fn authorized_orgs_descs_delete(
1631        &self,
1632        name: &str,
1633    ) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
1634        AccessPolicyAuthorizedOrgsDescDeleteCall {
1635            hub: self.hub,
1636            _name: name.to_string(),
1637            _delegate: Default::default(),
1638            _additional_params: Default::default(),
1639            _scopes: Default::default(),
1640        }
1641    }
1642
1643    /// Create a builder to help you perform the following task:
1644    ///
1645    /// Gets an authorized orgs desc based on the resource name.
1646    ///
1647    /// # Arguments
1648    ///
1649    /// * `name` - Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDescs/{authorized_orgs_descs_id}`
1650    pub fn authorized_orgs_descs_get(
1651        &self,
1652        name: &str,
1653    ) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
1654        AccessPolicyAuthorizedOrgsDescGetCall {
1655            hub: self.hub,
1656            _name: name.to_string(),
1657            _delegate: Default::default(),
1658            _additional_params: Default::default(),
1659            _scopes: Default::default(),
1660        }
1661    }
1662
1663    /// Create a builder to help you perform the following task:
1664    ///
1665    /// Lists all authorized orgs descs for an access policy.
1666    ///
1667    /// # Arguments
1668    ///
1669    /// * `parent` - Required. Resource name for the access policy to list Authorized Orgs Desc from. Format: `accessPolicies/{policy_id}`
1670    pub fn authorized_orgs_descs_list(
1671        &self,
1672        parent: &str,
1673    ) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
1674        AccessPolicyAuthorizedOrgsDescListCall {
1675            hub: self.hub,
1676            _parent: parent.to_string(),
1677            _page_token: Default::default(),
1678            _page_size: Default::default(),
1679            _delegate: Default::default(),
1680            _additional_params: Default::default(),
1681            _scopes: Default::default(),
1682        }
1683    }
1684
1685    /// Create a builder to help you perform the following task:
1686    ///
1687    /// Updates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. Only the organization list in `AuthorizedOrgsDesc` can be updated. The name, authorization_type, asset_type and authorization_direction cannot be updated.
1688    ///
1689    /// # Arguments
1690    ///
1691    /// * `request` - No description provided.
1692    /// * `name` - Identifier. Resource name for the `AuthorizedOrgsDesc`. Format: `accessPolicies/{access_policy}/authorizedOrgsDescs/{authorized_orgs_desc}`. The `authorized_orgs_desc` component must begin with a letter, followed by alphanumeric characters or `_`. After you create an `AuthorizedOrgsDesc`, you cannot change its `name`.
1693    pub fn authorized_orgs_descs_patch(
1694        &self,
1695        request: AuthorizedOrgsDesc,
1696        name: &str,
1697    ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
1698        AccessPolicyAuthorizedOrgsDescPatchCall {
1699            hub: self.hub,
1700            _request: request,
1701            _name: name.to_string(),
1702            _update_mask: Default::default(),
1703            _delegate: Default::default(),
1704            _additional_params: Default::default(),
1705            _scopes: Default::default(),
1706        }
1707    }
1708
1709    /// Create a builder to help you perform the following task:
1710    ///
1711    /// Commits the dry-run specification for all the service perimeters in an access policy. A commit operation on a service perimeter involves copying its `spec` field to the `status` field of the service perimeter. Only service perimeters with `use_explicit_dry_run_spec` field set to true are affected by a commit operation. The long-running operation from this RPC has a successful status after the dry-run specifications for all the service perimeters have been committed. If a commit fails, it causes the long-running operation to return an error response and the entire commit operation is cancelled. When successful, the Operation.response field contains CommitServicePerimetersResponse. The `dry_run` and the `spec` fields are cleared after a successful commit operation.
1712    ///
1713    /// # Arguments
1714    ///
1715    /// * `request` - No description provided.
1716    /// * `parent` - Required. Resource name for the parent Access Policy which owns all Service Perimeters in scope for the commit operation. Format: `accessPolicies/{policy_id}`
1717    pub fn service_perimeters_commit(
1718        &self,
1719        request: CommitServicePerimetersRequest,
1720        parent: &str,
1721    ) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
1722        AccessPolicyServicePerimeterCommitCall {
1723            hub: self.hub,
1724            _request: request,
1725            _parent: parent.to_string(),
1726            _delegate: Default::default(),
1727            _additional_params: Default::default(),
1728            _scopes: Default::default(),
1729        }
1730    }
1731
1732    /// Create a builder to help you perform the following task:
1733    ///
1734    /// Creates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
1735    ///
1736    /// # Arguments
1737    ///
1738    /// * `request` - No description provided.
1739    /// * `parent` - Required. Resource name for the access policy which owns this Service Perimeter. Format: `accessPolicies/{policy_id}`
1740    pub fn service_perimeters_create(
1741        &self,
1742        request: ServicePerimeter,
1743        parent: &str,
1744    ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
1745        AccessPolicyServicePerimeterCreateCall {
1746            hub: self.hub,
1747            _request: request,
1748            _parent: parent.to_string(),
1749            _delegate: Default::default(),
1750            _additional_params: Default::default(),
1751            _scopes: Default::default(),
1752        }
1753    }
1754
1755    /// Create a builder to help you perform the following task:
1756    ///
1757    /// Deletes a service perimeter based on the resource name. The long-running operation from this RPC has a successful status after the service perimeter is removed from long-lasting storage.
1758    ///
1759    /// # Arguments
1760    ///
1761    /// * `name` - Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeter_id}`
1762    pub fn service_perimeters_delete(
1763        &self,
1764        name: &str,
1765    ) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
1766        AccessPolicyServicePerimeterDeleteCall {
1767            hub: self.hub,
1768            _name: name.to_string(),
1769            _delegate: Default::default(),
1770            _additional_params: Default::default(),
1771            _scopes: Default::default(),
1772        }
1773    }
1774
1775    /// Create a builder to help you perform the following task:
1776    ///
1777    /// Gets a service perimeter based on the resource name.
1778    ///
1779    /// # Arguments
1780    ///
1781    /// * `name` - Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeters_id}`
1782    pub fn service_perimeters_get(&self, name: &str) -> AccessPolicyServicePerimeterGetCall<'a, C> {
1783        AccessPolicyServicePerimeterGetCall {
1784            hub: self.hub,
1785            _name: name.to_string(),
1786            _delegate: Default::default(),
1787            _additional_params: Default::default(),
1788            _scopes: Default::default(),
1789        }
1790    }
1791
1792    /// Create a builder to help you perform the following task:
1793    ///
1794    /// Lists all service perimeters for an access policy.
1795    ///
1796    /// # Arguments
1797    ///
1798    /// * `parent` - Required. Resource name for the access policy to list Service Perimeters from. Format: `accessPolicies/{policy_id}`
1799    pub fn service_perimeters_list(
1800        &self,
1801        parent: &str,
1802    ) -> AccessPolicyServicePerimeterListCall<'a, C> {
1803        AccessPolicyServicePerimeterListCall {
1804            hub: self.hub,
1805            _parent: parent.to_string(),
1806            _page_token: Default::default(),
1807            _page_size: Default::default(),
1808            _delegate: Default::default(),
1809            _additional_params: Default::default(),
1810            _scopes: Default::default(),
1811        }
1812    }
1813
1814    /// Create a builder to help you perform the following task:
1815    ///
1816    /// Updates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
1817    ///
1818    /// # Arguments
1819    ///
1820    /// * `request` - No description provided.
1821    /// * `name` - Identifier. Resource name for the `ServicePerimeter`. Format: `accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}`. The `service_perimeter` component must begin with a letter, followed by alphanumeric characters or `_`. After you create a `ServicePerimeter`, you cannot change its `name`.
1822    pub fn service_perimeters_patch(
1823        &self,
1824        request: ServicePerimeter,
1825        name: &str,
1826    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
1827        AccessPolicyServicePerimeterPatchCall {
1828            hub: self.hub,
1829            _request: request,
1830            _name: name.to_string(),
1831            _update_mask: Default::default(),
1832            _delegate: Default::default(),
1833            _additional_params: Default::default(),
1834            _scopes: Default::default(),
1835        }
1836    }
1837
1838    /// Create a builder to help you perform the following task:
1839    ///
1840    /// Replace all existing service perimeters in an access policy with the service perimeters provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. Replacements containing errors result in an error response for the first error encountered. Upon an error, replacement are cancelled and existing service perimeters are not affected. The Operation.response field contains ReplaceServicePerimetersResponse.
1841    ///
1842    /// # Arguments
1843    ///
1844    /// * `request` - No description provided.
1845    /// * `parent` - Required. Resource name for the access policy which owns these Service Perimeters. Format: `accessPolicies/{policy_id}`
1846    pub fn service_perimeters_replace_all(
1847        &self,
1848        request: ReplaceServicePerimetersRequest,
1849        parent: &str,
1850    ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
1851        AccessPolicyServicePerimeterReplaceAllCall {
1852            hub: self.hub,
1853            _request: request,
1854            _parent: parent.to_string(),
1855            _delegate: Default::default(),
1856            _additional_params: Default::default(),
1857            _scopes: Default::default(),
1858        }
1859    }
1860
1861    /// Create a builder to help you perform the following task:
1862    ///
1863    /// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
1864    ///
1865    /// # Arguments
1866    ///
1867    /// * `request` - No description provided.
1868    /// * `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.
1869    pub fn service_perimeters_test_iam_permissions(
1870        &self,
1871        request: TestIamPermissionsRequest,
1872        resource: &str,
1873    ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
1874        AccessPolicyServicePerimeterTestIamPermissionCall {
1875            hub: self.hub,
1876            _request: request,
1877            _resource: resource.to_string(),
1878            _delegate: Default::default(),
1879            _additional_params: Default::default(),
1880            _scopes: Default::default(),
1881        }
1882    }
1883
1884    /// Create a builder to help you perform the following task:
1885    ///
1886    /// Creates an access policy. This method fails if the organization already has an access policy. The long-running operation has a successful status after the access policy propagates to long-lasting storage. Syntactic and basic semantic errors are returned in `metadata` as a BadRequest proto.
1887    ///
1888    /// # Arguments
1889    ///
1890    /// * `request` - No description provided.
1891    pub fn create(&self, request: AccessPolicy) -> AccessPolicyCreateCall<'a, C> {
1892        AccessPolicyCreateCall {
1893            hub: self.hub,
1894            _request: request,
1895            _delegate: Default::default(),
1896            _additional_params: Default::default(),
1897            _scopes: Default::default(),
1898        }
1899    }
1900
1901    /// Create a builder to help you perform the following task:
1902    ///
1903    /// Deletes an access policy based on the resource name. The long-running operation has a successful status after the access policy is removed from long-lasting storage.
1904    ///
1905    /// # Arguments
1906    ///
1907    /// * `name` - Required. Resource name for the access policy to delete. Format `accessPolicies/{policy_id}`
1908    pub fn delete(&self, name: &str) -> AccessPolicyDeleteCall<'a, C> {
1909        AccessPolicyDeleteCall {
1910            hub: self.hub,
1911            _name: name.to_string(),
1912            _delegate: Default::default(),
1913            _additional_params: Default::default(),
1914            _scopes: Default::default(),
1915        }
1916    }
1917
1918    /// Create a builder to help you perform the following task:
1919    ///
1920    /// Returns an access policy based on the name.
1921    ///
1922    /// # Arguments
1923    ///
1924    /// * `name` - Required. Resource name for the access policy to get. Format `accessPolicies/{policy_id}`
1925    pub fn get(&self, name: &str) -> AccessPolicyGetCall<'a, C> {
1926        AccessPolicyGetCall {
1927            hub: self.hub,
1928            _name: name.to_string(),
1929            _delegate: Default::default(),
1930            _additional_params: Default::default(),
1931            _scopes: Default::default(),
1932        }
1933    }
1934
1935    /// Create a builder to help you perform the following task:
1936    ///
1937    /// Gets the IAM policy for the specified Access Context Manager access policy.
1938    ///
1939    /// # Arguments
1940    ///
1941    /// * `request` - No description provided.
1942    /// * `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.
1943    pub fn get_iam_policy(
1944        &self,
1945        request: GetIamPolicyRequest,
1946        resource: &str,
1947    ) -> AccessPolicyGetIamPolicyCall<'a, C> {
1948        AccessPolicyGetIamPolicyCall {
1949            hub: self.hub,
1950            _request: request,
1951            _resource: resource.to_string(),
1952            _delegate: Default::default(),
1953            _additional_params: Default::default(),
1954            _scopes: Default::default(),
1955        }
1956    }
1957
1958    /// Create a builder to help you perform the following task:
1959    ///
1960    /// Lists all access policies in an organization.
1961    pub fn list(&self) -> AccessPolicyListCall<'a, C> {
1962        AccessPolicyListCall {
1963            hub: self.hub,
1964            _parent: Default::default(),
1965            _page_token: Default::default(),
1966            _page_size: Default::default(),
1967            _delegate: Default::default(),
1968            _additional_params: Default::default(),
1969            _scopes: Default::default(),
1970        }
1971    }
1972
1973    /// Create a builder to help you perform the following task:
1974    ///
1975    /// Updates an access policy. The long-running operation from this RPC has a successful status after the changes to the access policy propagate to long-lasting storage.
1976    ///
1977    /// # Arguments
1978    ///
1979    /// * `request` - No description provided.
1980    /// * `name` - Output only. Identifier. Resource name of the `AccessPolicy`. Format: `accessPolicies/{access_policy}`
1981    pub fn patch(&self, request: AccessPolicy, name: &str) -> AccessPolicyPatchCall<'a, C> {
1982        AccessPolicyPatchCall {
1983            hub: self.hub,
1984            _request: request,
1985            _name: name.to_string(),
1986            _update_mask: Default::default(),
1987            _delegate: Default::default(),
1988            _additional_params: Default::default(),
1989            _scopes: Default::default(),
1990        }
1991    }
1992
1993    /// Create a builder to help you perform the following task:
1994    ///
1995    /// Sets the IAM policy for the specified Access Context Manager access policy. This method replaces the existing IAM policy on the access policy. The IAM policy controls the set of users who can perform specific operations on the Access Context Manager access policy.
1996    ///
1997    /// # Arguments
1998    ///
1999    /// * `request` - No description provided.
2000    /// * `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.
2001    pub fn set_iam_policy(
2002        &self,
2003        request: SetIamPolicyRequest,
2004        resource: &str,
2005    ) -> AccessPolicySetIamPolicyCall<'a, C> {
2006        AccessPolicySetIamPolicyCall {
2007            hub: self.hub,
2008            _request: request,
2009            _resource: resource.to_string(),
2010            _delegate: Default::default(),
2011            _additional_params: Default::default(),
2012            _scopes: Default::default(),
2013        }
2014    }
2015
2016    /// Create a builder to help you perform the following task:
2017    ///
2018    /// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
2019    ///
2020    /// # Arguments
2021    ///
2022    /// * `request` - No description provided.
2023    /// * `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.
2024    pub fn test_iam_permissions(
2025        &self,
2026        request: TestIamPermissionsRequest,
2027        resource: &str,
2028    ) -> AccessPolicyTestIamPermissionCall<'a, C> {
2029        AccessPolicyTestIamPermissionCall {
2030            hub: self.hub,
2031            _request: request,
2032            _resource: resource.to_string(),
2033            _delegate: Default::default(),
2034            _additional_params: Default::default(),
2035            _scopes: Default::default(),
2036        }
2037    }
2038}
2039
2040/// A builder providing access to all methods supported on *operation* resources.
2041/// It is not used directly, but through the [`AccessContextManager`] hub.
2042///
2043/// # Example
2044///
2045/// Instantiate a resource builder
2046///
2047/// ```test_harness,no_run
2048/// extern crate hyper;
2049/// extern crate hyper_rustls;
2050/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
2051///
2052/// # async fn dox() {
2053/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2054///
2055/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2056/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2057///     .with_native_roots()
2058///     .unwrap()
2059///     .https_only()
2060///     .enable_http2()
2061///     .build();
2062///
2063/// let executor = hyper_util::rt::TokioExecutor::new();
2064/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2065///     secret,
2066///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2067///     yup_oauth2::client::CustomHyperClientBuilder::from(
2068///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2069///     ),
2070/// ).build().await.unwrap();
2071///
2072/// let client = hyper_util::client::legacy::Client::builder(
2073///     hyper_util::rt::TokioExecutor::new()
2074/// )
2075/// .build(
2076///     hyper_rustls::HttpsConnectorBuilder::new()
2077///         .with_native_roots()
2078///         .unwrap()
2079///         .https_or_http()
2080///         .enable_http2()
2081///         .build()
2082/// );
2083/// let mut hub = AccessContextManager::new(client, auth);
2084/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2085/// // like `cancel(...)`, `delete(...)`, `get(...)` and `list(...)`
2086/// // to build up your call.
2087/// let rb = hub.operations();
2088/// # }
2089/// ```
2090pub struct OperationMethods<'a, C>
2091where
2092    C: 'a,
2093{
2094    hub: &'a AccessContextManager<C>,
2095}
2096
2097impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
2098
2099impl<'a, C> OperationMethods<'a, C> {
2100    /// Create a builder to help you perform the following task:
2101    ///
2102    /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
2103    ///
2104    /// # Arguments
2105    ///
2106    /// * `request` - No description provided.
2107    /// * `name` - The name of the operation resource to be cancelled.
2108    pub fn cancel(
2109        &self,
2110        request: CancelOperationRequest,
2111        name: &str,
2112    ) -> OperationCancelCall<'a, C> {
2113        OperationCancelCall {
2114            hub: self.hub,
2115            _request: request,
2116            _name: name.to_string(),
2117            _delegate: Default::default(),
2118            _additional_params: Default::default(),
2119            _scopes: Default::default(),
2120        }
2121    }
2122
2123    /// Create a builder to help you perform the following task:
2124    ///
2125    /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
2126    ///
2127    /// # Arguments
2128    ///
2129    /// * `name` - The name of the operation resource to be deleted.
2130    pub fn delete(&self, name: &str) -> OperationDeleteCall<'a, C> {
2131        OperationDeleteCall {
2132            hub: self.hub,
2133            _name: name.to_string(),
2134            _delegate: Default::default(),
2135            _additional_params: Default::default(),
2136            _scopes: Default::default(),
2137        }
2138    }
2139
2140    /// Create a builder to help you perform the following task:
2141    ///
2142    /// 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.
2143    ///
2144    /// # Arguments
2145    ///
2146    /// * `name` - The name of the operation resource.
2147    pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
2148        OperationGetCall {
2149            hub: self.hub,
2150            _name: name.to_string(),
2151            _delegate: Default::default(),
2152            _additional_params: Default::default(),
2153            _scopes: Default::default(),
2154        }
2155    }
2156
2157    /// Create a builder to help you perform the following task:
2158    ///
2159    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2160    ///
2161    /// # Arguments
2162    ///
2163    /// * `name` - The name of the operation's parent resource.
2164    pub fn list(&self, name: &str) -> OperationListCall<'a, C> {
2165        OperationListCall {
2166            hub: self.hub,
2167            _name: name.to_string(),
2168            _return_partial_success: Default::default(),
2169            _page_token: Default::default(),
2170            _page_size: Default::default(),
2171            _filter: Default::default(),
2172            _delegate: Default::default(),
2173            _additional_params: Default::default(),
2174            _scopes: Default::default(),
2175        }
2176    }
2177}
2178
2179/// A builder providing access to all methods supported on *organization* resources.
2180/// It is not used directly, but through the [`AccessContextManager`] hub.
2181///
2182/// # Example
2183///
2184/// Instantiate a resource builder
2185///
2186/// ```test_harness,no_run
2187/// extern crate hyper;
2188/// extern crate hyper_rustls;
2189/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
2190///
2191/// # async fn dox() {
2192/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2193///
2194/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2195/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2196///     .with_native_roots()
2197///     .unwrap()
2198///     .https_only()
2199///     .enable_http2()
2200///     .build();
2201///
2202/// let executor = hyper_util::rt::TokioExecutor::new();
2203/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2204///     secret,
2205///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2206///     yup_oauth2::client::CustomHyperClientBuilder::from(
2207///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2208///     ),
2209/// ).build().await.unwrap();
2210///
2211/// let client = hyper_util::client::legacy::Client::builder(
2212///     hyper_util::rt::TokioExecutor::new()
2213/// )
2214/// .build(
2215///     hyper_rustls::HttpsConnectorBuilder::new()
2216///         .with_native_roots()
2217///         .unwrap()
2218///         .https_or_http()
2219///         .enable_http2()
2220///         .build()
2221/// );
2222/// let mut hub = AccessContextManager::new(client, auth);
2223/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2224/// // like `gcp_user_access_bindings_create(...)`, `gcp_user_access_bindings_delete(...)`, `gcp_user_access_bindings_get(...)`, `gcp_user_access_bindings_list(...)` and `gcp_user_access_bindings_patch(...)`
2225/// // to build up your call.
2226/// let rb = hub.organizations();
2227/// # }
2228/// ```
2229pub struct OrganizationMethods<'a, C>
2230where
2231    C: 'a,
2232{
2233    hub: &'a AccessContextManager<C>,
2234}
2235
2236impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
2237
2238impl<'a, C> OrganizationMethods<'a, C> {
2239    /// Create a builder to help you perform the following task:
2240    ///
2241    /// Creates a GcpUserAccessBinding. If the client specifies a name, the server ignores it. Fails if a resource already exists with the same group_key. Completion of this long-running operation does not necessarily signify that the new binding is deployed onto all affected users, which may take more time.
2242    ///
2243    /// # Arguments
2244    ///
2245    /// * `request` - No description provided.
2246    /// * `parent` - Required. Example: "organizations/256"
2247    pub fn gcp_user_access_bindings_create(
2248        &self,
2249        request: GcpUserAccessBinding,
2250        parent: &str,
2251    ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
2252        OrganizationGcpUserAccessBindingCreateCall {
2253            hub: self.hub,
2254            _request: request,
2255            _parent: parent.to_string(),
2256            _delegate: Default::default(),
2257            _additional_params: Default::default(),
2258            _scopes: Default::default(),
2259        }
2260    }
2261
2262    /// Create a builder to help you perform the following task:
2263    ///
2264    /// Deletes a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the binding deletion is deployed onto all affected users, which may take more time.
2265    ///
2266    /// # Arguments
2267    ///
2268    /// * `name` - Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
2269    pub fn gcp_user_access_bindings_delete(
2270        &self,
2271        name: &str,
2272    ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
2273        OrganizationGcpUserAccessBindingDeleteCall {
2274            hub: self.hub,
2275            _name: name.to_string(),
2276            _delegate: Default::default(),
2277            _additional_params: Default::default(),
2278            _scopes: Default::default(),
2279        }
2280    }
2281
2282    /// Create a builder to help you perform the following task:
2283    ///
2284    /// Gets the GcpUserAccessBinding with the given name.
2285    ///
2286    /// # Arguments
2287    ///
2288    /// * `name` - Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
2289    pub fn gcp_user_access_bindings_get(
2290        &self,
2291        name: &str,
2292    ) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
2293        OrganizationGcpUserAccessBindingGetCall {
2294            hub: self.hub,
2295            _name: name.to_string(),
2296            _delegate: Default::default(),
2297            _additional_params: Default::default(),
2298            _scopes: Default::default(),
2299        }
2300    }
2301
2302    /// Create a builder to help you perform the following task:
2303    ///
2304    /// Lists all GcpUserAccessBindings for a Google Cloud organization.
2305    ///
2306    /// # Arguments
2307    ///
2308    /// * `parent` - Required. Example: "organizations/256"
2309    pub fn gcp_user_access_bindings_list(
2310        &self,
2311        parent: &str,
2312    ) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
2313        OrganizationGcpUserAccessBindingListCall {
2314            hub: self.hub,
2315            _parent: parent.to_string(),
2316            _page_token: Default::default(),
2317            _page_size: Default::default(),
2318            _delegate: Default::default(),
2319            _additional_params: Default::default(),
2320            _scopes: Default::default(),
2321        }
2322    }
2323
2324    /// Create a builder to help you perform the following task:
2325    ///
2326    /// Updates a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the changed binding is deployed onto all affected users, which may take more time.
2327    ///
2328    /// # Arguments
2329    ///
2330    /// * `request` - No description provided.
2331    /// * `name` - Immutable. Assigned by the server during creation. The last segment has an arbitrary length and has only URI unreserved characters (as defined by [RFC 3986 Section 2.3](https://tools.ietf.org/html/rfc3986#section-2.3)). Should not be specified by the client during creation. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
2332    pub fn gcp_user_access_bindings_patch(
2333        &self,
2334        request: GcpUserAccessBinding,
2335        name: &str,
2336    ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
2337        OrganizationGcpUserAccessBindingPatchCall {
2338            hub: self.hub,
2339            _request: request,
2340            _name: name.to_string(),
2341            _update_mask: Default::default(),
2342            _append: Default::default(),
2343            _delegate: Default::default(),
2344            _additional_params: Default::default(),
2345            _scopes: Default::default(),
2346        }
2347    }
2348}
2349
2350/// A builder providing access to all methods supported on *service* resources.
2351/// It is not used directly, but through the [`AccessContextManager`] hub.
2352///
2353/// # Example
2354///
2355/// Instantiate a resource builder
2356///
2357/// ```test_harness,no_run
2358/// extern crate hyper;
2359/// extern crate hyper_rustls;
2360/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
2361///
2362/// # async fn dox() {
2363/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2364///
2365/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2366/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2367///     .with_native_roots()
2368///     .unwrap()
2369///     .https_only()
2370///     .enable_http2()
2371///     .build();
2372///
2373/// let executor = hyper_util::rt::TokioExecutor::new();
2374/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2375///     secret,
2376///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2377///     yup_oauth2::client::CustomHyperClientBuilder::from(
2378///         hyper_util::client::legacy::Client::builder(executor).build(connector),
2379///     ),
2380/// ).build().await.unwrap();
2381///
2382/// let client = hyper_util::client::legacy::Client::builder(
2383///     hyper_util::rt::TokioExecutor::new()
2384/// )
2385/// .build(
2386///     hyper_rustls::HttpsConnectorBuilder::new()
2387///         .with_native_roots()
2388///         .unwrap()
2389///         .https_or_http()
2390///         .enable_http2()
2391///         .build()
2392/// );
2393/// let mut hub = AccessContextManager::new(client, auth);
2394/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2395/// // like `get(...)` and `list(...)`
2396/// // to build up your call.
2397/// let rb = hub.services();
2398/// # }
2399/// ```
2400pub struct ServiceMethods<'a, C>
2401where
2402    C: 'a,
2403{
2404    hub: &'a AccessContextManager<C>,
2405}
2406
2407impl<'a, C> common::MethodsBuilder for ServiceMethods<'a, C> {}
2408
2409impl<'a, C> ServiceMethods<'a, C> {
2410    /// Create a builder to help you perform the following task:
2411    ///
2412    /// Returns a VPC-SC supported service based on the service name.
2413    ///
2414    /// # Arguments
2415    ///
2416    /// * `name` - The name of the service to get information about. The names must be in the same format as used in defining a service perimeter, for example, `storage.googleapis.com`.
2417    pub fn get(&self, name: &str) -> ServiceGetCall<'a, C> {
2418        ServiceGetCall {
2419            hub: self.hub,
2420            _name: name.to_string(),
2421            _delegate: Default::default(),
2422            _additional_params: Default::default(),
2423            _scopes: Default::default(),
2424        }
2425    }
2426
2427    /// Create a builder to help you perform the following task:
2428    ///
2429    /// Lists all VPC-SC supported services.
2430    pub fn list(&self) -> ServiceListCall<'a, C> {
2431        ServiceListCall {
2432            hub: self.hub,
2433            _page_token: Default::default(),
2434            _page_size: Default::default(),
2435            _delegate: Default::default(),
2436            _additional_params: Default::default(),
2437            _scopes: Default::default(),
2438        }
2439    }
2440}
2441
2442// ###################
2443// CallBuilders   ###
2444// #################
2445
2446/// Creates an access level. The long-running operation from this RPC has a successful status after the access level propagates to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
2447///
2448/// A builder for the *accessLevels.create* method supported by a *accessPolicy* resource.
2449/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2450///
2451/// # Example
2452///
2453/// Instantiate a resource method builder
2454///
2455/// ```test_harness,no_run
2456/// # extern crate hyper;
2457/// # extern crate hyper_rustls;
2458/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
2459/// use accesscontextmanager1::api::AccessLevel;
2460/// # async fn dox() {
2461/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2462///
2463/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2464/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2465/// #     .with_native_roots()
2466/// #     .unwrap()
2467/// #     .https_only()
2468/// #     .enable_http2()
2469/// #     .build();
2470///
2471/// # let executor = hyper_util::rt::TokioExecutor::new();
2472/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2473/// #     secret,
2474/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2475/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2476/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2477/// #     ),
2478/// # ).build().await.unwrap();
2479///
2480/// # let client = hyper_util::client::legacy::Client::builder(
2481/// #     hyper_util::rt::TokioExecutor::new()
2482/// # )
2483/// # .build(
2484/// #     hyper_rustls::HttpsConnectorBuilder::new()
2485/// #         .with_native_roots()
2486/// #         .unwrap()
2487/// #         .https_or_http()
2488/// #         .enable_http2()
2489/// #         .build()
2490/// # );
2491/// # let mut hub = AccessContextManager::new(client, auth);
2492/// // As the method needs a request, you would usually fill it with the desired information
2493/// // into the respective structure. Some of the parts shown here might not be applicable !
2494/// // Values shown here are possibly random and not representative !
2495/// let mut req = AccessLevel::default();
2496///
2497/// // You can configure optional parameters by calling the respective setters at will, and
2498/// // execute the final call using `doit()`.
2499/// // Values shown here are possibly random and not representative !
2500/// let result = hub.access_policies().access_levels_create(req, "parent")
2501///              .doit().await;
2502/// # }
2503/// ```
2504pub struct AccessPolicyAccessLevelCreateCall<'a, C>
2505where
2506    C: 'a,
2507{
2508    hub: &'a AccessContextManager<C>,
2509    _request: AccessLevel,
2510    _parent: String,
2511    _delegate: Option<&'a mut dyn common::Delegate>,
2512    _additional_params: HashMap<String, String>,
2513    _scopes: BTreeSet<String>,
2514}
2515
2516impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelCreateCall<'a, C> {}
2517
2518impl<'a, C> AccessPolicyAccessLevelCreateCall<'a, C>
2519where
2520    C: common::Connector,
2521{
2522    /// Perform the operation you have build so far.
2523    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2524        use std::borrow::Cow;
2525        use std::io::{Read, Seek};
2526
2527        use common::{url::Params, ToParts};
2528        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2529
2530        let mut dd = common::DefaultDelegate;
2531        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2532        dlg.begin(common::MethodInfo {
2533            id: "accesscontextmanager.accessPolicies.accessLevels.create",
2534            http_method: hyper::Method::POST,
2535        });
2536
2537        for &field in ["alt", "parent"].iter() {
2538            if self._additional_params.contains_key(field) {
2539                dlg.finished(false);
2540                return Err(common::Error::FieldClash(field));
2541            }
2542        }
2543
2544        let mut params = Params::with_capacity(4 + self._additional_params.len());
2545        params.push("parent", self._parent);
2546
2547        params.extend(self._additional_params.iter());
2548
2549        params.push("alt", "json");
2550        let mut url = self.hub._base_url.clone() + "v1/{+parent}/accessLevels";
2551        if self._scopes.is_empty() {
2552            self._scopes
2553                .insert(Scope::CloudPlatform.as_ref().to_string());
2554        }
2555
2556        #[allow(clippy::single_element_loop)]
2557        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2558            url = params.uri_replacement(url, param_name, find_this, true);
2559        }
2560        {
2561            let to_remove = ["parent"];
2562            params.remove_params(&to_remove);
2563        }
2564
2565        let url = params.parse_with_url(&url);
2566
2567        let mut json_mime_type = mime::APPLICATION_JSON;
2568        let mut request_value_reader = {
2569            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2570            common::remove_json_null_values(&mut value);
2571            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2572            serde_json::to_writer(&mut dst, &value).unwrap();
2573            dst
2574        };
2575        let request_size = request_value_reader
2576            .seek(std::io::SeekFrom::End(0))
2577            .unwrap();
2578        request_value_reader
2579            .seek(std::io::SeekFrom::Start(0))
2580            .unwrap();
2581
2582        loop {
2583            let token = match self
2584                .hub
2585                .auth
2586                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2587                .await
2588            {
2589                Ok(token) => token,
2590                Err(e) => match dlg.token(e) {
2591                    Ok(token) => token,
2592                    Err(e) => {
2593                        dlg.finished(false);
2594                        return Err(common::Error::MissingToken(e));
2595                    }
2596                },
2597            };
2598            request_value_reader
2599                .seek(std::io::SeekFrom::Start(0))
2600                .unwrap();
2601            let mut req_result = {
2602                let client = &self.hub.client;
2603                dlg.pre_request();
2604                let mut req_builder = hyper::Request::builder()
2605                    .method(hyper::Method::POST)
2606                    .uri(url.as_str())
2607                    .header(USER_AGENT, self.hub._user_agent.clone());
2608
2609                if let Some(token) = token.as_ref() {
2610                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2611                }
2612
2613                let request = req_builder
2614                    .header(CONTENT_TYPE, json_mime_type.to_string())
2615                    .header(CONTENT_LENGTH, request_size as u64)
2616                    .body(common::to_body(
2617                        request_value_reader.get_ref().clone().into(),
2618                    ));
2619
2620                client.request(request.unwrap()).await
2621            };
2622
2623            match req_result {
2624                Err(err) => {
2625                    if let common::Retry::After(d) = dlg.http_error(&err) {
2626                        sleep(d).await;
2627                        continue;
2628                    }
2629                    dlg.finished(false);
2630                    return Err(common::Error::HttpError(err));
2631                }
2632                Ok(res) => {
2633                    let (mut parts, body) = res.into_parts();
2634                    let mut body = common::Body::new(body);
2635                    if !parts.status.is_success() {
2636                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2637                        let error = serde_json::from_str(&common::to_string(&bytes));
2638                        let response = common::to_response(parts, bytes.into());
2639
2640                        if let common::Retry::After(d) =
2641                            dlg.http_failure(&response, error.as_ref().ok())
2642                        {
2643                            sleep(d).await;
2644                            continue;
2645                        }
2646
2647                        dlg.finished(false);
2648
2649                        return Err(match error {
2650                            Ok(value) => common::Error::BadRequest(value),
2651                            _ => common::Error::Failure(response),
2652                        });
2653                    }
2654                    let response = {
2655                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2656                        let encoded = common::to_string(&bytes);
2657                        match serde_json::from_str(&encoded) {
2658                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2659                            Err(error) => {
2660                                dlg.response_json_decode_error(&encoded, &error);
2661                                return Err(common::Error::JsonDecodeError(
2662                                    encoded.to_string(),
2663                                    error,
2664                                ));
2665                            }
2666                        }
2667                    };
2668
2669                    dlg.finished(true);
2670                    return Ok(response);
2671                }
2672            }
2673        }
2674    }
2675
2676    ///
2677    /// Sets the *request* property to the given value.
2678    ///
2679    /// Even though the property as already been set when instantiating this call,
2680    /// we provide this method for API completeness.
2681    pub fn request(mut self, new_value: AccessLevel) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2682        self._request = new_value;
2683        self
2684    }
2685    /// Required. Resource name for the access policy which owns this Access Level. Format: `accessPolicies/{policy_id}`
2686    ///
2687    /// Sets the *parent* path property to the given value.
2688    ///
2689    /// Even though the property as already been set when instantiating this call,
2690    /// we provide this method for API completeness.
2691    pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2692        self._parent = new_value.to_string();
2693        self
2694    }
2695    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2696    /// while executing the actual API request.
2697    ///
2698    /// ````text
2699    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2700    /// ````
2701    ///
2702    /// Sets the *delegate* property to the given value.
2703    pub fn delegate(
2704        mut self,
2705        new_value: &'a mut dyn common::Delegate,
2706    ) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2707        self._delegate = Some(new_value);
2708        self
2709    }
2710
2711    /// Set any additional parameter of the query string used in the request.
2712    /// It should be used to set parameters which are not yet available through their own
2713    /// setters.
2714    ///
2715    /// Please note that this method must not be used to set any of the known parameters
2716    /// which have their own setter method. If done anyway, the request will fail.
2717    ///
2718    /// # Additional Parameters
2719    ///
2720    /// * *$.xgafv* (query-string) - V1 error format.
2721    /// * *access_token* (query-string) - OAuth access token.
2722    /// * *alt* (query-string) - Data format for response.
2723    /// * *callback* (query-string) - JSONP
2724    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2725    /// * *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.
2726    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2727    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2728    /// * *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.
2729    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2730    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2731    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelCreateCall<'a, C>
2732    where
2733        T: AsRef<str>,
2734    {
2735        self._additional_params
2736            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2737        self
2738    }
2739
2740    /// Identifies the authorization scope for the method you are building.
2741    ///
2742    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2743    /// [`Scope::CloudPlatform`].
2744    ///
2745    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2746    /// tokens for more than one scope.
2747    ///
2748    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2749    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2750    /// sufficient, a read-write scope will do as well.
2751    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelCreateCall<'a, C>
2752    where
2753        St: AsRef<str>,
2754    {
2755        self._scopes.insert(String::from(scope.as_ref()));
2756        self
2757    }
2758    /// Identifies the authorization scope(s) for the method you are building.
2759    ///
2760    /// See [`Self::add_scope()`] for details.
2761    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelCreateCall<'a, C>
2762    where
2763        I: IntoIterator<Item = St>,
2764        St: AsRef<str>,
2765    {
2766        self._scopes
2767            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2768        self
2769    }
2770
2771    /// Removes all scopes, and no default scope will be used either.
2772    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2773    /// for details).
2774    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2775        self._scopes.clear();
2776        self
2777    }
2778}
2779
2780/// Deletes an access level based on the resource name. The long-running operation from this RPC has a successful status after the access level has been removed from long-lasting storage.
2781///
2782/// A builder for the *accessLevels.delete* method supported by a *accessPolicy* resource.
2783/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2784///
2785/// # Example
2786///
2787/// Instantiate a resource method builder
2788///
2789/// ```test_harness,no_run
2790/// # extern crate hyper;
2791/// # extern crate hyper_rustls;
2792/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
2793/// # async fn dox() {
2794/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2795///
2796/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2797/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2798/// #     .with_native_roots()
2799/// #     .unwrap()
2800/// #     .https_only()
2801/// #     .enable_http2()
2802/// #     .build();
2803///
2804/// # let executor = hyper_util::rt::TokioExecutor::new();
2805/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2806/// #     secret,
2807/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2808/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2809/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2810/// #     ),
2811/// # ).build().await.unwrap();
2812///
2813/// # let client = hyper_util::client::legacy::Client::builder(
2814/// #     hyper_util::rt::TokioExecutor::new()
2815/// # )
2816/// # .build(
2817/// #     hyper_rustls::HttpsConnectorBuilder::new()
2818/// #         .with_native_roots()
2819/// #         .unwrap()
2820/// #         .https_or_http()
2821/// #         .enable_http2()
2822/// #         .build()
2823/// # );
2824/// # let mut hub = AccessContextManager::new(client, auth);
2825/// // You can configure optional parameters by calling the respective setters at will, and
2826/// // execute the final call using `doit()`.
2827/// // Values shown here are possibly random and not representative !
2828/// let result = hub.access_policies().access_levels_delete("name")
2829///              .doit().await;
2830/// # }
2831/// ```
2832pub struct AccessPolicyAccessLevelDeleteCall<'a, C>
2833where
2834    C: 'a,
2835{
2836    hub: &'a AccessContextManager<C>,
2837    _name: String,
2838    _delegate: Option<&'a mut dyn common::Delegate>,
2839    _additional_params: HashMap<String, String>,
2840    _scopes: BTreeSet<String>,
2841}
2842
2843impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelDeleteCall<'a, C> {}
2844
2845impl<'a, C> AccessPolicyAccessLevelDeleteCall<'a, C>
2846where
2847    C: common::Connector,
2848{
2849    /// Perform the operation you have build so far.
2850    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2851        use std::borrow::Cow;
2852        use std::io::{Read, Seek};
2853
2854        use common::{url::Params, ToParts};
2855        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2856
2857        let mut dd = common::DefaultDelegate;
2858        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2859        dlg.begin(common::MethodInfo {
2860            id: "accesscontextmanager.accessPolicies.accessLevels.delete",
2861            http_method: hyper::Method::DELETE,
2862        });
2863
2864        for &field in ["alt", "name"].iter() {
2865            if self._additional_params.contains_key(field) {
2866                dlg.finished(false);
2867                return Err(common::Error::FieldClash(field));
2868            }
2869        }
2870
2871        let mut params = Params::with_capacity(3 + self._additional_params.len());
2872        params.push("name", self._name);
2873
2874        params.extend(self._additional_params.iter());
2875
2876        params.push("alt", "json");
2877        let mut url = self.hub._base_url.clone() + "v1/{+name}";
2878        if self._scopes.is_empty() {
2879            self._scopes
2880                .insert(Scope::CloudPlatform.as_ref().to_string());
2881        }
2882
2883        #[allow(clippy::single_element_loop)]
2884        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2885            url = params.uri_replacement(url, param_name, find_this, true);
2886        }
2887        {
2888            let to_remove = ["name"];
2889            params.remove_params(&to_remove);
2890        }
2891
2892        let url = params.parse_with_url(&url);
2893
2894        loop {
2895            let token = match self
2896                .hub
2897                .auth
2898                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2899                .await
2900            {
2901                Ok(token) => token,
2902                Err(e) => match dlg.token(e) {
2903                    Ok(token) => token,
2904                    Err(e) => {
2905                        dlg.finished(false);
2906                        return Err(common::Error::MissingToken(e));
2907                    }
2908                },
2909            };
2910            let mut req_result = {
2911                let client = &self.hub.client;
2912                dlg.pre_request();
2913                let mut req_builder = hyper::Request::builder()
2914                    .method(hyper::Method::DELETE)
2915                    .uri(url.as_str())
2916                    .header(USER_AGENT, self.hub._user_agent.clone());
2917
2918                if let Some(token) = token.as_ref() {
2919                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2920                }
2921
2922                let request = req_builder
2923                    .header(CONTENT_LENGTH, 0_u64)
2924                    .body(common::to_body::<String>(None));
2925
2926                client.request(request.unwrap()).await
2927            };
2928
2929            match req_result {
2930                Err(err) => {
2931                    if let common::Retry::After(d) = dlg.http_error(&err) {
2932                        sleep(d).await;
2933                        continue;
2934                    }
2935                    dlg.finished(false);
2936                    return Err(common::Error::HttpError(err));
2937                }
2938                Ok(res) => {
2939                    let (mut parts, body) = res.into_parts();
2940                    let mut body = common::Body::new(body);
2941                    if !parts.status.is_success() {
2942                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2943                        let error = serde_json::from_str(&common::to_string(&bytes));
2944                        let response = common::to_response(parts, bytes.into());
2945
2946                        if let common::Retry::After(d) =
2947                            dlg.http_failure(&response, error.as_ref().ok())
2948                        {
2949                            sleep(d).await;
2950                            continue;
2951                        }
2952
2953                        dlg.finished(false);
2954
2955                        return Err(match error {
2956                            Ok(value) => common::Error::BadRequest(value),
2957                            _ => common::Error::Failure(response),
2958                        });
2959                    }
2960                    let response = {
2961                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2962                        let encoded = common::to_string(&bytes);
2963                        match serde_json::from_str(&encoded) {
2964                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2965                            Err(error) => {
2966                                dlg.response_json_decode_error(&encoded, &error);
2967                                return Err(common::Error::JsonDecodeError(
2968                                    encoded.to_string(),
2969                                    error,
2970                                ));
2971                            }
2972                        }
2973                    };
2974
2975                    dlg.finished(true);
2976                    return Ok(response);
2977                }
2978            }
2979        }
2980    }
2981
2982    /// Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
2983    ///
2984    /// Sets the *name* path property to the given value.
2985    ///
2986    /// Even though the property as already been set when instantiating this call,
2987    /// we provide this method for API completeness.
2988    pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
2989        self._name = new_value.to_string();
2990        self
2991    }
2992    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2993    /// while executing the actual API request.
2994    ///
2995    /// ````text
2996    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2997    /// ````
2998    ///
2999    /// Sets the *delegate* property to the given value.
3000    pub fn delegate(
3001        mut self,
3002        new_value: &'a mut dyn common::Delegate,
3003    ) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
3004        self._delegate = Some(new_value);
3005        self
3006    }
3007
3008    /// Set any additional parameter of the query string used in the request.
3009    /// It should be used to set parameters which are not yet available through their own
3010    /// setters.
3011    ///
3012    /// Please note that this method must not be used to set any of the known parameters
3013    /// which have their own setter method. If done anyway, the request will fail.
3014    ///
3015    /// # Additional Parameters
3016    ///
3017    /// * *$.xgafv* (query-string) - V1 error format.
3018    /// * *access_token* (query-string) - OAuth access token.
3019    /// * *alt* (query-string) - Data format for response.
3020    /// * *callback* (query-string) - JSONP
3021    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3022    /// * *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.
3023    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3024    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3025    /// * *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.
3026    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3027    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3028    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelDeleteCall<'a, C>
3029    where
3030        T: AsRef<str>,
3031    {
3032        self._additional_params
3033            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3034        self
3035    }
3036
3037    /// Identifies the authorization scope for the method you are building.
3038    ///
3039    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3040    /// [`Scope::CloudPlatform`].
3041    ///
3042    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3043    /// tokens for more than one scope.
3044    ///
3045    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3046    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3047    /// sufficient, a read-write scope will do as well.
3048    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelDeleteCall<'a, C>
3049    where
3050        St: AsRef<str>,
3051    {
3052        self._scopes.insert(String::from(scope.as_ref()));
3053        self
3054    }
3055    /// Identifies the authorization scope(s) for the method you are building.
3056    ///
3057    /// See [`Self::add_scope()`] for details.
3058    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelDeleteCall<'a, C>
3059    where
3060        I: IntoIterator<Item = St>,
3061        St: AsRef<str>,
3062    {
3063        self._scopes
3064            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3065        self
3066    }
3067
3068    /// Removes all scopes, and no default scope will be used either.
3069    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3070    /// for details).
3071    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
3072        self._scopes.clear();
3073        self
3074    }
3075}
3076
3077/// Gets an access level based on the resource name.
3078///
3079/// A builder for the *accessLevels.get* method supported by a *accessPolicy* resource.
3080/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3081///
3082/// # Example
3083///
3084/// Instantiate a resource method builder
3085///
3086/// ```test_harness,no_run
3087/// # extern crate hyper;
3088/// # extern crate hyper_rustls;
3089/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
3090/// # async fn dox() {
3091/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3092///
3093/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3094/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3095/// #     .with_native_roots()
3096/// #     .unwrap()
3097/// #     .https_only()
3098/// #     .enable_http2()
3099/// #     .build();
3100///
3101/// # let executor = hyper_util::rt::TokioExecutor::new();
3102/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3103/// #     secret,
3104/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3105/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3106/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3107/// #     ),
3108/// # ).build().await.unwrap();
3109///
3110/// # let client = hyper_util::client::legacy::Client::builder(
3111/// #     hyper_util::rt::TokioExecutor::new()
3112/// # )
3113/// # .build(
3114/// #     hyper_rustls::HttpsConnectorBuilder::new()
3115/// #         .with_native_roots()
3116/// #         .unwrap()
3117/// #         .https_or_http()
3118/// #         .enable_http2()
3119/// #         .build()
3120/// # );
3121/// # let mut hub = AccessContextManager::new(client, auth);
3122/// // You can configure optional parameters by calling the respective setters at will, and
3123/// // execute the final call using `doit()`.
3124/// // Values shown here are possibly random and not representative !
3125/// let result = hub.access_policies().access_levels_get("name")
3126///              .access_level_format("amet")
3127///              .doit().await;
3128/// # }
3129/// ```
3130pub struct AccessPolicyAccessLevelGetCall<'a, C>
3131where
3132    C: 'a,
3133{
3134    hub: &'a AccessContextManager<C>,
3135    _name: String,
3136    _access_level_format: Option<String>,
3137    _delegate: Option<&'a mut dyn common::Delegate>,
3138    _additional_params: HashMap<String, String>,
3139    _scopes: BTreeSet<String>,
3140}
3141
3142impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelGetCall<'a, C> {}
3143
3144impl<'a, C> AccessPolicyAccessLevelGetCall<'a, C>
3145where
3146    C: common::Connector,
3147{
3148    /// Perform the operation you have build so far.
3149    pub async fn doit(mut self) -> common::Result<(common::Response, AccessLevel)> {
3150        use std::borrow::Cow;
3151        use std::io::{Read, Seek};
3152
3153        use common::{url::Params, ToParts};
3154        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3155
3156        let mut dd = common::DefaultDelegate;
3157        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3158        dlg.begin(common::MethodInfo {
3159            id: "accesscontextmanager.accessPolicies.accessLevels.get",
3160            http_method: hyper::Method::GET,
3161        });
3162
3163        for &field in ["alt", "name", "accessLevelFormat"].iter() {
3164            if self._additional_params.contains_key(field) {
3165                dlg.finished(false);
3166                return Err(common::Error::FieldClash(field));
3167            }
3168        }
3169
3170        let mut params = Params::with_capacity(4 + self._additional_params.len());
3171        params.push("name", self._name);
3172        if let Some(value) = self._access_level_format.as_ref() {
3173            params.push("accessLevelFormat", value);
3174        }
3175
3176        params.extend(self._additional_params.iter());
3177
3178        params.push("alt", "json");
3179        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3180        if self._scopes.is_empty() {
3181            self._scopes
3182                .insert(Scope::CloudPlatform.as_ref().to_string());
3183        }
3184
3185        #[allow(clippy::single_element_loop)]
3186        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3187            url = params.uri_replacement(url, param_name, find_this, true);
3188        }
3189        {
3190            let to_remove = ["name"];
3191            params.remove_params(&to_remove);
3192        }
3193
3194        let url = params.parse_with_url(&url);
3195
3196        loop {
3197            let token = match self
3198                .hub
3199                .auth
3200                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3201                .await
3202            {
3203                Ok(token) => token,
3204                Err(e) => match dlg.token(e) {
3205                    Ok(token) => token,
3206                    Err(e) => {
3207                        dlg.finished(false);
3208                        return Err(common::Error::MissingToken(e));
3209                    }
3210                },
3211            };
3212            let mut req_result = {
3213                let client = &self.hub.client;
3214                dlg.pre_request();
3215                let mut req_builder = hyper::Request::builder()
3216                    .method(hyper::Method::GET)
3217                    .uri(url.as_str())
3218                    .header(USER_AGENT, self.hub._user_agent.clone());
3219
3220                if let Some(token) = token.as_ref() {
3221                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3222                }
3223
3224                let request = req_builder
3225                    .header(CONTENT_LENGTH, 0_u64)
3226                    .body(common::to_body::<String>(None));
3227
3228                client.request(request.unwrap()).await
3229            };
3230
3231            match req_result {
3232                Err(err) => {
3233                    if let common::Retry::After(d) = dlg.http_error(&err) {
3234                        sleep(d).await;
3235                        continue;
3236                    }
3237                    dlg.finished(false);
3238                    return Err(common::Error::HttpError(err));
3239                }
3240                Ok(res) => {
3241                    let (mut parts, body) = res.into_parts();
3242                    let mut body = common::Body::new(body);
3243                    if !parts.status.is_success() {
3244                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3245                        let error = serde_json::from_str(&common::to_string(&bytes));
3246                        let response = common::to_response(parts, bytes.into());
3247
3248                        if let common::Retry::After(d) =
3249                            dlg.http_failure(&response, error.as_ref().ok())
3250                        {
3251                            sleep(d).await;
3252                            continue;
3253                        }
3254
3255                        dlg.finished(false);
3256
3257                        return Err(match error {
3258                            Ok(value) => common::Error::BadRequest(value),
3259                            _ => common::Error::Failure(response),
3260                        });
3261                    }
3262                    let response = {
3263                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3264                        let encoded = common::to_string(&bytes);
3265                        match serde_json::from_str(&encoded) {
3266                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3267                            Err(error) => {
3268                                dlg.response_json_decode_error(&encoded, &error);
3269                                return Err(common::Error::JsonDecodeError(
3270                                    encoded.to_string(),
3271                                    error,
3272                                ));
3273                            }
3274                        }
3275                    };
3276
3277                    dlg.finished(true);
3278                    return Ok(response);
3279                }
3280            }
3281        }
3282    }
3283
3284    /// Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
3285    ///
3286    /// Sets the *name* path property to the given value.
3287    ///
3288    /// Even though the property as already been set when instantiating this call,
3289    /// we provide this method for API completeness.
3290    pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
3291        self._name = new_value.to_string();
3292        self
3293    }
3294    /// Whether to return `BasicLevels` in the Cloud Common Expression Language rather than as `BasicLevels`. Defaults to AS_DEFINED, where Access Levels are returned as `BasicLevels` or `CustomLevels` based on how they were created. If set to CEL, all Access Levels are returned as `CustomLevels`. In the CEL case, `BasicLevels` are translated to equivalent `CustomLevels`.
3295    ///
3296    /// Sets the *access level format* query property to the given value.
3297    pub fn access_level_format(mut self, new_value: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
3298        self._access_level_format = Some(new_value.to_string());
3299        self
3300    }
3301    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3302    /// while executing the actual API request.
3303    ///
3304    /// ````text
3305    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3306    /// ````
3307    ///
3308    /// Sets the *delegate* property to the given value.
3309    pub fn delegate(
3310        mut self,
3311        new_value: &'a mut dyn common::Delegate,
3312    ) -> AccessPolicyAccessLevelGetCall<'a, C> {
3313        self._delegate = Some(new_value);
3314        self
3315    }
3316
3317    /// Set any additional parameter of the query string used in the request.
3318    /// It should be used to set parameters which are not yet available through their own
3319    /// setters.
3320    ///
3321    /// Please note that this method must not be used to set any of the known parameters
3322    /// which have their own setter method. If done anyway, the request will fail.
3323    ///
3324    /// # Additional Parameters
3325    ///
3326    /// * *$.xgafv* (query-string) - V1 error format.
3327    /// * *access_token* (query-string) - OAuth access token.
3328    /// * *alt* (query-string) - Data format for response.
3329    /// * *callback* (query-string) - JSONP
3330    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3331    /// * *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.
3332    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3333    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3334    /// * *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.
3335    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3336    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3337    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelGetCall<'a, C>
3338    where
3339        T: AsRef<str>,
3340    {
3341        self._additional_params
3342            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3343        self
3344    }
3345
3346    /// Identifies the authorization scope for the method you are building.
3347    ///
3348    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3349    /// [`Scope::CloudPlatform`].
3350    ///
3351    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3352    /// tokens for more than one scope.
3353    ///
3354    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3355    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3356    /// sufficient, a read-write scope will do as well.
3357    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelGetCall<'a, C>
3358    where
3359        St: AsRef<str>,
3360    {
3361        self._scopes.insert(String::from(scope.as_ref()));
3362        self
3363    }
3364    /// Identifies the authorization scope(s) for the method you are building.
3365    ///
3366    /// See [`Self::add_scope()`] for details.
3367    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelGetCall<'a, C>
3368    where
3369        I: IntoIterator<Item = St>,
3370        St: AsRef<str>,
3371    {
3372        self._scopes
3373            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3374        self
3375    }
3376
3377    /// Removes all scopes, and no default scope will be used either.
3378    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3379    /// for details).
3380    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelGetCall<'a, C> {
3381        self._scopes.clear();
3382        self
3383    }
3384}
3385
3386/// Lists all access levels for an access policy.
3387///
3388/// A builder for the *accessLevels.list* method supported by a *accessPolicy* resource.
3389/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3390///
3391/// # Example
3392///
3393/// Instantiate a resource method builder
3394///
3395/// ```test_harness,no_run
3396/// # extern crate hyper;
3397/// # extern crate hyper_rustls;
3398/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
3399/// # async fn dox() {
3400/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3401///
3402/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3403/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3404/// #     .with_native_roots()
3405/// #     .unwrap()
3406/// #     .https_only()
3407/// #     .enable_http2()
3408/// #     .build();
3409///
3410/// # let executor = hyper_util::rt::TokioExecutor::new();
3411/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3412/// #     secret,
3413/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3414/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3415/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3416/// #     ),
3417/// # ).build().await.unwrap();
3418///
3419/// # let client = hyper_util::client::legacy::Client::builder(
3420/// #     hyper_util::rt::TokioExecutor::new()
3421/// # )
3422/// # .build(
3423/// #     hyper_rustls::HttpsConnectorBuilder::new()
3424/// #         .with_native_roots()
3425/// #         .unwrap()
3426/// #         .https_or_http()
3427/// #         .enable_http2()
3428/// #         .build()
3429/// # );
3430/// # let mut hub = AccessContextManager::new(client, auth);
3431/// // You can configure optional parameters by calling the respective setters at will, and
3432/// // execute the final call using `doit()`.
3433/// // Values shown here are possibly random and not representative !
3434/// let result = hub.access_policies().access_levels_list("parent")
3435///              .page_token("ipsum")
3436///              .page_size(-93)
3437///              .access_level_format("ut")
3438///              .doit().await;
3439/// # }
3440/// ```
3441pub struct AccessPolicyAccessLevelListCall<'a, C>
3442where
3443    C: 'a,
3444{
3445    hub: &'a AccessContextManager<C>,
3446    _parent: String,
3447    _page_token: Option<String>,
3448    _page_size: Option<i32>,
3449    _access_level_format: Option<String>,
3450    _delegate: Option<&'a mut dyn common::Delegate>,
3451    _additional_params: HashMap<String, String>,
3452    _scopes: BTreeSet<String>,
3453}
3454
3455impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelListCall<'a, C> {}
3456
3457impl<'a, C> AccessPolicyAccessLevelListCall<'a, C>
3458where
3459    C: common::Connector,
3460{
3461    /// Perform the operation you have build so far.
3462    pub async fn doit(mut self) -> common::Result<(common::Response, ListAccessLevelsResponse)> {
3463        use std::borrow::Cow;
3464        use std::io::{Read, Seek};
3465
3466        use common::{url::Params, ToParts};
3467        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3468
3469        let mut dd = common::DefaultDelegate;
3470        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3471        dlg.begin(common::MethodInfo {
3472            id: "accesscontextmanager.accessPolicies.accessLevels.list",
3473            http_method: hyper::Method::GET,
3474        });
3475
3476        for &field in [
3477            "alt",
3478            "parent",
3479            "pageToken",
3480            "pageSize",
3481            "accessLevelFormat",
3482        ]
3483        .iter()
3484        {
3485            if self._additional_params.contains_key(field) {
3486                dlg.finished(false);
3487                return Err(common::Error::FieldClash(field));
3488            }
3489        }
3490
3491        let mut params = Params::with_capacity(6 + self._additional_params.len());
3492        params.push("parent", self._parent);
3493        if let Some(value) = self._page_token.as_ref() {
3494            params.push("pageToken", value);
3495        }
3496        if let Some(value) = self._page_size.as_ref() {
3497            params.push("pageSize", value.to_string());
3498        }
3499        if let Some(value) = self._access_level_format.as_ref() {
3500            params.push("accessLevelFormat", value);
3501        }
3502
3503        params.extend(self._additional_params.iter());
3504
3505        params.push("alt", "json");
3506        let mut url = self.hub._base_url.clone() + "v1/{+parent}/accessLevels";
3507        if self._scopes.is_empty() {
3508            self._scopes
3509                .insert(Scope::CloudPlatform.as_ref().to_string());
3510        }
3511
3512        #[allow(clippy::single_element_loop)]
3513        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3514            url = params.uri_replacement(url, param_name, find_this, true);
3515        }
3516        {
3517            let to_remove = ["parent"];
3518            params.remove_params(&to_remove);
3519        }
3520
3521        let url = params.parse_with_url(&url);
3522
3523        loop {
3524            let token = match self
3525                .hub
3526                .auth
3527                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3528                .await
3529            {
3530                Ok(token) => token,
3531                Err(e) => match dlg.token(e) {
3532                    Ok(token) => token,
3533                    Err(e) => {
3534                        dlg.finished(false);
3535                        return Err(common::Error::MissingToken(e));
3536                    }
3537                },
3538            };
3539            let mut req_result = {
3540                let client = &self.hub.client;
3541                dlg.pre_request();
3542                let mut req_builder = hyper::Request::builder()
3543                    .method(hyper::Method::GET)
3544                    .uri(url.as_str())
3545                    .header(USER_AGENT, self.hub._user_agent.clone());
3546
3547                if let Some(token) = token.as_ref() {
3548                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3549                }
3550
3551                let request = req_builder
3552                    .header(CONTENT_LENGTH, 0_u64)
3553                    .body(common::to_body::<String>(None));
3554
3555                client.request(request.unwrap()).await
3556            };
3557
3558            match req_result {
3559                Err(err) => {
3560                    if let common::Retry::After(d) = dlg.http_error(&err) {
3561                        sleep(d).await;
3562                        continue;
3563                    }
3564                    dlg.finished(false);
3565                    return Err(common::Error::HttpError(err));
3566                }
3567                Ok(res) => {
3568                    let (mut parts, body) = res.into_parts();
3569                    let mut body = common::Body::new(body);
3570                    if !parts.status.is_success() {
3571                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3572                        let error = serde_json::from_str(&common::to_string(&bytes));
3573                        let response = common::to_response(parts, bytes.into());
3574
3575                        if let common::Retry::After(d) =
3576                            dlg.http_failure(&response, error.as_ref().ok())
3577                        {
3578                            sleep(d).await;
3579                            continue;
3580                        }
3581
3582                        dlg.finished(false);
3583
3584                        return Err(match error {
3585                            Ok(value) => common::Error::BadRequest(value),
3586                            _ => common::Error::Failure(response),
3587                        });
3588                    }
3589                    let response = {
3590                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3591                        let encoded = common::to_string(&bytes);
3592                        match serde_json::from_str(&encoded) {
3593                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3594                            Err(error) => {
3595                                dlg.response_json_decode_error(&encoded, &error);
3596                                return Err(common::Error::JsonDecodeError(
3597                                    encoded.to_string(),
3598                                    error,
3599                                ));
3600                            }
3601                        }
3602                    };
3603
3604                    dlg.finished(true);
3605                    return Ok(response);
3606                }
3607            }
3608        }
3609    }
3610
3611    /// Required. Resource name for the access policy to list Access Levels from. Format: `accessPolicies/{policy_id}`
3612    ///
3613    /// Sets the *parent* path property to the given value.
3614    ///
3615    /// Even though the property as already been set when instantiating this call,
3616    /// we provide this method for API completeness.
3617    pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
3618        self._parent = new_value.to_string();
3619        self
3620    }
3621    /// Next page token for the next batch of Access Level instances. Defaults to the first page of results.
3622    ///
3623    /// Sets the *page token* query property to the given value.
3624    pub fn page_token(mut self, new_value: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
3625        self._page_token = Some(new_value.to_string());
3626        self
3627    }
3628    /// Number of Access Levels to include in the list. Default 100.
3629    ///
3630    /// Sets the *page size* query property to the given value.
3631    pub fn page_size(mut self, new_value: i32) -> AccessPolicyAccessLevelListCall<'a, C> {
3632        self._page_size = Some(new_value);
3633        self
3634    }
3635    /// Whether to return `BasicLevels` in the Cloud Common Expression language, as `CustomLevels`, rather than as `BasicLevels`. Defaults to returning `AccessLevels` in the format they were defined.
3636    ///
3637    /// Sets the *access level format* query property to the given value.
3638    pub fn access_level_format(
3639        mut self,
3640        new_value: &str,
3641    ) -> AccessPolicyAccessLevelListCall<'a, C> {
3642        self._access_level_format = Some(new_value.to_string());
3643        self
3644    }
3645    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3646    /// while executing the actual API request.
3647    ///
3648    /// ````text
3649    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3650    /// ````
3651    ///
3652    /// Sets the *delegate* property to the given value.
3653    pub fn delegate(
3654        mut self,
3655        new_value: &'a mut dyn common::Delegate,
3656    ) -> AccessPolicyAccessLevelListCall<'a, C> {
3657        self._delegate = Some(new_value);
3658        self
3659    }
3660
3661    /// Set any additional parameter of the query string used in the request.
3662    /// It should be used to set parameters which are not yet available through their own
3663    /// setters.
3664    ///
3665    /// Please note that this method must not be used to set any of the known parameters
3666    /// which have their own setter method. If done anyway, the request will fail.
3667    ///
3668    /// # Additional Parameters
3669    ///
3670    /// * *$.xgafv* (query-string) - V1 error format.
3671    /// * *access_token* (query-string) - OAuth access token.
3672    /// * *alt* (query-string) - Data format for response.
3673    /// * *callback* (query-string) - JSONP
3674    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3675    /// * *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.
3676    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3677    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3678    /// * *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.
3679    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3680    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3681    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelListCall<'a, C>
3682    where
3683        T: AsRef<str>,
3684    {
3685        self._additional_params
3686            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3687        self
3688    }
3689
3690    /// Identifies the authorization scope for the method you are building.
3691    ///
3692    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3693    /// [`Scope::CloudPlatform`].
3694    ///
3695    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3696    /// tokens for more than one scope.
3697    ///
3698    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3699    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3700    /// sufficient, a read-write scope will do as well.
3701    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelListCall<'a, C>
3702    where
3703        St: AsRef<str>,
3704    {
3705        self._scopes.insert(String::from(scope.as_ref()));
3706        self
3707    }
3708    /// Identifies the authorization scope(s) for the method you are building.
3709    ///
3710    /// See [`Self::add_scope()`] for details.
3711    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelListCall<'a, C>
3712    where
3713        I: IntoIterator<Item = St>,
3714        St: AsRef<str>,
3715    {
3716        self._scopes
3717            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3718        self
3719    }
3720
3721    /// Removes all scopes, and no default scope will be used either.
3722    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3723    /// for details).
3724    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelListCall<'a, C> {
3725        self._scopes.clear();
3726        self
3727    }
3728}
3729
3730/// Updates an access level. The long-running operation from this RPC has a successful status after the changes to the access level propagate to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
3731///
3732/// A builder for the *accessLevels.patch* method supported by a *accessPolicy* resource.
3733/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3734///
3735/// # Example
3736///
3737/// Instantiate a resource method builder
3738///
3739/// ```test_harness,no_run
3740/// # extern crate hyper;
3741/// # extern crate hyper_rustls;
3742/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
3743/// use accesscontextmanager1::api::AccessLevel;
3744/// # async fn dox() {
3745/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3746///
3747/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3748/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3749/// #     .with_native_roots()
3750/// #     .unwrap()
3751/// #     .https_only()
3752/// #     .enable_http2()
3753/// #     .build();
3754///
3755/// # let executor = hyper_util::rt::TokioExecutor::new();
3756/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3757/// #     secret,
3758/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3759/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3760/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3761/// #     ),
3762/// # ).build().await.unwrap();
3763///
3764/// # let client = hyper_util::client::legacy::Client::builder(
3765/// #     hyper_util::rt::TokioExecutor::new()
3766/// # )
3767/// # .build(
3768/// #     hyper_rustls::HttpsConnectorBuilder::new()
3769/// #         .with_native_roots()
3770/// #         .unwrap()
3771/// #         .https_or_http()
3772/// #         .enable_http2()
3773/// #         .build()
3774/// # );
3775/// # let mut hub = AccessContextManager::new(client, auth);
3776/// // As the method needs a request, you would usually fill it with the desired information
3777/// // into the respective structure. Some of the parts shown here might not be applicable !
3778/// // Values shown here are possibly random and not representative !
3779/// let mut req = AccessLevel::default();
3780///
3781/// // You can configure optional parameters by calling the respective setters at will, and
3782/// // execute the final call using `doit()`.
3783/// // Values shown here are possibly random and not representative !
3784/// let result = hub.access_policies().access_levels_patch(req, "name")
3785///              .update_mask(FieldMask::new::<&str>(&[]))
3786///              .doit().await;
3787/// # }
3788/// ```
3789pub struct AccessPolicyAccessLevelPatchCall<'a, C>
3790where
3791    C: 'a,
3792{
3793    hub: &'a AccessContextManager<C>,
3794    _request: AccessLevel,
3795    _name: String,
3796    _update_mask: Option<common::FieldMask>,
3797    _delegate: Option<&'a mut dyn common::Delegate>,
3798    _additional_params: HashMap<String, String>,
3799    _scopes: BTreeSet<String>,
3800}
3801
3802impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelPatchCall<'a, C> {}
3803
3804impl<'a, C> AccessPolicyAccessLevelPatchCall<'a, C>
3805where
3806    C: common::Connector,
3807{
3808    /// Perform the operation you have build so far.
3809    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3810        use std::borrow::Cow;
3811        use std::io::{Read, Seek};
3812
3813        use common::{url::Params, ToParts};
3814        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3815
3816        let mut dd = common::DefaultDelegate;
3817        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3818        dlg.begin(common::MethodInfo {
3819            id: "accesscontextmanager.accessPolicies.accessLevels.patch",
3820            http_method: hyper::Method::PATCH,
3821        });
3822
3823        for &field in ["alt", "name", "updateMask"].iter() {
3824            if self._additional_params.contains_key(field) {
3825                dlg.finished(false);
3826                return Err(common::Error::FieldClash(field));
3827            }
3828        }
3829
3830        let mut params = Params::with_capacity(5 + self._additional_params.len());
3831        params.push("name", self._name);
3832        if let Some(value) = self._update_mask.as_ref() {
3833            params.push("updateMask", value.to_string());
3834        }
3835
3836        params.extend(self._additional_params.iter());
3837
3838        params.push("alt", "json");
3839        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3840        if self._scopes.is_empty() {
3841            self._scopes
3842                .insert(Scope::CloudPlatform.as_ref().to_string());
3843        }
3844
3845        #[allow(clippy::single_element_loop)]
3846        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3847            url = params.uri_replacement(url, param_name, find_this, true);
3848        }
3849        {
3850            let to_remove = ["name"];
3851            params.remove_params(&to_remove);
3852        }
3853
3854        let url = params.parse_with_url(&url);
3855
3856        let mut json_mime_type = mime::APPLICATION_JSON;
3857        let mut request_value_reader = {
3858            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3859            common::remove_json_null_values(&mut value);
3860            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3861            serde_json::to_writer(&mut dst, &value).unwrap();
3862            dst
3863        };
3864        let request_size = request_value_reader
3865            .seek(std::io::SeekFrom::End(0))
3866            .unwrap();
3867        request_value_reader
3868            .seek(std::io::SeekFrom::Start(0))
3869            .unwrap();
3870
3871        loop {
3872            let token = match self
3873                .hub
3874                .auth
3875                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3876                .await
3877            {
3878                Ok(token) => token,
3879                Err(e) => match dlg.token(e) {
3880                    Ok(token) => token,
3881                    Err(e) => {
3882                        dlg.finished(false);
3883                        return Err(common::Error::MissingToken(e));
3884                    }
3885                },
3886            };
3887            request_value_reader
3888                .seek(std::io::SeekFrom::Start(0))
3889                .unwrap();
3890            let mut req_result = {
3891                let client = &self.hub.client;
3892                dlg.pre_request();
3893                let mut req_builder = hyper::Request::builder()
3894                    .method(hyper::Method::PATCH)
3895                    .uri(url.as_str())
3896                    .header(USER_AGENT, self.hub._user_agent.clone());
3897
3898                if let Some(token) = token.as_ref() {
3899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3900                }
3901
3902                let request = req_builder
3903                    .header(CONTENT_TYPE, json_mime_type.to_string())
3904                    .header(CONTENT_LENGTH, request_size as u64)
3905                    .body(common::to_body(
3906                        request_value_reader.get_ref().clone().into(),
3907                    ));
3908
3909                client.request(request.unwrap()).await
3910            };
3911
3912            match req_result {
3913                Err(err) => {
3914                    if let common::Retry::After(d) = dlg.http_error(&err) {
3915                        sleep(d).await;
3916                        continue;
3917                    }
3918                    dlg.finished(false);
3919                    return Err(common::Error::HttpError(err));
3920                }
3921                Ok(res) => {
3922                    let (mut parts, body) = res.into_parts();
3923                    let mut body = common::Body::new(body);
3924                    if !parts.status.is_success() {
3925                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3926                        let error = serde_json::from_str(&common::to_string(&bytes));
3927                        let response = common::to_response(parts, bytes.into());
3928
3929                        if let common::Retry::After(d) =
3930                            dlg.http_failure(&response, error.as_ref().ok())
3931                        {
3932                            sleep(d).await;
3933                            continue;
3934                        }
3935
3936                        dlg.finished(false);
3937
3938                        return Err(match error {
3939                            Ok(value) => common::Error::BadRequest(value),
3940                            _ => common::Error::Failure(response),
3941                        });
3942                    }
3943                    let response = {
3944                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3945                        let encoded = common::to_string(&bytes);
3946                        match serde_json::from_str(&encoded) {
3947                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3948                            Err(error) => {
3949                                dlg.response_json_decode_error(&encoded, &error);
3950                                return Err(common::Error::JsonDecodeError(
3951                                    encoded.to_string(),
3952                                    error,
3953                                ));
3954                            }
3955                        }
3956                    };
3957
3958                    dlg.finished(true);
3959                    return Ok(response);
3960                }
3961            }
3962        }
3963    }
3964
3965    ///
3966    /// Sets the *request* property to the given value.
3967    ///
3968    /// Even though the property as already been set when instantiating this call,
3969    /// we provide this method for API completeness.
3970    pub fn request(mut self, new_value: AccessLevel) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3971        self._request = new_value;
3972        self
3973    }
3974    /// Identifier. Resource name for the `AccessLevel`. Format: `accessPolicies/{access_policy}/accessLevels/{access_level}`. The `access_level` component must begin with a letter, followed by alphanumeric characters or `_`. Its maximum length is 50 characters. After you create an `AccessLevel`, you cannot change its `name`.
3975    ///
3976    /// Sets the *name* path property to the given value.
3977    ///
3978    /// Even though the property as already been set when instantiating this call,
3979    /// we provide this method for API completeness.
3980    pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3981        self._name = new_value.to_string();
3982        self
3983    }
3984    /// Required. Mask to control which fields get updated. Must be non-empty.
3985    ///
3986    /// Sets the *update mask* query property to the given value.
3987    pub fn update_mask(
3988        mut self,
3989        new_value: common::FieldMask,
3990    ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3991        self._update_mask = Some(new_value);
3992        self
3993    }
3994    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3995    /// while executing the actual API request.
3996    ///
3997    /// ````text
3998    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3999    /// ````
4000    ///
4001    /// Sets the *delegate* property to the given value.
4002    pub fn delegate(
4003        mut self,
4004        new_value: &'a mut dyn common::Delegate,
4005    ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
4006        self._delegate = Some(new_value);
4007        self
4008    }
4009
4010    /// Set any additional parameter of the query string used in the request.
4011    /// It should be used to set parameters which are not yet available through their own
4012    /// setters.
4013    ///
4014    /// Please note that this method must not be used to set any of the known parameters
4015    /// which have their own setter method. If done anyway, the request will fail.
4016    ///
4017    /// # Additional Parameters
4018    ///
4019    /// * *$.xgafv* (query-string) - V1 error format.
4020    /// * *access_token* (query-string) - OAuth access token.
4021    /// * *alt* (query-string) - Data format for response.
4022    /// * *callback* (query-string) - JSONP
4023    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4024    /// * *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.
4025    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4026    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4027    /// * *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.
4028    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4029    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4030    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelPatchCall<'a, C>
4031    where
4032        T: AsRef<str>,
4033    {
4034        self._additional_params
4035            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4036        self
4037    }
4038
4039    /// Identifies the authorization scope for the method you are building.
4040    ///
4041    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4042    /// [`Scope::CloudPlatform`].
4043    ///
4044    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4045    /// tokens for more than one scope.
4046    ///
4047    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4048    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4049    /// sufficient, a read-write scope will do as well.
4050    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelPatchCall<'a, C>
4051    where
4052        St: AsRef<str>,
4053    {
4054        self._scopes.insert(String::from(scope.as_ref()));
4055        self
4056    }
4057    /// Identifies the authorization scope(s) for the method you are building.
4058    ///
4059    /// See [`Self::add_scope()`] for details.
4060    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelPatchCall<'a, C>
4061    where
4062        I: IntoIterator<Item = St>,
4063        St: AsRef<str>,
4064    {
4065        self._scopes
4066            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4067        self
4068    }
4069
4070    /// Removes all scopes, and no default scope will be used either.
4071    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4072    /// for details).
4073    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelPatchCall<'a, C> {
4074        self._scopes.clear();
4075        self
4076    }
4077}
4078
4079/// Replaces all existing access levels in an access policy with the access levels provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. If the replacement contains errors, an error response is returned for the first error encountered. Upon error, the replacement is cancelled, and existing access levels are not affected. The Operation.response field contains ReplaceAccessLevelsResponse. Removing access levels contained in existing service perimeters result in an error.
4080///
4081/// A builder for the *accessLevels.replaceAll* method supported by a *accessPolicy* resource.
4082/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4083///
4084/// # Example
4085///
4086/// Instantiate a resource method builder
4087///
4088/// ```test_harness,no_run
4089/// # extern crate hyper;
4090/// # extern crate hyper_rustls;
4091/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
4092/// use accesscontextmanager1::api::ReplaceAccessLevelsRequest;
4093/// # async fn dox() {
4094/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4095///
4096/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4097/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4098/// #     .with_native_roots()
4099/// #     .unwrap()
4100/// #     .https_only()
4101/// #     .enable_http2()
4102/// #     .build();
4103///
4104/// # let executor = hyper_util::rt::TokioExecutor::new();
4105/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4106/// #     secret,
4107/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4108/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4109/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4110/// #     ),
4111/// # ).build().await.unwrap();
4112///
4113/// # let client = hyper_util::client::legacy::Client::builder(
4114/// #     hyper_util::rt::TokioExecutor::new()
4115/// # )
4116/// # .build(
4117/// #     hyper_rustls::HttpsConnectorBuilder::new()
4118/// #         .with_native_roots()
4119/// #         .unwrap()
4120/// #         .https_or_http()
4121/// #         .enable_http2()
4122/// #         .build()
4123/// # );
4124/// # let mut hub = AccessContextManager::new(client, auth);
4125/// // As the method needs a request, you would usually fill it with the desired information
4126/// // into the respective structure. Some of the parts shown here might not be applicable !
4127/// // Values shown here are possibly random and not representative !
4128/// let mut req = ReplaceAccessLevelsRequest::default();
4129///
4130/// // You can configure optional parameters by calling the respective setters at will, and
4131/// // execute the final call using `doit()`.
4132/// // Values shown here are possibly random and not representative !
4133/// let result = hub.access_policies().access_levels_replace_all(req, "parent")
4134///              .doit().await;
4135/// # }
4136/// ```
4137pub struct AccessPolicyAccessLevelReplaceAllCall<'a, C>
4138where
4139    C: 'a,
4140{
4141    hub: &'a AccessContextManager<C>,
4142    _request: ReplaceAccessLevelsRequest,
4143    _parent: String,
4144    _delegate: Option<&'a mut dyn common::Delegate>,
4145    _additional_params: HashMap<String, String>,
4146    _scopes: BTreeSet<String>,
4147}
4148
4149impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelReplaceAllCall<'a, C> {}
4150
4151impl<'a, C> AccessPolicyAccessLevelReplaceAllCall<'a, C>
4152where
4153    C: common::Connector,
4154{
4155    /// Perform the operation you have build so far.
4156    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4157        use std::borrow::Cow;
4158        use std::io::{Read, Seek};
4159
4160        use common::{url::Params, ToParts};
4161        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4162
4163        let mut dd = common::DefaultDelegate;
4164        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4165        dlg.begin(common::MethodInfo {
4166            id: "accesscontextmanager.accessPolicies.accessLevels.replaceAll",
4167            http_method: hyper::Method::POST,
4168        });
4169
4170        for &field in ["alt", "parent"].iter() {
4171            if self._additional_params.contains_key(field) {
4172                dlg.finished(false);
4173                return Err(common::Error::FieldClash(field));
4174            }
4175        }
4176
4177        let mut params = Params::with_capacity(4 + self._additional_params.len());
4178        params.push("parent", self._parent);
4179
4180        params.extend(self._additional_params.iter());
4181
4182        params.push("alt", "json");
4183        let mut url = self.hub._base_url.clone() + "v1/{+parent}/accessLevels:replaceAll";
4184        if self._scopes.is_empty() {
4185            self._scopes
4186                .insert(Scope::CloudPlatform.as_ref().to_string());
4187        }
4188
4189        #[allow(clippy::single_element_loop)]
4190        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4191            url = params.uri_replacement(url, param_name, find_this, true);
4192        }
4193        {
4194            let to_remove = ["parent"];
4195            params.remove_params(&to_remove);
4196        }
4197
4198        let url = params.parse_with_url(&url);
4199
4200        let mut json_mime_type = mime::APPLICATION_JSON;
4201        let mut request_value_reader = {
4202            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4203            common::remove_json_null_values(&mut value);
4204            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4205            serde_json::to_writer(&mut dst, &value).unwrap();
4206            dst
4207        };
4208        let request_size = request_value_reader
4209            .seek(std::io::SeekFrom::End(0))
4210            .unwrap();
4211        request_value_reader
4212            .seek(std::io::SeekFrom::Start(0))
4213            .unwrap();
4214
4215        loop {
4216            let token = match self
4217                .hub
4218                .auth
4219                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4220                .await
4221            {
4222                Ok(token) => token,
4223                Err(e) => match dlg.token(e) {
4224                    Ok(token) => token,
4225                    Err(e) => {
4226                        dlg.finished(false);
4227                        return Err(common::Error::MissingToken(e));
4228                    }
4229                },
4230            };
4231            request_value_reader
4232                .seek(std::io::SeekFrom::Start(0))
4233                .unwrap();
4234            let mut req_result = {
4235                let client = &self.hub.client;
4236                dlg.pre_request();
4237                let mut req_builder = hyper::Request::builder()
4238                    .method(hyper::Method::POST)
4239                    .uri(url.as_str())
4240                    .header(USER_AGENT, self.hub._user_agent.clone());
4241
4242                if let Some(token) = token.as_ref() {
4243                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4244                }
4245
4246                let request = req_builder
4247                    .header(CONTENT_TYPE, json_mime_type.to_string())
4248                    .header(CONTENT_LENGTH, request_size as u64)
4249                    .body(common::to_body(
4250                        request_value_reader.get_ref().clone().into(),
4251                    ));
4252
4253                client.request(request.unwrap()).await
4254            };
4255
4256            match req_result {
4257                Err(err) => {
4258                    if let common::Retry::After(d) = dlg.http_error(&err) {
4259                        sleep(d).await;
4260                        continue;
4261                    }
4262                    dlg.finished(false);
4263                    return Err(common::Error::HttpError(err));
4264                }
4265                Ok(res) => {
4266                    let (mut parts, body) = res.into_parts();
4267                    let mut body = common::Body::new(body);
4268                    if !parts.status.is_success() {
4269                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4270                        let error = serde_json::from_str(&common::to_string(&bytes));
4271                        let response = common::to_response(parts, bytes.into());
4272
4273                        if let common::Retry::After(d) =
4274                            dlg.http_failure(&response, error.as_ref().ok())
4275                        {
4276                            sleep(d).await;
4277                            continue;
4278                        }
4279
4280                        dlg.finished(false);
4281
4282                        return Err(match error {
4283                            Ok(value) => common::Error::BadRequest(value),
4284                            _ => common::Error::Failure(response),
4285                        });
4286                    }
4287                    let response = {
4288                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4289                        let encoded = common::to_string(&bytes);
4290                        match serde_json::from_str(&encoded) {
4291                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4292                            Err(error) => {
4293                                dlg.response_json_decode_error(&encoded, &error);
4294                                return Err(common::Error::JsonDecodeError(
4295                                    encoded.to_string(),
4296                                    error,
4297                                ));
4298                            }
4299                        }
4300                    };
4301
4302                    dlg.finished(true);
4303                    return Ok(response);
4304                }
4305            }
4306        }
4307    }
4308
4309    ///
4310    /// Sets the *request* property to the given value.
4311    ///
4312    /// Even though the property as already been set when instantiating this call,
4313    /// we provide this method for API completeness.
4314    pub fn request(
4315        mut self,
4316        new_value: ReplaceAccessLevelsRequest,
4317    ) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4318        self._request = new_value;
4319        self
4320    }
4321    /// Required. Resource name for the access policy which owns these Access Levels. Format: `accessPolicies/{policy_id}`
4322    ///
4323    /// Sets the *parent* path property to the given value.
4324    ///
4325    /// Even though the property as already been set when instantiating this call,
4326    /// we provide this method for API completeness.
4327    pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4328        self._parent = new_value.to_string();
4329        self
4330    }
4331    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4332    /// while executing the actual API request.
4333    ///
4334    /// ````text
4335    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4336    /// ````
4337    ///
4338    /// Sets the *delegate* property to the given value.
4339    pub fn delegate(
4340        mut self,
4341        new_value: &'a mut dyn common::Delegate,
4342    ) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4343        self._delegate = Some(new_value);
4344        self
4345    }
4346
4347    /// Set any additional parameter of the query string used in the request.
4348    /// It should be used to set parameters which are not yet available through their own
4349    /// setters.
4350    ///
4351    /// Please note that this method must not be used to set any of the known parameters
4352    /// which have their own setter method. If done anyway, the request will fail.
4353    ///
4354    /// # Additional Parameters
4355    ///
4356    /// * *$.xgafv* (query-string) - V1 error format.
4357    /// * *access_token* (query-string) - OAuth access token.
4358    /// * *alt* (query-string) - Data format for response.
4359    /// * *callback* (query-string) - JSONP
4360    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4361    /// * *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.
4362    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4363    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4364    /// * *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.
4365    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4366    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4367    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelReplaceAllCall<'a, C>
4368    where
4369        T: AsRef<str>,
4370    {
4371        self._additional_params
4372            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4373        self
4374    }
4375
4376    /// Identifies the authorization scope for the method you are building.
4377    ///
4378    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4379    /// [`Scope::CloudPlatform`].
4380    ///
4381    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4382    /// tokens for more than one scope.
4383    ///
4384    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4385    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4386    /// sufficient, a read-write scope will do as well.
4387    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelReplaceAllCall<'a, C>
4388    where
4389        St: AsRef<str>,
4390    {
4391        self._scopes.insert(String::from(scope.as_ref()));
4392        self
4393    }
4394    /// Identifies the authorization scope(s) for the method you are building.
4395    ///
4396    /// See [`Self::add_scope()`] for details.
4397    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelReplaceAllCall<'a, C>
4398    where
4399        I: IntoIterator<Item = St>,
4400        St: AsRef<str>,
4401    {
4402        self._scopes
4403            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4404        self
4405    }
4406
4407    /// Removes all scopes, and no default scope will be used either.
4408    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4409    /// for details).
4410    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4411        self._scopes.clear();
4412        self
4413    }
4414}
4415
4416/// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
4417///
4418/// A builder for the *accessLevels.testIamPermissions* method supported by a *accessPolicy* resource.
4419/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4420///
4421/// # Example
4422///
4423/// Instantiate a resource method builder
4424///
4425/// ```test_harness,no_run
4426/// # extern crate hyper;
4427/// # extern crate hyper_rustls;
4428/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
4429/// use accesscontextmanager1::api::TestIamPermissionsRequest;
4430/// # async fn dox() {
4431/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4432///
4433/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4434/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4435/// #     .with_native_roots()
4436/// #     .unwrap()
4437/// #     .https_only()
4438/// #     .enable_http2()
4439/// #     .build();
4440///
4441/// # let executor = hyper_util::rt::TokioExecutor::new();
4442/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4443/// #     secret,
4444/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4445/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4446/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4447/// #     ),
4448/// # ).build().await.unwrap();
4449///
4450/// # let client = hyper_util::client::legacy::Client::builder(
4451/// #     hyper_util::rt::TokioExecutor::new()
4452/// # )
4453/// # .build(
4454/// #     hyper_rustls::HttpsConnectorBuilder::new()
4455/// #         .with_native_roots()
4456/// #         .unwrap()
4457/// #         .https_or_http()
4458/// #         .enable_http2()
4459/// #         .build()
4460/// # );
4461/// # let mut hub = AccessContextManager::new(client, auth);
4462/// // As the method needs a request, you would usually fill it with the desired information
4463/// // into the respective structure. Some of the parts shown here might not be applicable !
4464/// // Values shown here are possibly random and not representative !
4465/// let mut req = TestIamPermissionsRequest::default();
4466///
4467/// // You can configure optional parameters by calling the respective setters at will, and
4468/// // execute the final call using `doit()`.
4469/// // Values shown here are possibly random and not representative !
4470/// let result = hub.access_policies().access_levels_test_iam_permissions(req, "resource")
4471///              .doit().await;
4472/// # }
4473/// ```
4474pub struct AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4475where
4476    C: 'a,
4477{
4478    hub: &'a AccessContextManager<C>,
4479    _request: TestIamPermissionsRequest,
4480    _resource: String,
4481    _delegate: Option<&'a mut dyn common::Delegate>,
4482    _additional_params: HashMap<String, String>,
4483    _scopes: BTreeSet<String>,
4484}
4485
4486impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {}
4487
4488impl<'a, C> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4489where
4490    C: common::Connector,
4491{
4492    /// Perform the operation you have build so far.
4493    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
4494        use std::borrow::Cow;
4495        use std::io::{Read, Seek};
4496
4497        use common::{url::Params, ToParts};
4498        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4499
4500        let mut dd = common::DefaultDelegate;
4501        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4502        dlg.begin(common::MethodInfo {
4503            id: "accesscontextmanager.accessPolicies.accessLevels.testIamPermissions",
4504            http_method: hyper::Method::POST,
4505        });
4506
4507        for &field in ["alt", "resource"].iter() {
4508            if self._additional_params.contains_key(field) {
4509                dlg.finished(false);
4510                return Err(common::Error::FieldClash(field));
4511            }
4512        }
4513
4514        let mut params = Params::with_capacity(4 + self._additional_params.len());
4515        params.push("resource", self._resource);
4516
4517        params.extend(self._additional_params.iter());
4518
4519        params.push("alt", "json");
4520        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
4521        if self._scopes.is_empty() {
4522            self._scopes
4523                .insert(Scope::CloudPlatform.as_ref().to_string());
4524        }
4525
4526        #[allow(clippy::single_element_loop)]
4527        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4528            url = params.uri_replacement(url, param_name, find_this, true);
4529        }
4530        {
4531            let to_remove = ["resource"];
4532            params.remove_params(&to_remove);
4533        }
4534
4535        let url = params.parse_with_url(&url);
4536
4537        let mut json_mime_type = mime::APPLICATION_JSON;
4538        let mut request_value_reader = {
4539            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4540            common::remove_json_null_values(&mut value);
4541            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4542            serde_json::to_writer(&mut dst, &value).unwrap();
4543            dst
4544        };
4545        let request_size = request_value_reader
4546            .seek(std::io::SeekFrom::End(0))
4547            .unwrap();
4548        request_value_reader
4549            .seek(std::io::SeekFrom::Start(0))
4550            .unwrap();
4551
4552        loop {
4553            let token = match self
4554                .hub
4555                .auth
4556                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4557                .await
4558            {
4559                Ok(token) => token,
4560                Err(e) => match dlg.token(e) {
4561                    Ok(token) => token,
4562                    Err(e) => {
4563                        dlg.finished(false);
4564                        return Err(common::Error::MissingToken(e));
4565                    }
4566                },
4567            };
4568            request_value_reader
4569                .seek(std::io::SeekFrom::Start(0))
4570                .unwrap();
4571            let mut req_result = {
4572                let client = &self.hub.client;
4573                dlg.pre_request();
4574                let mut req_builder = hyper::Request::builder()
4575                    .method(hyper::Method::POST)
4576                    .uri(url.as_str())
4577                    .header(USER_AGENT, self.hub._user_agent.clone());
4578
4579                if let Some(token) = token.as_ref() {
4580                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4581                }
4582
4583                let request = req_builder
4584                    .header(CONTENT_TYPE, json_mime_type.to_string())
4585                    .header(CONTENT_LENGTH, request_size as u64)
4586                    .body(common::to_body(
4587                        request_value_reader.get_ref().clone().into(),
4588                    ));
4589
4590                client.request(request.unwrap()).await
4591            };
4592
4593            match req_result {
4594                Err(err) => {
4595                    if let common::Retry::After(d) = dlg.http_error(&err) {
4596                        sleep(d).await;
4597                        continue;
4598                    }
4599                    dlg.finished(false);
4600                    return Err(common::Error::HttpError(err));
4601                }
4602                Ok(res) => {
4603                    let (mut parts, body) = res.into_parts();
4604                    let mut body = common::Body::new(body);
4605                    if !parts.status.is_success() {
4606                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4607                        let error = serde_json::from_str(&common::to_string(&bytes));
4608                        let response = common::to_response(parts, bytes.into());
4609
4610                        if let common::Retry::After(d) =
4611                            dlg.http_failure(&response, error.as_ref().ok())
4612                        {
4613                            sleep(d).await;
4614                            continue;
4615                        }
4616
4617                        dlg.finished(false);
4618
4619                        return Err(match error {
4620                            Ok(value) => common::Error::BadRequest(value),
4621                            _ => common::Error::Failure(response),
4622                        });
4623                    }
4624                    let response = {
4625                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4626                        let encoded = common::to_string(&bytes);
4627                        match serde_json::from_str(&encoded) {
4628                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4629                            Err(error) => {
4630                                dlg.response_json_decode_error(&encoded, &error);
4631                                return Err(common::Error::JsonDecodeError(
4632                                    encoded.to_string(),
4633                                    error,
4634                                ));
4635                            }
4636                        }
4637                    };
4638
4639                    dlg.finished(true);
4640                    return Ok(response);
4641                }
4642            }
4643        }
4644    }
4645
4646    ///
4647    /// Sets the *request* property to the given value.
4648    ///
4649    /// Even though the property as already been set when instantiating this call,
4650    /// we provide this method for API completeness.
4651    pub fn request(
4652        mut self,
4653        new_value: TestIamPermissionsRequest,
4654    ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4655        self._request = new_value;
4656        self
4657    }
4658    /// 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.
4659    ///
4660    /// Sets the *resource* path property to the given value.
4661    ///
4662    /// Even though the property as already been set when instantiating this call,
4663    /// we provide this method for API completeness.
4664    pub fn resource(
4665        mut self,
4666        new_value: &str,
4667    ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4668        self._resource = new_value.to_string();
4669        self
4670    }
4671    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4672    /// while executing the actual API request.
4673    ///
4674    /// ````text
4675    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4676    /// ````
4677    ///
4678    /// Sets the *delegate* property to the given value.
4679    pub fn delegate(
4680        mut self,
4681        new_value: &'a mut dyn common::Delegate,
4682    ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4683        self._delegate = Some(new_value);
4684        self
4685    }
4686
4687    /// Set any additional parameter of the query string used in the request.
4688    /// It should be used to set parameters which are not yet available through their own
4689    /// setters.
4690    ///
4691    /// Please note that this method must not be used to set any of the known parameters
4692    /// which have their own setter method. If done anyway, the request will fail.
4693    ///
4694    /// # Additional Parameters
4695    ///
4696    /// * *$.xgafv* (query-string) - V1 error format.
4697    /// * *access_token* (query-string) - OAuth access token.
4698    /// * *alt* (query-string) - Data format for response.
4699    /// * *callback* (query-string) - JSONP
4700    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4701    /// * *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.
4702    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4703    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4704    /// * *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.
4705    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4706    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4707    pub fn param<T>(
4708        mut self,
4709        name: T,
4710        value: T,
4711    ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4712    where
4713        T: AsRef<str>,
4714    {
4715        self._additional_params
4716            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4717        self
4718    }
4719
4720    /// Identifies the authorization scope for the method you are building.
4721    ///
4722    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4723    /// [`Scope::CloudPlatform`].
4724    ///
4725    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4726    /// tokens for more than one scope.
4727    ///
4728    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4729    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4730    /// sufficient, a read-write scope will do as well.
4731    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4732    where
4733        St: AsRef<str>,
4734    {
4735        self._scopes.insert(String::from(scope.as_ref()));
4736        self
4737    }
4738    /// Identifies the authorization scope(s) for the method you are building.
4739    ///
4740    /// See [`Self::add_scope()`] for details.
4741    pub fn add_scopes<I, St>(
4742        mut self,
4743        scopes: I,
4744    ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4745    where
4746        I: IntoIterator<Item = St>,
4747        St: AsRef<str>,
4748    {
4749        self._scopes
4750            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4751        self
4752    }
4753
4754    /// Removes all scopes, and no default scope will be used either.
4755    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4756    /// for details).
4757    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4758        self._scopes.clear();
4759        self
4760    }
4761}
4762
4763/// Creates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. The name of this `AuthorizedOrgsDesc` will be assigned during creation.
4764///
4765/// A builder for the *authorizedOrgsDescs.create* method supported by a *accessPolicy* resource.
4766/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4767///
4768/// # Example
4769///
4770/// Instantiate a resource method builder
4771///
4772/// ```test_harness,no_run
4773/// # extern crate hyper;
4774/// # extern crate hyper_rustls;
4775/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
4776/// use accesscontextmanager1::api::AuthorizedOrgsDesc;
4777/// # async fn dox() {
4778/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4779///
4780/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4781/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4782/// #     .with_native_roots()
4783/// #     .unwrap()
4784/// #     .https_only()
4785/// #     .enable_http2()
4786/// #     .build();
4787///
4788/// # let executor = hyper_util::rt::TokioExecutor::new();
4789/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4790/// #     secret,
4791/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4792/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4793/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4794/// #     ),
4795/// # ).build().await.unwrap();
4796///
4797/// # let client = hyper_util::client::legacy::Client::builder(
4798/// #     hyper_util::rt::TokioExecutor::new()
4799/// # )
4800/// # .build(
4801/// #     hyper_rustls::HttpsConnectorBuilder::new()
4802/// #         .with_native_roots()
4803/// #         .unwrap()
4804/// #         .https_or_http()
4805/// #         .enable_http2()
4806/// #         .build()
4807/// # );
4808/// # let mut hub = AccessContextManager::new(client, auth);
4809/// // As the method needs a request, you would usually fill it with the desired information
4810/// // into the respective structure. Some of the parts shown here might not be applicable !
4811/// // Values shown here are possibly random and not representative !
4812/// let mut req = AuthorizedOrgsDesc::default();
4813///
4814/// // You can configure optional parameters by calling the respective setters at will, and
4815/// // execute the final call using `doit()`.
4816/// // Values shown here are possibly random and not representative !
4817/// let result = hub.access_policies().authorized_orgs_descs_create(req, "parent")
4818///              .doit().await;
4819/// # }
4820/// ```
4821pub struct AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
4822where
4823    C: 'a,
4824{
4825    hub: &'a AccessContextManager<C>,
4826    _request: AuthorizedOrgsDesc,
4827    _parent: String,
4828    _delegate: Option<&'a mut dyn common::Delegate>,
4829    _additional_params: HashMap<String, String>,
4830    _scopes: BTreeSet<String>,
4831}
4832
4833impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {}
4834
4835impl<'a, C> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
4836where
4837    C: common::Connector,
4838{
4839    /// Perform the operation you have build so far.
4840    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4841        use std::borrow::Cow;
4842        use std::io::{Read, Seek};
4843
4844        use common::{url::Params, ToParts};
4845        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4846
4847        let mut dd = common::DefaultDelegate;
4848        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4849        dlg.begin(common::MethodInfo {
4850            id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.create",
4851            http_method: hyper::Method::POST,
4852        });
4853
4854        for &field in ["alt", "parent"].iter() {
4855            if self._additional_params.contains_key(field) {
4856                dlg.finished(false);
4857                return Err(common::Error::FieldClash(field));
4858            }
4859        }
4860
4861        let mut params = Params::with_capacity(4 + self._additional_params.len());
4862        params.push("parent", self._parent);
4863
4864        params.extend(self._additional_params.iter());
4865
4866        params.push("alt", "json");
4867        let mut url = self.hub._base_url.clone() + "v1/{+parent}/authorizedOrgsDescs";
4868        if self._scopes.is_empty() {
4869            self._scopes
4870                .insert(Scope::CloudPlatform.as_ref().to_string());
4871        }
4872
4873        #[allow(clippy::single_element_loop)]
4874        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4875            url = params.uri_replacement(url, param_name, find_this, true);
4876        }
4877        {
4878            let to_remove = ["parent"];
4879            params.remove_params(&to_remove);
4880        }
4881
4882        let url = params.parse_with_url(&url);
4883
4884        let mut json_mime_type = mime::APPLICATION_JSON;
4885        let mut request_value_reader = {
4886            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4887            common::remove_json_null_values(&mut value);
4888            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4889            serde_json::to_writer(&mut dst, &value).unwrap();
4890            dst
4891        };
4892        let request_size = request_value_reader
4893            .seek(std::io::SeekFrom::End(0))
4894            .unwrap();
4895        request_value_reader
4896            .seek(std::io::SeekFrom::Start(0))
4897            .unwrap();
4898
4899        loop {
4900            let token = match self
4901                .hub
4902                .auth
4903                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4904                .await
4905            {
4906                Ok(token) => token,
4907                Err(e) => match dlg.token(e) {
4908                    Ok(token) => token,
4909                    Err(e) => {
4910                        dlg.finished(false);
4911                        return Err(common::Error::MissingToken(e));
4912                    }
4913                },
4914            };
4915            request_value_reader
4916                .seek(std::io::SeekFrom::Start(0))
4917                .unwrap();
4918            let mut req_result = {
4919                let client = &self.hub.client;
4920                dlg.pre_request();
4921                let mut req_builder = hyper::Request::builder()
4922                    .method(hyper::Method::POST)
4923                    .uri(url.as_str())
4924                    .header(USER_AGENT, self.hub._user_agent.clone());
4925
4926                if let Some(token) = token.as_ref() {
4927                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4928                }
4929
4930                let request = req_builder
4931                    .header(CONTENT_TYPE, json_mime_type.to_string())
4932                    .header(CONTENT_LENGTH, request_size as u64)
4933                    .body(common::to_body(
4934                        request_value_reader.get_ref().clone().into(),
4935                    ));
4936
4937                client.request(request.unwrap()).await
4938            };
4939
4940            match req_result {
4941                Err(err) => {
4942                    if let common::Retry::After(d) = dlg.http_error(&err) {
4943                        sleep(d).await;
4944                        continue;
4945                    }
4946                    dlg.finished(false);
4947                    return Err(common::Error::HttpError(err));
4948                }
4949                Ok(res) => {
4950                    let (mut parts, body) = res.into_parts();
4951                    let mut body = common::Body::new(body);
4952                    if !parts.status.is_success() {
4953                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4954                        let error = serde_json::from_str(&common::to_string(&bytes));
4955                        let response = common::to_response(parts, bytes.into());
4956
4957                        if let common::Retry::After(d) =
4958                            dlg.http_failure(&response, error.as_ref().ok())
4959                        {
4960                            sleep(d).await;
4961                            continue;
4962                        }
4963
4964                        dlg.finished(false);
4965
4966                        return Err(match error {
4967                            Ok(value) => common::Error::BadRequest(value),
4968                            _ => common::Error::Failure(response),
4969                        });
4970                    }
4971                    let response = {
4972                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4973                        let encoded = common::to_string(&bytes);
4974                        match serde_json::from_str(&encoded) {
4975                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4976                            Err(error) => {
4977                                dlg.response_json_decode_error(&encoded, &error);
4978                                return Err(common::Error::JsonDecodeError(
4979                                    encoded.to_string(),
4980                                    error,
4981                                ));
4982                            }
4983                        }
4984                    };
4985
4986                    dlg.finished(true);
4987                    return Ok(response);
4988                }
4989            }
4990        }
4991    }
4992
4993    ///
4994    /// Sets the *request* property to the given value.
4995    ///
4996    /// Even though the property as already been set when instantiating this call,
4997    /// we provide this method for API completeness.
4998    pub fn request(
4999        mut self,
5000        new_value: AuthorizedOrgsDesc,
5001    ) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
5002        self._request = new_value;
5003        self
5004    }
5005    /// Required. Resource name for the access policy which owns this Authorized Orgs Desc. Format: `accessPolicies/{policy_id}`
5006    ///
5007    /// Sets the *parent* path property to the given value.
5008    ///
5009    /// Even though the property as already been set when instantiating this call,
5010    /// we provide this method for API completeness.
5011    pub fn parent(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
5012        self._parent = new_value.to_string();
5013        self
5014    }
5015    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5016    /// while executing the actual API request.
5017    ///
5018    /// ````text
5019    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5020    /// ````
5021    ///
5022    /// Sets the *delegate* property to the given value.
5023    pub fn delegate(
5024        mut self,
5025        new_value: &'a mut dyn common::Delegate,
5026    ) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
5027        self._delegate = Some(new_value);
5028        self
5029    }
5030
5031    /// Set any additional parameter of the query string used in the request.
5032    /// It should be used to set parameters which are not yet available through their own
5033    /// setters.
5034    ///
5035    /// Please note that this method must not be used to set any of the known parameters
5036    /// which have their own setter method. If done anyway, the request will fail.
5037    ///
5038    /// # Additional Parameters
5039    ///
5040    /// * *$.xgafv* (query-string) - V1 error format.
5041    /// * *access_token* (query-string) - OAuth access token.
5042    /// * *alt* (query-string) - Data format for response.
5043    /// * *callback* (query-string) - JSONP
5044    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5045    /// * *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.
5046    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5047    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5048    /// * *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.
5049    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5050    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5051    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
5052    where
5053        T: AsRef<str>,
5054    {
5055        self._additional_params
5056            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5057        self
5058    }
5059
5060    /// Identifies the authorization scope for the method you are building.
5061    ///
5062    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5063    /// [`Scope::CloudPlatform`].
5064    ///
5065    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5066    /// tokens for more than one scope.
5067    ///
5068    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5069    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5070    /// sufficient, a read-write scope will do as well.
5071    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
5072    where
5073        St: AsRef<str>,
5074    {
5075        self._scopes.insert(String::from(scope.as_ref()));
5076        self
5077    }
5078    /// Identifies the authorization scope(s) for the method you are building.
5079    ///
5080    /// See [`Self::add_scope()`] for details.
5081    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
5082    where
5083        I: IntoIterator<Item = St>,
5084        St: AsRef<str>,
5085    {
5086        self._scopes
5087            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5088        self
5089    }
5090
5091    /// Removes all scopes, and no default scope will be used either.
5092    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5093    /// for details).
5094    pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
5095        self._scopes.clear();
5096        self
5097    }
5098}
5099
5100/// Deletes an authorized orgs desc based on the resource name. The long-running operation from this RPC has a successful status after the authorized orgs desc is removed from long-lasting storage.
5101///
5102/// A builder for the *authorizedOrgsDescs.delete* method supported by a *accessPolicy* resource.
5103/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
5104///
5105/// # Example
5106///
5107/// Instantiate a resource method builder
5108///
5109/// ```test_harness,no_run
5110/// # extern crate hyper;
5111/// # extern crate hyper_rustls;
5112/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
5113/// # async fn dox() {
5114/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5115///
5116/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5117/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5118/// #     .with_native_roots()
5119/// #     .unwrap()
5120/// #     .https_only()
5121/// #     .enable_http2()
5122/// #     .build();
5123///
5124/// # let executor = hyper_util::rt::TokioExecutor::new();
5125/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5126/// #     secret,
5127/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5128/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5129/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5130/// #     ),
5131/// # ).build().await.unwrap();
5132///
5133/// # let client = hyper_util::client::legacy::Client::builder(
5134/// #     hyper_util::rt::TokioExecutor::new()
5135/// # )
5136/// # .build(
5137/// #     hyper_rustls::HttpsConnectorBuilder::new()
5138/// #         .with_native_roots()
5139/// #         .unwrap()
5140/// #         .https_or_http()
5141/// #         .enable_http2()
5142/// #         .build()
5143/// # );
5144/// # let mut hub = AccessContextManager::new(client, auth);
5145/// // You can configure optional parameters by calling the respective setters at will, and
5146/// // execute the final call using `doit()`.
5147/// // Values shown here are possibly random and not representative !
5148/// let result = hub.access_policies().authorized_orgs_descs_delete("name")
5149///              .doit().await;
5150/// # }
5151/// ```
5152pub struct AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5153where
5154    C: 'a,
5155{
5156    hub: &'a AccessContextManager<C>,
5157    _name: String,
5158    _delegate: Option<&'a mut dyn common::Delegate>,
5159    _additional_params: HashMap<String, String>,
5160    _scopes: BTreeSet<String>,
5161}
5162
5163impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {}
5164
5165impl<'a, C> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5166where
5167    C: common::Connector,
5168{
5169    /// Perform the operation you have build so far.
5170    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5171        use std::borrow::Cow;
5172        use std::io::{Read, Seek};
5173
5174        use common::{url::Params, ToParts};
5175        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5176
5177        let mut dd = common::DefaultDelegate;
5178        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5179        dlg.begin(common::MethodInfo {
5180            id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.delete",
5181            http_method: hyper::Method::DELETE,
5182        });
5183
5184        for &field in ["alt", "name"].iter() {
5185            if self._additional_params.contains_key(field) {
5186                dlg.finished(false);
5187                return Err(common::Error::FieldClash(field));
5188            }
5189        }
5190
5191        let mut params = Params::with_capacity(3 + self._additional_params.len());
5192        params.push("name", self._name);
5193
5194        params.extend(self._additional_params.iter());
5195
5196        params.push("alt", "json");
5197        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5198        if self._scopes.is_empty() {
5199            self._scopes
5200                .insert(Scope::CloudPlatform.as_ref().to_string());
5201        }
5202
5203        #[allow(clippy::single_element_loop)]
5204        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5205            url = params.uri_replacement(url, param_name, find_this, true);
5206        }
5207        {
5208            let to_remove = ["name"];
5209            params.remove_params(&to_remove);
5210        }
5211
5212        let url = params.parse_with_url(&url);
5213
5214        loop {
5215            let token = match self
5216                .hub
5217                .auth
5218                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5219                .await
5220            {
5221                Ok(token) => token,
5222                Err(e) => match dlg.token(e) {
5223                    Ok(token) => token,
5224                    Err(e) => {
5225                        dlg.finished(false);
5226                        return Err(common::Error::MissingToken(e));
5227                    }
5228                },
5229            };
5230            let mut req_result = {
5231                let client = &self.hub.client;
5232                dlg.pre_request();
5233                let mut req_builder = hyper::Request::builder()
5234                    .method(hyper::Method::DELETE)
5235                    .uri(url.as_str())
5236                    .header(USER_AGENT, self.hub._user_agent.clone());
5237
5238                if let Some(token) = token.as_ref() {
5239                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5240                }
5241
5242                let request = req_builder
5243                    .header(CONTENT_LENGTH, 0_u64)
5244                    .body(common::to_body::<String>(None));
5245
5246                client.request(request.unwrap()).await
5247            };
5248
5249            match req_result {
5250                Err(err) => {
5251                    if let common::Retry::After(d) = dlg.http_error(&err) {
5252                        sleep(d).await;
5253                        continue;
5254                    }
5255                    dlg.finished(false);
5256                    return Err(common::Error::HttpError(err));
5257                }
5258                Ok(res) => {
5259                    let (mut parts, body) = res.into_parts();
5260                    let mut body = common::Body::new(body);
5261                    if !parts.status.is_success() {
5262                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5263                        let error = serde_json::from_str(&common::to_string(&bytes));
5264                        let response = common::to_response(parts, bytes.into());
5265
5266                        if let common::Retry::After(d) =
5267                            dlg.http_failure(&response, error.as_ref().ok())
5268                        {
5269                            sleep(d).await;
5270                            continue;
5271                        }
5272
5273                        dlg.finished(false);
5274
5275                        return Err(match error {
5276                            Ok(value) => common::Error::BadRequest(value),
5277                            _ => common::Error::Failure(response),
5278                        });
5279                    }
5280                    let response = {
5281                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5282                        let encoded = common::to_string(&bytes);
5283                        match serde_json::from_str(&encoded) {
5284                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5285                            Err(error) => {
5286                                dlg.response_json_decode_error(&encoded, &error);
5287                                return Err(common::Error::JsonDecodeError(
5288                                    encoded.to_string(),
5289                                    error,
5290                                ));
5291                            }
5292                        }
5293                    };
5294
5295                    dlg.finished(true);
5296                    return Ok(response);
5297                }
5298            }
5299        }
5300    }
5301
5302    /// Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDesc/{authorized_orgs_desc_id}`
5303    ///
5304    /// Sets the *name* path property to the given value.
5305    ///
5306    /// Even though the property as already been set when instantiating this call,
5307    /// we provide this method for API completeness.
5308    pub fn name(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
5309        self._name = new_value.to_string();
5310        self
5311    }
5312    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5313    /// while executing the actual API request.
5314    ///
5315    /// ````text
5316    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5317    /// ````
5318    ///
5319    /// Sets the *delegate* property to the given value.
5320    pub fn delegate(
5321        mut self,
5322        new_value: &'a mut dyn common::Delegate,
5323    ) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
5324        self._delegate = Some(new_value);
5325        self
5326    }
5327
5328    /// Set any additional parameter of the query string used in the request.
5329    /// It should be used to set parameters which are not yet available through their own
5330    /// setters.
5331    ///
5332    /// Please note that this method must not be used to set any of the known parameters
5333    /// which have their own setter method. If done anyway, the request will fail.
5334    ///
5335    /// # Additional Parameters
5336    ///
5337    /// * *$.xgafv* (query-string) - V1 error format.
5338    /// * *access_token* (query-string) - OAuth access token.
5339    /// * *alt* (query-string) - Data format for response.
5340    /// * *callback* (query-string) - JSONP
5341    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5342    /// * *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.
5343    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5344    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5345    /// * *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.
5346    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5347    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5348    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5349    where
5350        T: AsRef<str>,
5351    {
5352        self._additional_params
5353            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5354        self
5355    }
5356
5357    /// Identifies the authorization scope for the method you are building.
5358    ///
5359    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5360    /// [`Scope::CloudPlatform`].
5361    ///
5362    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5363    /// tokens for more than one scope.
5364    ///
5365    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5366    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5367    /// sufficient, a read-write scope will do as well.
5368    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5369    where
5370        St: AsRef<str>,
5371    {
5372        self._scopes.insert(String::from(scope.as_ref()));
5373        self
5374    }
5375    /// Identifies the authorization scope(s) for the method you are building.
5376    ///
5377    /// See [`Self::add_scope()`] for details.
5378    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5379    where
5380        I: IntoIterator<Item = St>,
5381        St: AsRef<str>,
5382    {
5383        self._scopes
5384            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5385        self
5386    }
5387
5388    /// Removes all scopes, and no default scope will be used either.
5389    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5390    /// for details).
5391    pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
5392        self._scopes.clear();
5393        self
5394    }
5395}
5396
5397/// Gets an authorized orgs desc based on the resource name.
5398///
5399/// A builder for the *authorizedOrgsDescs.get* method supported by a *accessPolicy* resource.
5400/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
5401///
5402/// # Example
5403///
5404/// Instantiate a resource method builder
5405///
5406/// ```test_harness,no_run
5407/// # extern crate hyper;
5408/// # extern crate hyper_rustls;
5409/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
5410/// # async fn dox() {
5411/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5412///
5413/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5414/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5415/// #     .with_native_roots()
5416/// #     .unwrap()
5417/// #     .https_only()
5418/// #     .enable_http2()
5419/// #     .build();
5420///
5421/// # let executor = hyper_util::rt::TokioExecutor::new();
5422/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5423/// #     secret,
5424/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5425/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5426/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5427/// #     ),
5428/// # ).build().await.unwrap();
5429///
5430/// # let client = hyper_util::client::legacy::Client::builder(
5431/// #     hyper_util::rt::TokioExecutor::new()
5432/// # )
5433/// # .build(
5434/// #     hyper_rustls::HttpsConnectorBuilder::new()
5435/// #         .with_native_roots()
5436/// #         .unwrap()
5437/// #         .https_or_http()
5438/// #         .enable_http2()
5439/// #         .build()
5440/// # );
5441/// # let mut hub = AccessContextManager::new(client, auth);
5442/// // You can configure optional parameters by calling the respective setters at will, and
5443/// // execute the final call using `doit()`.
5444/// // Values shown here are possibly random and not representative !
5445/// let result = hub.access_policies().authorized_orgs_descs_get("name")
5446///              .doit().await;
5447/// # }
5448/// ```
5449pub struct AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5450where
5451    C: 'a,
5452{
5453    hub: &'a AccessContextManager<C>,
5454    _name: String,
5455    _delegate: Option<&'a mut dyn common::Delegate>,
5456    _additional_params: HashMap<String, String>,
5457    _scopes: BTreeSet<String>,
5458}
5459
5460impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {}
5461
5462impl<'a, C> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5463where
5464    C: common::Connector,
5465{
5466    /// Perform the operation you have build so far.
5467    pub async fn doit(mut self) -> common::Result<(common::Response, AuthorizedOrgsDesc)> {
5468        use std::borrow::Cow;
5469        use std::io::{Read, Seek};
5470
5471        use common::{url::Params, ToParts};
5472        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5473
5474        let mut dd = common::DefaultDelegate;
5475        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5476        dlg.begin(common::MethodInfo {
5477            id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.get",
5478            http_method: hyper::Method::GET,
5479        });
5480
5481        for &field in ["alt", "name"].iter() {
5482            if self._additional_params.contains_key(field) {
5483                dlg.finished(false);
5484                return Err(common::Error::FieldClash(field));
5485            }
5486        }
5487
5488        let mut params = Params::with_capacity(3 + self._additional_params.len());
5489        params.push("name", self._name);
5490
5491        params.extend(self._additional_params.iter());
5492
5493        params.push("alt", "json");
5494        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5495        if self._scopes.is_empty() {
5496            self._scopes
5497                .insert(Scope::CloudPlatform.as_ref().to_string());
5498        }
5499
5500        #[allow(clippy::single_element_loop)]
5501        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5502            url = params.uri_replacement(url, param_name, find_this, true);
5503        }
5504        {
5505            let to_remove = ["name"];
5506            params.remove_params(&to_remove);
5507        }
5508
5509        let url = params.parse_with_url(&url);
5510
5511        loop {
5512            let token = match self
5513                .hub
5514                .auth
5515                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5516                .await
5517            {
5518                Ok(token) => token,
5519                Err(e) => match dlg.token(e) {
5520                    Ok(token) => token,
5521                    Err(e) => {
5522                        dlg.finished(false);
5523                        return Err(common::Error::MissingToken(e));
5524                    }
5525                },
5526            };
5527            let mut req_result = {
5528                let client = &self.hub.client;
5529                dlg.pre_request();
5530                let mut req_builder = hyper::Request::builder()
5531                    .method(hyper::Method::GET)
5532                    .uri(url.as_str())
5533                    .header(USER_AGENT, self.hub._user_agent.clone());
5534
5535                if let Some(token) = token.as_ref() {
5536                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5537                }
5538
5539                let request = req_builder
5540                    .header(CONTENT_LENGTH, 0_u64)
5541                    .body(common::to_body::<String>(None));
5542
5543                client.request(request.unwrap()).await
5544            };
5545
5546            match req_result {
5547                Err(err) => {
5548                    if let common::Retry::After(d) = dlg.http_error(&err) {
5549                        sleep(d).await;
5550                        continue;
5551                    }
5552                    dlg.finished(false);
5553                    return Err(common::Error::HttpError(err));
5554                }
5555                Ok(res) => {
5556                    let (mut parts, body) = res.into_parts();
5557                    let mut body = common::Body::new(body);
5558                    if !parts.status.is_success() {
5559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5560                        let error = serde_json::from_str(&common::to_string(&bytes));
5561                        let response = common::to_response(parts, bytes.into());
5562
5563                        if let common::Retry::After(d) =
5564                            dlg.http_failure(&response, error.as_ref().ok())
5565                        {
5566                            sleep(d).await;
5567                            continue;
5568                        }
5569
5570                        dlg.finished(false);
5571
5572                        return Err(match error {
5573                            Ok(value) => common::Error::BadRequest(value),
5574                            _ => common::Error::Failure(response),
5575                        });
5576                    }
5577                    let response = {
5578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5579                        let encoded = common::to_string(&bytes);
5580                        match serde_json::from_str(&encoded) {
5581                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5582                            Err(error) => {
5583                                dlg.response_json_decode_error(&encoded, &error);
5584                                return Err(common::Error::JsonDecodeError(
5585                                    encoded.to_string(),
5586                                    error,
5587                                ));
5588                            }
5589                        }
5590                    };
5591
5592                    dlg.finished(true);
5593                    return Ok(response);
5594                }
5595            }
5596        }
5597    }
5598
5599    /// Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDescs/{authorized_orgs_descs_id}`
5600    ///
5601    /// Sets the *name* path property to the given value.
5602    ///
5603    /// Even though the property as already been set when instantiating this call,
5604    /// we provide this method for API completeness.
5605    pub fn name(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
5606        self._name = new_value.to_string();
5607        self
5608    }
5609    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5610    /// while executing the actual API request.
5611    ///
5612    /// ````text
5613    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5614    /// ````
5615    ///
5616    /// Sets the *delegate* property to the given value.
5617    pub fn delegate(
5618        mut self,
5619        new_value: &'a mut dyn common::Delegate,
5620    ) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
5621        self._delegate = Some(new_value);
5622        self
5623    }
5624
5625    /// Set any additional parameter of the query string used in the request.
5626    /// It should be used to set parameters which are not yet available through their own
5627    /// setters.
5628    ///
5629    /// Please note that this method must not be used to set any of the known parameters
5630    /// which have their own setter method. If done anyway, the request will fail.
5631    ///
5632    /// # Additional Parameters
5633    ///
5634    /// * *$.xgafv* (query-string) - V1 error format.
5635    /// * *access_token* (query-string) - OAuth access token.
5636    /// * *alt* (query-string) - Data format for response.
5637    /// * *callback* (query-string) - JSONP
5638    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5639    /// * *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.
5640    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5641    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5642    /// * *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.
5643    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5644    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5645    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5646    where
5647        T: AsRef<str>,
5648    {
5649        self._additional_params
5650            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5651        self
5652    }
5653
5654    /// Identifies the authorization scope for the method you are building.
5655    ///
5656    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5657    /// [`Scope::CloudPlatform`].
5658    ///
5659    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5660    /// tokens for more than one scope.
5661    ///
5662    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5663    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5664    /// sufficient, a read-write scope will do as well.
5665    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5666    where
5667        St: AsRef<str>,
5668    {
5669        self._scopes.insert(String::from(scope.as_ref()));
5670        self
5671    }
5672    /// Identifies the authorization scope(s) for the method you are building.
5673    ///
5674    /// See [`Self::add_scope()`] for details.
5675    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5676    where
5677        I: IntoIterator<Item = St>,
5678        St: AsRef<str>,
5679    {
5680        self._scopes
5681            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5682        self
5683    }
5684
5685    /// Removes all scopes, and no default scope will be used either.
5686    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5687    /// for details).
5688    pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
5689        self._scopes.clear();
5690        self
5691    }
5692}
5693
5694/// Lists all authorized orgs descs for an access policy.
5695///
5696/// A builder for the *authorizedOrgsDescs.list* method supported by a *accessPolicy* resource.
5697/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
5698///
5699/// # Example
5700///
5701/// Instantiate a resource method builder
5702///
5703/// ```test_harness,no_run
5704/// # extern crate hyper;
5705/// # extern crate hyper_rustls;
5706/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
5707/// # async fn dox() {
5708/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5709///
5710/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5711/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5712/// #     .with_native_roots()
5713/// #     .unwrap()
5714/// #     .https_only()
5715/// #     .enable_http2()
5716/// #     .build();
5717///
5718/// # let executor = hyper_util::rt::TokioExecutor::new();
5719/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5720/// #     secret,
5721/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5722/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5723/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5724/// #     ),
5725/// # ).build().await.unwrap();
5726///
5727/// # let client = hyper_util::client::legacy::Client::builder(
5728/// #     hyper_util::rt::TokioExecutor::new()
5729/// # )
5730/// # .build(
5731/// #     hyper_rustls::HttpsConnectorBuilder::new()
5732/// #         .with_native_roots()
5733/// #         .unwrap()
5734/// #         .https_or_http()
5735/// #         .enable_http2()
5736/// #         .build()
5737/// # );
5738/// # let mut hub = AccessContextManager::new(client, auth);
5739/// // You can configure optional parameters by calling the respective setters at will, and
5740/// // execute the final call using `doit()`.
5741/// // Values shown here are possibly random and not representative !
5742/// let result = hub.access_policies().authorized_orgs_descs_list("parent")
5743///              .page_token("ea")
5744///              .page_size(-99)
5745///              .doit().await;
5746/// # }
5747/// ```
5748pub struct AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5749where
5750    C: 'a,
5751{
5752    hub: &'a AccessContextManager<C>,
5753    _parent: String,
5754    _page_token: Option<String>,
5755    _page_size: Option<i32>,
5756    _delegate: Option<&'a mut dyn common::Delegate>,
5757    _additional_params: HashMap<String, String>,
5758    _scopes: BTreeSet<String>,
5759}
5760
5761impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescListCall<'a, C> {}
5762
5763impl<'a, C> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5764where
5765    C: common::Connector,
5766{
5767    /// Perform the operation you have build so far.
5768    pub async fn doit(
5769        mut self,
5770    ) -> common::Result<(common::Response, ListAuthorizedOrgsDescsResponse)> {
5771        use std::borrow::Cow;
5772        use std::io::{Read, Seek};
5773
5774        use common::{url::Params, ToParts};
5775        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5776
5777        let mut dd = common::DefaultDelegate;
5778        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5779        dlg.begin(common::MethodInfo {
5780            id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.list",
5781            http_method: hyper::Method::GET,
5782        });
5783
5784        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5785            if self._additional_params.contains_key(field) {
5786                dlg.finished(false);
5787                return Err(common::Error::FieldClash(field));
5788            }
5789        }
5790
5791        let mut params = Params::with_capacity(5 + self._additional_params.len());
5792        params.push("parent", self._parent);
5793        if let Some(value) = self._page_token.as_ref() {
5794            params.push("pageToken", value);
5795        }
5796        if let Some(value) = self._page_size.as_ref() {
5797            params.push("pageSize", value.to_string());
5798        }
5799
5800        params.extend(self._additional_params.iter());
5801
5802        params.push("alt", "json");
5803        let mut url = self.hub._base_url.clone() + "v1/{+parent}/authorizedOrgsDescs";
5804        if self._scopes.is_empty() {
5805            self._scopes
5806                .insert(Scope::CloudPlatform.as_ref().to_string());
5807        }
5808
5809        #[allow(clippy::single_element_loop)]
5810        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5811            url = params.uri_replacement(url, param_name, find_this, true);
5812        }
5813        {
5814            let to_remove = ["parent"];
5815            params.remove_params(&to_remove);
5816        }
5817
5818        let url = params.parse_with_url(&url);
5819
5820        loop {
5821            let token = match self
5822                .hub
5823                .auth
5824                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5825                .await
5826            {
5827                Ok(token) => token,
5828                Err(e) => match dlg.token(e) {
5829                    Ok(token) => token,
5830                    Err(e) => {
5831                        dlg.finished(false);
5832                        return Err(common::Error::MissingToken(e));
5833                    }
5834                },
5835            };
5836            let mut req_result = {
5837                let client = &self.hub.client;
5838                dlg.pre_request();
5839                let mut req_builder = hyper::Request::builder()
5840                    .method(hyper::Method::GET)
5841                    .uri(url.as_str())
5842                    .header(USER_AGENT, self.hub._user_agent.clone());
5843
5844                if let Some(token) = token.as_ref() {
5845                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5846                }
5847
5848                let request = req_builder
5849                    .header(CONTENT_LENGTH, 0_u64)
5850                    .body(common::to_body::<String>(None));
5851
5852                client.request(request.unwrap()).await
5853            };
5854
5855            match req_result {
5856                Err(err) => {
5857                    if let common::Retry::After(d) = dlg.http_error(&err) {
5858                        sleep(d).await;
5859                        continue;
5860                    }
5861                    dlg.finished(false);
5862                    return Err(common::Error::HttpError(err));
5863                }
5864                Ok(res) => {
5865                    let (mut parts, body) = res.into_parts();
5866                    let mut body = common::Body::new(body);
5867                    if !parts.status.is_success() {
5868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5869                        let error = serde_json::from_str(&common::to_string(&bytes));
5870                        let response = common::to_response(parts, bytes.into());
5871
5872                        if let common::Retry::After(d) =
5873                            dlg.http_failure(&response, error.as_ref().ok())
5874                        {
5875                            sleep(d).await;
5876                            continue;
5877                        }
5878
5879                        dlg.finished(false);
5880
5881                        return Err(match error {
5882                            Ok(value) => common::Error::BadRequest(value),
5883                            _ => common::Error::Failure(response),
5884                        });
5885                    }
5886                    let response = {
5887                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5888                        let encoded = common::to_string(&bytes);
5889                        match serde_json::from_str(&encoded) {
5890                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5891                            Err(error) => {
5892                                dlg.response_json_decode_error(&encoded, &error);
5893                                return Err(common::Error::JsonDecodeError(
5894                                    encoded.to_string(),
5895                                    error,
5896                                ));
5897                            }
5898                        }
5899                    };
5900
5901                    dlg.finished(true);
5902                    return Ok(response);
5903                }
5904            }
5905        }
5906    }
5907
5908    /// Required. Resource name for the access policy to list Authorized Orgs Desc from. Format: `accessPolicies/{policy_id}`
5909    ///
5910    /// Sets the *parent* path property to the given value.
5911    ///
5912    /// Even though the property as already been set when instantiating this call,
5913    /// we provide this method for API completeness.
5914    pub fn parent(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5915        self._parent = new_value.to_string();
5916        self
5917    }
5918    /// Next page token for the next batch of Authorized Orgs Desc instances. Defaults to the first page of results.
5919    ///
5920    /// Sets the *page token* query property to the given value.
5921    pub fn page_token(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5922        self._page_token = Some(new_value.to_string());
5923        self
5924    }
5925    /// Number of Authorized Orgs Descs to include in the list. Default 100.
5926    ///
5927    /// Sets the *page size* query property to the given value.
5928    pub fn page_size(mut self, new_value: i32) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5929        self._page_size = Some(new_value);
5930        self
5931    }
5932    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5933    /// while executing the actual API request.
5934    ///
5935    /// ````text
5936    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5937    /// ````
5938    ///
5939    /// Sets the *delegate* property to the given value.
5940    pub fn delegate(
5941        mut self,
5942        new_value: &'a mut dyn common::Delegate,
5943    ) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5944        self._delegate = Some(new_value);
5945        self
5946    }
5947
5948    /// Set any additional parameter of the query string used in the request.
5949    /// It should be used to set parameters which are not yet available through their own
5950    /// setters.
5951    ///
5952    /// Please note that this method must not be used to set any of the known parameters
5953    /// which have their own setter method. If done anyway, the request will fail.
5954    ///
5955    /// # Additional Parameters
5956    ///
5957    /// * *$.xgafv* (query-string) - V1 error format.
5958    /// * *access_token* (query-string) - OAuth access token.
5959    /// * *alt* (query-string) - Data format for response.
5960    /// * *callback* (query-string) - JSONP
5961    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5962    /// * *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.
5963    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5964    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5965    /// * *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.
5966    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5967    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5968    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5969    where
5970        T: AsRef<str>,
5971    {
5972        self._additional_params
5973            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5974        self
5975    }
5976
5977    /// Identifies the authorization scope for the method you are building.
5978    ///
5979    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5980    /// [`Scope::CloudPlatform`].
5981    ///
5982    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5983    /// tokens for more than one scope.
5984    ///
5985    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5986    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5987    /// sufficient, a read-write scope will do as well.
5988    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5989    where
5990        St: AsRef<str>,
5991    {
5992        self._scopes.insert(String::from(scope.as_ref()));
5993        self
5994    }
5995    /// Identifies the authorization scope(s) for the method you are building.
5996    ///
5997    /// See [`Self::add_scope()`] for details.
5998    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5999    where
6000        I: IntoIterator<Item = St>,
6001        St: AsRef<str>,
6002    {
6003        self._scopes
6004            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6005        self
6006    }
6007
6008    /// Removes all scopes, and no default scope will be used either.
6009    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6010    /// for details).
6011    pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
6012        self._scopes.clear();
6013        self
6014    }
6015}
6016
6017/// Updates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. Only the organization list in `AuthorizedOrgsDesc` can be updated. The name, authorization_type, asset_type and authorization_direction cannot be updated.
6018///
6019/// A builder for the *authorizedOrgsDescs.patch* method supported by a *accessPolicy* resource.
6020/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
6021///
6022/// # Example
6023///
6024/// Instantiate a resource method builder
6025///
6026/// ```test_harness,no_run
6027/// # extern crate hyper;
6028/// # extern crate hyper_rustls;
6029/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
6030/// use accesscontextmanager1::api::AuthorizedOrgsDesc;
6031/// # async fn dox() {
6032/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6033///
6034/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6035/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6036/// #     .with_native_roots()
6037/// #     .unwrap()
6038/// #     .https_only()
6039/// #     .enable_http2()
6040/// #     .build();
6041///
6042/// # let executor = hyper_util::rt::TokioExecutor::new();
6043/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6044/// #     secret,
6045/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6046/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6047/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6048/// #     ),
6049/// # ).build().await.unwrap();
6050///
6051/// # let client = hyper_util::client::legacy::Client::builder(
6052/// #     hyper_util::rt::TokioExecutor::new()
6053/// # )
6054/// # .build(
6055/// #     hyper_rustls::HttpsConnectorBuilder::new()
6056/// #         .with_native_roots()
6057/// #         .unwrap()
6058/// #         .https_or_http()
6059/// #         .enable_http2()
6060/// #         .build()
6061/// # );
6062/// # let mut hub = AccessContextManager::new(client, auth);
6063/// // As the method needs a request, you would usually fill it with the desired information
6064/// // into the respective structure. Some of the parts shown here might not be applicable !
6065/// // Values shown here are possibly random and not representative !
6066/// let mut req = AuthorizedOrgsDesc::default();
6067///
6068/// // You can configure optional parameters by calling the respective setters at will, and
6069/// // execute the final call using `doit()`.
6070/// // Values shown here are possibly random and not representative !
6071/// let result = hub.access_policies().authorized_orgs_descs_patch(req, "name")
6072///              .update_mask(FieldMask::new::<&str>(&[]))
6073///              .doit().await;
6074/// # }
6075/// ```
6076pub struct AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6077where
6078    C: 'a,
6079{
6080    hub: &'a AccessContextManager<C>,
6081    _request: AuthorizedOrgsDesc,
6082    _name: String,
6083    _update_mask: Option<common::FieldMask>,
6084    _delegate: Option<&'a mut dyn common::Delegate>,
6085    _additional_params: HashMap<String, String>,
6086    _scopes: BTreeSet<String>,
6087}
6088
6089impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {}
6090
6091impl<'a, C> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6092where
6093    C: common::Connector,
6094{
6095    /// Perform the operation you have build so far.
6096    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6097        use std::borrow::Cow;
6098        use std::io::{Read, Seek};
6099
6100        use common::{url::Params, ToParts};
6101        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6102
6103        let mut dd = common::DefaultDelegate;
6104        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6105        dlg.begin(common::MethodInfo {
6106            id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.patch",
6107            http_method: hyper::Method::PATCH,
6108        });
6109
6110        for &field in ["alt", "name", "updateMask"].iter() {
6111            if self._additional_params.contains_key(field) {
6112                dlg.finished(false);
6113                return Err(common::Error::FieldClash(field));
6114            }
6115        }
6116
6117        let mut params = Params::with_capacity(5 + self._additional_params.len());
6118        params.push("name", self._name);
6119        if let Some(value) = self._update_mask.as_ref() {
6120            params.push("updateMask", value.to_string());
6121        }
6122
6123        params.extend(self._additional_params.iter());
6124
6125        params.push("alt", "json");
6126        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6127        if self._scopes.is_empty() {
6128            self._scopes
6129                .insert(Scope::CloudPlatform.as_ref().to_string());
6130        }
6131
6132        #[allow(clippy::single_element_loop)]
6133        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6134            url = params.uri_replacement(url, param_name, find_this, true);
6135        }
6136        {
6137            let to_remove = ["name"];
6138            params.remove_params(&to_remove);
6139        }
6140
6141        let url = params.parse_with_url(&url);
6142
6143        let mut json_mime_type = mime::APPLICATION_JSON;
6144        let mut request_value_reader = {
6145            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6146            common::remove_json_null_values(&mut value);
6147            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6148            serde_json::to_writer(&mut dst, &value).unwrap();
6149            dst
6150        };
6151        let request_size = request_value_reader
6152            .seek(std::io::SeekFrom::End(0))
6153            .unwrap();
6154        request_value_reader
6155            .seek(std::io::SeekFrom::Start(0))
6156            .unwrap();
6157
6158        loop {
6159            let token = match self
6160                .hub
6161                .auth
6162                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6163                .await
6164            {
6165                Ok(token) => token,
6166                Err(e) => match dlg.token(e) {
6167                    Ok(token) => token,
6168                    Err(e) => {
6169                        dlg.finished(false);
6170                        return Err(common::Error::MissingToken(e));
6171                    }
6172                },
6173            };
6174            request_value_reader
6175                .seek(std::io::SeekFrom::Start(0))
6176                .unwrap();
6177            let mut req_result = {
6178                let client = &self.hub.client;
6179                dlg.pre_request();
6180                let mut req_builder = hyper::Request::builder()
6181                    .method(hyper::Method::PATCH)
6182                    .uri(url.as_str())
6183                    .header(USER_AGENT, self.hub._user_agent.clone());
6184
6185                if let Some(token) = token.as_ref() {
6186                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6187                }
6188
6189                let request = req_builder
6190                    .header(CONTENT_TYPE, json_mime_type.to_string())
6191                    .header(CONTENT_LENGTH, request_size as u64)
6192                    .body(common::to_body(
6193                        request_value_reader.get_ref().clone().into(),
6194                    ));
6195
6196                client.request(request.unwrap()).await
6197            };
6198
6199            match req_result {
6200                Err(err) => {
6201                    if let common::Retry::After(d) = dlg.http_error(&err) {
6202                        sleep(d).await;
6203                        continue;
6204                    }
6205                    dlg.finished(false);
6206                    return Err(common::Error::HttpError(err));
6207                }
6208                Ok(res) => {
6209                    let (mut parts, body) = res.into_parts();
6210                    let mut body = common::Body::new(body);
6211                    if !parts.status.is_success() {
6212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6213                        let error = serde_json::from_str(&common::to_string(&bytes));
6214                        let response = common::to_response(parts, bytes.into());
6215
6216                        if let common::Retry::After(d) =
6217                            dlg.http_failure(&response, error.as_ref().ok())
6218                        {
6219                            sleep(d).await;
6220                            continue;
6221                        }
6222
6223                        dlg.finished(false);
6224
6225                        return Err(match error {
6226                            Ok(value) => common::Error::BadRequest(value),
6227                            _ => common::Error::Failure(response),
6228                        });
6229                    }
6230                    let response = {
6231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6232                        let encoded = common::to_string(&bytes);
6233                        match serde_json::from_str(&encoded) {
6234                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6235                            Err(error) => {
6236                                dlg.response_json_decode_error(&encoded, &error);
6237                                return Err(common::Error::JsonDecodeError(
6238                                    encoded.to_string(),
6239                                    error,
6240                                ));
6241                            }
6242                        }
6243                    };
6244
6245                    dlg.finished(true);
6246                    return Ok(response);
6247                }
6248            }
6249        }
6250    }
6251
6252    ///
6253    /// Sets the *request* property to the given value.
6254    ///
6255    /// Even though the property as already been set when instantiating this call,
6256    /// we provide this method for API completeness.
6257    pub fn request(
6258        mut self,
6259        new_value: AuthorizedOrgsDesc,
6260    ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
6261        self._request = new_value;
6262        self
6263    }
6264    /// Identifier. Resource name for the `AuthorizedOrgsDesc`. Format: `accessPolicies/{access_policy}/authorizedOrgsDescs/{authorized_orgs_desc}`. The `authorized_orgs_desc` component must begin with a letter, followed by alphanumeric characters or `_`. After you create an `AuthorizedOrgsDesc`, you cannot change its `name`.
6265    ///
6266    /// Sets the *name* path property to the given value.
6267    ///
6268    /// Even though the property as already been set when instantiating this call,
6269    /// we provide this method for API completeness.
6270    pub fn name(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
6271        self._name = new_value.to_string();
6272        self
6273    }
6274    /// Required. Mask to control which fields get updated. Must be non-empty.
6275    ///
6276    /// Sets the *update mask* query property to the given value.
6277    pub fn update_mask(
6278        mut self,
6279        new_value: common::FieldMask,
6280    ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
6281        self._update_mask = Some(new_value);
6282        self
6283    }
6284    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6285    /// while executing the actual API request.
6286    ///
6287    /// ````text
6288    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6289    /// ````
6290    ///
6291    /// Sets the *delegate* property to the given value.
6292    pub fn delegate(
6293        mut self,
6294        new_value: &'a mut dyn common::Delegate,
6295    ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
6296        self._delegate = Some(new_value);
6297        self
6298    }
6299
6300    /// Set any additional parameter of the query string used in the request.
6301    /// It should be used to set parameters which are not yet available through their own
6302    /// setters.
6303    ///
6304    /// Please note that this method must not be used to set any of the known parameters
6305    /// which have their own setter method. If done anyway, the request will fail.
6306    ///
6307    /// # Additional Parameters
6308    ///
6309    /// * *$.xgafv* (query-string) - V1 error format.
6310    /// * *access_token* (query-string) - OAuth access token.
6311    /// * *alt* (query-string) - Data format for response.
6312    /// * *callback* (query-string) - JSONP
6313    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6314    /// * *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.
6315    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6316    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6317    /// * *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.
6318    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6319    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6320    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6321    where
6322        T: AsRef<str>,
6323    {
6324        self._additional_params
6325            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6326        self
6327    }
6328
6329    /// Identifies the authorization scope for the method you are building.
6330    ///
6331    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6332    /// [`Scope::CloudPlatform`].
6333    ///
6334    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6335    /// tokens for more than one scope.
6336    ///
6337    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6338    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6339    /// sufficient, a read-write scope will do as well.
6340    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6341    where
6342        St: AsRef<str>,
6343    {
6344        self._scopes.insert(String::from(scope.as_ref()));
6345        self
6346    }
6347    /// Identifies the authorization scope(s) for the method you are building.
6348    ///
6349    /// See [`Self::add_scope()`] for details.
6350    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6351    where
6352        I: IntoIterator<Item = St>,
6353        St: AsRef<str>,
6354    {
6355        self._scopes
6356            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6357        self
6358    }
6359
6360    /// Removes all scopes, and no default scope will be used either.
6361    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6362    /// for details).
6363    pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
6364        self._scopes.clear();
6365        self
6366    }
6367}
6368
6369/// Commits the dry-run specification for all the service perimeters in an access policy. A commit operation on a service perimeter involves copying its `spec` field to the `status` field of the service perimeter. Only service perimeters with `use_explicit_dry_run_spec` field set to true are affected by a commit operation. The long-running operation from this RPC has a successful status after the dry-run specifications for all the service perimeters have been committed. If a commit fails, it causes the long-running operation to return an error response and the entire commit operation is cancelled. When successful, the Operation.response field contains CommitServicePerimetersResponse. The `dry_run` and the `spec` fields are cleared after a successful commit operation.
6370///
6371/// A builder for the *servicePerimeters.commit* method supported by a *accessPolicy* resource.
6372/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
6373///
6374/// # Example
6375///
6376/// Instantiate a resource method builder
6377///
6378/// ```test_harness,no_run
6379/// # extern crate hyper;
6380/// # extern crate hyper_rustls;
6381/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
6382/// use accesscontextmanager1::api::CommitServicePerimetersRequest;
6383/// # async fn dox() {
6384/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6385///
6386/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6387/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6388/// #     .with_native_roots()
6389/// #     .unwrap()
6390/// #     .https_only()
6391/// #     .enable_http2()
6392/// #     .build();
6393///
6394/// # let executor = hyper_util::rt::TokioExecutor::new();
6395/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6396/// #     secret,
6397/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6398/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6399/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6400/// #     ),
6401/// # ).build().await.unwrap();
6402///
6403/// # let client = hyper_util::client::legacy::Client::builder(
6404/// #     hyper_util::rt::TokioExecutor::new()
6405/// # )
6406/// # .build(
6407/// #     hyper_rustls::HttpsConnectorBuilder::new()
6408/// #         .with_native_roots()
6409/// #         .unwrap()
6410/// #         .https_or_http()
6411/// #         .enable_http2()
6412/// #         .build()
6413/// # );
6414/// # let mut hub = AccessContextManager::new(client, auth);
6415/// // As the method needs a request, you would usually fill it with the desired information
6416/// // into the respective structure. Some of the parts shown here might not be applicable !
6417/// // Values shown here are possibly random and not representative !
6418/// let mut req = CommitServicePerimetersRequest::default();
6419///
6420/// // You can configure optional parameters by calling the respective setters at will, and
6421/// // execute the final call using `doit()`.
6422/// // Values shown here are possibly random and not representative !
6423/// let result = hub.access_policies().service_perimeters_commit(req, "parent")
6424///              .doit().await;
6425/// # }
6426/// ```
6427pub struct AccessPolicyServicePerimeterCommitCall<'a, C>
6428where
6429    C: 'a,
6430{
6431    hub: &'a AccessContextManager<C>,
6432    _request: CommitServicePerimetersRequest,
6433    _parent: String,
6434    _delegate: Option<&'a mut dyn common::Delegate>,
6435    _additional_params: HashMap<String, String>,
6436    _scopes: BTreeSet<String>,
6437}
6438
6439impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterCommitCall<'a, C> {}
6440
6441impl<'a, C> AccessPolicyServicePerimeterCommitCall<'a, C>
6442where
6443    C: common::Connector,
6444{
6445    /// Perform the operation you have build so far.
6446    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6447        use std::borrow::Cow;
6448        use std::io::{Read, Seek};
6449
6450        use common::{url::Params, ToParts};
6451        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6452
6453        let mut dd = common::DefaultDelegate;
6454        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6455        dlg.begin(common::MethodInfo {
6456            id: "accesscontextmanager.accessPolicies.servicePerimeters.commit",
6457            http_method: hyper::Method::POST,
6458        });
6459
6460        for &field in ["alt", "parent"].iter() {
6461            if self._additional_params.contains_key(field) {
6462                dlg.finished(false);
6463                return Err(common::Error::FieldClash(field));
6464            }
6465        }
6466
6467        let mut params = Params::with_capacity(4 + self._additional_params.len());
6468        params.push("parent", self._parent);
6469
6470        params.extend(self._additional_params.iter());
6471
6472        params.push("alt", "json");
6473        let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters:commit";
6474        if self._scopes.is_empty() {
6475            self._scopes
6476                .insert(Scope::CloudPlatform.as_ref().to_string());
6477        }
6478
6479        #[allow(clippy::single_element_loop)]
6480        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6481            url = params.uri_replacement(url, param_name, find_this, true);
6482        }
6483        {
6484            let to_remove = ["parent"];
6485            params.remove_params(&to_remove);
6486        }
6487
6488        let url = params.parse_with_url(&url);
6489
6490        let mut json_mime_type = mime::APPLICATION_JSON;
6491        let mut request_value_reader = {
6492            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6493            common::remove_json_null_values(&mut value);
6494            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6495            serde_json::to_writer(&mut dst, &value).unwrap();
6496            dst
6497        };
6498        let request_size = request_value_reader
6499            .seek(std::io::SeekFrom::End(0))
6500            .unwrap();
6501        request_value_reader
6502            .seek(std::io::SeekFrom::Start(0))
6503            .unwrap();
6504
6505        loop {
6506            let token = match self
6507                .hub
6508                .auth
6509                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6510                .await
6511            {
6512                Ok(token) => token,
6513                Err(e) => match dlg.token(e) {
6514                    Ok(token) => token,
6515                    Err(e) => {
6516                        dlg.finished(false);
6517                        return Err(common::Error::MissingToken(e));
6518                    }
6519                },
6520            };
6521            request_value_reader
6522                .seek(std::io::SeekFrom::Start(0))
6523                .unwrap();
6524            let mut req_result = {
6525                let client = &self.hub.client;
6526                dlg.pre_request();
6527                let mut req_builder = hyper::Request::builder()
6528                    .method(hyper::Method::POST)
6529                    .uri(url.as_str())
6530                    .header(USER_AGENT, self.hub._user_agent.clone());
6531
6532                if let Some(token) = token.as_ref() {
6533                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6534                }
6535
6536                let request = req_builder
6537                    .header(CONTENT_TYPE, json_mime_type.to_string())
6538                    .header(CONTENT_LENGTH, request_size as u64)
6539                    .body(common::to_body(
6540                        request_value_reader.get_ref().clone().into(),
6541                    ));
6542
6543                client.request(request.unwrap()).await
6544            };
6545
6546            match req_result {
6547                Err(err) => {
6548                    if let common::Retry::After(d) = dlg.http_error(&err) {
6549                        sleep(d).await;
6550                        continue;
6551                    }
6552                    dlg.finished(false);
6553                    return Err(common::Error::HttpError(err));
6554                }
6555                Ok(res) => {
6556                    let (mut parts, body) = res.into_parts();
6557                    let mut body = common::Body::new(body);
6558                    if !parts.status.is_success() {
6559                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6560                        let error = serde_json::from_str(&common::to_string(&bytes));
6561                        let response = common::to_response(parts, bytes.into());
6562
6563                        if let common::Retry::After(d) =
6564                            dlg.http_failure(&response, error.as_ref().ok())
6565                        {
6566                            sleep(d).await;
6567                            continue;
6568                        }
6569
6570                        dlg.finished(false);
6571
6572                        return Err(match error {
6573                            Ok(value) => common::Error::BadRequest(value),
6574                            _ => common::Error::Failure(response),
6575                        });
6576                    }
6577                    let response = {
6578                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6579                        let encoded = common::to_string(&bytes);
6580                        match serde_json::from_str(&encoded) {
6581                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6582                            Err(error) => {
6583                                dlg.response_json_decode_error(&encoded, &error);
6584                                return Err(common::Error::JsonDecodeError(
6585                                    encoded.to_string(),
6586                                    error,
6587                                ));
6588                            }
6589                        }
6590                    };
6591
6592                    dlg.finished(true);
6593                    return Ok(response);
6594                }
6595            }
6596        }
6597    }
6598
6599    ///
6600    /// Sets the *request* property to the given value.
6601    ///
6602    /// Even though the property as already been set when instantiating this call,
6603    /// we provide this method for API completeness.
6604    pub fn request(
6605        mut self,
6606        new_value: CommitServicePerimetersRequest,
6607    ) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6608        self._request = new_value;
6609        self
6610    }
6611    /// Required. Resource name for the parent Access Policy which owns all Service Perimeters in scope for the commit operation. Format: `accessPolicies/{policy_id}`
6612    ///
6613    /// Sets the *parent* path property to the given value.
6614    ///
6615    /// Even though the property as already been set when instantiating this call,
6616    /// we provide this method for API completeness.
6617    pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6618        self._parent = new_value.to_string();
6619        self
6620    }
6621    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6622    /// while executing the actual API request.
6623    ///
6624    /// ````text
6625    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6626    /// ````
6627    ///
6628    /// Sets the *delegate* property to the given value.
6629    pub fn delegate(
6630        mut self,
6631        new_value: &'a mut dyn common::Delegate,
6632    ) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6633        self._delegate = Some(new_value);
6634        self
6635    }
6636
6637    /// Set any additional parameter of the query string used in the request.
6638    /// It should be used to set parameters which are not yet available through their own
6639    /// setters.
6640    ///
6641    /// Please note that this method must not be used to set any of the known parameters
6642    /// which have their own setter method. If done anyway, the request will fail.
6643    ///
6644    /// # Additional Parameters
6645    ///
6646    /// * *$.xgafv* (query-string) - V1 error format.
6647    /// * *access_token* (query-string) - OAuth access token.
6648    /// * *alt* (query-string) - Data format for response.
6649    /// * *callback* (query-string) - JSONP
6650    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6651    /// * *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.
6652    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6653    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6654    /// * *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.
6655    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6656    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6657    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterCommitCall<'a, C>
6658    where
6659        T: AsRef<str>,
6660    {
6661        self._additional_params
6662            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6663        self
6664    }
6665
6666    /// Identifies the authorization scope for the method you are building.
6667    ///
6668    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6669    /// [`Scope::CloudPlatform`].
6670    ///
6671    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6672    /// tokens for more than one scope.
6673    ///
6674    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6675    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6676    /// sufficient, a read-write scope will do as well.
6677    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterCommitCall<'a, C>
6678    where
6679        St: AsRef<str>,
6680    {
6681        self._scopes.insert(String::from(scope.as_ref()));
6682        self
6683    }
6684    /// Identifies the authorization scope(s) for the method you are building.
6685    ///
6686    /// See [`Self::add_scope()`] for details.
6687    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterCommitCall<'a, C>
6688    where
6689        I: IntoIterator<Item = St>,
6690        St: AsRef<str>,
6691    {
6692        self._scopes
6693            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6694        self
6695    }
6696
6697    /// Removes all scopes, and no default scope will be used either.
6698    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6699    /// for details).
6700    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6701        self._scopes.clear();
6702        self
6703    }
6704}
6705
6706/// Creates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
6707///
6708/// A builder for the *servicePerimeters.create* method supported by a *accessPolicy* resource.
6709/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
6710///
6711/// # Example
6712///
6713/// Instantiate a resource method builder
6714///
6715/// ```test_harness,no_run
6716/// # extern crate hyper;
6717/// # extern crate hyper_rustls;
6718/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
6719/// use accesscontextmanager1::api::ServicePerimeter;
6720/// # async fn dox() {
6721/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6722///
6723/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6724/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6725/// #     .with_native_roots()
6726/// #     .unwrap()
6727/// #     .https_only()
6728/// #     .enable_http2()
6729/// #     .build();
6730///
6731/// # let executor = hyper_util::rt::TokioExecutor::new();
6732/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6733/// #     secret,
6734/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6735/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6736/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6737/// #     ),
6738/// # ).build().await.unwrap();
6739///
6740/// # let client = hyper_util::client::legacy::Client::builder(
6741/// #     hyper_util::rt::TokioExecutor::new()
6742/// # )
6743/// # .build(
6744/// #     hyper_rustls::HttpsConnectorBuilder::new()
6745/// #         .with_native_roots()
6746/// #         .unwrap()
6747/// #         .https_or_http()
6748/// #         .enable_http2()
6749/// #         .build()
6750/// # );
6751/// # let mut hub = AccessContextManager::new(client, auth);
6752/// // As the method needs a request, you would usually fill it with the desired information
6753/// // into the respective structure. Some of the parts shown here might not be applicable !
6754/// // Values shown here are possibly random and not representative !
6755/// let mut req = ServicePerimeter::default();
6756///
6757/// // You can configure optional parameters by calling the respective setters at will, and
6758/// // execute the final call using `doit()`.
6759/// // Values shown here are possibly random and not representative !
6760/// let result = hub.access_policies().service_perimeters_create(req, "parent")
6761///              .doit().await;
6762/// # }
6763/// ```
6764pub struct AccessPolicyServicePerimeterCreateCall<'a, C>
6765where
6766    C: 'a,
6767{
6768    hub: &'a AccessContextManager<C>,
6769    _request: ServicePerimeter,
6770    _parent: String,
6771    _delegate: Option<&'a mut dyn common::Delegate>,
6772    _additional_params: HashMap<String, String>,
6773    _scopes: BTreeSet<String>,
6774}
6775
6776impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterCreateCall<'a, C> {}
6777
6778impl<'a, C> AccessPolicyServicePerimeterCreateCall<'a, C>
6779where
6780    C: common::Connector,
6781{
6782    /// Perform the operation you have build so far.
6783    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6784        use std::borrow::Cow;
6785        use std::io::{Read, Seek};
6786
6787        use common::{url::Params, ToParts};
6788        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6789
6790        let mut dd = common::DefaultDelegate;
6791        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6792        dlg.begin(common::MethodInfo {
6793            id: "accesscontextmanager.accessPolicies.servicePerimeters.create",
6794            http_method: hyper::Method::POST,
6795        });
6796
6797        for &field in ["alt", "parent"].iter() {
6798            if self._additional_params.contains_key(field) {
6799                dlg.finished(false);
6800                return Err(common::Error::FieldClash(field));
6801            }
6802        }
6803
6804        let mut params = Params::with_capacity(4 + self._additional_params.len());
6805        params.push("parent", self._parent);
6806
6807        params.extend(self._additional_params.iter());
6808
6809        params.push("alt", "json");
6810        let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters";
6811        if self._scopes.is_empty() {
6812            self._scopes
6813                .insert(Scope::CloudPlatform.as_ref().to_string());
6814        }
6815
6816        #[allow(clippy::single_element_loop)]
6817        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6818            url = params.uri_replacement(url, param_name, find_this, true);
6819        }
6820        {
6821            let to_remove = ["parent"];
6822            params.remove_params(&to_remove);
6823        }
6824
6825        let url = params.parse_with_url(&url);
6826
6827        let mut json_mime_type = mime::APPLICATION_JSON;
6828        let mut request_value_reader = {
6829            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6830            common::remove_json_null_values(&mut value);
6831            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6832            serde_json::to_writer(&mut dst, &value).unwrap();
6833            dst
6834        };
6835        let request_size = request_value_reader
6836            .seek(std::io::SeekFrom::End(0))
6837            .unwrap();
6838        request_value_reader
6839            .seek(std::io::SeekFrom::Start(0))
6840            .unwrap();
6841
6842        loop {
6843            let token = match self
6844                .hub
6845                .auth
6846                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6847                .await
6848            {
6849                Ok(token) => token,
6850                Err(e) => match dlg.token(e) {
6851                    Ok(token) => token,
6852                    Err(e) => {
6853                        dlg.finished(false);
6854                        return Err(common::Error::MissingToken(e));
6855                    }
6856                },
6857            };
6858            request_value_reader
6859                .seek(std::io::SeekFrom::Start(0))
6860                .unwrap();
6861            let mut req_result = {
6862                let client = &self.hub.client;
6863                dlg.pre_request();
6864                let mut req_builder = hyper::Request::builder()
6865                    .method(hyper::Method::POST)
6866                    .uri(url.as_str())
6867                    .header(USER_AGENT, self.hub._user_agent.clone());
6868
6869                if let Some(token) = token.as_ref() {
6870                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6871                }
6872
6873                let request = req_builder
6874                    .header(CONTENT_TYPE, json_mime_type.to_string())
6875                    .header(CONTENT_LENGTH, request_size as u64)
6876                    .body(common::to_body(
6877                        request_value_reader.get_ref().clone().into(),
6878                    ));
6879
6880                client.request(request.unwrap()).await
6881            };
6882
6883            match req_result {
6884                Err(err) => {
6885                    if let common::Retry::After(d) = dlg.http_error(&err) {
6886                        sleep(d).await;
6887                        continue;
6888                    }
6889                    dlg.finished(false);
6890                    return Err(common::Error::HttpError(err));
6891                }
6892                Ok(res) => {
6893                    let (mut parts, body) = res.into_parts();
6894                    let mut body = common::Body::new(body);
6895                    if !parts.status.is_success() {
6896                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6897                        let error = serde_json::from_str(&common::to_string(&bytes));
6898                        let response = common::to_response(parts, bytes.into());
6899
6900                        if let common::Retry::After(d) =
6901                            dlg.http_failure(&response, error.as_ref().ok())
6902                        {
6903                            sleep(d).await;
6904                            continue;
6905                        }
6906
6907                        dlg.finished(false);
6908
6909                        return Err(match error {
6910                            Ok(value) => common::Error::BadRequest(value),
6911                            _ => common::Error::Failure(response),
6912                        });
6913                    }
6914                    let response = {
6915                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6916                        let encoded = common::to_string(&bytes);
6917                        match serde_json::from_str(&encoded) {
6918                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6919                            Err(error) => {
6920                                dlg.response_json_decode_error(&encoded, &error);
6921                                return Err(common::Error::JsonDecodeError(
6922                                    encoded.to_string(),
6923                                    error,
6924                                ));
6925                            }
6926                        }
6927                    };
6928
6929                    dlg.finished(true);
6930                    return Ok(response);
6931                }
6932            }
6933        }
6934    }
6935
6936    ///
6937    /// Sets the *request* property to the given value.
6938    ///
6939    /// Even though the property as already been set when instantiating this call,
6940    /// we provide this method for API completeness.
6941    pub fn request(
6942        mut self,
6943        new_value: ServicePerimeter,
6944    ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
6945        self._request = new_value;
6946        self
6947    }
6948    /// Required. Resource name for the access policy which owns this Service Perimeter. Format: `accessPolicies/{policy_id}`
6949    ///
6950    /// Sets the *parent* path property to the given value.
6951    ///
6952    /// Even though the property as already been set when instantiating this call,
6953    /// we provide this method for API completeness.
6954    pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
6955        self._parent = new_value.to_string();
6956        self
6957    }
6958    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6959    /// while executing the actual API request.
6960    ///
6961    /// ````text
6962    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6963    /// ````
6964    ///
6965    /// Sets the *delegate* property to the given value.
6966    pub fn delegate(
6967        mut self,
6968        new_value: &'a mut dyn common::Delegate,
6969    ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
6970        self._delegate = Some(new_value);
6971        self
6972    }
6973
6974    /// Set any additional parameter of the query string used in the request.
6975    /// It should be used to set parameters which are not yet available through their own
6976    /// setters.
6977    ///
6978    /// Please note that this method must not be used to set any of the known parameters
6979    /// which have their own setter method. If done anyway, the request will fail.
6980    ///
6981    /// # Additional Parameters
6982    ///
6983    /// * *$.xgafv* (query-string) - V1 error format.
6984    /// * *access_token* (query-string) - OAuth access token.
6985    /// * *alt* (query-string) - Data format for response.
6986    /// * *callback* (query-string) - JSONP
6987    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6988    /// * *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.
6989    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6990    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6991    /// * *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.
6992    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6993    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6994    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterCreateCall<'a, C>
6995    where
6996        T: AsRef<str>,
6997    {
6998        self._additional_params
6999            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7000        self
7001    }
7002
7003    /// Identifies the authorization scope for the method you are building.
7004    ///
7005    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7006    /// [`Scope::CloudPlatform`].
7007    ///
7008    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7009    /// tokens for more than one scope.
7010    ///
7011    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7012    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7013    /// sufficient, a read-write scope will do as well.
7014    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterCreateCall<'a, C>
7015    where
7016        St: AsRef<str>,
7017    {
7018        self._scopes.insert(String::from(scope.as_ref()));
7019        self
7020    }
7021    /// Identifies the authorization scope(s) for the method you are building.
7022    ///
7023    /// See [`Self::add_scope()`] for details.
7024    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterCreateCall<'a, C>
7025    where
7026        I: IntoIterator<Item = St>,
7027        St: AsRef<str>,
7028    {
7029        self._scopes
7030            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7031        self
7032    }
7033
7034    /// Removes all scopes, and no default scope will be used either.
7035    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7036    /// for details).
7037    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
7038        self._scopes.clear();
7039        self
7040    }
7041}
7042
7043/// Deletes a service perimeter based on the resource name. The long-running operation from this RPC has a successful status after the service perimeter is removed from long-lasting storage.
7044///
7045/// A builder for the *servicePerimeters.delete* method supported by a *accessPolicy* resource.
7046/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7047///
7048/// # Example
7049///
7050/// Instantiate a resource method builder
7051///
7052/// ```test_harness,no_run
7053/// # extern crate hyper;
7054/// # extern crate hyper_rustls;
7055/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7056/// # async fn dox() {
7057/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7058///
7059/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7060/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7061/// #     .with_native_roots()
7062/// #     .unwrap()
7063/// #     .https_only()
7064/// #     .enable_http2()
7065/// #     .build();
7066///
7067/// # let executor = hyper_util::rt::TokioExecutor::new();
7068/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7069/// #     secret,
7070/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7071/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7072/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7073/// #     ),
7074/// # ).build().await.unwrap();
7075///
7076/// # let client = hyper_util::client::legacy::Client::builder(
7077/// #     hyper_util::rt::TokioExecutor::new()
7078/// # )
7079/// # .build(
7080/// #     hyper_rustls::HttpsConnectorBuilder::new()
7081/// #         .with_native_roots()
7082/// #         .unwrap()
7083/// #         .https_or_http()
7084/// #         .enable_http2()
7085/// #         .build()
7086/// # );
7087/// # let mut hub = AccessContextManager::new(client, auth);
7088/// // You can configure optional parameters by calling the respective setters at will, and
7089/// // execute the final call using `doit()`.
7090/// // Values shown here are possibly random and not representative !
7091/// let result = hub.access_policies().service_perimeters_delete("name")
7092///              .doit().await;
7093/// # }
7094/// ```
7095pub struct AccessPolicyServicePerimeterDeleteCall<'a, C>
7096where
7097    C: 'a,
7098{
7099    hub: &'a AccessContextManager<C>,
7100    _name: String,
7101    _delegate: Option<&'a mut dyn common::Delegate>,
7102    _additional_params: HashMap<String, String>,
7103    _scopes: BTreeSet<String>,
7104}
7105
7106impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterDeleteCall<'a, C> {}
7107
7108impl<'a, C> AccessPolicyServicePerimeterDeleteCall<'a, C>
7109where
7110    C: common::Connector,
7111{
7112    /// Perform the operation you have build so far.
7113    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7114        use std::borrow::Cow;
7115        use std::io::{Read, Seek};
7116
7117        use common::{url::Params, ToParts};
7118        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7119
7120        let mut dd = common::DefaultDelegate;
7121        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7122        dlg.begin(common::MethodInfo {
7123            id: "accesscontextmanager.accessPolicies.servicePerimeters.delete",
7124            http_method: hyper::Method::DELETE,
7125        });
7126
7127        for &field in ["alt", "name"].iter() {
7128            if self._additional_params.contains_key(field) {
7129                dlg.finished(false);
7130                return Err(common::Error::FieldClash(field));
7131            }
7132        }
7133
7134        let mut params = Params::with_capacity(3 + self._additional_params.len());
7135        params.push("name", self._name);
7136
7137        params.extend(self._additional_params.iter());
7138
7139        params.push("alt", "json");
7140        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7141        if self._scopes.is_empty() {
7142            self._scopes
7143                .insert(Scope::CloudPlatform.as_ref().to_string());
7144        }
7145
7146        #[allow(clippy::single_element_loop)]
7147        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7148            url = params.uri_replacement(url, param_name, find_this, true);
7149        }
7150        {
7151            let to_remove = ["name"];
7152            params.remove_params(&to_remove);
7153        }
7154
7155        let url = params.parse_with_url(&url);
7156
7157        loop {
7158            let token = match self
7159                .hub
7160                .auth
7161                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7162                .await
7163            {
7164                Ok(token) => token,
7165                Err(e) => match dlg.token(e) {
7166                    Ok(token) => token,
7167                    Err(e) => {
7168                        dlg.finished(false);
7169                        return Err(common::Error::MissingToken(e));
7170                    }
7171                },
7172            };
7173            let mut req_result = {
7174                let client = &self.hub.client;
7175                dlg.pre_request();
7176                let mut req_builder = hyper::Request::builder()
7177                    .method(hyper::Method::DELETE)
7178                    .uri(url.as_str())
7179                    .header(USER_AGENT, self.hub._user_agent.clone());
7180
7181                if let Some(token) = token.as_ref() {
7182                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7183                }
7184
7185                let request = req_builder
7186                    .header(CONTENT_LENGTH, 0_u64)
7187                    .body(common::to_body::<String>(None));
7188
7189                client.request(request.unwrap()).await
7190            };
7191
7192            match req_result {
7193                Err(err) => {
7194                    if let common::Retry::After(d) = dlg.http_error(&err) {
7195                        sleep(d).await;
7196                        continue;
7197                    }
7198                    dlg.finished(false);
7199                    return Err(common::Error::HttpError(err));
7200                }
7201                Ok(res) => {
7202                    let (mut parts, body) = res.into_parts();
7203                    let mut body = common::Body::new(body);
7204                    if !parts.status.is_success() {
7205                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7206                        let error = serde_json::from_str(&common::to_string(&bytes));
7207                        let response = common::to_response(parts, bytes.into());
7208
7209                        if let common::Retry::After(d) =
7210                            dlg.http_failure(&response, error.as_ref().ok())
7211                        {
7212                            sleep(d).await;
7213                            continue;
7214                        }
7215
7216                        dlg.finished(false);
7217
7218                        return Err(match error {
7219                            Ok(value) => common::Error::BadRequest(value),
7220                            _ => common::Error::Failure(response),
7221                        });
7222                    }
7223                    let response = {
7224                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7225                        let encoded = common::to_string(&bytes);
7226                        match serde_json::from_str(&encoded) {
7227                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7228                            Err(error) => {
7229                                dlg.response_json_decode_error(&encoded, &error);
7230                                return Err(common::Error::JsonDecodeError(
7231                                    encoded.to_string(),
7232                                    error,
7233                                ));
7234                            }
7235                        }
7236                    };
7237
7238                    dlg.finished(true);
7239                    return Ok(response);
7240                }
7241            }
7242        }
7243    }
7244
7245    /// Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeter_id}`
7246    ///
7247    /// Sets the *name* path property to the given value.
7248    ///
7249    /// Even though the property as already been set when instantiating this call,
7250    /// we provide this method for API completeness.
7251    pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
7252        self._name = new_value.to_string();
7253        self
7254    }
7255    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7256    /// while executing the actual API request.
7257    ///
7258    /// ````text
7259    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7260    /// ````
7261    ///
7262    /// Sets the *delegate* property to the given value.
7263    pub fn delegate(
7264        mut self,
7265        new_value: &'a mut dyn common::Delegate,
7266    ) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
7267        self._delegate = Some(new_value);
7268        self
7269    }
7270
7271    /// Set any additional parameter of the query string used in the request.
7272    /// It should be used to set parameters which are not yet available through their own
7273    /// setters.
7274    ///
7275    /// Please note that this method must not be used to set any of the known parameters
7276    /// which have their own setter method. If done anyway, the request will fail.
7277    ///
7278    /// # Additional Parameters
7279    ///
7280    /// * *$.xgafv* (query-string) - V1 error format.
7281    /// * *access_token* (query-string) - OAuth access token.
7282    /// * *alt* (query-string) - Data format for response.
7283    /// * *callback* (query-string) - JSONP
7284    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7285    /// * *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.
7286    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7287    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7288    /// * *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.
7289    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7290    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7291    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
7292    where
7293        T: AsRef<str>,
7294    {
7295        self._additional_params
7296            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7297        self
7298    }
7299
7300    /// Identifies the authorization scope for the method you are building.
7301    ///
7302    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7303    /// [`Scope::CloudPlatform`].
7304    ///
7305    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7306    /// tokens for more than one scope.
7307    ///
7308    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7309    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7310    /// sufficient, a read-write scope will do as well.
7311    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
7312    where
7313        St: AsRef<str>,
7314    {
7315        self._scopes.insert(String::from(scope.as_ref()));
7316        self
7317    }
7318    /// Identifies the authorization scope(s) for the method you are building.
7319    ///
7320    /// See [`Self::add_scope()`] for details.
7321    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
7322    where
7323        I: IntoIterator<Item = St>,
7324        St: AsRef<str>,
7325    {
7326        self._scopes
7327            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7328        self
7329    }
7330
7331    /// Removes all scopes, and no default scope will be used either.
7332    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7333    /// for details).
7334    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
7335        self._scopes.clear();
7336        self
7337    }
7338}
7339
7340/// Gets a service perimeter based on the resource name.
7341///
7342/// A builder for the *servicePerimeters.get* method supported by a *accessPolicy* resource.
7343/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7344///
7345/// # Example
7346///
7347/// Instantiate a resource method builder
7348///
7349/// ```test_harness,no_run
7350/// # extern crate hyper;
7351/// # extern crate hyper_rustls;
7352/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7353/// # async fn dox() {
7354/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7355///
7356/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7357/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7358/// #     .with_native_roots()
7359/// #     .unwrap()
7360/// #     .https_only()
7361/// #     .enable_http2()
7362/// #     .build();
7363///
7364/// # let executor = hyper_util::rt::TokioExecutor::new();
7365/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7366/// #     secret,
7367/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7368/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7369/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7370/// #     ),
7371/// # ).build().await.unwrap();
7372///
7373/// # let client = hyper_util::client::legacy::Client::builder(
7374/// #     hyper_util::rt::TokioExecutor::new()
7375/// # )
7376/// # .build(
7377/// #     hyper_rustls::HttpsConnectorBuilder::new()
7378/// #         .with_native_roots()
7379/// #         .unwrap()
7380/// #         .https_or_http()
7381/// #         .enable_http2()
7382/// #         .build()
7383/// # );
7384/// # let mut hub = AccessContextManager::new(client, auth);
7385/// // You can configure optional parameters by calling the respective setters at will, and
7386/// // execute the final call using `doit()`.
7387/// // Values shown here are possibly random and not representative !
7388/// let result = hub.access_policies().service_perimeters_get("name")
7389///              .doit().await;
7390/// # }
7391/// ```
7392pub struct AccessPolicyServicePerimeterGetCall<'a, C>
7393where
7394    C: 'a,
7395{
7396    hub: &'a AccessContextManager<C>,
7397    _name: String,
7398    _delegate: Option<&'a mut dyn common::Delegate>,
7399    _additional_params: HashMap<String, String>,
7400    _scopes: BTreeSet<String>,
7401}
7402
7403impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterGetCall<'a, C> {}
7404
7405impl<'a, C> AccessPolicyServicePerimeterGetCall<'a, C>
7406where
7407    C: common::Connector,
7408{
7409    /// Perform the operation you have build so far.
7410    pub async fn doit(mut self) -> common::Result<(common::Response, ServicePerimeter)> {
7411        use std::borrow::Cow;
7412        use std::io::{Read, Seek};
7413
7414        use common::{url::Params, ToParts};
7415        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7416
7417        let mut dd = common::DefaultDelegate;
7418        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7419        dlg.begin(common::MethodInfo {
7420            id: "accesscontextmanager.accessPolicies.servicePerimeters.get",
7421            http_method: hyper::Method::GET,
7422        });
7423
7424        for &field in ["alt", "name"].iter() {
7425            if self._additional_params.contains_key(field) {
7426                dlg.finished(false);
7427                return Err(common::Error::FieldClash(field));
7428            }
7429        }
7430
7431        let mut params = Params::with_capacity(3 + self._additional_params.len());
7432        params.push("name", self._name);
7433
7434        params.extend(self._additional_params.iter());
7435
7436        params.push("alt", "json");
7437        let mut url = self.hub._base_url.clone() + "v1/{+name}";
7438        if self._scopes.is_empty() {
7439            self._scopes
7440                .insert(Scope::CloudPlatform.as_ref().to_string());
7441        }
7442
7443        #[allow(clippy::single_element_loop)]
7444        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7445            url = params.uri_replacement(url, param_name, find_this, true);
7446        }
7447        {
7448            let to_remove = ["name"];
7449            params.remove_params(&to_remove);
7450        }
7451
7452        let url = params.parse_with_url(&url);
7453
7454        loop {
7455            let token = match self
7456                .hub
7457                .auth
7458                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7459                .await
7460            {
7461                Ok(token) => token,
7462                Err(e) => match dlg.token(e) {
7463                    Ok(token) => token,
7464                    Err(e) => {
7465                        dlg.finished(false);
7466                        return Err(common::Error::MissingToken(e));
7467                    }
7468                },
7469            };
7470            let mut req_result = {
7471                let client = &self.hub.client;
7472                dlg.pre_request();
7473                let mut req_builder = hyper::Request::builder()
7474                    .method(hyper::Method::GET)
7475                    .uri(url.as_str())
7476                    .header(USER_AGENT, self.hub._user_agent.clone());
7477
7478                if let Some(token) = token.as_ref() {
7479                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7480                }
7481
7482                let request = req_builder
7483                    .header(CONTENT_LENGTH, 0_u64)
7484                    .body(common::to_body::<String>(None));
7485
7486                client.request(request.unwrap()).await
7487            };
7488
7489            match req_result {
7490                Err(err) => {
7491                    if let common::Retry::After(d) = dlg.http_error(&err) {
7492                        sleep(d).await;
7493                        continue;
7494                    }
7495                    dlg.finished(false);
7496                    return Err(common::Error::HttpError(err));
7497                }
7498                Ok(res) => {
7499                    let (mut parts, body) = res.into_parts();
7500                    let mut body = common::Body::new(body);
7501                    if !parts.status.is_success() {
7502                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7503                        let error = serde_json::from_str(&common::to_string(&bytes));
7504                        let response = common::to_response(parts, bytes.into());
7505
7506                        if let common::Retry::After(d) =
7507                            dlg.http_failure(&response, error.as_ref().ok())
7508                        {
7509                            sleep(d).await;
7510                            continue;
7511                        }
7512
7513                        dlg.finished(false);
7514
7515                        return Err(match error {
7516                            Ok(value) => common::Error::BadRequest(value),
7517                            _ => common::Error::Failure(response),
7518                        });
7519                    }
7520                    let response = {
7521                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7522                        let encoded = common::to_string(&bytes);
7523                        match serde_json::from_str(&encoded) {
7524                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7525                            Err(error) => {
7526                                dlg.response_json_decode_error(&encoded, &error);
7527                                return Err(common::Error::JsonDecodeError(
7528                                    encoded.to_string(),
7529                                    error,
7530                                ));
7531                            }
7532                        }
7533                    };
7534
7535                    dlg.finished(true);
7536                    return Ok(response);
7537                }
7538            }
7539        }
7540    }
7541
7542    /// Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeters_id}`
7543    ///
7544    /// Sets the *name* path property to the given value.
7545    ///
7546    /// Even though the property as already been set when instantiating this call,
7547    /// we provide this method for API completeness.
7548    pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterGetCall<'a, C> {
7549        self._name = new_value.to_string();
7550        self
7551    }
7552    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7553    /// while executing the actual API request.
7554    ///
7555    /// ````text
7556    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7557    /// ````
7558    ///
7559    /// Sets the *delegate* property to the given value.
7560    pub fn delegate(
7561        mut self,
7562        new_value: &'a mut dyn common::Delegate,
7563    ) -> AccessPolicyServicePerimeterGetCall<'a, C> {
7564        self._delegate = Some(new_value);
7565        self
7566    }
7567
7568    /// Set any additional parameter of the query string used in the request.
7569    /// It should be used to set parameters which are not yet available through their own
7570    /// setters.
7571    ///
7572    /// Please note that this method must not be used to set any of the known parameters
7573    /// which have their own setter method. If done anyway, the request will fail.
7574    ///
7575    /// # Additional Parameters
7576    ///
7577    /// * *$.xgafv* (query-string) - V1 error format.
7578    /// * *access_token* (query-string) - OAuth access token.
7579    /// * *alt* (query-string) - Data format for response.
7580    /// * *callback* (query-string) - JSONP
7581    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7582    /// * *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.
7583    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7584    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7585    /// * *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.
7586    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7587    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7588    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterGetCall<'a, C>
7589    where
7590        T: AsRef<str>,
7591    {
7592        self._additional_params
7593            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7594        self
7595    }
7596
7597    /// Identifies the authorization scope for the method you are building.
7598    ///
7599    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7600    /// [`Scope::CloudPlatform`].
7601    ///
7602    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7603    /// tokens for more than one scope.
7604    ///
7605    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7606    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7607    /// sufficient, a read-write scope will do as well.
7608    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterGetCall<'a, C>
7609    where
7610        St: AsRef<str>,
7611    {
7612        self._scopes.insert(String::from(scope.as_ref()));
7613        self
7614    }
7615    /// Identifies the authorization scope(s) for the method you are building.
7616    ///
7617    /// See [`Self::add_scope()`] for details.
7618    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterGetCall<'a, C>
7619    where
7620        I: IntoIterator<Item = St>,
7621        St: AsRef<str>,
7622    {
7623        self._scopes
7624            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7625        self
7626    }
7627
7628    /// Removes all scopes, and no default scope will be used either.
7629    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7630    /// for details).
7631    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterGetCall<'a, C> {
7632        self._scopes.clear();
7633        self
7634    }
7635}
7636
7637/// Lists all service perimeters for an access policy.
7638///
7639/// A builder for the *servicePerimeters.list* method supported by a *accessPolicy* resource.
7640/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7641///
7642/// # Example
7643///
7644/// Instantiate a resource method builder
7645///
7646/// ```test_harness,no_run
7647/// # extern crate hyper;
7648/// # extern crate hyper_rustls;
7649/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7650/// # async fn dox() {
7651/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7652///
7653/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7654/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7655/// #     .with_native_roots()
7656/// #     .unwrap()
7657/// #     .https_only()
7658/// #     .enable_http2()
7659/// #     .build();
7660///
7661/// # let executor = hyper_util::rt::TokioExecutor::new();
7662/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7663/// #     secret,
7664/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7665/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7666/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7667/// #     ),
7668/// # ).build().await.unwrap();
7669///
7670/// # let client = hyper_util::client::legacy::Client::builder(
7671/// #     hyper_util::rt::TokioExecutor::new()
7672/// # )
7673/// # .build(
7674/// #     hyper_rustls::HttpsConnectorBuilder::new()
7675/// #         .with_native_roots()
7676/// #         .unwrap()
7677/// #         .https_or_http()
7678/// #         .enable_http2()
7679/// #         .build()
7680/// # );
7681/// # let mut hub = AccessContextManager::new(client, auth);
7682/// // You can configure optional parameters by calling the respective setters at will, and
7683/// // execute the final call using `doit()`.
7684/// // Values shown here are possibly random and not representative !
7685/// let result = hub.access_policies().service_perimeters_list("parent")
7686///              .page_token("no")
7687///              .page_size(-15)
7688///              .doit().await;
7689/// # }
7690/// ```
7691pub struct AccessPolicyServicePerimeterListCall<'a, C>
7692where
7693    C: 'a,
7694{
7695    hub: &'a AccessContextManager<C>,
7696    _parent: String,
7697    _page_token: Option<String>,
7698    _page_size: Option<i32>,
7699    _delegate: Option<&'a mut dyn common::Delegate>,
7700    _additional_params: HashMap<String, String>,
7701    _scopes: BTreeSet<String>,
7702}
7703
7704impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterListCall<'a, C> {}
7705
7706impl<'a, C> AccessPolicyServicePerimeterListCall<'a, C>
7707where
7708    C: common::Connector,
7709{
7710    /// Perform the operation you have build so far.
7711    pub async fn doit(
7712        mut self,
7713    ) -> common::Result<(common::Response, ListServicePerimetersResponse)> {
7714        use std::borrow::Cow;
7715        use std::io::{Read, Seek};
7716
7717        use common::{url::Params, ToParts};
7718        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7719
7720        let mut dd = common::DefaultDelegate;
7721        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7722        dlg.begin(common::MethodInfo {
7723            id: "accesscontextmanager.accessPolicies.servicePerimeters.list",
7724            http_method: hyper::Method::GET,
7725        });
7726
7727        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
7728            if self._additional_params.contains_key(field) {
7729                dlg.finished(false);
7730                return Err(common::Error::FieldClash(field));
7731            }
7732        }
7733
7734        let mut params = Params::with_capacity(5 + self._additional_params.len());
7735        params.push("parent", self._parent);
7736        if let Some(value) = self._page_token.as_ref() {
7737            params.push("pageToken", value);
7738        }
7739        if let Some(value) = self._page_size.as_ref() {
7740            params.push("pageSize", value.to_string());
7741        }
7742
7743        params.extend(self._additional_params.iter());
7744
7745        params.push("alt", "json");
7746        let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters";
7747        if self._scopes.is_empty() {
7748            self._scopes
7749                .insert(Scope::CloudPlatform.as_ref().to_string());
7750        }
7751
7752        #[allow(clippy::single_element_loop)]
7753        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7754            url = params.uri_replacement(url, param_name, find_this, true);
7755        }
7756        {
7757            let to_remove = ["parent"];
7758            params.remove_params(&to_remove);
7759        }
7760
7761        let url = params.parse_with_url(&url);
7762
7763        loop {
7764            let token = match self
7765                .hub
7766                .auth
7767                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7768                .await
7769            {
7770                Ok(token) => token,
7771                Err(e) => match dlg.token(e) {
7772                    Ok(token) => token,
7773                    Err(e) => {
7774                        dlg.finished(false);
7775                        return Err(common::Error::MissingToken(e));
7776                    }
7777                },
7778            };
7779            let mut req_result = {
7780                let client = &self.hub.client;
7781                dlg.pre_request();
7782                let mut req_builder = hyper::Request::builder()
7783                    .method(hyper::Method::GET)
7784                    .uri(url.as_str())
7785                    .header(USER_AGENT, self.hub._user_agent.clone());
7786
7787                if let Some(token) = token.as_ref() {
7788                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7789                }
7790
7791                let request = req_builder
7792                    .header(CONTENT_LENGTH, 0_u64)
7793                    .body(common::to_body::<String>(None));
7794
7795                client.request(request.unwrap()).await
7796            };
7797
7798            match req_result {
7799                Err(err) => {
7800                    if let common::Retry::After(d) = dlg.http_error(&err) {
7801                        sleep(d).await;
7802                        continue;
7803                    }
7804                    dlg.finished(false);
7805                    return Err(common::Error::HttpError(err));
7806                }
7807                Ok(res) => {
7808                    let (mut parts, body) = res.into_parts();
7809                    let mut body = common::Body::new(body);
7810                    if !parts.status.is_success() {
7811                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7812                        let error = serde_json::from_str(&common::to_string(&bytes));
7813                        let response = common::to_response(parts, bytes.into());
7814
7815                        if let common::Retry::After(d) =
7816                            dlg.http_failure(&response, error.as_ref().ok())
7817                        {
7818                            sleep(d).await;
7819                            continue;
7820                        }
7821
7822                        dlg.finished(false);
7823
7824                        return Err(match error {
7825                            Ok(value) => common::Error::BadRequest(value),
7826                            _ => common::Error::Failure(response),
7827                        });
7828                    }
7829                    let response = {
7830                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7831                        let encoded = common::to_string(&bytes);
7832                        match serde_json::from_str(&encoded) {
7833                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7834                            Err(error) => {
7835                                dlg.response_json_decode_error(&encoded, &error);
7836                                return Err(common::Error::JsonDecodeError(
7837                                    encoded.to_string(),
7838                                    error,
7839                                ));
7840                            }
7841                        }
7842                    };
7843
7844                    dlg.finished(true);
7845                    return Ok(response);
7846                }
7847            }
7848        }
7849    }
7850
7851    /// Required. Resource name for the access policy to list Service Perimeters from. Format: `accessPolicies/{policy_id}`
7852    ///
7853    /// Sets the *parent* path property to the given value.
7854    ///
7855    /// Even though the property as already been set when instantiating this call,
7856    /// we provide this method for API completeness.
7857    pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterListCall<'a, C> {
7858        self._parent = new_value.to_string();
7859        self
7860    }
7861    /// Next page token for the next batch of Service Perimeter instances. Defaults to the first page of results.
7862    ///
7863    /// Sets the *page token* query property to the given value.
7864    pub fn page_token(mut self, new_value: &str) -> AccessPolicyServicePerimeterListCall<'a, C> {
7865        self._page_token = Some(new_value.to_string());
7866        self
7867    }
7868    /// Number of Service Perimeters to include in the list. Default 100.
7869    ///
7870    /// Sets the *page size* query property to the given value.
7871    pub fn page_size(mut self, new_value: i32) -> AccessPolicyServicePerimeterListCall<'a, C> {
7872        self._page_size = Some(new_value);
7873        self
7874    }
7875    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7876    /// while executing the actual API request.
7877    ///
7878    /// ````text
7879    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7880    /// ````
7881    ///
7882    /// Sets the *delegate* property to the given value.
7883    pub fn delegate(
7884        mut self,
7885        new_value: &'a mut dyn common::Delegate,
7886    ) -> AccessPolicyServicePerimeterListCall<'a, C> {
7887        self._delegate = Some(new_value);
7888        self
7889    }
7890
7891    /// Set any additional parameter of the query string used in the request.
7892    /// It should be used to set parameters which are not yet available through their own
7893    /// setters.
7894    ///
7895    /// Please note that this method must not be used to set any of the known parameters
7896    /// which have their own setter method. If done anyway, the request will fail.
7897    ///
7898    /// # Additional Parameters
7899    ///
7900    /// * *$.xgafv* (query-string) - V1 error format.
7901    /// * *access_token* (query-string) - OAuth access token.
7902    /// * *alt* (query-string) - Data format for response.
7903    /// * *callback* (query-string) - JSONP
7904    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7905    /// * *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.
7906    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7907    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7908    /// * *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.
7909    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7910    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7911    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterListCall<'a, C>
7912    where
7913        T: AsRef<str>,
7914    {
7915        self._additional_params
7916            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7917        self
7918    }
7919
7920    /// Identifies the authorization scope for the method you are building.
7921    ///
7922    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7923    /// [`Scope::CloudPlatform`].
7924    ///
7925    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7926    /// tokens for more than one scope.
7927    ///
7928    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7929    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7930    /// sufficient, a read-write scope will do as well.
7931    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterListCall<'a, C>
7932    where
7933        St: AsRef<str>,
7934    {
7935        self._scopes.insert(String::from(scope.as_ref()));
7936        self
7937    }
7938    /// Identifies the authorization scope(s) for the method you are building.
7939    ///
7940    /// See [`Self::add_scope()`] for details.
7941    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterListCall<'a, C>
7942    where
7943        I: IntoIterator<Item = St>,
7944        St: AsRef<str>,
7945    {
7946        self._scopes
7947            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7948        self
7949    }
7950
7951    /// Removes all scopes, and no default scope will be used either.
7952    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7953    /// for details).
7954    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterListCall<'a, C> {
7955        self._scopes.clear();
7956        self
7957    }
7958}
7959
7960/// Updates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
7961///
7962/// A builder for the *servicePerimeters.patch* method supported by a *accessPolicy* resource.
7963/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7964///
7965/// # Example
7966///
7967/// Instantiate a resource method builder
7968///
7969/// ```test_harness,no_run
7970/// # extern crate hyper;
7971/// # extern crate hyper_rustls;
7972/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7973/// use accesscontextmanager1::api::ServicePerimeter;
7974/// # async fn dox() {
7975/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7976///
7977/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7978/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7979/// #     .with_native_roots()
7980/// #     .unwrap()
7981/// #     .https_only()
7982/// #     .enable_http2()
7983/// #     .build();
7984///
7985/// # let executor = hyper_util::rt::TokioExecutor::new();
7986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7987/// #     secret,
7988/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7989/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7990/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7991/// #     ),
7992/// # ).build().await.unwrap();
7993///
7994/// # let client = hyper_util::client::legacy::Client::builder(
7995/// #     hyper_util::rt::TokioExecutor::new()
7996/// # )
7997/// # .build(
7998/// #     hyper_rustls::HttpsConnectorBuilder::new()
7999/// #         .with_native_roots()
8000/// #         .unwrap()
8001/// #         .https_or_http()
8002/// #         .enable_http2()
8003/// #         .build()
8004/// # );
8005/// # let mut hub = AccessContextManager::new(client, auth);
8006/// // As the method needs a request, you would usually fill it with the desired information
8007/// // into the respective structure. Some of the parts shown here might not be applicable !
8008/// // Values shown here are possibly random and not representative !
8009/// let mut req = ServicePerimeter::default();
8010///
8011/// // You can configure optional parameters by calling the respective setters at will, and
8012/// // execute the final call using `doit()`.
8013/// // Values shown here are possibly random and not representative !
8014/// let result = hub.access_policies().service_perimeters_patch(req, "name")
8015///              .update_mask(FieldMask::new::<&str>(&[]))
8016///              .doit().await;
8017/// # }
8018/// ```
8019pub struct AccessPolicyServicePerimeterPatchCall<'a, C>
8020where
8021    C: 'a,
8022{
8023    hub: &'a AccessContextManager<C>,
8024    _request: ServicePerimeter,
8025    _name: String,
8026    _update_mask: Option<common::FieldMask>,
8027    _delegate: Option<&'a mut dyn common::Delegate>,
8028    _additional_params: HashMap<String, String>,
8029    _scopes: BTreeSet<String>,
8030}
8031
8032impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterPatchCall<'a, C> {}
8033
8034impl<'a, C> AccessPolicyServicePerimeterPatchCall<'a, C>
8035where
8036    C: common::Connector,
8037{
8038    /// Perform the operation you have build so far.
8039    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8040        use std::borrow::Cow;
8041        use std::io::{Read, Seek};
8042
8043        use common::{url::Params, ToParts};
8044        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8045
8046        let mut dd = common::DefaultDelegate;
8047        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8048        dlg.begin(common::MethodInfo {
8049            id: "accesscontextmanager.accessPolicies.servicePerimeters.patch",
8050            http_method: hyper::Method::PATCH,
8051        });
8052
8053        for &field in ["alt", "name", "updateMask"].iter() {
8054            if self._additional_params.contains_key(field) {
8055                dlg.finished(false);
8056                return Err(common::Error::FieldClash(field));
8057            }
8058        }
8059
8060        let mut params = Params::with_capacity(5 + self._additional_params.len());
8061        params.push("name", self._name);
8062        if let Some(value) = self._update_mask.as_ref() {
8063            params.push("updateMask", value.to_string());
8064        }
8065
8066        params.extend(self._additional_params.iter());
8067
8068        params.push("alt", "json");
8069        let mut url = self.hub._base_url.clone() + "v1/{+name}";
8070        if self._scopes.is_empty() {
8071            self._scopes
8072                .insert(Scope::CloudPlatform.as_ref().to_string());
8073        }
8074
8075        #[allow(clippy::single_element_loop)]
8076        for &(find_this, param_name) in [("{+name}", "name")].iter() {
8077            url = params.uri_replacement(url, param_name, find_this, true);
8078        }
8079        {
8080            let to_remove = ["name"];
8081            params.remove_params(&to_remove);
8082        }
8083
8084        let url = params.parse_with_url(&url);
8085
8086        let mut json_mime_type = mime::APPLICATION_JSON;
8087        let mut request_value_reader = {
8088            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8089            common::remove_json_null_values(&mut value);
8090            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8091            serde_json::to_writer(&mut dst, &value).unwrap();
8092            dst
8093        };
8094        let request_size = request_value_reader
8095            .seek(std::io::SeekFrom::End(0))
8096            .unwrap();
8097        request_value_reader
8098            .seek(std::io::SeekFrom::Start(0))
8099            .unwrap();
8100
8101        loop {
8102            let token = match self
8103                .hub
8104                .auth
8105                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8106                .await
8107            {
8108                Ok(token) => token,
8109                Err(e) => match dlg.token(e) {
8110                    Ok(token) => token,
8111                    Err(e) => {
8112                        dlg.finished(false);
8113                        return Err(common::Error::MissingToken(e));
8114                    }
8115                },
8116            };
8117            request_value_reader
8118                .seek(std::io::SeekFrom::Start(0))
8119                .unwrap();
8120            let mut req_result = {
8121                let client = &self.hub.client;
8122                dlg.pre_request();
8123                let mut req_builder = hyper::Request::builder()
8124                    .method(hyper::Method::PATCH)
8125                    .uri(url.as_str())
8126                    .header(USER_AGENT, self.hub._user_agent.clone());
8127
8128                if let Some(token) = token.as_ref() {
8129                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8130                }
8131
8132                let request = req_builder
8133                    .header(CONTENT_TYPE, json_mime_type.to_string())
8134                    .header(CONTENT_LENGTH, request_size as u64)
8135                    .body(common::to_body(
8136                        request_value_reader.get_ref().clone().into(),
8137                    ));
8138
8139                client.request(request.unwrap()).await
8140            };
8141
8142            match req_result {
8143                Err(err) => {
8144                    if let common::Retry::After(d) = dlg.http_error(&err) {
8145                        sleep(d).await;
8146                        continue;
8147                    }
8148                    dlg.finished(false);
8149                    return Err(common::Error::HttpError(err));
8150                }
8151                Ok(res) => {
8152                    let (mut parts, body) = res.into_parts();
8153                    let mut body = common::Body::new(body);
8154                    if !parts.status.is_success() {
8155                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8156                        let error = serde_json::from_str(&common::to_string(&bytes));
8157                        let response = common::to_response(parts, bytes.into());
8158
8159                        if let common::Retry::After(d) =
8160                            dlg.http_failure(&response, error.as_ref().ok())
8161                        {
8162                            sleep(d).await;
8163                            continue;
8164                        }
8165
8166                        dlg.finished(false);
8167
8168                        return Err(match error {
8169                            Ok(value) => common::Error::BadRequest(value),
8170                            _ => common::Error::Failure(response),
8171                        });
8172                    }
8173                    let response = {
8174                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8175                        let encoded = common::to_string(&bytes);
8176                        match serde_json::from_str(&encoded) {
8177                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8178                            Err(error) => {
8179                                dlg.response_json_decode_error(&encoded, &error);
8180                                return Err(common::Error::JsonDecodeError(
8181                                    encoded.to_string(),
8182                                    error,
8183                                ));
8184                            }
8185                        }
8186                    };
8187
8188                    dlg.finished(true);
8189                    return Ok(response);
8190                }
8191            }
8192        }
8193    }
8194
8195    ///
8196    /// Sets the *request* property to the given value.
8197    ///
8198    /// Even though the property as already been set when instantiating this call,
8199    /// we provide this method for API completeness.
8200    pub fn request(
8201        mut self,
8202        new_value: ServicePerimeter,
8203    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
8204        self._request = new_value;
8205        self
8206    }
8207    /// Identifier. Resource name for the `ServicePerimeter`. Format: `accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}`. The `service_perimeter` component must begin with a letter, followed by alphanumeric characters or `_`. After you create a `ServicePerimeter`, you cannot change its `name`.
8208    ///
8209    /// Sets the *name* path property to the given value.
8210    ///
8211    /// Even though the property as already been set when instantiating this call,
8212    /// we provide this method for API completeness.
8213    pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
8214        self._name = new_value.to_string();
8215        self
8216    }
8217    /// Required. Mask to control which fields get updated. Must be non-empty.
8218    ///
8219    /// Sets the *update mask* query property to the given value.
8220    pub fn update_mask(
8221        mut self,
8222        new_value: common::FieldMask,
8223    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
8224        self._update_mask = Some(new_value);
8225        self
8226    }
8227    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8228    /// while executing the actual API request.
8229    ///
8230    /// ````text
8231    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8232    /// ````
8233    ///
8234    /// Sets the *delegate* property to the given value.
8235    pub fn delegate(
8236        mut self,
8237        new_value: &'a mut dyn common::Delegate,
8238    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
8239        self._delegate = Some(new_value);
8240        self
8241    }
8242
8243    /// Set any additional parameter of the query string used in the request.
8244    /// It should be used to set parameters which are not yet available through their own
8245    /// setters.
8246    ///
8247    /// Please note that this method must not be used to set any of the known parameters
8248    /// which have their own setter method. If done anyway, the request will fail.
8249    ///
8250    /// # Additional Parameters
8251    ///
8252    /// * *$.xgafv* (query-string) - V1 error format.
8253    /// * *access_token* (query-string) - OAuth access token.
8254    /// * *alt* (query-string) - Data format for response.
8255    /// * *callback* (query-string) - JSONP
8256    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8257    /// * *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.
8258    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8259    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8260    /// * *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.
8261    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8262    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8263    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterPatchCall<'a, C>
8264    where
8265        T: AsRef<str>,
8266    {
8267        self._additional_params
8268            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8269        self
8270    }
8271
8272    /// Identifies the authorization scope for the method you are building.
8273    ///
8274    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8275    /// [`Scope::CloudPlatform`].
8276    ///
8277    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8278    /// tokens for more than one scope.
8279    ///
8280    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8281    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8282    /// sufficient, a read-write scope will do as well.
8283    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterPatchCall<'a, C>
8284    where
8285        St: AsRef<str>,
8286    {
8287        self._scopes.insert(String::from(scope.as_ref()));
8288        self
8289    }
8290    /// Identifies the authorization scope(s) for the method you are building.
8291    ///
8292    /// See [`Self::add_scope()`] for details.
8293    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterPatchCall<'a, C>
8294    where
8295        I: IntoIterator<Item = St>,
8296        St: AsRef<str>,
8297    {
8298        self._scopes
8299            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8300        self
8301    }
8302
8303    /// Removes all scopes, and no default scope will be used either.
8304    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8305    /// for details).
8306    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
8307        self._scopes.clear();
8308        self
8309    }
8310}
8311
8312/// Replace all existing service perimeters in an access policy with the service perimeters provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. Replacements containing errors result in an error response for the first error encountered. Upon an error, replacement are cancelled and existing service perimeters are not affected. The Operation.response field contains ReplaceServicePerimetersResponse.
8313///
8314/// A builder for the *servicePerimeters.replaceAll* method supported by a *accessPolicy* resource.
8315/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
8316///
8317/// # Example
8318///
8319/// Instantiate a resource method builder
8320///
8321/// ```test_harness,no_run
8322/// # extern crate hyper;
8323/// # extern crate hyper_rustls;
8324/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
8325/// use accesscontextmanager1::api::ReplaceServicePerimetersRequest;
8326/// # async fn dox() {
8327/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8328///
8329/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8330/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8331/// #     .with_native_roots()
8332/// #     .unwrap()
8333/// #     .https_only()
8334/// #     .enable_http2()
8335/// #     .build();
8336///
8337/// # let executor = hyper_util::rt::TokioExecutor::new();
8338/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8339/// #     secret,
8340/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8341/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8342/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8343/// #     ),
8344/// # ).build().await.unwrap();
8345///
8346/// # let client = hyper_util::client::legacy::Client::builder(
8347/// #     hyper_util::rt::TokioExecutor::new()
8348/// # )
8349/// # .build(
8350/// #     hyper_rustls::HttpsConnectorBuilder::new()
8351/// #         .with_native_roots()
8352/// #         .unwrap()
8353/// #         .https_or_http()
8354/// #         .enable_http2()
8355/// #         .build()
8356/// # );
8357/// # let mut hub = AccessContextManager::new(client, auth);
8358/// // As the method needs a request, you would usually fill it with the desired information
8359/// // into the respective structure. Some of the parts shown here might not be applicable !
8360/// // Values shown here are possibly random and not representative !
8361/// let mut req = ReplaceServicePerimetersRequest::default();
8362///
8363/// // You can configure optional parameters by calling the respective setters at will, and
8364/// // execute the final call using `doit()`.
8365/// // Values shown here are possibly random and not representative !
8366/// let result = hub.access_policies().service_perimeters_replace_all(req, "parent")
8367///              .doit().await;
8368/// # }
8369/// ```
8370pub struct AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8371where
8372    C: 'a,
8373{
8374    hub: &'a AccessContextManager<C>,
8375    _request: ReplaceServicePerimetersRequest,
8376    _parent: String,
8377    _delegate: Option<&'a mut dyn common::Delegate>,
8378    _additional_params: HashMap<String, String>,
8379    _scopes: BTreeSet<String>,
8380}
8381
8382impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterReplaceAllCall<'a, C> {}
8383
8384impl<'a, C> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8385where
8386    C: common::Connector,
8387{
8388    /// Perform the operation you have build so far.
8389    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8390        use std::borrow::Cow;
8391        use std::io::{Read, Seek};
8392
8393        use common::{url::Params, ToParts};
8394        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8395
8396        let mut dd = common::DefaultDelegate;
8397        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8398        dlg.begin(common::MethodInfo {
8399            id: "accesscontextmanager.accessPolicies.servicePerimeters.replaceAll",
8400            http_method: hyper::Method::POST,
8401        });
8402
8403        for &field in ["alt", "parent"].iter() {
8404            if self._additional_params.contains_key(field) {
8405                dlg.finished(false);
8406                return Err(common::Error::FieldClash(field));
8407            }
8408        }
8409
8410        let mut params = Params::with_capacity(4 + self._additional_params.len());
8411        params.push("parent", self._parent);
8412
8413        params.extend(self._additional_params.iter());
8414
8415        params.push("alt", "json");
8416        let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters:replaceAll";
8417        if self._scopes.is_empty() {
8418            self._scopes
8419                .insert(Scope::CloudPlatform.as_ref().to_string());
8420        }
8421
8422        #[allow(clippy::single_element_loop)]
8423        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8424            url = params.uri_replacement(url, param_name, find_this, true);
8425        }
8426        {
8427            let to_remove = ["parent"];
8428            params.remove_params(&to_remove);
8429        }
8430
8431        let url = params.parse_with_url(&url);
8432
8433        let mut json_mime_type = mime::APPLICATION_JSON;
8434        let mut request_value_reader = {
8435            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8436            common::remove_json_null_values(&mut value);
8437            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8438            serde_json::to_writer(&mut dst, &value).unwrap();
8439            dst
8440        };
8441        let request_size = request_value_reader
8442            .seek(std::io::SeekFrom::End(0))
8443            .unwrap();
8444        request_value_reader
8445            .seek(std::io::SeekFrom::Start(0))
8446            .unwrap();
8447
8448        loop {
8449            let token = match self
8450                .hub
8451                .auth
8452                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8453                .await
8454            {
8455                Ok(token) => token,
8456                Err(e) => match dlg.token(e) {
8457                    Ok(token) => token,
8458                    Err(e) => {
8459                        dlg.finished(false);
8460                        return Err(common::Error::MissingToken(e));
8461                    }
8462                },
8463            };
8464            request_value_reader
8465                .seek(std::io::SeekFrom::Start(0))
8466                .unwrap();
8467            let mut req_result = {
8468                let client = &self.hub.client;
8469                dlg.pre_request();
8470                let mut req_builder = hyper::Request::builder()
8471                    .method(hyper::Method::POST)
8472                    .uri(url.as_str())
8473                    .header(USER_AGENT, self.hub._user_agent.clone());
8474
8475                if let Some(token) = token.as_ref() {
8476                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8477                }
8478
8479                let request = req_builder
8480                    .header(CONTENT_TYPE, json_mime_type.to_string())
8481                    .header(CONTENT_LENGTH, request_size as u64)
8482                    .body(common::to_body(
8483                        request_value_reader.get_ref().clone().into(),
8484                    ));
8485
8486                client.request(request.unwrap()).await
8487            };
8488
8489            match req_result {
8490                Err(err) => {
8491                    if let common::Retry::After(d) = dlg.http_error(&err) {
8492                        sleep(d).await;
8493                        continue;
8494                    }
8495                    dlg.finished(false);
8496                    return Err(common::Error::HttpError(err));
8497                }
8498                Ok(res) => {
8499                    let (mut parts, body) = res.into_parts();
8500                    let mut body = common::Body::new(body);
8501                    if !parts.status.is_success() {
8502                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8503                        let error = serde_json::from_str(&common::to_string(&bytes));
8504                        let response = common::to_response(parts, bytes.into());
8505
8506                        if let common::Retry::After(d) =
8507                            dlg.http_failure(&response, error.as_ref().ok())
8508                        {
8509                            sleep(d).await;
8510                            continue;
8511                        }
8512
8513                        dlg.finished(false);
8514
8515                        return Err(match error {
8516                            Ok(value) => common::Error::BadRequest(value),
8517                            _ => common::Error::Failure(response),
8518                        });
8519                    }
8520                    let response = {
8521                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8522                        let encoded = common::to_string(&bytes);
8523                        match serde_json::from_str(&encoded) {
8524                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8525                            Err(error) => {
8526                                dlg.response_json_decode_error(&encoded, &error);
8527                                return Err(common::Error::JsonDecodeError(
8528                                    encoded.to_string(),
8529                                    error,
8530                                ));
8531                            }
8532                        }
8533                    };
8534
8535                    dlg.finished(true);
8536                    return Ok(response);
8537                }
8538            }
8539        }
8540    }
8541
8542    ///
8543    /// Sets the *request* property to the given value.
8544    ///
8545    /// Even though the property as already been set when instantiating this call,
8546    /// we provide this method for API completeness.
8547    pub fn request(
8548        mut self,
8549        new_value: ReplaceServicePerimetersRequest,
8550    ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8551        self._request = new_value;
8552        self
8553    }
8554    /// Required. Resource name for the access policy which owns these Service Perimeters. Format: `accessPolicies/{policy_id}`
8555    ///
8556    /// Sets the *parent* path property to the given value.
8557    ///
8558    /// Even though the property as already been set when instantiating this call,
8559    /// we provide this method for API completeness.
8560    pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8561        self._parent = new_value.to_string();
8562        self
8563    }
8564    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8565    /// while executing the actual API request.
8566    ///
8567    /// ````text
8568    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8569    /// ````
8570    ///
8571    /// Sets the *delegate* property to the given value.
8572    pub fn delegate(
8573        mut self,
8574        new_value: &'a mut dyn common::Delegate,
8575    ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8576        self._delegate = Some(new_value);
8577        self
8578    }
8579
8580    /// Set any additional parameter of the query string used in the request.
8581    /// It should be used to set parameters which are not yet available through their own
8582    /// setters.
8583    ///
8584    /// Please note that this method must not be used to set any of the known parameters
8585    /// which have their own setter method. If done anyway, the request will fail.
8586    ///
8587    /// # Additional Parameters
8588    ///
8589    /// * *$.xgafv* (query-string) - V1 error format.
8590    /// * *access_token* (query-string) - OAuth access token.
8591    /// * *alt* (query-string) - Data format for response.
8592    /// * *callback* (query-string) - JSONP
8593    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8594    /// * *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.
8595    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8596    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8597    /// * *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.
8598    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8599    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8600    pub fn param<T>(
8601        mut self,
8602        name: T,
8603        value: T,
8604    ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8605    where
8606        T: AsRef<str>,
8607    {
8608        self._additional_params
8609            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8610        self
8611    }
8612
8613    /// Identifies the authorization scope for the method you are building.
8614    ///
8615    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8616    /// [`Scope::CloudPlatform`].
8617    ///
8618    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8619    /// tokens for more than one scope.
8620    ///
8621    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8622    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8623    /// sufficient, a read-write scope will do as well.
8624    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8625    where
8626        St: AsRef<str>,
8627    {
8628        self._scopes.insert(String::from(scope.as_ref()));
8629        self
8630    }
8631    /// Identifies the authorization scope(s) for the method you are building.
8632    ///
8633    /// See [`Self::add_scope()`] for details.
8634    pub fn add_scopes<I, St>(
8635        mut self,
8636        scopes: I,
8637    ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8638    where
8639        I: IntoIterator<Item = St>,
8640        St: AsRef<str>,
8641    {
8642        self._scopes
8643            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8644        self
8645    }
8646
8647    /// Removes all scopes, and no default scope will be used either.
8648    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8649    /// for details).
8650    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8651        self._scopes.clear();
8652        self
8653    }
8654}
8655
8656/// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
8657///
8658/// A builder for the *servicePerimeters.testIamPermissions* method supported by a *accessPolicy* resource.
8659/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
8660///
8661/// # Example
8662///
8663/// Instantiate a resource method builder
8664///
8665/// ```test_harness,no_run
8666/// # extern crate hyper;
8667/// # extern crate hyper_rustls;
8668/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
8669/// use accesscontextmanager1::api::TestIamPermissionsRequest;
8670/// # async fn dox() {
8671/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8672///
8673/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8674/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8675/// #     .with_native_roots()
8676/// #     .unwrap()
8677/// #     .https_only()
8678/// #     .enable_http2()
8679/// #     .build();
8680///
8681/// # let executor = hyper_util::rt::TokioExecutor::new();
8682/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8683/// #     secret,
8684/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8685/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
8686/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
8687/// #     ),
8688/// # ).build().await.unwrap();
8689///
8690/// # let client = hyper_util::client::legacy::Client::builder(
8691/// #     hyper_util::rt::TokioExecutor::new()
8692/// # )
8693/// # .build(
8694/// #     hyper_rustls::HttpsConnectorBuilder::new()
8695/// #         .with_native_roots()
8696/// #         .unwrap()
8697/// #         .https_or_http()
8698/// #         .enable_http2()
8699/// #         .build()
8700/// # );
8701/// # let mut hub = AccessContextManager::new(client, auth);
8702/// // As the method needs a request, you would usually fill it with the desired information
8703/// // into the respective structure. Some of the parts shown here might not be applicable !
8704/// // Values shown here are possibly random and not representative !
8705/// let mut req = TestIamPermissionsRequest::default();
8706///
8707/// // You can configure optional parameters by calling the respective setters at will, and
8708/// // execute the final call using `doit()`.
8709/// // Values shown here are possibly random and not representative !
8710/// let result = hub.access_policies().service_perimeters_test_iam_permissions(req, "resource")
8711///              .doit().await;
8712/// # }
8713/// ```
8714pub struct AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8715where
8716    C: 'a,
8717{
8718    hub: &'a AccessContextManager<C>,
8719    _request: TestIamPermissionsRequest,
8720    _resource: String,
8721    _delegate: Option<&'a mut dyn common::Delegate>,
8722    _additional_params: HashMap<String, String>,
8723    _scopes: BTreeSet<String>,
8724}
8725
8726impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {}
8727
8728impl<'a, C> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8729where
8730    C: common::Connector,
8731{
8732    /// Perform the operation you have build so far.
8733    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8734        use std::borrow::Cow;
8735        use std::io::{Read, Seek};
8736
8737        use common::{url::Params, ToParts};
8738        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8739
8740        let mut dd = common::DefaultDelegate;
8741        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8742        dlg.begin(common::MethodInfo {
8743            id: "accesscontextmanager.accessPolicies.servicePerimeters.testIamPermissions",
8744            http_method: hyper::Method::POST,
8745        });
8746
8747        for &field in ["alt", "resource"].iter() {
8748            if self._additional_params.contains_key(field) {
8749                dlg.finished(false);
8750                return Err(common::Error::FieldClash(field));
8751            }
8752        }
8753
8754        let mut params = Params::with_capacity(4 + self._additional_params.len());
8755        params.push("resource", self._resource);
8756
8757        params.extend(self._additional_params.iter());
8758
8759        params.push("alt", "json");
8760        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
8761        if self._scopes.is_empty() {
8762            self._scopes
8763                .insert(Scope::CloudPlatform.as_ref().to_string());
8764        }
8765
8766        #[allow(clippy::single_element_loop)]
8767        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8768            url = params.uri_replacement(url, param_name, find_this, true);
8769        }
8770        {
8771            let to_remove = ["resource"];
8772            params.remove_params(&to_remove);
8773        }
8774
8775        let url = params.parse_with_url(&url);
8776
8777        let mut json_mime_type = mime::APPLICATION_JSON;
8778        let mut request_value_reader = {
8779            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8780            common::remove_json_null_values(&mut value);
8781            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8782            serde_json::to_writer(&mut dst, &value).unwrap();
8783            dst
8784        };
8785        let request_size = request_value_reader
8786            .seek(std::io::SeekFrom::End(0))
8787            .unwrap();
8788        request_value_reader
8789            .seek(std::io::SeekFrom::Start(0))
8790            .unwrap();
8791
8792        loop {
8793            let token = match self
8794                .hub
8795                .auth
8796                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8797                .await
8798            {
8799                Ok(token) => token,
8800                Err(e) => match dlg.token(e) {
8801                    Ok(token) => token,
8802                    Err(e) => {
8803                        dlg.finished(false);
8804                        return Err(common::Error::MissingToken(e));
8805                    }
8806                },
8807            };
8808            request_value_reader
8809                .seek(std::io::SeekFrom::Start(0))
8810                .unwrap();
8811            let mut req_result = {
8812                let client = &self.hub.client;
8813                dlg.pre_request();
8814                let mut req_builder = hyper::Request::builder()
8815                    .method(hyper::Method::POST)
8816                    .uri(url.as_str())
8817                    .header(USER_AGENT, self.hub._user_agent.clone());
8818
8819                if let Some(token) = token.as_ref() {
8820                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8821                }
8822
8823                let request = req_builder
8824                    .header(CONTENT_TYPE, json_mime_type.to_string())
8825                    .header(CONTENT_LENGTH, request_size as u64)
8826                    .body(common::to_body(
8827                        request_value_reader.get_ref().clone().into(),
8828                    ));
8829
8830                client.request(request.unwrap()).await
8831            };
8832
8833            match req_result {
8834                Err(err) => {
8835                    if let common::Retry::After(d) = dlg.http_error(&err) {
8836                        sleep(d).await;
8837                        continue;
8838                    }
8839                    dlg.finished(false);
8840                    return Err(common::Error::HttpError(err));
8841                }
8842                Ok(res) => {
8843                    let (mut parts, body) = res.into_parts();
8844                    let mut body = common::Body::new(body);
8845                    if !parts.status.is_success() {
8846                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8847                        let error = serde_json::from_str(&common::to_string(&bytes));
8848                        let response = common::to_response(parts, bytes.into());
8849
8850                        if let common::Retry::After(d) =
8851                            dlg.http_failure(&response, error.as_ref().ok())
8852                        {
8853                            sleep(d).await;
8854                            continue;
8855                        }
8856
8857                        dlg.finished(false);
8858
8859                        return Err(match error {
8860                            Ok(value) => common::Error::BadRequest(value),
8861                            _ => common::Error::Failure(response),
8862                        });
8863                    }
8864                    let response = {
8865                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8866                        let encoded = common::to_string(&bytes);
8867                        match serde_json::from_str(&encoded) {
8868                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8869                            Err(error) => {
8870                                dlg.response_json_decode_error(&encoded, &error);
8871                                return Err(common::Error::JsonDecodeError(
8872                                    encoded.to_string(),
8873                                    error,
8874                                ));
8875                            }
8876                        }
8877                    };
8878
8879                    dlg.finished(true);
8880                    return Ok(response);
8881                }
8882            }
8883        }
8884    }
8885
8886    ///
8887    /// Sets the *request* property to the given value.
8888    ///
8889    /// Even though the property as already been set when instantiating this call,
8890    /// we provide this method for API completeness.
8891    pub fn request(
8892        mut self,
8893        new_value: TestIamPermissionsRequest,
8894    ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
8895        self._request = new_value;
8896        self
8897    }
8898    /// 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.
8899    ///
8900    /// Sets the *resource* path property to the given value.
8901    ///
8902    /// Even though the property as already been set when instantiating this call,
8903    /// we provide this method for API completeness.
8904    pub fn resource(
8905        mut self,
8906        new_value: &str,
8907    ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
8908        self._resource = new_value.to_string();
8909        self
8910    }
8911    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8912    /// while executing the actual API request.
8913    ///
8914    /// ````text
8915    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8916    /// ````
8917    ///
8918    /// Sets the *delegate* property to the given value.
8919    pub fn delegate(
8920        mut self,
8921        new_value: &'a mut dyn common::Delegate,
8922    ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
8923        self._delegate = Some(new_value);
8924        self
8925    }
8926
8927    /// Set any additional parameter of the query string used in the request.
8928    /// It should be used to set parameters which are not yet available through their own
8929    /// setters.
8930    ///
8931    /// Please note that this method must not be used to set any of the known parameters
8932    /// which have their own setter method. If done anyway, the request will fail.
8933    ///
8934    /// # Additional Parameters
8935    ///
8936    /// * *$.xgafv* (query-string) - V1 error format.
8937    /// * *access_token* (query-string) - OAuth access token.
8938    /// * *alt* (query-string) - Data format for response.
8939    /// * *callback* (query-string) - JSONP
8940    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8941    /// * *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.
8942    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8943    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8944    /// * *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.
8945    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8946    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8947    pub fn param<T>(
8948        mut self,
8949        name: T,
8950        value: T,
8951    ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8952    where
8953        T: AsRef<str>,
8954    {
8955        self._additional_params
8956            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8957        self
8958    }
8959
8960    /// Identifies the authorization scope for the method you are building.
8961    ///
8962    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8963    /// [`Scope::CloudPlatform`].
8964    ///
8965    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8966    /// tokens for more than one scope.
8967    ///
8968    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8969    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8970    /// sufficient, a read-write scope will do as well.
8971    pub fn add_scope<St>(
8972        mut self,
8973        scope: St,
8974    ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8975    where
8976        St: AsRef<str>,
8977    {
8978        self._scopes.insert(String::from(scope.as_ref()));
8979        self
8980    }
8981    /// Identifies the authorization scope(s) for the method you are building.
8982    ///
8983    /// See [`Self::add_scope()`] for details.
8984    pub fn add_scopes<I, St>(
8985        mut self,
8986        scopes: I,
8987    ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8988    where
8989        I: IntoIterator<Item = St>,
8990        St: AsRef<str>,
8991    {
8992        self._scopes
8993            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8994        self
8995    }
8996
8997    /// Removes all scopes, and no default scope will be used either.
8998    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8999    /// for details).
9000    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
9001        self._scopes.clear();
9002        self
9003    }
9004}
9005
9006/// Creates an access policy. This method fails if the organization already has an access policy. The long-running operation has a successful status after the access policy propagates to long-lasting storage. Syntactic and basic semantic errors are returned in `metadata` as a BadRequest proto.
9007///
9008/// A builder for the *create* method supported by a *accessPolicy* resource.
9009/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
9010///
9011/// # Example
9012///
9013/// Instantiate a resource method builder
9014///
9015/// ```test_harness,no_run
9016/// # extern crate hyper;
9017/// # extern crate hyper_rustls;
9018/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
9019/// use accesscontextmanager1::api::AccessPolicy;
9020/// # async fn dox() {
9021/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9022///
9023/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9024/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9025/// #     .with_native_roots()
9026/// #     .unwrap()
9027/// #     .https_only()
9028/// #     .enable_http2()
9029/// #     .build();
9030///
9031/// # let executor = hyper_util::rt::TokioExecutor::new();
9032/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9033/// #     secret,
9034/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9035/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9036/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9037/// #     ),
9038/// # ).build().await.unwrap();
9039///
9040/// # let client = hyper_util::client::legacy::Client::builder(
9041/// #     hyper_util::rt::TokioExecutor::new()
9042/// # )
9043/// # .build(
9044/// #     hyper_rustls::HttpsConnectorBuilder::new()
9045/// #         .with_native_roots()
9046/// #         .unwrap()
9047/// #         .https_or_http()
9048/// #         .enable_http2()
9049/// #         .build()
9050/// # );
9051/// # let mut hub = AccessContextManager::new(client, auth);
9052/// // As the method needs a request, you would usually fill it with the desired information
9053/// // into the respective structure. Some of the parts shown here might not be applicable !
9054/// // Values shown here are possibly random and not representative !
9055/// let mut req = AccessPolicy::default();
9056///
9057/// // You can configure optional parameters by calling the respective setters at will, and
9058/// // execute the final call using `doit()`.
9059/// // Values shown here are possibly random and not representative !
9060/// let result = hub.access_policies().create(req)
9061///              .doit().await;
9062/// # }
9063/// ```
9064pub struct AccessPolicyCreateCall<'a, C>
9065where
9066    C: 'a,
9067{
9068    hub: &'a AccessContextManager<C>,
9069    _request: AccessPolicy,
9070    _delegate: Option<&'a mut dyn common::Delegate>,
9071    _additional_params: HashMap<String, String>,
9072    _scopes: BTreeSet<String>,
9073}
9074
9075impl<'a, C> common::CallBuilder for AccessPolicyCreateCall<'a, C> {}
9076
9077impl<'a, C> AccessPolicyCreateCall<'a, C>
9078where
9079    C: common::Connector,
9080{
9081    /// Perform the operation you have build so far.
9082    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9083        use std::borrow::Cow;
9084        use std::io::{Read, Seek};
9085
9086        use common::{url::Params, ToParts};
9087        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9088
9089        let mut dd = common::DefaultDelegate;
9090        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9091        dlg.begin(common::MethodInfo {
9092            id: "accesscontextmanager.accessPolicies.create",
9093            http_method: hyper::Method::POST,
9094        });
9095
9096        for &field in ["alt"].iter() {
9097            if self._additional_params.contains_key(field) {
9098                dlg.finished(false);
9099                return Err(common::Error::FieldClash(field));
9100            }
9101        }
9102
9103        let mut params = Params::with_capacity(3 + self._additional_params.len());
9104
9105        params.extend(self._additional_params.iter());
9106
9107        params.push("alt", "json");
9108        let mut url = self.hub._base_url.clone() + "v1/accessPolicies";
9109        if self._scopes.is_empty() {
9110            self._scopes
9111                .insert(Scope::CloudPlatform.as_ref().to_string());
9112        }
9113
9114        let url = params.parse_with_url(&url);
9115
9116        let mut json_mime_type = mime::APPLICATION_JSON;
9117        let mut request_value_reader = {
9118            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9119            common::remove_json_null_values(&mut value);
9120            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9121            serde_json::to_writer(&mut dst, &value).unwrap();
9122            dst
9123        };
9124        let request_size = request_value_reader
9125            .seek(std::io::SeekFrom::End(0))
9126            .unwrap();
9127        request_value_reader
9128            .seek(std::io::SeekFrom::Start(0))
9129            .unwrap();
9130
9131        loop {
9132            let token = match self
9133                .hub
9134                .auth
9135                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9136                .await
9137            {
9138                Ok(token) => token,
9139                Err(e) => match dlg.token(e) {
9140                    Ok(token) => token,
9141                    Err(e) => {
9142                        dlg.finished(false);
9143                        return Err(common::Error::MissingToken(e));
9144                    }
9145                },
9146            };
9147            request_value_reader
9148                .seek(std::io::SeekFrom::Start(0))
9149                .unwrap();
9150            let mut req_result = {
9151                let client = &self.hub.client;
9152                dlg.pre_request();
9153                let mut req_builder = hyper::Request::builder()
9154                    .method(hyper::Method::POST)
9155                    .uri(url.as_str())
9156                    .header(USER_AGENT, self.hub._user_agent.clone());
9157
9158                if let Some(token) = token.as_ref() {
9159                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9160                }
9161
9162                let request = req_builder
9163                    .header(CONTENT_TYPE, json_mime_type.to_string())
9164                    .header(CONTENT_LENGTH, request_size as u64)
9165                    .body(common::to_body(
9166                        request_value_reader.get_ref().clone().into(),
9167                    ));
9168
9169                client.request(request.unwrap()).await
9170            };
9171
9172            match req_result {
9173                Err(err) => {
9174                    if let common::Retry::After(d) = dlg.http_error(&err) {
9175                        sleep(d).await;
9176                        continue;
9177                    }
9178                    dlg.finished(false);
9179                    return Err(common::Error::HttpError(err));
9180                }
9181                Ok(res) => {
9182                    let (mut parts, body) = res.into_parts();
9183                    let mut body = common::Body::new(body);
9184                    if !parts.status.is_success() {
9185                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9186                        let error = serde_json::from_str(&common::to_string(&bytes));
9187                        let response = common::to_response(parts, bytes.into());
9188
9189                        if let common::Retry::After(d) =
9190                            dlg.http_failure(&response, error.as_ref().ok())
9191                        {
9192                            sleep(d).await;
9193                            continue;
9194                        }
9195
9196                        dlg.finished(false);
9197
9198                        return Err(match error {
9199                            Ok(value) => common::Error::BadRequest(value),
9200                            _ => common::Error::Failure(response),
9201                        });
9202                    }
9203                    let response = {
9204                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9205                        let encoded = common::to_string(&bytes);
9206                        match serde_json::from_str(&encoded) {
9207                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9208                            Err(error) => {
9209                                dlg.response_json_decode_error(&encoded, &error);
9210                                return Err(common::Error::JsonDecodeError(
9211                                    encoded.to_string(),
9212                                    error,
9213                                ));
9214                            }
9215                        }
9216                    };
9217
9218                    dlg.finished(true);
9219                    return Ok(response);
9220                }
9221            }
9222        }
9223    }
9224
9225    ///
9226    /// Sets the *request* property to the given value.
9227    ///
9228    /// Even though the property as already been set when instantiating this call,
9229    /// we provide this method for API completeness.
9230    pub fn request(mut self, new_value: AccessPolicy) -> AccessPolicyCreateCall<'a, C> {
9231        self._request = new_value;
9232        self
9233    }
9234    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9235    /// while executing the actual API request.
9236    ///
9237    /// ````text
9238    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9239    /// ````
9240    ///
9241    /// Sets the *delegate* property to the given value.
9242    pub fn delegate(
9243        mut self,
9244        new_value: &'a mut dyn common::Delegate,
9245    ) -> AccessPolicyCreateCall<'a, C> {
9246        self._delegate = Some(new_value);
9247        self
9248    }
9249
9250    /// Set any additional parameter of the query string used in the request.
9251    /// It should be used to set parameters which are not yet available through their own
9252    /// setters.
9253    ///
9254    /// Please note that this method must not be used to set any of the known parameters
9255    /// which have their own setter method. If done anyway, the request will fail.
9256    ///
9257    /// # Additional Parameters
9258    ///
9259    /// * *$.xgafv* (query-string) - V1 error format.
9260    /// * *access_token* (query-string) - OAuth access token.
9261    /// * *alt* (query-string) - Data format for response.
9262    /// * *callback* (query-string) - JSONP
9263    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9264    /// * *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.
9265    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9266    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9267    /// * *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.
9268    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9269    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9270    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyCreateCall<'a, C>
9271    where
9272        T: AsRef<str>,
9273    {
9274        self._additional_params
9275            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9276        self
9277    }
9278
9279    /// Identifies the authorization scope for the method you are building.
9280    ///
9281    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9282    /// [`Scope::CloudPlatform`].
9283    ///
9284    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9285    /// tokens for more than one scope.
9286    ///
9287    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9288    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9289    /// sufficient, a read-write scope will do as well.
9290    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyCreateCall<'a, C>
9291    where
9292        St: AsRef<str>,
9293    {
9294        self._scopes.insert(String::from(scope.as_ref()));
9295        self
9296    }
9297    /// Identifies the authorization scope(s) for the method you are building.
9298    ///
9299    /// See [`Self::add_scope()`] for details.
9300    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyCreateCall<'a, C>
9301    where
9302        I: IntoIterator<Item = St>,
9303        St: AsRef<str>,
9304    {
9305        self._scopes
9306            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9307        self
9308    }
9309
9310    /// Removes all scopes, and no default scope will be used either.
9311    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9312    /// for details).
9313    pub fn clear_scopes(mut self) -> AccessPolicyCreateCall<'a, C> {
9314        self._scopes.clear();
9315        self
9316    }
9317}
9318
9319/// Deletes an access policy based on the resource name. The long-running operation has a successful status after the access policy is removed from long-lasting storage.
9320///
9321/// A builder for the *delete* method supported by a *accessPolicy* resource.
9322/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
9323///
9324/// # Example
9325///
9326/// Instantiate a resource method builder
9327///
9328/// ```test_harness,no_run
9329/// # extern crate hyper;
9330/// # extern crate hyper_rustls;
9331/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
9332/// # async fn dox() {
9333/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9334///
9335/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9336/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9337/// #     .with_native_roots()
9338/// #     .unwrap()
9339/// #     .https_only()
9340/// #     .enable_http2()
9341/// #     .build();
9342///
9343/// # let executor = hyper_util::rt::TokioExecutor::new();
9344/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9345/// #     secret,
9346/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9347/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9348/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9349/// #     ),
9350/// # ).build().await.unwrap();
9351///
9352/// # let client = hyper_util::client::legacy::Client::builder(
9353/// #     hyper_util::rt::TokioExecutor::new()
9354/// # )
9355/// # .build(
9356/// #     hyper_rustls::HttpsConnectorBuilder::new()
9357/// #         .with_native_roots()
9358/// #         .unwrap()
9359/// #         .https_or_http()
9360/// #         .enable_http2()
9361/// #         .build()
9362/// # );
9363/// # let mut hub = AccessContextManager::new(client, auth);
9364/// // You can configure optional parameters by calling the respective setters at will, and
9365/// // execute the final call using `doit()`.
9366/// // Values shown here are possibly random and not representative !
9367/// let result = hub.access_policies().delete("name")
9368///              .doit().await;
9369/// # }
9370/// ```
9371pub struct AccessPolicyDeleteCall<'a, C>
9372where
9373    C: 'a,
9374{
9375    hub: &'a AccessContextManager<C>,
9376    _name: String,
9377    _delegate: Option<&'a mut dyn common::Delegate>,
9378    _additional_params: HashMap<String, String>,
9379    _scopes: BTreeSet<String>,
9380}
9381
9382impl<'a, C> common::CallBuilder for AccessPolicyDeleteCall<'a, C> {}
9383
9384impl<'a, C> AccessPolicyDeleteCall<'a, C>
9385where
9386    C: common::Connector,
9387{
9388    /// Perform the operation you have build so far.
9389    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9390        use std::borrow::Cow;
9391        use std::io::{Read, Seek};
9392
9393        use common::{url::Params, ToParts};
9394        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9395
9396        let mut dd = common::DefaultDelegate;
9397        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9398        dlg.begin(common::MethodInfo {
9399            id: "accesscontextmanager.accessPolicies.delete",
9400            http_method: hyper::Method::DELETE,
9401        });
9402
9403        for &field in ["alt", "name"].iter() {
9404            if self._additional_params.contains_key(field) {
9405                dlg.finished(false);
9406                return Err(common::Error::FieldClash(field));
9407            }
9408        }
9409
9410        let mut params = Params::with_capacity(3 + self._additional_params.len());
9411        params.push("name", self._name);
9412
9413        params.extend(self._additional_params.iter());
9414
9415        params.push("alt", "json");
9416        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9417        if self._scopes.is_empty() {
9418            self._scopes
9419                .insert(Scope::CloudPlatform.as_ref().to_string());
9420        }
9421
9422        #[allow(clippy::single_element_loop)]
9423        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9424            url = params.uri_replacement(url, param_name, find_this, true);
9425        }
9426        {
9427            let to_remove = ["name"];
9428            params.remove_params(&to_remove);
9429        }
9430
9431        let url = params.parse_with_url(&url);
9432
9433        loop {
9434            let token = match self
9435                .hub
9436                .auth
9437                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9438                .await
9439            {
9440                Ok(token) => token,
9441                Err(e) => match dlg.token(e) {
9442                    Ok(token) => token,
9443                    Err(e) => {
9444                        dlg.finished(false);
9445                        return Err(common::Error::MissingToken(e));
9446                    }
9447                },
9448            };
9449            let mut req_result = {
9450                let client = &self.hub.client;
9451                dlg.pre_request();
9452                let mut req_builder = hyper::Request::builder()
9453                    .method(hyper::Method::DELETE)
9454                    .uri(url.as_str())
9455                    .header(USER_AGENT, self.hub._user_agent.clone());
9456
9457                if let Some(token) = token.as_ref() {
9458                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9459                }
9460
9461                let request = req_builder
9462                    .header(CONTENT_LENGTH, 0_u64)
9463                    .body(common::to_body::<String>(None));
9464
9465                client.request(request.unwrap()).await
9466            };
9467
9468            match req_result {
9469                Err(err) => {
9470                    if let common::Retry::After(d) = dlg.http_error(&err) {
9471                        sleep(d).await;
9472                        continue;
9473                    }
9474                    dlg.finished(false);
9475                    return Err(common::Error::HttpError(err));
9476                }
9477                Ok(res) => {
9478                    let (mut parts, body) = res.into_parts();
9479                    let mut body = common::Body::new(body);
9480                    if !parts.status.is_success() {
9481                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9482                        let error = serde_json::from_str(&common::to_string(&bytes));
9483                        let response = common::to_response(parts, bytes.into());
9484
9485                        if let common::Retry::After(d) =
9486                            dlg.http_failure(&response, error.as_ref().ok())
9487                        {
9488                            sleep(d).await;
9489                            continue;
9490                        }
9491
9492                        dlg.finished(false);
9493
9494                        return Err(match error {
9495                            Ok(value) => common::Error::BadRequest(value),
9496                            _ => common::Error::Failure(response),
9497                        });
9498                    }
9499                    let response = {
9500                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9501                        let encoded = common::to_string(&bytes);
9502                        match serde_json::from_str(&encoded) {
9503                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9504                            Err(error) => {
9505                                dlg.response_json_decode_error(&encoded, &error);
9506                                return Err(common::Error::JsonDecodeError(
9507                                    encoded.to_string(),
9508                                    error,
9509                                ));
9510                            }
9511                        }
9512                    };
9513
9514                    dlg.finished(true);
9515                    return Ok(response);
9516                }
9517            }
9518        }
9519    }
9520
9521    /// Required. Resource name for the access policy to delete. Format `accessPolicies/{policy_id}`
9522    ///
9523    /// Sets the *name* path property to the given value.
9524    ///
9525    /// Even though the property as already been set when instantiating this call,
9526    /// we provide this method for API completeness.
9527    pub fn name(mut self, new_value: &str) -> AccessPolicyDeleteCall<'a, C> {
9528        self._name = new_value.to_string();
9529        self
9530    }
9531    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9532    /// while executing the actual API request.
9533    ///
9534    /// ````text
9535    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9536    /// ````
9537    ///
9538    /// Sets the *delegate* property to the given value.
9539    pub fn delegate(
9540        mut self,
9541        new_value: &'a mut dyn common::Delegate,
9542    ) -> AccessPolicyDeleteCall<'a, C> {
9543        self._delegate = Some(new_value);
9544        self
9545    }
9546
9547    /// Set any additional parameter of the query string used in the request.
9548    /// It should be used to set parameters which are not yet available through their own
9549    /// setters.
9550    ///
9551    /// Please note that this method must not be used to set any of the known parameters
9552    /// which have their own setter method. If done anyway, the request will fail.
9553    ///
9554    /// # Additional Parameters
9555    ///
9556    /// * *$.xgafv* (query-string) - V1 error format.
9557    /// * *access_token* (query-string) - OAuth access token.
9558    /// * *alt* (query-string) - Data format for response.
9559    /// * *callback* (query-string) - JSONP
9560    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9561    /// * *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.
9562    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9563    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9564    /// * *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.
9565    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9566    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9567    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyDeleteCall<'a, C>
9568    where
9569        T: AsRef<str>,
9570    {
9571        self._additional_params
9572            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9573        self
9574    }
9575
9576    /// Identifies the authorization scope for the method you are building.
9577    ///
9578    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9579    /// [`Scope::CloudPlatform`].
9580    ///
9581    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9582    /// tokens for more than one scope.
9583    ///
9584    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9585    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9586    /// sufficient, a read-write scope will do as well.
9587    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyDeleteCall<'a, C>
9588    where
9589        St: AsRef<str>,
9590    {
9591        self._scopes.insert(String::from(scope.as_ref()));
9592        self
9593    }
9594    /// Identifies the authorization scope(s) for the method you are building.
9595    ///
9596    /// See [`Self::add_scope()`] for details.
9597    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyDeleteCall<'a, C>
9598    where
9599        I: IntoIterator<Item = St>,
9600        St: AsRef<str>,
9601    {
9602        self._scopes
9603            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9604        self
9605    }
9606
9607    /// Removes all scopes, and no default scope will be used either.
9608    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9609    /// for details).
9610    pub fn clear_scopes(mut self) -> AccessPolicyDeleteCall<'a, C> {
9611        self._scopes.clear();
9612        self
9613    }
9614}
9615
9616/// Returns an access policy based on the name.
9617///
9618/// A builder for the *get* method supported by a *accessPolicy* resource.
9619/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
9620///
9621/// # Example
9622///
9623/// Instantiate a resource method builder
9624///
9625/// ```test_harness,no_run
9626/// # extern crate hyper;
9627/// # extern crate hyper_rustls;
9628/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
9629/// # async fn dox() {
9630/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9631///
9632/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9633/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9634/// #     .with_native_roots()
9635/// #     .unwrap()
9636/// #     .https_only()
9637/// #     .enable_http2()
9638/// #     .build();
9639///
9640/// # let executor = hyper_util::rt::TokioExecutor::new();
9641/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9642/// #     secret,
9643/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9644/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9645/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9646/// #     ),
9647/// # ).build().await.unwrap();
9648///
9649/// # let client = hyper_util::client::legacy::Client::builder(
9650/// #     hyper_util::rt::TokioExecutor::new()
9651/// # )
9652/// # .build(
9653/// #     hyper_rustls::HttpsConnectorBuilder::new()
9654/// #         .with_native_roots()
9655/// #         .unwrap()
9656/// #         .https_or_http()
9657/// #         .enable_http2()
9658/// #         .build()
9659/// # );
9660/// # let mut hub = AccessContextManager::new(client, auth);
9661/// // You can configure optional parameters by calling the respective setters at will, and
9662/// // execute the final call using `doit()`.
9663/// // Values shown here are possibly random and not representative !
9664/// let result = hub.access_policies().get("name")
9665///              .doit().await;
9666/// # }
9667/// ```
9668pub struct AccessPolicyGetCall<'a, C>
9669where
9670    C: 'a,
9671{
9672    hub: &'a AccessContextManager<C>,
9673    _name: String,
9674    _delegate: Option<&'a mut dyn common::Delegate>,
9675    _additional_params: HashMap<String, String>,
9676    _scopes: BTreeSet<String>,
9677}
9678
9679impl<'a, C> common::CallBuilder for AccessPolicyGetCall<'a, C> {}
9680
9681impl<'a, C> AccessPolicyGetCall<'a, C>
9682where
9683    C: common::Connector,
9684{
9685    /// Perform the operation you have build so far.
9686    pub async fn doit(mut self) -> common::Result<(common::Response, AccessPolicy)> {
9687        use std::borrow::Cow;
9688        use std::io::{Read, Seek};
9689
9690        use common::{url::Params, ToParts};
9691        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9692
9693        let mut dd = common::DefaultDelegate;
9694        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9695        dlg.begin(common::MethodInfo {
9696            id: "accesscontextmanager.accessPolicies.get",
9697            http_method: hyper::Method::GET,
9698        });
9699
9700        for &field in ["alt", "name"].iter() {
9701            if self._additional_params.contains_key(field) {
9702                dlg.finished(false);
9703                return Err(common::Error::FieldClash(field));
9704            }
9705        }
9706
9707        let mut params = Params::with_capacity(3 + self._additional_params.len());
9708        params.push("name", self._name);
9709
9710        params.extend(self._additional_params.iter());
9711
9712        params.push("alt", "json");
9713        let mut url = self.hub._base_url.clone() + "v1/{+name}";
9714        if self._scopes.is_empty() {
9715            self._scopes
9716                .insert(Scope::CloudPlatform.as_ref().to_string());
9717        }
9718
9719        #[allow(clippy::single_element_loop)]
9720        for &(find_this, param_name) in [("{+name}", "name")].iter() {
9721            url = params.uri_replacement(url, param_name, find_this, true);
9722        }
9723        {
9724            let to_remove = ["name"];
9725            params.remove_params(&to_remove);
9726        }
9727
9728        let url = params.parse_with_url(&url);
9729
9730        loop {
9731            let token = match self
9732                .hub
9733                .auth
9734                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9735                .await
9736            {
9737                Ok(token) => token,
9738                Err(e) => match dlg.token(e) {
9739                    Ok(token) => token,
9740                    Err(e) => {
9741                        dlg.finished(false);
9742                        return Err(common::Error::MissingToken(e));
9743                    }
9744                },
9745            };
9746            let mut req_result = {
9747                let client = &self.hub.client;
9748                dlg.pre_request();
9749                let mut req_builder = hyper::Request::builder()
9750                    .method(hyper::Method::GET)
9751                    .uri(url.as_str())
9752                    .header(USER_AGENT, self.hub._user_agent.clone());
9753
9754                if let Some(token) = token.as_ref() {
9755                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9756                }
9757
9758                let request = req_builder
9759                    .header(CONTENT_LENGTH, 0_u64)
9760                    .body(common::to_body::<String>(None));
9761
9762                client.request(request.unwrap()).await
9763            };
9764
9765            match req_result {
9766                Err(err) => {
9767                    if let common::Retry::After(d) = dlg.http_error(&err) {
9768                        sleep(d).await;
9769                        continue;
9770                    }
9771                    dlg.finished(false);
9772                    return Err(common::Error::HttpError(err));
9773                }
9774                Ok(res) => {
9775                    let (mut parts, body) = res.into_parts();
9776                    let mut body = common::Body::new(body);
9777                    if !parts.status.is_success() {
9778                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9779                        let error = serde_json::from_str(&common::to_string(&bytes));
9780                        let response = common::to_response(parts, bytes.into());
9781
9782                        if let common::Retry::After(d) =
9783                            dlg.http_failure(&response, error.as_ref().ok())
9784                        {
9785                            sleep(d).await;
9786                            continue;
9787                        }
9788
9789                        dlg.finished(false);
9790
9791                        return Err(match error {
9792                            Ok(value) => common::Error::BadRequest(value),
9793                            _ => common::Error::Failure(response),
9794                        });
9795                    }
9796                    let response = {
9797                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9798                        let encoded = common::to_string(&bytes);
9799                        match serde_json::from_str(&encoded) {
9800                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9801                            Err(error) => {
9802                                dlg.response_json_decode_error(&encoded, &error);
9803                                return Err(common::Error::JsonDecodeError(
9804                                    encoded.to_string(),
9805                                    error,
9806                                ));
9807                            }
9808                        }
9809                    };
9810
9811                    dlg.finished(true);
9812                    return Ok(response);
9813                }
9814            }
9815        }
9816    }
9817
9818    /// Required. Resource name for the access policy to get. Format `accessPolicies/{policy_id}`
9819    ///
9820    /// Sets the *name* path property to the given value.
9821    ///
9822    /// Even though the property as already been set when instantiating this call,
9823    /// we provide this method for API completeness.
9824    pub fn name(mut self, new_value: &str) -> AccessPolicyGetCall<'a, C> {
9825        self._name = new_value.to_string();
9826        self
9827    }
9828    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9829    /// while executing the actual API request.
9830    ///
9831    /// ````text
9832    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9833    /// ````
9834    ///
9835    /// Sets the *delegate* property to the given value.
9836    pub fn delegate(
9837        mut self,
9838        new_value: &'a mut dyn common::Delegate,
9839    ) -> AccessPolicyGetCall<'a, C> {
9840        self._delegate = Some(new_value);
9841        self
9842    }
9843
9844    /// Set any additional parameter of the query string used in the request.
9845    /// It should be used to set parameters which are not yet available through their own
9846    /// setters.
9847    ///
9848    /// Please note that this method must not be used to set any of the known parameters
9849    /// which have their own setter method. If done anyway, the request will fail.
9850    ///
9851    /// # Additional Parameters
9852    ///
9853    /// * *$.xgafv* (query-string) - V1 error format.
9854    /// * *access_token* (query-string) - OAuth access token.
9855    /// * *alt* (query-string) - Data format for response.
9856    /// * *callback* (query-string) - JSONP
9857    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9858    /// * *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.
9859    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9860    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9861    /// * *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.
9862    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9863    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9864    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyGetCall<'a, C>
9865    where
9866        T: AsRef<str>,
9867    {
9868        self._additional_params
9869            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9870        self
9871    }
9872
9873    /// Identifies the authorization scope for the method you are building.
9874    ///
9875    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9876    /// [`Scope::CloudPlatform`].
9877    ///
9878    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9879    /// tokens for more than one scope.
9880    ///
9881    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9882    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9883    /// sufficient, a read-write scope will do as well.
9884    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyGetCall<'a, C>
9885    where
9886        St: AsRef<str>,
9887    {
9888        self._scopes.insert(String::from(scope.as_ref()));
9889        self
9890    }
9891    /// Identifies the authorization scope(s) for the method you are building.
9892    ///
9893    /// See [`Self::add_scope()`] for details.
9894    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyGetCall<'a, C>
9895    where
9896        I: IntoIterator<Item = St>,
9897        St: AsRef<str>,
9898    {
9899        self._scopes
9900            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9901        self
9902    }
9903
9904    /// Removes all scopes, and no default scope will be used either.
9905    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9906    /// for details).
9907    pub fn clear_scopes(mut self) -> AccessPolicyGetCall<'a, C> {
9908        self._scopes.clear();
9909        self
9910    }
9911}
9912
9913/// Gets the IAM policy for the specified Access Context Manager access policy.
9914///
9915/// A builder for the *getIamPolicy* method supported by a *accessPolicy* resource.
9916/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
9917///
9918/// # Example
9919///
9920/// Instantiate a resource method builder
9921///
9922/// ```test_harness,no_run
9923/// # extern crate hyper;
9924/// # extern crate hyper_rustls;
9925/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
9926/// use accesscontextmanager1::api::GetIamPolicyRequest;
9927/// # async fn dox() {
9928/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9929///
9930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9931/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9932/// #     .with_native_roots()
9933/// #     .unwrap()
9934/// #     .https_only()
9935/// #     .enable_http2()
9936/// #     .build();
9937///
9938/// # let executor = hyper_util::rt::TokioExecutor::new();
9939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9940/// #     secret,
9941/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9942/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
9943/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
9944/// #     ),
9945/// # ).build().await.unwrap();
9946///
9947/// # let client = hyper_util::client::legacy::Client::builder(
9948/// #     hyper_util::rt::TokioExecutor::new()
9949/// # )
9950/// # .build(
9951/// #     hyper_rustls::HttpsConnectorBuilder::new()
9952/// #         .with_native_roots()
9953/// #         .unwrap()
9954/// #         .https_or_http()
9955/// #         .enable_http2()
9956/// #         .build()
9957/// # );
9958/// # let mut hub = AccessContextManager::new(client, auth);
9959/// // As the method needs a request, you would usually fill it with the desired information
9960/// // into the respective structure. Some of the parts shown here might not be applicable !
9961/// // Values shown here are possibly random and not representative !
9962/// let mut req = GetIamPolicyRequest::default();
9963///
9964/// // You can configure optional parameters by calling the respective setters at will, and
9965/// // execute the final call using `doit()`.
9966/// // Values shown here are possibly random and not representative !
9967/// let result = hub.access_policies().get_iam_policy(req, "resource")
9968///              .doit().await;
9969/// # }
9970/// ```
9971pub struct AccessPolicyGetIamPolicyCall<'a, C>
9972where
9973    C: 'a,
9974{
9975    hub: &'a AccessContextManager<C>,
9976    _request: GetIamPolicyRequest,
9977    _resource: String,
9978    _delegate: Option<&'a mut dyn common::Delegate>,
9979    _additional_params: HashMap<String, String>,
9980    _scopes: BTreeSet<String>,
9981}
9982
9983impl<'a, C> common::CallBuilder for AccessPolicyGetIamPolicyCall<'a, C> {}
9984
9985impl<'a, C> AccessPolicyGetIamPolicyCall<'a, C>
9986where
9987    C: common::Connector,
9988{
9989    /// Perform the operation you have build so far.
9990    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9991        use std::borrow::Cow;
9992        use std::io::{Read, Seek};
9993
9994        use common::{url::Params, ToParts};
9995        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9996
9997        let mut dd = common::DefaultDelegate;
9998        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9999        dlg.begin(common::MethodInfo {
10000            id: "accesscontextmanager.accessPolicies.getIamPolicy",
10001            http_method: hyper::Method::POST,
10002        });
10003
10004        for &field in ["alt", "resource"].iter() {
10005            if self._additional_params.contains_key(field) {
10006                dlg.finished(false);
10007                return Err(common::Error::FieldClash(field));
10008            }
10009        }
10010
10011        let mut params = Params::with_capacity(4 + self._additional_params.len());
10012        params.push("resource", self._resource);
10013
10014        params.extend(self._additional_params.iter());
10015
10016        params.push("alt", "json");
10017        let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
10018        if self._scopes.is_empty() {
10019            self._scopes
10020                .insert(Scope::CloudPlatform.as_ref().to_string());
10021        }
10022
10023        #[allow(clippy::single_element_loop)]
10024        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10025            url = params.uri_replacement(url, param_name, find_this, true);
10026        }
10027        {
10028            let to_remove = ["resource"];
10029            params.remove_params(&to_remove);
10030        }
10031
10032        let url = params.parse_with_url(&url);
10033
10034        let mut json_mime_type = mime::APPLICATION_JSON;
10035        let mut request_value_reader = {
10036            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10037            common::remove_json_null_values(&mut value);
10038            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10039            serde_json::to_writer(&mut dst, &value).unwrap();
10040            dst
10041        };
10042        let request_size = request_value_reader
10043            .seek(std::io::SeekFrom::End(0))
10044            .unwrap();
10045        request_value_reader
10046            .seek(std::io::SeekFrom::Start(0))
10047            .unwrap();
10048
10049        loop {
10050            let token = match self
10051                .hub
10052                .auth
10053                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10054                .await
10055            {
10056                Ok(token) => token,
10057                Err(e) => match dlg.token(e) {
10058                    Ok(token) => token,
10059                    Err(e) => {
10060                        dlg.finished(false);
10061                        return Err(common::Error::MissingToken(e));
10062                    }
10063                },
10064            };
10065            request_value_reader
10066                .seek(std::io::SeekFrom::Start(0))
10067                .unwrap();
10068            let mut req_result = {
10069                let client = &self.hub.client;
10070                dlg.pre_request();
10071                let mut req_builder = hyper::Request::builder()
10072                    .method(hyper::Method::POST)
10073                    .uri(url.as_str())
10074                    .header(USER_AGENT, self.hub._user_agent.clone());
10075
10076                if let Some(token) = token.as_ref() {
10077                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10078                }
10079
10080                let request = req_builder
10081                    .header(CONTENT_TYPE, json_mime_type.to_string())
10082                    .header(CONTENT_LENGTH, request_size as u64)
10083                    .body(common::to_body(
10084                        request_value_reader.get_ref().clone().into(),
10085                    ));
10086
10087                client.request(request.unwrap()).await
10088            };
10089
10090            match req_result {
10091                Err(err) => {
10092                    if let common::Retry::After(d) = dlg.http_error(&err) {
10093                        sleep(d).await;
10094                        continue;
10095                    }
10096                    dlg.finished(false);
10097                    return Err(common::Error::HttpError(err));
10098                }
10099                Ok(res) => {
10100                    let (mut parts, body) = res.into_parts();
10101                    let mut body = common::Body::new(body);
10102                    if !parts.status.is_success() {
10103                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10104                        let error = serde_json::from_str(&common::to_string(&bytes));
10105                        let response = common::to_response(parts, bytes.into());
10106
10107                        if let common::Retry::After(d) =
10108                            dlg.http_failure(&response, error.as_ref().ok())
10109                        {
10110                            sleep(d).await;
10111                            continue;
10112                        }
10113
10114                        dlg.finished(false);
10115
10116                        return Err(match error {
10117                            Ok(value) => common::Error::BadRequest(value),
10118                            _ => common::Error::Failure(response),
10119                        });
10120                    }
10121                    let response = {
10122                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10123                        let encoded = common::to_string(&bytes);
10124                        match serde_json::from_str(&encoded) {
10125                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10126                            Err(error) => {
10127                                dlg.response_json_decode_error(&encoded, &error);
10128                                return Err(common::Error::JsonDecodeError(
10129                                    encoded.to_string(),
10130                                    error,
10131                                ));
10132                            }
10133                        }
10134                    };
10135
10136                    dlg.finished(true);
10137                    return Ok(response);
10138                }
10139            }
10140        }
10141    }
10142
10143    ///
10144    /// Sets the *request* property to the given value.
10145    ///
10146    /// Even though the property as already been set when instantiating this call,
10147    /// we provide this method for API completeness.
10148    pub fn request(
10149        mut self,
10150        new_value: GetIamPolicyRequest,
10151    ) -> AccessPolicyGetIamPolicyCall<'a, C> {
10152        self._request = new_value;
10153        self
10154    }
10155    /// 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.
10156    ///
10157    /// Sets the *resource* path property to the given value.
10158    ///
10159    /// Even though the property as already been set when instantiating this call,
10160    /// we provide this method for API completeness.
10161    pub fn resource(mut self, new_value: &str) -> AccessPolicyGetIamPolicyCall<'a, C> {
10162        self._resource = new_value.to_string();
10163        self
10164    }
10165    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10166    /// while executing the actual API request.
10167    ///
10168    /// ````text
10169    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10170    /// ````
10171    ///
10172    /// Sets the *delegate* property to the given value.
10173    pub fn delegate(
10174        mut self,
10175        new_value: &'a mut dyn common::Delegate,
10176    ) -> AccessPolicyGetIamPolicyCall<'a, C> {
10177        self._delegate = Some(new_value);
10178        self
10179    }
10180
10181    /// Set any additional parameter of the query string used in the request.
10182    /// It should be used to set parameters which are not yet available through their own
10183    /// setters.
10184    ///
10185    /// Please note that this method must not be used to set any of the known parameters
10186    /// which have their own setter method. If done anyway, the request will fail.
10187    ///
10188    /// # Additional Parameters
10189    ///
10190    /// * *$.xgafv* (query-string) - V1 error format.
10191    /// * *access_token* (query-string) - OAuth access token.
10192    /// * *alt* (query-string) - Data format for response.
10193    /// * *callback* (query-string) - JSONP
10194    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10195    /// * *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.
10196    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10197    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10198    /// * *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.
10199    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10200    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10201    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyGetIamPolicyCall<'a, C>
10202    where
10203        T: AsRef<str>,
10204    {
10205        self._additional_params
10206            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10207        self
10208    }
10209
10210    /// Identifies the authorization scope for the method you are building.
10211    ///
10212    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10213    /// [`Scope::CloudPlatform`].
10214    ///
10215    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10216    /// tokens for more than one scope.
10217    ///
10218    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10219    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10220    /// sufficient, a read-write scope will do as well.
10221    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyGetIamPolicyCall<'a, C>
10222    where
10223        St: AsRef<str>,
10224    {
10225        self._scopes.insert(String::from(scope.as_ref()));
10226        self
10227    }
10228    /// Identifies the authorization scope(s) for the method you are building.
10229    ///
10230    /// See [`Self::add_scope()`] for details.
10231    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyGetIamPolicyCall<'a, C>
10232    where
10233        I: IntoIterator<Item = St>,
10234        St: AsRef<str>,
10235    {
10236        self._scopes
10237            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10238        self
10239    }
10240
10241    /// Removes all scopes, and no default scope will be used either.
10242    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10243    /// for details).
10244    pub fn clear_scopes(mut self) -> AccessPolicyGetIamPolicyCall<'a, C> {
10245        self._scopes.clear();
10246        self
10247    }
10248}
10249
10250/// Lists all access policies in an organization.
10251///
10252/// A builder for the *list* method supported by a *accessPolicy* resource.
10253/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
10254///
10255/// # Example
10256///
10257/// Instantiate a resource method builder
10258///
10259/// ```test_harness,no_run
10260/// # extern crate hyper;
10261/// # extern crate hyper_rustls;
10262/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
10263/// # async fn dox() {
10264/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10265///
10266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10267/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10268/// #     .with_native_roots()
10269/// #     .unwrap()
10270/// #     .https_only()
10271/// #     .enable_http2()
10272/// #     .build();
10273///
10274/// # let executor = hyper_util::rt::TokioExecutor::new();
10275/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10276/// #     secret,
10277/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10278/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10279/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10280/// #     ),
10281/// # ).build().await.unwrap();
10282///
10283/// # let client = hyper_util::client::legacy::Client::builder(
10284/// #     hyper_util::rt::TokioExecutor::new()
10285/// # )
10286/// # .build(
10287/// #     hyper_rustls::HttpsConnectorBuilder::new()
10288/// #         .with_native_roots()
10289/// #         .unwrap()
10290/// #         .https_or_http()
10291/// #         .enable_http2()
10292/// #         .build()
10293/// # );
10294/// # let mut hub = AccessContextManager::new(client, auth);
10295/// // You can configure optional parameters by calling the respective setters at will, and
10296/// // execute the final call using `doit()`.
10297/// // Values shown here are possibly random and not representative !
10298/// let result = hub.access_policies().list()
10299///              .parent("erat")
10300///              .page_token("sed")
10301///              .page_size(-20)
10302///              .doit().await;
10303/// # }
10304/// ```
10305pub struct AccessPolicyListCall<'a, C>
10306where
10307    C: 'a,
10308{
10309    hub: &'a AccessContextManager<C>,
10310    _parent: Option<String>,
10311    _page_token: Option<String>,
10312    _page_size: Option<i32>,
10313    _delegate: Option<&'a mut dyn common::Delegate>,
10314    _additional_params: HashMap<String, String>,
10315    _scopes: BTreeSet<String>,
10316}
10317
10318impl<'a, C> common::CallBuilder for AccessPolicyListCall<'a, C> {}
10319
10320impl<'a, C> AccessPolicyListCall<'a, C>
10321where
10322    C: common::Connector,
10323{
10324    /// Perform the operation you have build so far.
10325    pub async fn doit(mut self) -> common::Result<(common::Response, ListAccessPoliciesResponse)> {
10326        use std::borrow::Cow;
10327        use std::io::{Read, Seek};
10328
10329        use common::{url::Params, ToParts};
10330        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10331
10332        let mut dd = common::DefaultDelegate;
10333        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10334        dlg.begin(common::MethodInfo {
10335            id: "accesscontextmanager.accessPolicies.list",
10336            http_method: hyper::Method::GET,
10337        });
10338
10339        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
10340            if self._additional_params.contains_key(field) {
10341                dlg.finished(false);
10342                return Err(common::Error::FieldClash(field));
10343            }
10344        }
10345
10346        let mut params = Params::with_capacity(5 + self._additional_params.len());
10347        if let Some(value) = self._parent.as_ref() {
10348            params.push("parent", value);
10349        }
10350        if let Some(value) = self._page_token.as_ref() {
10351            params.push("pageToken", value);
10352        }
10353        if let Some(value) = self._page_size.as_ref() {
10354            params.push("pageSize", value.to_string());
10355        }
10356
10357        params.extend(self._additional_params.iter());
10358
10359        params.push("alt", "json");
10360        let mut url = self.hub._base_url.clone() + "v1/accessPolicies";
10361        if self._scopes.is_empty() {
10362            self._scopes
10363                .insert(Scope::CloudPlatform.as_ref().to_string());
10364        }
10365
10366        let url = params.parse_with_url(&url);
10367
10368        loop {
10369            let token = match self
10370                .hub
10371                .auth
10372                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10373                .await
10374            {
10375                Ok(token) => token,
10376                Err(e) => match dlg.token(e) {
10377                    Ok(token) => token,
10378                    Err(e) => {
10379                        dlg.finished(false);
10380                        return Err(common::Error::MissingToken(e));
10381                    }
10382                },
10383            };
10384            let mut req_result = {
10385                let client = &self.hub.client;
10386                dlg.pre_request();
10387                let mut req_builder = hyper::Request::builder()
10388                    .method(hyper::Method::GET)
10389                    .uri(url.as_str())
10390                    .header(USER_AGENT, self.hub._user_agent.clone());
10391
10392                if let Some(token) = token.as_ref() {
10393                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10394                }
10395
10396                let request = req_builder
10397                    .header(CONTENT_LENGTH, 0_u64)
10398                    .body(common::to_body::<String>(None));
10399
10400                client.request(request.unwrap()).await
10401            };
10402
10403            match req_result {
10404                Err(err) => {
10405                    if let common::Retry::After(d) = dlg.http_error(&err) {
10406                        sleep(d).await;
10407                        continue;
10408                    }
10409                    dlg.finished(false);
10410                    return Err(common::Error::HttpError(err));
10411                }
10412                Ok(res) => {
10413                    let (mut parts, body) = res.into_parts();
10414                    let mut body = common::Body::new(body);
10415                    if !parts.status.is_success() {
10416                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10417                        let error = serde_json::from_str(&common::to_string(&bytes));
10418                        let response = common::to_response(parts, bytes.into());
10419
10420                        if let common::Retry::After(d) =
10421                            dlg.http_failure(&response, error.as_ref().ok())
10422                        {
10423                            sleep(d).await;
10424                            continue;
10425                        }
10426
10427                        dlg.finished(false);
10428
10429                        return Err(match error {
10430                            Ok(value) => common::Error::BadRequest(value),
10431                            _ => common::Error::Failure(response),
10432                        });
10433                    }
10434                    let response = {
10435                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10436                        let encoded = common::to_string(&bytes);
10437                        match serde_json::from_str(&encoded) {
10438                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10439                            Err(error) => {
10440                                dlg.response_json_decode_error(&encoded, &error);
10441                                return Err(common::Error::JsonDecodeError(
10442                                    encoded.to_string(),
10443                                    error,
10444                                ));
10445                            }
10446                        }
10447                    };
10448
10449                    dlg.finished(true);
10450                    return Ok(response);
10451                }
10452            }
10453        }
10454    }
10455
10456    /// Required. Resource name for the container to list AccessPolicy instances from. Format: `organizations/{org_id}`
10457    ///
10458    /// Sets the *parent* query property to the given value.
10459    pub fn parent(mut self, new_value: &str) -> AccessPolicyListCall<'a, C> {
10460        self._parent = Some(new_value.to_string());
10461        self
10462    }
10463    /// Next page token for the next batch of AccessPolicy instances. Defaults to the first page of results.
10464    ///
10465    /// Sets the *page token* query property to the given value.
10466    pub fn page_token(mut self, new_value: &str) -> AccessPolicyListCall<'a, C> {
10467        self._page_token = Some(new_value.to_string());
10468        self
10469    }
10470    /// Number of AccessPolicy instances to include in the list. Default 100.
10471    ///
10472    /// Sets the *page size* query property to the given value.
10473    pub fn page_size(mut self, new_value: i32) -> AccessPolicyListCall<'a, C> {
10474        self._page_size = Some(new_value);
10475        self
10476    }
10477    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10478    /// while executing the actual API request.
10479    ///
10480    /// ````text
10481    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10482    /// ````
10483    ///
10484    /// Sets the *delegate* property to the given value.
10485    pub fn delegate(
10486        mut self,
10487        new_value: &'a mut dyn common::Delegate,
10488    ) -> AccessPolicyListCall<'a, C> {
10489        self._delegate = Some(new_value);
10490        self
10491    }
10492
10493    /// Set any additional parameter of the query string used in the request.
10494    /// It should be used to set parameters which are not yet available through their own
10495    /// setters.
10496    ///
10497    /// Please note that this method must not be used to set any of the known parameters
10498    /// which have their own setter method. If done anyway, the request will fail.
10499    ///
10500    /// # Additional Parameters
10501    ///
10502    /// * *$.xgafv* (query-string) - V1 error format.
10503    /// * *access_token* (query-string) - OAuth access token.
10504    /// * *alt* (query-string) - Data format for response.
10505    /// * *callback* (query-string) - JSONP
10506    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10507    /// * *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.
10508    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10509    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10510    /// * *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.
10511    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10512    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10513    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyListCall<'a, C>
10514    where
10515        T: AsRef<str>,
10516    {
10517        self._additional_params
10518            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10519        self
10520    }
10521
10522    /// Identifies the authorization scope for the method you are building.
10523    ///
10524    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10525    /// [`Scope::CloudPlatform`].
10526    ///
10527    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10528    /// tokens for more than one scope.
10529    ///
10530    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10531    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10532    /// sufficient, a read-write scope will do as well.
10533    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyListCall<'a, C>
10534    where
10535        St: AsRef<str>,
10536    {
10537        self._scopes.insert(String::from(scope.as_ref()));
10538        self
10539    }
10540    /// Identifies the authorization scope(s) for the method you are building.
10541    ///
10542    /// See [`Self::add_scope()`] for details.
10543    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyListCall<'a, C>
10544    where
10545        I: IntoIterator<Item = St>,
10546        St: AsRef<str>,
10547    {
10548        self._scopes
10549            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10550        self
10551    }
10552
10553    /// Removes all scopes, and no default scope will be used either.
10554    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10555    /// for details).
10556    pub fn clear_scopes(mut self) -> AccessPolicyListCall<'a, C> {
10557        self._scopes.clear();
10558        self
10559    }
10560}
10561
10562/// Updates an access policy. The long-running operation from this RPC has a successful status after the changes to the access policy propagate to long-lasting storage.
10563///
10564/// A builder for the *patch* method supported by a *accessPolicy* resource.
10565/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
10566///
10567/// # Example
10568///
10569/// Instantiate a resource method builder
10570///
10571/// ```test_harness,no_run
10572/// # extern crate hyper;
10573/// # extern crate hyper_rustls;
10574/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
10575/// use accesscontextmanager1::api::AccessPolicy;
10576/// # async fn dox() {
10577/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10578///
10579/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10580/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10581/// #     .with_native_roots()
10582/// #     .unwrap()
10583/// #     .https_only()
10584/// #     .enable_http2()
10585/// #     .build();
10586///
10587/// # let executor = hyper_util::rt::TokioExecutor::new();
10588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10589/// #     secret,
10590/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10591/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10592/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10593/// #     ),
10594/// # ).build().await.unwrap();
10595///
10596/// # let client = hyper_util::client::legacy::Client::builder(
10597/// #     hyper_util::rt::TokioExecutor::new()
10598/// # )
10599/// # .build(
10600/// #     hyper_rustls::HttpsConnectorBuilder::new()
10601/// #         .with_native_roots()
10602/// #         .unwrap()
10603/// #         .https_or_http()
10604/// #         .enable_http2()
10605/// #         .build()
10606/// # );
10607/// # let mut hub = AccessContextManager::new(client, auth);
10608/// // As the method needs a request, you would usually fill it with the desired information
10609/// // into the respective structure. Some of the parts shown here might not be applicable !
10610/// // Values shown here are possibly random and not representative !
10611/// let mut req = AccessPolicy::default();
10612///
10613/// // You can configure optional parameters by calling the respective setters at will, and
10614/// // execute the final call using `doit()`.
10615/// // Values shown here are possibly random and not representative !
10616/// let result = hub.access_policies().patch(req, "name")
10617///              .update_mask(FieldMask::new::<&str>(&[]))
10618///              .doit().await;
10619/// # }
10620/// ```
10621pub struct AccessPolicyPatchCall<'a, C>
10622where
10623    C: 'a,
10624{
10625    hub: &'a AccessContextManager<C>,
10626    _request: AccessPolicy,
10627    _name: String,
10628    _update_mask: Option<common::FieldMask>,
10629    _delegate: Option<&'a mut dyn common::Delegate>,
10630    _additional_params: HashMap<String, String>,
10631    _scopes: BTreeSet<String>,
10632}
10633
10634impl<'a, C> common::CallBuilder for AccessPolicyPatchCall<'a, C> {}
10635
10636impl<'a, C> AccessPolicyPatchCall<'a, C>
10637where
10638    C: common::Connector,
10639{
10640    /// Perform the operation you have build so far.
10641    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10642        use std::borrow::Cow;
10643        use std::io::{Read, Seek};
10644
10645        use common::{url::Params, ToParts};
10646        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10647
10648        let mut dd = common::DefaultDelegate;
10649        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10650        dlg.begin(common::MethodInfo {
10651            id: "accesscontextmanager.accessPolicies.patch",
10652            http_method: hyper::Method::PATCH,
10653        });
10654
10655        for &field in ["alt", "name", "updateMask"].iter() {
10656            if self._additional_params.contains_key(field) {
10657                dlg.finished(false);
10658                return Err(common::Error::FieldClash(field));
10659            }
10660        }
10661
10662        let mut params = Params::with_capacity(5 + self._additional_params.len());
10663        params.push("name", self._name);
10664        if let Some(value) = self._update_mask.as_ref() {
10665            params.push("updateMask", value.to_string());
10666        }
10667
10668        params.extend(self._additional_params.iter());
10669
10670        params.push("alt", "json");
10671        let mut url = self.hub._base_url.clone() + "v1/{+name}";
10672        if self._scopes.is_empty() {
10673            self._scopes
10674                .insert(Scope::CloudPlatform.as_ref().to_string());
10675        }
10676
10677        #[allow(clippy::single_element_loop)]
10678        for &(find_this, param_name) in [("{+name}", "name")].iter() {
10679            url = params.uri_replacement(url, param_name, find_this, true);
10680        }
10681        {
10682            let to_remove = ["name"];
10683            params.remove_params(&to_remove);
10684        }
10685
10686        let url = params.parse_with_url(&url);
10687
10688        let mut json_mime_type = mime::APPLICATION_JSON;
10689        let mut request_value_reader = {
10690            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10691            common::remove_json_null_values(&mut value);
10692            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10693            serde_json::to_writer(&mut dst, &value).unwrap();
10694            dst
10695        };
10696        let request_size = request_value_reader
10697            .seek(std::io::SeekFrom::End(0))
10698            .unwrap();
10699        request_value_reader
10700            .seek(std::io::SeekFrom::Start(0))
10701            .unwrap();
10702
10703        loop {
10704            let token = match self
10705                .hub
10706                .auth
10707                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10708                .await
10709            {
10710                Ok(token) => token,
10711                Err(e) => match dlg.token(e) {
10712                    Ok(token) => token,
10713                    Err(e) => {
10714                        dlg.finished(false);
10715                        return Err(common::Error::MissingToken(e));
10716                    }
10717                },
10718            };
10719            request_value_reader
10720                .seek(std::io::SeekFrom::Start(0))
10721                .unwrap();
10722            let mut req_result = {
10723                let client = &self.hub.client;
10724                dlg.pre_request();
10725                let mut req_builder = hyper::Request::builder()
10726                    .method(hyper::Method::PATCH)
10727                    .uri(url.as_str())
10728                    .header(USER_AGENT, self.hub._user_agent.clone());
10729
10730                if let Some(token) = token.as_ref() {
10731                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10732                }
10733
10734                let request = req_builder
10735                    .header(CONTENT_TYPE, json_mime_type.to_string())
10736                    .header(CONTENT_LENGTH, request_size as u64)
10737                    .body(common::to_body(
10738                        request_value_reader.get_ref().clone().into(),
10739                    ));
10740
10741                client.request(request.unwrap()).await
10742            };
10743
10744            match req_result {
10745                Err(err) => {
10746                    if let common::Retry::After(d) = dlg.http_error(&err) {
10747                        sleep(d).await;
10748                        continue;
10749                    }
10750                    dlg.finished(false);
10751                    return Err(common::Error::HttpError(err));
10752                }
10753                Ok(res) => {
10754                    let (mut parts, body) = res.into_parts();
10755                    let mut body = common::Body::new(body);
10756                    if !parts.status.is_success() {
10757                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10758                        let error = serde_json::from_str(&common::to_string(&bytes));
10759                        let response = common::to_response(parts, bytes.into());
10760
10761                        if let common::Retry::After(d) =
10762                            dlg.http_failure(&response, error.as_ref().ok())
10763                        {
10764                            sleep(d).await;
10765                            continue;
10766                        }
10767
10768                        dlg.finished(false);
10769
10770                        return Err(match error {
10771                            Ok(value) => common::Error::BadRequest(value),
10772                            _ => common::Error::Failure(response),
10773                        });
10774                    }
10775                    let response = {
10776                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10777                        let encoded = common::to_string(&bytes);
10778                        match serde_json::from_str(&encoded) {
10779                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10780                            Err(error) => {
10781                                dlg.response_json_decode_error(&encoded, &error);
10782                                return Err(common::Error::JsonDecodeError(
10783                                    encoded.to_string(),
10784                                    error,
10785                                ));
10786                            }
10787                        }
10788                    };
10789
10790                    dlg.finished(true);
10791                    return Ok(response);
10792                }
10793            }
10794        }
10795    }
10796
10797    ///
10798    /// Sets the *request* property to the given value.
10799    ///
10800    /// Even though the property as already been set when instantiating this call,
10801    /// we provide this method for API completeness.
10802    pub fn request(mut self, new_value: AccessPolicy) -> AccessPolicyPatchCall<'a, C> {
10803        self._request = new_value;
10804        self
10805    }
10806    /// Output only. Identifier. Resource name of the `AccessPolicy`. Format: `accessPolicies/{access_policy}`
10807    ///
10808    /// Sets the *name* path property to the given value.
10809    ///
10810    /// Even though the property as already been set when instantiating this call,
10811    /// we provide this method for API completeness.
10812    pub fn name(mut self, new_value: &str) -> AccessPolicyPatchCall<'a, C> {
10813        self._name = new_value.to_string();
10814        self
10815    }
10816    /// Required. Mask to control which fields get updated. Must be non-empty.
10817    ///
10818    /// Sets the *update mask* query property to the given value.
10819    pub fn update_mask(mut self, new_value: common::FieldMask) -> AccessPolicyPatchCall<'a, C> {
10820        self._update_mask = Some(new_value);
10821        self
10822    }
10823    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10824    /// while executing the actual API request.
10825    ///
10826    /// ````text
10827    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10828    /// ````
10829    ///
10830    /// Sets the *delegate* property to the given value.
10831    pub fn delegate(
10832        mut self,
10833        new_value: &'a mut dyn common::Delegate,
10834    ) -> AccessPolicyPatchCall<'a, C> {
10835        self._delegate = Some(new_value);
10836        self
10837    }
10838
10839    /// Set any additional parameter of the query string used in the request.
10840    /// It should be used to set parameters which are not yet available through their own
10841    /// setters.
10842    ///
10843    /// Please note that this method must not be used to set any of the known parameters
10844    /// which have their own setter method. If done anyway, the request will fail.
10845    ///
10846    /// # Additional Parameters
10847    ///
10848    /// * *$.xgafv* (query-string) - V1 error format.
10849    /// * *access_token* (query-string) - OAuth access token.
10850    /// * *alt* (query-string) - Data format for response.
10851    /// * *callback* (query-string) - JSONP
10852    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10853    /// * *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.
10854    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10855    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10856    /// * *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.
10857    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10858    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10859    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyPatchCall<'a, C>
10860    where
10861        T: AsRef<str>,
10862    {
10863        self._additional_params
10864            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10865        self
10866    }
10867
10868    /// Identifies the authorization scope for the method you are building.
10869    ///
10870    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10871    /// [`Scope::CloudPlatform`].
10872    ///
10873    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10874    /// tokens for more than one scope.
10875    ///
10876    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10877    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10878    /// sufficient, a read-write scope will do as well.
10879    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyPatchCall<'a, C>
10880    where
10881        St: AsRef<str>,
10882    {
10883        self._scopes.insert(String::from(scope.as_ref()));
10884        self
10885    }
10886    /// Identifies the authorization scope(s) for the method you are building.
10887    ///
10888    /// See [`Self::add_scope()`] for details.
10889    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyPatchCall<'a, C>
10890    where
10891        I: IntoIterator<Item = St>,
10892        St: AsRef<str>,
10893    {
10894        self._scopes
10895            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10896        self
10897    }
10898
10899    /// Removes all scopes, and no default scope will be used either.
10900    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10901    /// for details).
10902    pub fn clear_scopes(mut self) -> AccessPolicyPatchCall<'a, C> {
10903        self._scopes.clear();
10904        self
10905    }
10906}
10907
10908/// Sets the IAM policy for the specified Access Context Manager access policy. This method replaces the existing IAM policy on the access policy. The IAM policy controls the set of users who can perform specific operations on the Access Context Manager access policy.
10909///
10910/// A builder for the *setIamPolicy* method supported by a *accessPolicy* resource.
10911/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
10912///
10913/// # Example
10914///
10915/// Instantiate a resource method builder
10916///
10917/// ```test_harness,no_run
10918/// # extern crate hyper;
10919/// # extern crate hyper_rustls;
10920/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
10921/// use accesscontextmanager1::api::SetIamPolicyRequest;
10922/// # async fn dox() {
10923/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10924///
10925/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10926/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10927/// #     .with_native_roots()
10928/// #     .unwrap()
10929/// #     .https_only()
10930/// #     .enable_http2()
10931/// #     .build();
10932///
10933/// # let executor = hyper_util::rt::TokioExecutor::new();
10934/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10935/// #     secret,
10936/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10937/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
10938/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
10939/// #     ),
10940/// # ).build().await.unwrap();
10941///
10942/// # let client = hyper_util::client::legacy::Client::builder(
10943/// #     hyper_util::rt::TokioExecutor::new()
10944/// # )
10945/// # .build(
10946/// #     hyper_rustls::HttpsConnectorBuilder::new()
10947/// #         .with_native_roots()
10948/// #         .unwrap()
10949/// #         .https_or_http()
10950/// #         .enable_http2()
10951/// #         .build()
10952/// # );
10953/// # let mut hub = AccessContextManager::new(client, auth);
10954/// // As the method needs a request, you would usually fill it with the desired information
10955/// // into the respective structure. Some of the parts shown here might not be applicable !
10956/// // Values shown here are possibly random and not representative !
10957/// let mut req = SetIamPolicyRequest::default();
10958///
10959/// // You can configure optional parameters by calling the respective setters at will, and
10960/// // execute the final call using `doit()`.
10961/// // Values shown here are possibly random and not representative !
10962/// let result = hub.access_policies().set_iam_policy(req, "resource")
10963///              .doit().await;
10964/// # }
10965/// ```
10966pub struct AccessPolicySetIamPolicyCall<'a, C>
10967where
10968    C: 'a,
10969{
10970    hub: &'a AccessContextManager<C>,
10971    _request: SetIamPolicyRequest,
10972    _resource: String,
10973    _delegate: Option<&'a mut dyn common::Delegate>,
10974    _additional_params: HashMap<String, String>,
10975    _scopes: BTreeSet<String>,
10976}
10977
10978impl<'a, C> common::CallBuilder for AccessPolicySetIamPolicyCall<'a, C> {}
10979
10980impl<'a, C> AccessPolicySetIamPolicyCall<'a, C>
10981where
10982    C: common::Connector,
10983{
10984    /// Perform the operation you have build so far.
10985    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10986        use std::borrow::Cow;
10987        use std::io::{Read, Seek};
10988
10989        use common::{url::Params, ToParts};
10990        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10991
10992        let mut dd = common::DefaultDelegate;
10993        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10994        dlg.begin(common::MethodInfo {
10995            id: "accesscontextmanager.accessPolicies.setIamPolicy",
10996            http_method: hyper::Method::POST,
10997        });
10998
10999        for &field in ["alt", "resource"].iter() {
11000            if self._additional_params.contains_key(field) {
11001                dlg.finished(false);
11002                return Err(common::Error::FieldClash(field));
11003            }
11004        }
11005
11006        let mut params = Params::with_capacity(4 + self._additional_params.len());
11007        params.push("resource", self._resource);
11008
11009        params.extend(self._additional_params.iter());
11010
11011        params.push("alt", "json");
11012        let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
11013        if self._scopes.is_empty() {
11014            self._scopes
11015                .insert(Scope::CloudPlatform.as_ref().to_string());
11016        }
11017
11018        #[allow(clippy::single_element_loop)]
11019        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11020            url = params.uri_replacement(url, param_name, find_this, true);
11021        }
11022        {
11023            let to_remove = ["resource"];
11024            params.remove_params(&to_remove);
11025        }
11026
11027        let url = params.parse_with_url(&url);
11028
11029        let mut json_mime_type = mime::APPLICATION_JSON;
11030        let mut request_value_reader = {
11031            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11032            common::remove_json_null_values(&mut value);
11033            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11034            serde_json::to_writer(&mut dst, &value).unwrap();
11035            dst
11036        };
11037        let request_size = request_value_reader
11038            .seek(std::io::SeekFrom::End(0))
11039            .unwrap();
11040        request_value_reader
11041            .seek(std::io::SeekFrom::Start(0))
11042            .unwrap();
11043
11044        loop {
11045            let token = match self
11046                .hub
11047                .auth
11048                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11049                .await
11050            {
11051                Ok(token) => token,
11052                Err(e) => match dlg.token(e) {
11053                    Ok(token) => token,
11054                    Err(e) => {
11055                        dlg.finished(false);
11056                        return Err(common::Error::MissingToken(e));
11057                    }
11058                },
11059            };
11060            request_value_reader
11061                .seek(std::io::SeekFrom::Start(0))
11062                .unwrap();
11063            let mut req_result = {
11064                let client = &self.hub.client;
11065                dlg.pre_request();
11066                let mut req_builder = hyper::Request::builder()
11067                    .method(hyper::Method::POST)
11068                    .uri(url.as_str())
11069                    .header(USER_AGENT, self.hub._user_agent.clone());
11070
11071                if let Some(token) = token.as_ref() {
11072                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11073                }
11074
11075                let request = req_builder
11076                    .header(CONTENT_TYPE, json_mime_type.to_string())
11077                    .header(CONTENT_LENGTH, request_size as u64)
11078                    .body(common::to_body(
11079                        request_value_reader.get_ref().clone().into(),
11080                    ));
11081
11082                client.request(request.unwrap()).await
11083            };
11084
11085            match req_result {
11086                Err(err) => {
11087                    if let common::Retry::After(d) = dlg.http_error(&err) {
11088                        sleep(d).await;
11089                        continue;
11090                    }
11091                    dlg.finished(false);
11092                    return Err(common::Error::HttpError(err));
11093                }
11094                Ok(res) => {
11095                    let (mut parts, body) = res.into_parts();
11096                    let mut body = common::Body::new(body);
11097                    if !parts.status.is_success() {
11098                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11099                        let error = serde_json::from_str(&common::to_string(&bytes));
11100                        let response = common::to_response(parts, bytes.into());
11101
11102                        if let common::Retry::After(d) =
11103                            dlg.http_failure(&response, error.as_ref().ok())
11104                        {
11105                            sleep(d).await;
11106                            continue;
11107                        }
11108
11109                        dlg.finished(false);
11110
11111                        return Err(match error {
11112                            Ok(value) => common::Error::BadRequest(value),
11113                            _ => common::Error::Failure(response),
11114                        });
11115                    }
11116                    let response = {
11117                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11118                        let encoded = common::to_string(&bytes);
11119                        match serde_json::from_str(&encoded) {
11120                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11121                            Err(error) => {
11122                                dlg.response_json_decode_error(&encoded, &error);
11123                                return Err(common::Error::JsonDecodeError(
11124                                    encoded.to_string(),
11125                                    error,
11126                                ));
11127                            }
11128                        }
11129                    };
11130
11131                    dlg.finished(true);
11132                    return Ok(response);
11133                }
11134            }
11135        }
11136    }
11137
11138    ///
11139    /// Sets the *request* property to the given value.
11140    ///
11141    /// Even though the property as already been set when instantiating this call,
11142    /// we provide this method for API completeness.
11143    pub fn request(
11144        mut self,
11145        new_value: SetIamPolicyRequest,
11146    ) -> AccessPolicySetIamPolicyCall<'a, C> {
11147        self._request = new_value;
11148        self
11149    }
11150    /// 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.
11151    ///
11152    /// Sets the *resource* path property to the given value.
11153    ///
11154    /// Even though the property as already been set when instantiating this call,
11155    /// we provide this method for API completeness.
11156    pub fn resource(mut self, new_value: &str) -> AccessPolicySetIamPolicyCall<'a, C> {
11157        self._resource = new_value.to_string();
11158        self
11159    }
11160    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11161    /// while executing the actual API request.
11162    ///
11163    /// ````text
11164    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11165    /// ````
11166    ///
11167    /// Sets the *delegate* property to the given value.
11168    pub fn delegate(
11169        mut self,
11170        new_value: &'a mut dyn common::Delegate,
11171    ) -> AccessPolicySetIamPolicyCall<'a, C> {
11172        self._delegate = Some(new_value);
11173        self
11174    }
11175
11176    /// Set any additional parameter of the query string used in the request.
11177    /// It should be used to set parameters which are not yet available through their own
11178    /// setters.
11179    ///
11180    /// Please note that this method must not be used to set any of the known parameters
11181    /// which have their own setter method. If done anyway, the request will fail.
11182    ///
11183    /// # Additional Parameters
11184    ///
11185    /// * *$.xgafv* (query-string) - V1 error format.
11186    /// * *access_token* (query-string) - OAuth access token.
11187    /// * *alt* (query-string) - Data format for response.
11188    /// * *callback* (query-string) - JSONP
11189    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11190    /// * *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.
11191    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11192    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11193    /// * *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.
11194    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11195    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11196    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicySetIamPolicyCall<'a, C>
11197    where
11198        T: AsRef<str>,
11199    {
11200        self._additional_params
11201            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11202        self
11203    }
11204
11205    /// Identifies the authorization scope for the method you are building.
11206    ///
11207    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11208    /// [`Scope::CloudPlatform`].
11209    ///
11210    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11211    /// tokens for more than one scope.
11212    ///
11213    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11214    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11215    /// sufficient, a read-write scope will do as well.
11216    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicySetIamPolicyCall<'a, C>
11217    where
11218        St: AsRef<str>,
11219    {
11220        self._scopes.insert(String::from(scope.as_ref()));
11221        self
11222    }
11223    /// Identifies the authorization scope(s) for the method you are building.
11224    ///
11225    /// See [`Self::add_scope()`] for details.
11226    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicySetIamPolicyCall<'a, C>
11227    where
11228        I: IntoIterator<Item = St>,
11229        St: AsRef<str>,
11230    {
11231        self._scopes
11232            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11233        self
11234    }
11235
11236    /// Removes all scopes, and no default scope will be used either.
11237    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11238    /// for details).
11239    pub fn clear_scopes(mut self) -> AccessPolicySetIamPolicyCall<'a, C> {
11240        self._scopes.clear();
11241        self
11242    }
11243}
11244
11245/// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
11246///
11247/// A builder for the *testIamPermissions* method supported by a *accessPolicy* resource.
11248/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
11249///
11250/// # Example
11251///
11252/// Instantiate a resource method builder
11253///
11254/// ```test_harness,no_run
11255/// # extern crate hyper;
11256/// # extern crate hyper_rustls;
11257/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
11258/// use accesscontextmanager1::api::TestIamPermissionsRequest;
11259/// # async fn dox() {
11260/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11261///
11262/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11263/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11264/// #     .with_native_roots()
11265/// #     .unwrap()
11266/// #     .https_only()
11267/// #     .enable_http2()
11268/// #     .build();
11269///
11270/// # let executor = hyper_util::rt::TokioExecutor::new();
11271/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11272/// #     secret,
11273/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11274/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11275/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11276/// #     ),
11277/// # ).build().await.unwrap();
11278///
11279/// # let client = hyper_util::client::legacy::Client::builder(
11280/// #     hyper_util::rt::TokioExecutor::new()
11281/// # )
11282/// # .build(
11283/// #     hyper_rustls::HttpsConnectorBuilder::new()
11284/// #         .with_native_roots()
11285/// #         .unwrap()
11286/// #         .https_or_http()
11287/// #         .enable_http2()
11288/// #         .build()
11289/// # );
11290/// # let mut hub = AccessContextManager::new(client, auth);
11291/// // As the method needs a request, you would usually fill it with the desired information
11292/// // into the respective structure. Some of the parts shown here might not be applicable !
11293/// // Values shown here are possibly random and not representative !
11294/// let mut req = TestIamPermissionsRequest::default();
11295///
11296/// // You can configure optional parameters by calling the respective setters at will, and
11297/// // execute the final call using `doit()`.
11298/// // Values shown here are possibly random and not representative !
11299/// let result = hub.access_policies().test_iam_permissions(req, "resource")
11300///              .doit().await;
11301/// # }
11302/// ```
11303pub struct AccessPolicyTestIamPermissionCall<'a, C>
11304where
11305    C: 'a,
11306{
11307    hub: &'a AccessContextManager<C>,
11308    _request: TestIamPermissionsRequest,
11309    _resource: String,
11310    _delegate: Option<&'a mut dyn common::Delegate>,
11311    _additional_params: HashMap<String, String>,
11312    _scopes: BTreeSet<String>,
11313}
11314
11315impl<'a, C> common::CallBuilder for AccessPolicyTestIamPermissionCall<'a, C> {}
11316
11317impl<'a, C> AccessPolicyTestIamPermissionCall<'a, C>
11318where
11319    C: common::Connector,
11320{
11321    /// Perform the operation you have build so far.
11322    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
11323        use std::borrow::Cow;
11324        use std::io::{Read, Seek};
11325
11326        use common::{url::Params, ToParts};
11327        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11328
11329        let mut dd = common::DefaultDelegate;
11330        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11331        dlg.begin(common::MethodInfo {
11332            id: "accesscontextmanager.accessPolicies.testIamPermissions",
11333            http_method: hyper::Method::POST,
11334        });
11335
11336        for &field in ["alt", "resource"].iter() {
11337            if self._additional_params.contains_key(field) {
11338                dlg.finished(false);
11339                return Err(common::Error::FieldClash(field));
11340            }
11341        }
11342
11343        let mut params = Params::with_capacity(4 + self._additional_params.len());
11344        params.push("resource", self._resource);
11345
11346        params.extend(self._additional_params.iter());
11347
11348        params.push("alt", "json");
11349        let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
11350        if self._scopes.is_empty() {
11351            self._scopes
11352                .insert(Scope::CloudPlatform.as_ref().to_string());
11353        }
11354
11355        #[allow(clippy::single_element_loop)]
11356        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
11357            url = params.uri_replacement(url, param_name, find_this, true);
11358        }
11359        {
11360            let to_remove = ["resource"];
11361            params.remove_params(&to_remove);
11362        }
11363
11364        let url = params.parse_with_url(&url);
11365
11366        let mut json_mime_type = mime::APPLICATION_JSON;
11367        let mut request_value_reader = {
11368            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11369            common::remove_json_null_values(&mut value);
11370            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11371            serde_json::to_writer(&mut dst, &value).unwrap();
11372            dst
11373        };
11374        let request_size = request_value_reader
11375            .seek(std::io::SeekFrom::End(0))
11376            .unwrap();
11377        request_value_reader
11378            .seek(std::io::SeekFrom::Start(0))
11379            .unwrap();
11380
11381        loop {
11382            let token = match self
11383                .hub
11384                .auth
11385                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11386                .await
11387            {
11388                Ok(token) => token,
11389                Err(e) => match dlg.token(e) {
11390                    Ok(token) => token,
11391                    Err(e) => {
11392                        dlg.finished(false);
11393                        return Err(common::Error::MissingToken(e));
11394                    }
11395                },
11396            };
11397            request_value_reader
11398                .seek(std::io::SeekFrom::Start(0))
11399                .unwrap();
11400            let mut req_result = {
11401                let client = &self.hub.client;
11402                dlg.pre_request();
11403                let mut req_builder = hyper::Request::builder()
11404                    .method(hyper::Method::POST)
11405                    .uri(url.as_str())
11406                    .header(USER_AGENT, self.hub._user_agent.clone());
11407
11408                if let Some(token) = token.as_ref() {
11409                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11410                }
11411
11412                let request = req_builder
11413                    .header(CONTENT_TYPE, json_mime_type.to_string())
11414                    .header(CONTENT_LENGTH, request_size as u64)
11415                    .body(common::to_body(
11416                        request_value_reader.get_ref().clone().into(),
11417                    ));
11418
11419                client.request(request.unwrap()).await
11420            };
11421
11422            match req_result {
11423                Err(err) => {
11424                    if let common::Retry::After(d) = dlg.http_error(&err) {
11425                        sleep(d).await;
11426                        continue;
11427                    }
11428                    dlg.finished(false);
11429                    return Err(common::Error::HttpError(err));
11430                }
11431                Ok(res) => {
11432                    let (mut parts, body) = res.into_parts();
11433                    let mut body = common::Body::new(body);
11434                    if !parts.status.is_success() {
11435                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11436                        let error = serde_json::from_str(&common::to_string(&bytes));
11437                        let response = common::to_response(parts, bytes.into());
11438
11439                        if let common::Retry::After(d) =
11440                            dlg.http_failure(&response, error.as_ref().ok())
11441                        {
11442                            sleep(d).await;
11443                            continue;
11444                        }
11445
11446                        dlg.finished(false);
11447
11448                        return Err(match error {
11449                            Ok(value) => common::Error::BadRequest(value),
11450                            _ => common::Error::Failure(response),
11451                        });
11452                    }
11453                    let response = {
11454                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11455                        let encoded = common::to_string(&bytes);
11456                        match serde_json::from_str(&encoded) {
11457                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11458                            Err(error) => {
11459                                dlg.response_json_decode_error(&encoded, &error);
11460                                return Err(common::Error::JsonDecodeError(
11461                                    encoded.to_string(),
11462                                    error,
11463                                ));
11464                            }
11465                        }
11466                    };
11467
11468                    dlg.finished(true);
11469                    return Ok(response);
11470                }
11471            }
11472        }
11473    }
11474
11475    ///
11476    /// Sets the *request* property to the given value.
11477    ///
11478    /// Even though the property as already been set when instantiating this call,
11479    /// we provide this method for API completeness.
11480    pub fn request(
11481        mut self,
11482        new_value: TestIamPermissionsRequest,
11483    ) -> AccessPolicyTestIamPermissionCall<'a, C> {
11484        self._request = new_value;
11485        self
11486    }
11487    /// 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.
11488    ///
11489    /// Sets the *resource* path property to the given value.
11490    ///
11491    /// Even though the property as already been set when instantiating this call,
11492    /// we provide this method for API completeness.
11493    pub fn resource(mut self, new_value: &str) -> AccessPolicyTestIamPermissionCall<'a, C> {
11494        self._resource = new_value.to_string();
11495        self
11496    }
11497    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11498    /// while executing the actual API request.
11499    ///
11500    /// ````text
11501    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11502    /// ````
11503    ///
11504    /// Sets the *delegate* property to the given value.
11505    pub fn delegate(
11506        mut self,
11507        new_value: &'a mut dyn common::Delegate,
11508    ) -> AccessPolicyTestIamPermissionCall<'a, C> {
11509        self._delegate = Some(new_value);
11510        self
11511    }
11512
11513    /// Set any additional parameter of the query string used in the request.
11514    /// It should be used to set parameters which are not yet available through their own
11515    /// setters.
11516    ///
11517    /// Please note that this method must not be used to set any of the known parameters
11518    /// which have their own setter method. If done anyway, the request will fail.
11519    ///
11520    /// # Additional Parameters
11521    ///
11522    /// * *$.xgafv* (query-string) - V1 error format.
11523    /// * *access_token* (query-string) - OAuth access token.
11524    /// * *alt* (query-string) - Data format for response.
11525    /// * *callback* (query-string) - JSONP
11526    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11527    /// * *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.
11528    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11529    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11530    /// * *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.
11531    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11532    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11533    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyTestIamPermissionCall<'a, C>
11534    where
11535        T: AsRef<str>,
11536    {
11537        self._additional_params
11538            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11539        self
11540    }
11541
11542    /// Identifies the authorization scope for the method you are building.
11543    ///
11544    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11545    /// [`Scope::CloudPlatform`].
11546    ///
11547    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11548    /// tokens for more than one scope.
11549    ///
11550    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11551    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11552    /// sufficient, a read-write scope will do as well.
11553    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyTestIamPermissionCall<'a, C>
11554    where
11555        St: AsRef<str>,
11556    {
11557        self._scopes.insert(String::from(scope.as_ref()));
11558        self
11559    }
11560    /// Identifies the authorization scope(s) for the method you are building.
11561    ///
11562    /// See [`Self::add_scope()`] for details.
11563    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyTestIamPermissionCall<'a, C>
11564    where
11565        I: IntoIterator<Item = St>,
11566        St: AsRef<str>,
11567    {
11568        self._scopes
11569            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11570        self
11571    }
11572
11573    /// Removes all scopes, and no default scope will be used either.
11574    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11575    /// for details).
11576    pub fn clear_scopes(mut self) -> AccessPolicyTestIamPermissionCall<'a, C> {
11577        self._scopes.clear();
11578        self
11579    }
11580}
11581
11582/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of `1`, corresponding to `Code.CANCELLED`.
11583///
11584/// A builder for the *cancel* method supported by a *operation* resource.
11585/// It is not used directly, but through a [`OperationMethods`] instance.
11586///
11587/// # Example
11588///
11589/// Instantiate a resource method builder
11590///
11591/// ```test_harness,no_run
11592/// # extern crate hyper;
11593/// # extern crate hyper_rustls;
11594/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
11595/// use accesscontextmanager1::api::CancelOperationRequest;
11596/// # async fn dox() {
11597/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11598///
11599/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11600/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11601/// #     .with_native_roots()
11602/// #     .unwrap()
11603/// #     .https_only()
11604/// #     .enable_http2()
11605/// #     .build();
11606///
11607/// # let executor = hyper_util::rt::TokioExecutor::new();
11608/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11609/// #     secret,
11610/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11611/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11612/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11613/// #     ),
11614/// # ).build().await.unwrap();
11615///
11616/// # let client = hyper_util::client::legacy::Client::builder(
11617/// #     hyper_util::rt::TokioExecutor::new()
11618/// # )
11619/// # .build(
11620/// #     hyper_rustls::HttpsConnectorBuilder::new()
11621/// #         .with_native_roots()
11622/// #         .unwrap()
11623/// #         .https_or_http()
11624/// #         .enable_http2()
11625/// #         .build()
11626/// # );
11627/// # let mut hub = AccessContextManager::new(client, auth);
11628/// // As the method needs a request, you would usually fill it with the desired information
11629/// // into the respective structure. Some of the parts shown here might not be applicable !
11630/// // Values shown here are possibly random and not representative !
11631/// let mut req = CancelOperationRequest::default();
11632///
11633/// // You can configure optional parameters by calling the respective setters at will, and
11634/// // execute the final call using `doit()`.
11635/// // Values shown here are possibly random and not representative !
11636/// let result = hub.operations().cancel(req, "name")
11637///              .doit().await;
11638/// # }
11639/// ```
11640pub struct OperationCancelCall<'a, C>
11641where
11642    C: 'a,
11643{
11644    hub: &'a AccessContextManager<C>,
11645    _request: CancelOperationRequest,
11646    _name: String,
11647    _delegate: Option<&'a mut dyn common::Delegate>,
11648    _additional_params: HashMap<String, String>,
11649    _scopes: BTreeSet<String>,
11650}
11651
11652impl<'a, C> common::CallBuilder for OperationCancelCall<'a, C> {}
11653
11654impl<'a, C> OperationCancelCall<'a, C>
11655where
11656    C: common::Connector,
11657{
11658    /// Perform the operation you have build so far.
11659    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11660        use std::borrow::Cow;
11661        use std::io::{Read, Seek};
11662
11663        use common::{url::Params, ToParts};
11664        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11665
11666        let mut dd = common::DefaultDelegate;
11667        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11668        dlg.begin(common::MethodInfo {
11669            id: "accesscontextmanager.operations.cancel",
11670            http_method: hyper::Method::POST,
11671        });
11672
11673        for &field in ["alt", "name"].iter() {
11674            if self._additional_params.contains_key(field) {
11675                dlg.finished(false);
11676                return Err(common::Error::FieldClash(field));
11677            }
11678        }
11679
11680        let mut params = Params::with_capacity(4 + self._additional_params.len());
11681        params.push("name", self._name);
11682
11683        params.extend(self._additional_params.iter());
11684
11685        params.push("alt", "json");
11686        let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
11687        if self._scopes.is_empty() {
11688            self._scopes
11689                .insert(Scope::CloudPlatform.as_ref().to_string());
11690        }
11691
11692        #[allow(clippy::single_element_loop)]
11693        for &(find_this, param_name) in [("{+name}", "name")].iter() {
11694            url = params.uri_replacement(url, param_name, find_this, true);
11695        }
11696        {
11697            let to_remove = ["name"];
11698            params.remove_params(&to_remove);
11699        }
11700
11701        let url = params.parse_with_url(&url);
11702
11703        let mut json_mime_type = mime::APPLICATION_JSON;
11704        let mut request_value_reader = {
11705            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11706            common::remove_json_null_values(&mut value);
11707            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11708            serde_json::to_writer(&mut dst, &value).unwrap();
11709            dst
11710        };
11711        let request_size = request_value_reader
11712            .seek(std::io::SeekFrom::End(0))
11713            .unwrap();
11714        request_value_reader
11715            .seek(std::io::SeekFrom::Start(0))
11716            .unwrap();
11717
11718        loop {
11719            let token = match self
11720                .hub
11721                .auth
11722                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11723                .await
11724            {
11725                Ok(token) => token,
11726                Err(e) => match dlg.token(e) {
11727                    Ok(token) => token,
11728                    Err(e) => {
11729                        dlg.finished(false);
11730                        return Err(common::Error::MissingToken(e));
11731                    }
11732                },
11733            };
11734            request_value_reader
11735                .seek(std::io::SeekFrom::Start(0))
11736                .unwrap();
11737            let mut req_result = {
11738                let client = &self.hub.client;
11739                dlg.pre_request();
11740                let mut req_builder = hyper::Request::builder()
11741                    .method(hyper::Method::POST)
11742                    .uri(url.as_str())
11743                    .header(USER_AGENT, self.hub._user_agent.clone());
11744
11745                if let Some(token) = token.as_ref() {
11746                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11747                }
11748
11749                let request = req_builder
11750                    .header(CONTENT_TYPE, json_mime_type.to_string())
11751                    .header(CONTENT_LENGTH, request_size as u64)
11752                    .body(common::to_body(
11753                        request_value_reader.get_ref().clone().into(),
11754                    ));
11755
11756                client.request(request.unwrap()).await
11757            };
11758
11759            match req_result {
11760                Err(err) => {
11761                    if let common::Retry::After(d) = dlg.http_error(&err) {
11762                        sleep(d).await;
11763                        continue;
11764                    }
11765                    dlg.finished(false);
11766                    return Err(common::Error::HttpError(err));
11767                }
11768                Ok(res) => {
11769                    let (mut parts, body) = res.into_parts();
11770                    let mut body = common::Body::new(body);
11771                    if !parts.status.is_success() {
11772                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11773                        let error = serde_json::from_str(&common::to_string(&bytes));
11774                        let response = common::to_response(parts, bytes.into());
11775
11776                        if let common::Retry::After(d) =
11777                            dlg.http_failure(&response, error.as_ref().ok())
11778                        {
11779                            sleep(d).await;
11780                            continue;
11781                        }
11782
11783                        dlg.finished(false);
11784
11785                        return Err(match error {
11786                            Ok(value) => common::Error::BadRequest(value),
11787                            _ => common::Error::Failure(response),
11788                        });
11789                    }
11790                    let response = {
11791                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11792                        let encoded = common::to_string(&bytes);
11793                        match serde_json::from_str(&encoded) {
11794                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11795                            Err(error) => {
11796                                dlg.response_json_decode_error(&encoded, &error);
11797                                return Err(common::Error::JsonDecodeError(
11798                                    encoded.to_string(),
11799                                    error,
11800                                ));
11801                            }
11802                        }
11803                    };
11804
11805                    dlg.finished(true);
11806                    return Ok(response);
11807                }
11808            }
11809        }
11810    }
11811
11812    ///
11813    /// Sets the *request* property to the given value.
11814    ///
11815    /// Even though the property as already been set when instantiating this call,
11816    /// we provide this method for API completeness.
11817    pub fn request(mut self, new_value: CancelOperationRequest) -> OperationCancelCall<'a, C> {
11818        self._request = new_value;
11819        self
11820    }
11821    /// The name of the operation resource to be cancelled.
11822    ///
11823    /// Sets the *name* path property to the given value.
11824    ///
11825    /// Even though the property as already been set when instantiating this call,
11826    /// we provide this method for API completeness.
11827    pub fn name(mut self, new_value: &str) -> OperationCancelCall<'a, C> {
11828        self._name = new_value.to_string();
11829        self
11830    }
11831    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11832    /// while executing the actual API request.
11833    ///
11834    /// ````text
11835    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11836    /// ````
11837    ///
11838    /// Sets the *delegate* property to the given value.
11839    pub fn delegate(
11840        mut self,
11841        new_value: &'a mut dyn common::Delegate,
11842    ) -> OperationCancelCall<'a, C> {
11843        self._delegate = Some(new_value);
11844        self
11845    }
11846
11847    /// Set any additional parameter of the query string used in the request.
11848    /// It should be used to set parameters which are not yet available through their own
11849    /// setters.
11850    ///
11851    /// Please note that this method must not be used to set any of the known parameters
11852    /// which have their own setter method. If done anyway, the request will fail.
11853    ///
11854    /// # Additional Parameters
11855    ///
11856    /// * *$.xgafv* (query-string) - V1 error format.
11857    /// * *access_token* (query-string) - OAuth access token.
11858    /// * *alt* (query-string) - Data format for response.
11859    /// * *callback* (query-string) - JSONP
11860    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11861    /// * *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.
11862    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11863    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11864    /// * *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.
11865    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11866    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11867    pub fn param<T>(mut self, name: T, value: T) -> OperationCancelCall<'a, C>
11868    where
11869        T: AsRef<str>,
11870    {
11871        self._additional_params
11872            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11873        self
11874    }
11875
11876    /// Identifies the authorization scope for the method you are building.
11877    ///
11878    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11879    /// [`Scope::CloudPlatform`].
11880    ///
11881    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11882    /// tokens for more than one scope.
11883    ///
11884    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11885    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11886    /// sufficient, a read-write scope will do as well.
11887    pub fn add_scope<St>(mut self, scope: St) -> OperationCancelCall<'a, C>
11888    where
11889        St: AsRef<str>,
11890    {
11891        self._scopes.insert(String::from(scope.as_ref()));
11892        self
11893    }
11894    /// Identifies the authorization scope(s) for the method you are building.
11895    ///
11896    /// See [`Self::add_scope()`] for details.
11897    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationCancelCall<'a, C>
11898    where
11899        I: IntoIterator<Item = St>,
11900        St: AsRef<str>,
11901    {
11902        self._scopes
11903            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11904        self
11905    }
11906
11907    /// Removes all scopes, and no default scope will be used either.
11908    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11909    /// for details).
11910    pub fn clear_scopes(mut self) -> OperationCancelCall<'a, C> {
11911        self._scopes.clear();
11912        self
11913    }
11914}
11915
11916/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
11917///
11918/// A builder for the *delete* method supported by a *operation* resource.
11919/// It is not used directly, but through a [`OperationMethods`] instance.
11920///
11921/// # Example
11922///
11923/// Instantiate a resource method builder
11924///
11925/// ```test_harness,no_run
11926/// # extern crate hyper;
11927/// # extern crate hyper_rustls;
11928/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
11929/// # async fn dox() {
11930/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11931///
11932/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11933/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11934/// #     .with_native_roots()
11935/// #     .unwrap()
11936/// #     .https_only()
11937/// #     .enable_http2()
11938/// #     .build();
11939///
11940/// # let executor = hyper_util::rt::TokioExecutor::new();
11941/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11942/// #     secret,
11943/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11944/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
11945/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
11946/// #     ),
11947/// # ).build().await.unwrap();
11948///
11949/// # let client = hyper_util::client::legacy::Client::builder(
11950/// #     hyper_util::rt::TokioExecutor::new()
11951/// # )
11952/// # .build(
11953/// #     hyper_rustls::HttpsConnectorBuilder::new()
11954/// #         .with_native_roots()
11955/// #         .unwrap()
11956/// #         .https_or_http()
11957/// #         .enable_http2()
11958/// #         .build()
11959/// # );
11960/// # let mut hub = AccessContextManager::new(client, auth);
11961/// // You can configure optional parameters by calling the respective setters at will, and
11962/// // execute the final call using `doit()`.
11963/// // Values shown here are possibly random and not representative !
11964/// let result = hub.operations().delete("name")
11965///              .doit().await;
11966/// # }
11967/// ```
11968pub struct OperationDeleteCall<'a, C>
11969where
11970    C: 'a,
11971{
11972    hub: &'a AccessContextManager<C>,
11973    _name: String,
11974    _delegate: Option<&'a mut dyn common::Delegate>,
11975    _additional_params: HashMap<String, String>,
11976    _scopes: BTreeSet<String>,
11977}
11978
11979impl<'a, C> common::CallBuilder for OperationDeleteCall<'a, C> {}
11980
11981impl<'a, C> OperationDeleteCall<'a, C>
11982where
11983    C: common::Connector,
11984{
11985    /// Perform the operation you have build so far.
11986    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11987        use std::borrow::Cow;
11988        use std::io::{Read, Seek};
11989
11990        use common::{url::Params, ToParts};
11991        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11992
11993        let mut dd = common::DefaultDelegate;
11994        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11995        dlg.begin(common::MethodInfo {
11996            id: "accesscontextmanager.operations.delete",
11997            http_method: hyper::Method::DELETE,
11998        });
11999
12000        for &field in ["alt", "name"].iter() {
12001            if self._additional_params.contains_key(field) {
12002                dlg.finished(false);
12003                return Err(common::Error::FieldClash(field));
12004            }
12005        }
12006
12007        let mut params = Params::with_capacity(3 + self._additional_params.len());
12008        params.push("name", self._name);
12009
12010        params.extend(self._additional_params.iter());
12011
12012        params.push("alt", "json");
12013        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12014        if self._scopes.is_empty() {
12015            self._scopes
12016                .insert(Scope::CloudPlatform.as_ref().to_string());
12017        }
12018
12019        #[allow(clippy::single_element_loop)]
12020        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12021            url = params.uri_replacement(url, param_name, find_this, true);
12022        }
12023        {
12024            let to_remove = ["name"];
12025            params.remove_params(&to_remove);
12026        }
12027
12028        let url = params.parse_with_url(&url);
12029
12030        loop {
12031            let token = match self
12032                .hub
12033                .auth
12034                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12035                .await
12036            {
12037                Ok(token) => token,
12038                Err(e) => match dlg.token(e) {
12039                    Ok(token) => token,
12040                    Err(e) => {
12041                        dlg.finished(false);
12042                        return Err(common::Error::MissingToken(e));
12043                    }
12044                },
12045            };
12046            let mut req_result = {
12047                let client = &self.hub.client;
12048                dlg.pre_request();
12049                let mut req_builder = hyper::Request::builder()
12050                    .method(hyper::Method::DELETE)
12051                    .uri(url.as_str())
12052                    .header(USER_AGENT, self.hub._user_agent.clone());
12053
12054                if let Some(token) = token.as_ref() {
12055                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12056                }
12057
12058                let request = req_builder
12059                    .header(CONTENT_LENGTH, 0_u64)
12060                    .body(common::to_body::<String>(None));
12061
12062                client.request(request.unwrap()).await
12063            };
12064
12065            match req_result {
12066                Err(err) => {
12067                    if let common::Retry::After(d) = dlg.http_error(&err) {
12068                        sleep(d).await;
12069                        continue;
12070                    }
12071                    dlg.finished(false);
12072                    return Err(common::Error::HttpError(err));
12073                }
12074                Ok(res) => {
12075                    let (mut parts, body) = res.into_parts();
12076                    let mut body = common::Body::new(body);
12077                    if !parts.status.is_success() {
12078                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12079                        let error = serde_json::from_str(&common::to_string(&bytes));
12080                        let response = common::to_response(parts, bytes.into());
12081
12082                        if let common::Retry::After(d) =
12083                            dlg.http_failure(&response, error.as_ref().ok())
12084                        {
12085                            sleep(d).await;
12086                            continue;
12087                        }
12088
12089                        dlg.finished(false);
12090
12091                        return Err(match error {
12092                            Ok(value) => common::Error::BadRequest(value),
12093                            _ => common::Error::Failure(response),
12094                        });
12095                    }
12096                    let response = {
12097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12098                        let encoded = common::to_string(&bytes);
12099                        match serde_json::from_str(&encoded) {
12100                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12101                            Err(error) => {
12102                                dlg.response_json_decode_error(&encoded, &error);
12103                                return Err(common::Error::JsonDecodeError(
12104                                    encoded.to_string(),
12105                                    error,
12106                                ));
12107                            }
12108                        }
12109                    };
12110
12111                    dlg.finished(true);
12112                    return Ok(response);
12113                }
12114            }
12115        }
12116    }
12117
12118    /// The name of the operation resource to be deleted.
12119    ///
12120    /// Sets the *name* path property to the given value.
12121    ///
12122    /// Even though the property as already been set when instantiating this call,
12123    /// we provide this method for API completeness.
12124    pub fn name(mut self, new_value: &str) -> OperationDeleteCall<'a, C> {
12125        self._name = new_value.to_string();
12126        self
12127    }
12128    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12129    /// while executing the actual API request.
12130    ///
12131    /// ````text
12132    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12133    /// ````
12134    ///
12135    /// Sets the *delegate* property to the given value.
12136    pub fn delegate(
12137        mut self,
12138        new_value: &'a mut dyn common::Delegate,
12139    ) -> OperationDeleteCall<'a, C> {
12140        self._delegate = Some(new_value);
12141        self
12142    }
12143
12144    /// Set any additional parameter of the query string used in the request.
12145    /// It should be used to set parameters which are not yet available through their own
12146    /// setters.
12147    ///
12148    /// Please note that this method must not be used to set any of the known parameters
12149    /// which have their own setter method. If done anyway, the request will fail.
12150    ///
12151    /// # Additional Parameters
12152    ///
12153    /// * *$.xgafv* (query-string) - V1 error format.
12154    /// * *access_token* (query-string) - OAuth access token.
12155    /// * *alt* (query-string) - Data format for response.
12156    /// * *callback* (query-string) - JSONP
12157    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12158    /// * *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.
12159    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12160    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12161    /// * *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.
12162    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12163    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12164    pub fn param<T>(mut self, name: T, value: T) -> OperationDeleteCall<'a, C>
12165    where
12166        T: AsRef<str>,
12167    {
12168        self._additional_params
12169            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12170        self
12171    }
12172
12173    /// Identifies the authorization scope for the method you are building.
12174    ///
12175    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12176    /// [`Scope::CloudPlatform`].
12177    ///
12178    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12179    /// tokens for more than one scope.
12180    ///
12181    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12182    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12183    /// sufficient, a read-write scope will do as well.
12184    pub fn add_scope<St>(mut self, scope: St) -> OperationDeleteCall<'a, C>
12185    where
12186        St: AsRef<str>,
12187    {
12188        self._scopes.insert(String::from(scope.as_ref()));
12189        self
12190    }
12191    /// Identifies the authorization scope(s) for the method you are building.
12192    ///
12193    /// See [`Self::add_scope()`] for details.
12194    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationDeleteCall<'a, C>
12195    where
12196        I: IntoIterator<Item = St>,
12197        St: AsRef<str>,
12198    {
12199        self._scopes
12200            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12201        self
12202    }
12203
12204    /// Removes all scopes, and no default scope will be used either.
12205    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12206    /// for details).
12207    pub fn clear_scopes(mut self) -> OperationDeleteCall<'a, C> {
12208        self._scopes.clear();
12209        self
12210    }
12211}
12212
12213/// 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.
12214///
12215/// A builder for the *get* method supported by a *operation* resource.
12216/// It is not used directly, but through a [`OperationMethods`] instance.
12217///
12218/// # Example
12219///
12220/// Instantiate a resource method builder
12221///
12222/// ```test_harness,no_run
12223/// # extern crate hyper;
12224/// # extern crate hyper_rustls;
12225/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
12226/// # async fn dox() {
12227/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12228///
12229/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12230/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12231/// #     .with_native_roots()
12232/// #     .unwrap()
12233/// #     .https_only()
12234/// #     .enable_http2()
12235/// #     .build();
12236///
12237/// # let executor = hyper_util::rt::TokioExecutor::new();
12238/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12239/// #     secret,
12240/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12241/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12242/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12243/// #     ),
12244/// # ).build().await.unwrap();
12245///
12246/// # let client = hyper_util::client::legacy::Client::builder(
12247/// #     hyper_util::rt::TokioExecutor::new()
12248/// # )
12249/// # .build(
12250/// #     hyper_rustls::HttpsConnectorBuilder::new()
12251/// #         .with_native_roots()
12252/// #         .unwrap()
12253/// #         .https_or_http()
12254/// #         .enable_http2()
12255/// #         .build()
12256/// # );
12257/// # let mut hub = AccessContextManager::new(client, auth);
12258/// // You can configure optional parameters by calling the respective setters at will, and
12259/// // execute the final call using `doit()`.
12260/// // Values shown here are possibly random and not representative !
12261/// let result = hub.operations().get("name")
12262///              .doit().await;
12263/// # }
12264/// ```
12265pub struct OperationGetCall<'a, C>
12266where
12267    C: 'a,
12268{
12269    hub: &'a AccessContextManager<C>,
12270    _name: String,
12271    _delegate: Option<&'a mut dyn common::Delegate>,
12272    _additional_params: HashMap<String, String>,
12273    _scopes: BTreeSet<String>,
12274}
12275
12276impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
12277
12278impl<'a, C> OperationGetCall<'a, C>
12279where
12280    C: common::Connector,
12281{
12282    /// Perform the operation you have build so far.
12283    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12284        use std::borrow::Cow;
12285        use std::io::{Read, Seek};
12286
12287        use common::{url::Params, ToParts};
12288        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12289
12290        let mut dd = common::DefaultDelegate;
12291        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12292        dlg.begin(common::MethodInfo {
12293            id: "accesscontextmanager.operations.get",
12294            http_method: hyper::Method::GET,
12295        });
12296
12297        for &field in ["alt", "name"].iter() {
12298            if self._additional_params.contains_key(field) {
12299                dlg.finished(false);
12300                return Err(common::Error::FieldClash(field));
12301            }
12302        }
12303
12304        let mut params = Params::with_capacity(3 + self._additional_params.len());
12305        params.push("name", self._name);
12306
12307        params.extend(self._additional_params.iter());
12308
12309        params.push("alt", "json");
12310        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12311        if self._scopes.is_empty() {
12312            self._scopes
12313                .insert(Scope::CloudPlatform.as_ref().to_string());
12314        }
12315
12316        #[allow(clippy::single_element_loop)]
12317        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12318            url = params.uri_replacement(url, param_name, find_this, true);
12319        }
12320        {
12321            let to_remove = ["name"];
12322            params.remove_params(&to_remove);
12323        }
12324
12325        let url = params.parse_with_url(&url);
12326
12327        loop {
12328            let token = match self
12329                .hub
12330                .auth
12331                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12332                .await
12333            {
12334                Ok(token) => token,
12335                Err(e) => match dlg.token(e) {
12336                    Ok(token) => token,
12337                    Err(e) => {
12338                        dlg.finished(false);
12339                        return Err(common::Error::MissingToken(e));
12340                    }
12341                },
12342            };
12343            let mut req_result = {
12344                let client = &self.hub.client;
12345                dlg.pre_request();
12346                let mut req_builder = hyper::Request::builder()
12347                    .method(hyper::Method::GET)
12348                    .uri(url.as_str())
12349                    .header(USER_AGENT, self.hub._user_agent.clone());
12350
12351                if let Some(token) = token.as_ref() {
12352                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12353                }
12354
12355                let request = req_builder
12356                    .header(CONTENT_LENGTH, 0_u64)
12357                    .body(common::to_body::<String>(None));
12358
12359                client.request(request.unwrap()).await
12360            };
12361
12362            match req_result {
12363                Err(err) => {
12364                    if let common::Retry::After(d) = dlg.http_error(&err) {
12365                        sleep(d).await;
12366                        continue;
12367                    }
12368                    dlg.finished(false);
12369                    return Err(common::Error::HttpError(err));
12370                }
12371                Ok(res) => {
12372                    let (mut parts, body) = res.into_parts();
12373                    let mut body = common::Body::new(body);
12374                    if !parts.status.is_success() {
12375                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12376                        let error = serde_json::from_str(&common::to_string(&bytes));
12377                        let response = common::to_response(parts, bytes.into());
12378
12379                        if let common::Retry::After(d) =
12380                            dlg.http_failure(&response, error.as_ref().ok())
12381                        {
12382                            sleep(d).await;
12383                            continue;
12384                        }
12385
12386                        dlg.finished(false);
12387
12388                        return Err(match error {
12389                            Ok(value) => common::Error::BadRequest(value),
12390                            _ => common::Error::Failure(response),
12391                        });
12392                    }
12393                    let response = {
12394                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12395                        let encoded = common::to_string(&bytes);
12396                        match serde_json::from_str(&encoded) {
12397                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12398                            Err(error) => {
12399                                dlg.response_json_decode_error(&encoded, &error);
12400                                return Err(common::Error::JsonDecodeError(
12401                                    encoded.to_string(),
12402                                    error,
12403                                ));
12404                            }
12405                        }
12406                    };
12407
12408                    dlg.finished(true);
12409                    return Ok(response);
12410                }
12411            }
12412        }
12413    }
12414
12415    /// The name of the operation resource.
12416    ///
12417    /// Sets the *name* path property to the given value.
12418    ///
12419    /// Even though the property as already been set when instantiating this call,
12420    /// we provide this method for API completeness.
12421    pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
12422        self._name = new_value.to_string();
12423        self
12424    }
12425    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12426    /// while executing the actual API request.
12427    ///
12428    /// ````text
12429    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12430    /// ````
12431    ///
12432    /// Sets the *delegate* property to the given value.
12433    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
12434        self._delegate = Some(new_value);
12435        self
12436    }
12437
12438    /// Set any additional parameter of the query string used in the request.
12439    /// It should be used to set parameters which are not yet available through their own
12440    /// setters.
12441    ///
12442    /// Please note that this method must not be used to set any of the known parameters
12443    /// which have their own setter method. If done anyway, the request will fail.
12444    ///
12445    /// # Additional Parameters
12446    ///
12447    /// * *$.xgafv* (query-string) - V1 error format.
12448    /// * *access_token* (query-string) - OAuth access token.
12449    /// * *alt* (query-string) - Data format for response.
12450    /// * *callback* (query-string) - JSONP
12451    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12452    /// * *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.
12453    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12454    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12455    /// * *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.
12456    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12457    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12458    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
12459    where
12460        T: AsRef<str>,
12461    {
12462        self._additional_params
12463            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12464        self
12465    }
12466
12467    /// Identifies the authorization scope for the method you are building.
12468    ///
12469    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12470    /// [`Scope::CloudPlatform`].
12471    ///
12472    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12473    /// tokens for more than one scope.
12474    ///
12475    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12476    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12477    /// sufficient, a read-write scope will do as well.
12478    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
12479    where
12480        St: AsRef<str>,
12481    {
12482        self._scopes.insert(String::from(scope.as_ref()));
12483        self
12484    }
12485    /// Identifies the authorization scope(s) for the method you are building.
12486    ///
12487    /// See [`Self::add_scope()`] for details.
12488    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
12489    where
12490        I: IntoIterator<Item = St>,
12491        St: AsRef<str>,
12492    {
12493        self._scopes
12494            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12495        self
12496    }
12497
12498    /// Removes all scopes, and no default scope will be used either.
12499    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12500    /// for details).
12501    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
12502        self._scopes.clear();
12503        self
12504    }
12505}
12506
12507/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
12508///
12509/// A builder for the *list* method supported by a *operation* resource.
12510/// It is not used directly, but through a [`OperationMethods`] instance.
12511///
12512/// # Example
12513///
12514/// Instantiate a resource method builder
12515///
12516/// ```test_harness,no_run
12517/// # extern crate hyper;
12518/// # extern crate hyper_rustls;
12519/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
12520/// # async fn dox() {
12521/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12522///
12523/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12524/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12525/// #     .with_native_roots()
12526/// #     .unwrap()
12527/// #     .https_only()
12528/// #     .enable_http2()
12529/// #     .build();
12530///
12531/// # let executor = hyper_util::rt::TokioExecutor::new();
12532/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12533/// #     secret,
12534/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12535/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12536/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12537/// #     ),
12538/// # ).build().await.unwrap();
12539///
12540/// # let client = hyper_util::client::legacy::Client::builder(
12541/// #     hyper_util::rt::TokioExecutor::new()
12542/// # )
12543/// # .build(
12544/// #     hyper_rustls::HttpsConnectorBuilder::new()
12545/// #         .with_native_roots()
12546/// #         .unwrap()
12547/// #         .https_or_http()
12548/// #         .enable_http2()
12549/// #         .build()
12550/// # );
12551/// # let mut hub = AccessContextManager::new(client, auth);
12552/// // You can configure optional parameters by calling the respective setters at will, and
12553/// // execute the final call using `doit()`.
12554/// // Values shown here are possibly random and not representative !
12555/// let result = hub.operations().list("name")
12556///              .return_partial_success(false)
12557///              .page_token("Stet")
12558///              .page_size(-99)
12559///              .filter("duo")
12560///              .doit().await;
12561/// # }
12562/// ```
12563pub struct OperationListCall<'a, C>
12564where
12565    C: 'a,
12566{
12567    hub: &'a AccessContextManager<C>,
12568    _name: String,
12569    _return_partial_success: Option<bool>,
12570    _page_token: Option<String>,
12571    _page_size: Option<i32>,
12572    _filter: Option<String>,
12573    _delegate: Option<&'a mut dyn common::Delegate>,
12574    _additional_params: HashMap<String, String>,
12575    _scopes: BTreeSet<String>,
12576}
12577
12578impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
12579
12580impl<'a, C> OperationListCall<'a, C>
12581where
12582    C: common::Connector,
12583{
12584    /// Perform the operation you have build so far.
12585    pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
12586        use std::borrow::Cow;
12587        use std::io::{Read, Seek};
12588
12589        use common::{url::Params, ToParts};
12590        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12591
12592        let mut dd = common::DefaultDelegate;
12593        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12594        dlg.begin(common::MethodInfo {
12595            id: "accesscontextmanager.operations.list",
12596            http_method: hyper::Method::GET,
12597        });
12598
12599        for &field in [
12600            "alt",
12601            "name",
12602            "returnPartialSuccess",
12603            "pageToken",
12604            "pageSize",
12605            "filter",
12606        ]
12607        .iter()
12608        {
12609            if self._additional_params.contains_key(field) {
12610                dlg.finished(false);
12611                return Err(common::Error::FieldClash(field));
12612            }
12613        }
12614
12615        let mut params = Params::with_capacity(7 + self._additional_params.len());
12616        params.push("name", self._name);
12617        if let Some(value) = self._return_partial_success.as_ref() {
12618            params.push("returnPartialSuccess", value.to_string());
12619        }
12620        if let Some(value) = self._page_token.as_ref() {
12621            params.push("pageToken", value);
12622        }
12623        if let Some(value) = self._page_size.as_ref() {
12624            params.push("pageSize", value.to_string());
12625        }
12626        if let Some(value) = self._filter.as_ref() {
12627            params.push("filter", value);
12628        }
12629
12630        params.extend(self._additional_params.iter());
12631
12632        params.push("alt", "json");
12633        let mut url = self.hub._base_url.clone() + "v1/{+name}";
12634        if self._scopes.is_empty() {
12635            self._scopes
12636                .insert(Scope::CloudPlatform.as_ref().to_string());
12637        }
12638
12639        #[allow(clippy::single_element_loop)]
12640        for &(find_this, param_name) in [("{+name}", "name")].iter() {
12641            url = params.uri_replacement(url, param_name, find_this, true);
12642        }
12643        {
12644            let to_remove = ["name"];
12645            params.remove_params(&to_remove);
12646        }
12647
12648        let url = params.parse_with_url(&url);
12649
12650        loop {
12651            let token = match self
12652                .hub
12653                .auth
12654                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12655                .await
12656            {
12657                Ok(token) => token,
12658                Err(e) => match dlg.token(e) {
12659                    Ok(token) => token,
12660                    Err(e) => {
12661                        dlg.finished(false);
12662                        return Err(common::Error::MissingToken(e));
12663                    }
12664                },
12665            };
12666            let mut req_result = {
12667                let client = &self.hub.client;
12668                dlg.pre_request();
12669                let mut req_builder = hyper::Request::builder()
12670                    .method(hyper::Method::GET)
12671                    .uri(url.as_str())
12672                    .header(USER_AGENT, self.hub._user_agent.clone());
12673
12674                if let Some(token) = token.as_ref() {
12675                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12676                }
12677
12678                let request = req_builder
12679                    .header(CONTENT_LENGTH, 0_u64)
12680                    .body(common::to_body::<String>(None));
12681
12682                client.request(request.unwrap()).await
12683            };
12684
12685            match req_result {
12686                Err(err) => {
12687                    if let common::Retry::After(d) = dlg.http_error(&err) {
12688                        sleep(d).await;
12689                        continue;
12690                    }
12691                    dlg.finished(false);
12692                    return Err(common::Error::HttpError(err));
12693                }
12694                Ok(res) => {
12695                    let (mut parts, body) = res.into_parts();
12696                    let mut body = common::Body::new(body);
12697                    if !parts.status.is_success() {
12698                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12699                        let error = serde_json::from_str(&common::to_string(&bytes));
12700                        let response = common::to_response(parts, bytes.into());
12701
12702                        if let common::Retry::After(d) =
12703                            dlg.http_failure(&response, error.as_ref().ok())
12704                        {
12705                            sleep(d).await;
12706                            continue;
12707                        }
12708
12709                        dlg.finished(false);
12710
12711                        return Err(match error {
12712                            Ok(value) => common::Error::BadRequest(value),
12713                            _ => common::Error::Failure(response),
12714                        });
12715                    }
12716                    let response = {
12717                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12718                        let encoded = common::to_string(&bytes);
12719                        match serde_json::from_str(&encoded) {
12720                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12721                            Err(error) => {
12722                                dlg.response_json_decode_error(&encoded, &error);
12723                                return Err(common::Error::JsonDecodeError(
12724                                    encoded.to_string(),
12725                                    error,
12726                                ));
12727                            }
12728                        }
12729                    };
12730
12731                    dlg.finished(true);
12732                    return Ok(response);
12733                }
12734            }
12735        }
12736    }
12737
12738    /// The name of the operation's parent resource.
12739    ///
12740    /// Sets the *name* path property to the given value.
12741    ///
12742    /// Even though the property as already been set when instantiating this call,
12743    /// we provide this method for API completeness.
12744    pub fn name(mut self, new_value: &str) -> OperationListCall<'a, C> {
12745        self._name = new_value.to_string();
12746        self
12747    }
12748    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
12749    ///
12750    /// Sets the *return partial success* query property to the given value.
12751    pub fn return_partial_success(mut self, new_value: bool) -> OperationListCall<'a, C> {
12752        self._return_partial_success = Some(new_value);
12753        self
12754    }
12755    /// The standard list page token.
12756    ///
12757    /// Sets the *page token* query property to the given value.
12758    pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
12759        self._page_token = Some(new_value.to_string());
12760        self
12761    }
12762    /// The standard list page size.
12763    ///
12764    /// Sets the *page size* query property to the given value.
12765    pub fn page_size(mut self, new_value: i32) -> OperationListCall<'a, C> {
12766        self._page_size = Some(new_value);
12767        self
12768    }
12769    /// The standard list filter.
12770    ///
12771    /// Sets the *filter* query property to the given value.
12772    pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C> {
12773        self._filter = Some(new_value.to_string());
12774        self
12775    }
12776    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12777    /// while executing the actual API request.
12778    ///
12779    /// ````text
12780    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12781    /// ````
12782    ///
12783    /// Sets the *delegate* property to the given value.
12784    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
12785        self._delegate = Some(new_value);
12786        self
12787    }
12788
12789    /// Set any additional parameter of the query string used in the request.
12790    /// It should be used to set parameters which are not yet available through their own
12791    /// setters.
12792    ///
12793    /// Please note that this method must not be used to set any of the known parameters
12794    /// which have their own setter method. If done anyway, the request will fail.
12795    ///
12796    /// # Additional Parameters
12797    ///
12798    /// * *$.xgafv* (query-string) - V1 error format.
12799    /// * *access_token* (query-string) - OAuth access token.
12800    /// * *alt* (query-string) - Data format for response.
12801    /// * *callback* (query-string) - JSONP
12802    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12803    /// * *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.
12804    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12805    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12806    /// * *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.
12807    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12808    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12809    pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
12810    where
12811        T: AsRef<str>,
12812    {
12813        self._additional_params
12814            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12815        self
12816    }
12817
12818    /// Identifies the authorization scope for the method you are building.
12819    ///
12820    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12821    /// [`Scope::CloudPlatform`].
12822    ///
12823    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12824    /// tokens for more than one scope.
12825    ///
12826    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12827    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12828    /// sufficient, a read-write scope will do as well.
12829    pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
12830    where
12831        St: AsRef<str>,
12832    {
12833        self._scopes.insert(String::from(scope.as_ref()));
12834        self
12835    }
12836    /// Identifies the authorization scope(s) for the method you are building.
12837    ///
12838    /// See [`Self::add_scope()`] for details.
12839    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
12840    where
12841        I: IntoIterator<Item = St>,
12842        St: AsRef<str>,
12843    {
12844        self._scopes
12845            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12846        self
12847    }
12848
12849    /// Removes all scopes, and no default scope will be used either.
12850    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12851    /// for details).
12852    pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
12853        self._scopes.clear();
12854        self
12855    }
12856}
12857
12858/// Creates a GcpUserAccessBinding. If the client specifies a name, the server ignores it. Fails if a resource already exists with the same group_key. Completion of this long-running operation does not necessarily signify that the new binding is deployed onto all affected users, which may take more time.
12859///
12860/// A builder for the *gcpUserAccessBindings.create* method supported by a *organization* resource.
12861/// It is not used directly, but through a [`OrganizationMethods`] instance.
12862///
12863/// # Example
12864///
12865/// Instantiate a resource method builder
12866///
12867/// ```test_harness,no_run
12868/// # extern crate hyper;
12869/// # extern crate hyper_rustls;
12870/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
12871/// use accesscontextmanager1::api::GcpUserAccessBinding;
12872/// # async fn dox() {
12873/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12874///
12875/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12876/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12877/// #     .with_native_roots()
12878/// #     .unwrap()
12879/// #     .https_only()
12880/// #     .enable_http2()
12881/// #     .build();
12882///
12883/// # let executor = hyper_util::rt::TokioExecutor::new();
12884/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12885/// #     secret,
12886/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12887/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
12888/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
12889/// #     ),
12890/// # ).build().await.unwrap();
12891///
12892/// # let client = hyper_util::client::legacy::Client::builder(
12893/// #     hyper_util::rt::TokioExecutor::new()
12894/// # )
12895/// # .build(
12896/// #     hyper_rustls::HttpsConnectorBuilder::new()
12897/// #         .with_native_roots()
12898/// #         .unwrap()
12899/// #         .https_or_http()
12900/// #         .enable_http2()
12901/// #         .build()
12902/// # );
12903/// # let mut hub = AccessContextManager::new(client, auth);
12904/// // As the method needs a request, you would usually fill it with the desired information
12905/// // into the respective structure. Some of the parts shown here might not be applicable !
12906/// // Values shown here are possibly random and not representative !
12907/// let mut req = GcpUserAccessBinding::default();
12908///
12909/// // You can configure optional parameters by calling the respective setters at will, and
12910/// // execute the final call using `doit()`.
12911/// // Values shown here are possibly random and not representative !
12912/// let result = hub.organizations().gcp_user_access_bindings_create(req, "parent")
12913///              .doit().await;
12914/// # }
12915/// ```
12916pub struct OrganizationGcpUserAccessBindingCreateCall<'a, C>
12917where
12918    C: 'a,
12919{
12920    hub: &'a AccessContextManager<C>,
12921    _request: GcpUserAccessBinding,
12922    _parent: String,
12923    _delegate: Option<&'a mut dyn common::Delegate>,
12924    _additional_params: HashMap<String, String>,
12925    _scopes: BTreeSet<String>,
12926}
12927
12928impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingCreateCall<'a, C> {}
12929
12930impl<'a, C> OrganizationGcpUserAccessBindingCreateCall<'a, C>
12931where
12932    C: common::Connector,
12933{
12934    /// Perform the operation you have build so far.
12935    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12936        use std::borrow::Cow;
12937        use std::io::{Read, Seek};
12938
12939        use common::{url::Params, ToParts};
12940        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12941
12942        let mut dd = common::DefaultDelegate;
12943        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12944        dlg.begin(common::MethodInfo {
12945            id: "accesscontextmanager.organizations.gcpUserAccessBindings.create",
12946            http_method: hyper::Method::POST,
12947        });
12948
12949        for &field in ["alt", "parent"].iter() {
12950            if self._additional_params.contains_key(field) {
12951                dlg.finished(false);
12952                return Err(common::Error::FieldClash(field));
12953            }
12954        }
12955
12956        let mut params = Params::with_capacity(4 + self._additional_params.len());
12957        params.push("parent", self._parent);
12958
12959        params.extend(self._additional_params.iter());
12960
12961        params.push("alt", "json");
12962        let mut url = self.hub._base_url.clone() + "v1/{+parent}/gcpUserAccessBindings";
12963        if self._scopes.is_empty() {
12964            self._scopes
12965                .insert(Scope::CloudPlatform.as_ref().to_string());
12966        }
12967
12968        #[allow(clippy::single_element_loop)]
12969        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12970            url = params.uri_replacement(url, param_name, find_this, true);
12971        }
12972        {
12973            let to_remove = ["parent"];
12974            params.remove_params(&to_remove);
12975        }
12976
12977        let url = params.parse_with_url(&url);
12978
12979        let mut json_mime_type = mime::APPLICATION_JSON;
12980        let mut request_value_reader = {
12981            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12982            common::remove_json_null_values(&mut value);
12983            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12984            serde_json::to_writer(&mut dst, &value).unwrap();
12985            dst
12986        };
12987        let request_size = request_value_reader
12988            .seek(std::io::SeekFrom::End(0))
12989            .unwrap();
12990        request_value_reader
12991            .seek(std::io::SeekFrom::Start(0))
12992            .unwrap();
12993
12994        loop {
12995            let token = match self
12996                .hub
12997                .auth
12998                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12999                .await
13000            {
13001                Ok(token) => token,
13002                Err(e) => match dlg.token(e) {
13003                    Ok(token) => token,
13004                    Err(e) => {
13005                        dlg.finished(false);
13006                        return Err(common::Error::MissingToken(e));
13007                    }
13008                },
13009            };
13010            request_value_reader
13011                .seek(std::io::SeekFrom::Start(0))
13012                .unwrap();
13013            let mut req_result = {
13014                let client = &self.hub.client;
13015                dlg.pre_request();
13016                let mut req_builder = hyper::Request::builder()
13017                    .method(hyper::Method::POST)
13018                    .uri(url.as_str())
13019                    .header(USER_AGENT, self.hub._user_agent.clone());
13020
13021                if let Some(token) = token.as_ref() {
13022                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13023                }
13024
13025                let request = req_builder
13026                    .header(CONTENT_TYPE, json_mime_type.to_string())
13027                    .header(CONTENT_LENGTH, request_size as u64)
13028                    .body(common::to_body(
13029                        request_value_reader.get_ref().clone().into(),
13030                    ));
13031
13032                client.request(request.unwrap()).await
13033            };
13034
13035            match req_result {
13036                Err(err) => {
13037                    if let common::Retry::After(d) = dlg.http_error(&err) {
13038                        sleep(d).await;
13039                        continue;
13040                    }
13041                    dlg.finished(false);
13042                    return Err(common::Error::HttpError(err));
13043                }
13044                Ok(res) => {
13045                    let (mut parts, body) = res.into_parts();
13046                    let mut body = common::Body::new(body);
13047                    if !parts.status.is_success() {
13048                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13049                        let error = serde_json::from_str(&common::to_string(&bytes));
13050                        let response = common::to_response(parts, bytes.into());
13051
13052                        if let common::Retry::After(d) =
13053                            dlg.http_failure(&response, error.as_ref().ok())
13054                        {
13055                            sleep(d).await;
13056                            continue;
13057                        }
13058
13059                        dlg.finished(false);
13060
13061                        return Err(match error {
13062                            Ok(value) => common::Error::BadRequest(value),
13063                            _ => common::Error::Failure(response),
13064                        });
13065                    }
13066                    let response = {
13067                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13068                        let encoded = common::to_string(&bytes);
13069                        match serde_json::from_str(&encoded) {
13070                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13071                            Err(error) => {
13072                                dlg.response_json_decode_error(&encoded, &error);
13073                                return Err(common::Error::JsonDecodeError(
13074                                    encoded.to_string(),
13075                                    error,
13076                                ));
13077                            }
13078                        }
13079                    };
13080
13081                    dlg.finished(true);
13082                    return Ok(response);
13083                }
13084            }
13085        }
13086    }
13087
13088    ///
13089    /// Sets the *request* property to the given value.
13090    ///
13091    /// Even though the property as already been set when instantiating this call,
13092    /// we provide this method for API completeness.
13093    pub fn request(
13094        mut self,
13095        new_value: GcpUserAccessBinding,
13096    ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
13097        self._request = new_value;
13098        self
13099    }
13100    /// Required. Example: "organizations/256"
13101    ///
13102    /// Sets the *parent* path property to the given value.
13103    ///
13104    /// Even though the property as already been set when instantiating this call,
13105    /// we provide this method for API completeness.
13106    pub fn parent(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
13107        self._parent = new_value.to_string();
13108        self
13109    }
13110    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13111    /// while executing the actual API request.
13112    ///
13113    /// ````text
13114    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13115    /// ````
13116    ///
13117    /// Sets the *delegate* property to the given value.
13118    pub fn delegate(
13119        mut self,
13120        new_value: &'a mut dyn common::Delegate,
13121    ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
13122        self._delegate = Some(new_value);
13123        self
13124    }
13125
13126    /// Set any additional parameter of the query string used in the request.
13127    /// It should be used to set parameters which are not yet available through their own
13128    /// setters.
13129    ///
13130    /// Please note that this method must not be used to set any of the known parameters
13131    /// which have their own setter method. If done anyway, the request will fail.
13132    ///
13133    /// # Additional Parameters
13134    ///
13135    /// * *$.xgafv* (query-string) - V1 error format.
13136    /// * *access_token* (query-string) - OAuth access token.
13137    /// * *alt* (query-string) - Data format for response.
13138    /// * *callback* (query-string) - JSONP
13139    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13140    /// * *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.
13141    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13142    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13143    /// * *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.
13144    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13145    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13146    pub fn param<T>(
13147        mut self,
13148        name: T,
13149        value: T,
13150    ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C>
13151    where
13152        T: AsRef<str>,
13153    {
13154        self._additional_params
13155            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13156        self
13157    }
13158
13159    /// Identifies the authorization scope for the method you are building.
13160    ///
13161    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13162    /// [`Scope::CloudPlatform`].
13163    ///
13164    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13165    /// tokens for more than one scope.
13166    ///
13167    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13168    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13169    /// sufficient, a read-write scope will do as well.
13170    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingCreateCall<'a, C>
13171    where
13172        St: AsRef<str>,
13173    {
13174        self._scopes.insert(String::from(scope.as_ref()));
13175        self
13176    }
13177    /// Identifies the authorization scope(s) for the method you are building.
13178    ///
13179    /// See [`Self::add_scope()`] for details.
13180    pub fn add_scopes<I, St>(
13181        mut self,
13182        scopes: I,
13183    ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C>
13184    where
13185        I: IntoIterator<Item = St>,
13186        St: AsRef<str>,
13187    {
13188        self._scopes
13189            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13190        self
13191    }
13192
13193    /// Removes all scopes, and no default scope will be used either.
13194    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13195    /// for details).
13196    pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
13197        self._scopes.clear();
13198        self
13199    }
13200}
13201
13202/// Deletes a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the binding deletion is deployed onto all affected users, which may take more time.
13203///
13204/// A builder for the *gcpUserAccessBindings.delete* method supported by a *organization* resource.
13205/// It is not used directly, but through a [`OrganizationMethods`] instance.
13206///
13207/// # Example
13208///
13209/// Instantiate a resource method builder
13210///
13211/// ```test_harness,no_run
13212/// # extern crate hyper;
13213/// # extern crate hyper_rustls;
13214/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
13215/// # async fn dox() {
13216/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13217///
13218/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13219/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13220/// #     .with_native_roots()
13221/// #     .unwrap()
13222/// #     .https_only()
13223/// #     .enable_http2()
13224/// #     .build();
13225///
13226/// # let executor = hyper_util::rt::TokioExecutor::new();
13227/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13228/// #     secret,
13229/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13230/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13231/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13232/// #     ),
13233/// # ).build().await.unwrap();
13234///
13235/// # let client = hyper_util::client::legacy::Client::builder(
13236/// #     hyper_util::rt::TokioExecutor::new()
13237/// # )
13238/// # .build(
13239/// #     hyper_rustls::HttpsConnectorBuilder::new()
13240/// #         .with_native_roots()
13241/// #         .unwrap()
13242/// #         .https_or_http()
13243/// #         .enable_http2()
13244/// #         .build()
13245/// # );
13246/// # let mut hub = AccessContextManager::new(client, auth);
13247/// // You can configure optional parameters by calling the respective setters at will, and
13248/// // execute the final call using `doit()`.
13249/// // Values shown here are possibly random and not representative !
13250/// let result = hub.organizations().gcp_user_access_bindings_delete("name")
13251///              .doit().await;
13252/// # }
13253/// ```
13254pub struct OrganizationGcpUserAccessBindingDeleteCall<'a, C>
13255where
13256    C: 'a,
13257{
13258    hub: &'a AccessContextManager<C>,
13259    _name: String,
13260    _delegate: Option<&'a mut dyn common::Delegate>,
13261    _additional_params: HashMap<String, String>,
13262    _scopes: BTreeSet<String>,
13263}
13264
13265impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingDeleteCall<'a, C> {}
13266
13267impl<'a, C> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
13268where
13269    C: common::Connector,
13270{
13271    /// Perform the operation you have build so far.
13272    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13273        use std::borrow::Cow;
13274        use std::io::{Read, Seek};
13275
13276        use common::{url::Params, ToParts};
13277        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13278
13279        let mut dd = common::DefaultDelegate;
13280        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13281        dlg.begin(common::MethodInfo {
13282            id: "accesscontextmanager.organizations.gcpUserAccessBindings.delete",
13283            http_method: hyper::Method::DELETE,
13284        });
13285
13286        for &field in ["alt", "name"].iter() {
13287            if self._additional_params.contains_key(field) {
13288                dlg.finished(false);
13289                return Err(common::Error::FieldClash(field));
13290            }
13291        }
13292
13293        let mut params = Params::with_capacity(3 + self._additional_params.len());
13294        params.push("name", self._name);
13295
13296        params.extend(self._additional_params.iter());
13297
13298        params.push("alt", "json");
13299        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13300        if self._scopes.is_empty() {
13301            self._scopes
13302                .insert(Scope::CloudPlatform.as_ref().to_string());
13303        }
13304
13305        #[allow(clippy::single_element_loop)]
13306        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13307            url = params.uri_replacement(url, param_name, find_this, true);
13308        }
13309        {
13310            let to_remove = ["name"];
13311            params.remove_params(&to_remove);
13312        }
13313
13314        let url = params.parse_with_url(&url);
13315
13316        loop {
13317            let token = match self
13318                .hub
13319                .auth
13320                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13321                .await
13322            {
13323                Ok(token) => token,
13324                Err(e) => match dlg.token(e) {
13325                    Ok(token) => token,
13326                    Err(e) => {
13327                        dlg.finished(false);
13328                        return Err(common::Error::MissingToken(e));
13329                    }
13330                },
13331            };
13332            let mut req_result = {
13333                let client = &self.hub.client;
13334                dlg.pre_request();
13335                let mut req_builder = hyper::Request::builder()
13336                    .method(hyper::Method::DELETE)
13337                    .uri(url.as_str())
13338                    .header(USER_AGENT, self.hub._user_agent.clone());
13339
13340                if let Some(token) = token.as_ref() {
13341                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13342                }
13343
13344                let request = req_builder
13345                    .header(CONTENT_LENGTH, 0_u64)
13346                    .body(common::to_body::<String>(None));
13347
13348                client.request(request.unwrap()).await
13349            };
13350
13351            match req_result {
13352                Err(err) => {
13353                    if let common::Retry::After(d) = dlg.http_error(&err) {
13354                        sleep(d).await;
13355                        continue;
13356                    }
13357                    dlg.finished(false);
13358                    return Err(common::Error::HttpError(err));
13359                }
13360                Ok(res) => {
13361                    let (mut parts, body) = res.into_parts();
13362                    let mut body = common::Body::new(body);
13363                    if !parts.status.is_success() {
13364                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13365                        let error = serde_json::from_str(&common::to_string(&bytes));
13366                        let response = common::to_response(parts, bytes.into());
13367
13368                        if let common::Retry::After(d) =
13369                            dlg.http_failure(&response, error.as_ref().ok())
13370                        {
13371                            sleep(d).await;
13372                            continue;
13373                        }
13374
13375                        dlg.finished(false);
13376
13377                        return Err(match error {
13378                            Ok(value) => common::Error::BadRequest(value),
13379                            _ => common::Error::Failure(response),
13380                        });
13381                    }
13382                    let response = {
13383                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13384                        let encoded = common::to_string(&bytes);
13385                        match serde_json::from_str(&encoded) {
13386                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13387                            Err(error) => {
13388                                dlg.response_json_decode_error(&encoded, &error);
13389                                return Err(common::Error::JsonDecodeError(
13390                                    encoded.to_string(),
13391                                    error,
13392                                ));
13393                            }
13394                        }
13395                    };
13396
13397                    dlg.finished(true);
13398                    return Ok(response);
13399                }
13400            }
13401        }
13402    }
13403
13404    /// Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
13405    ///
13406    /// Sets the *name* path property to the given value.
13407    ///
13408    /// Even though the property as already been set when instantiating this call,
13409    /// we provide this method for API completeness.
13410    pub fn name(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
13411        self._name = new_value.to_string();
13412        self
13413    }
13414    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13415    /// while executing the actual API request.
13416    ///
13417    /// ````text
13418    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13419    /// ````
13420    ///
13421    /// Sets the *delegate* property to the given value.
13422    pub fn delegate(
13423        mut self,
13424        new_value: &'a mut dyn common::Delegate,
13425    ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
13426        self._delegate = Some(new_value);
13427        self
13428    }
13429
13430    /// Set any additional parameter of the query string used in the request.
13431    /// It should be used to set parameters which are not yet available through their own
13432    /// setters.
13433    ///
13434    /// Please note that this method must not be used to set any of the known parameters
13435    /// which have their own setter method. If done anyway, the request will fail.
13436    ///
13437    /// # Additional Parameters
13438    ///
13439    /// * *$.xgafv* (query-string) - V1 error format.
13440    /// * *access_token* (query-string) - OAuth access token.
13441    /// * *alt* (query-string) - Data format for response.
13442    /// * *callback* (query-string) - JSONP
13443    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13444    /// * *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.
13445    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13446    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13447    /// * *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.
13448    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13449    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13450    pub fn param<T>(
13451        mut self,
13452        name: T,
13453        value: T,
13454    ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
13455    where
13456        T: AsRef<str>,
13457    {
13458        self._additional_params
13459            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13460        self
13461    }
13462
13463    /// Identifies the authorization scope for the method you are building.
13464    ///
13465    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13466    /// [`Scope::CloudPlatform`].
13467    ///
13468    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13469    /// tokens for more than one scope.
13470    ///
13471    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13472    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13473    /// sufficient, a read-write scope will do as well.
13474    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
13475    where
13476        St: AsRef<str>,
13477    {
13478        self._scopes.insert(String::from(scope.as_ref()));
13479        self
13480    }
13481    /// Identifies the authorization scope(s) for the method you are building.
13482    ///
13483    /// See [`Self::add_scope()`] for details.
13484    pub fn add_scopes<I, St>(
13485        mut self,
13486        scopes: I,
13487    ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
13488    where
13489        I: IntoIterator<Item = St>,
13490        St: AsRef<str>,
13491    {
13492        self._scopes
13493            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13494        self
13495    }
13496
13497    /// Removes all scopes, and no default scope will be used either.
13498    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13499    /// for details).
13500    pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
13501        self._scopes.clear();
13502        self
13503    }
13504}
13505
13506/// Gets the GcpUserAccessBinding with the given name.
13507///
13508/// A builder for the *gcpUserAccessBindings.get* method supported by a *organization* resource.
13509/// It is not used directly, but through a [`OrganizationMethods`] instance.
13510///
13511/// # Example
13512///
13513/// Instantiate a resource method builder
13514///
13515/// ```test_harness,no_run
13516/// # extern crate hyper;
13517/// # extern crate hyper_rustls;
13518/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
13519/// # async fn dox() {
13520/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13521///
13522/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13523/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13524/// #     .with_native_roots()
13525/// #     .unwrap()
13526/// #     .https_only()
13527/// #     .enable_http2()
13528/// #     .build();
13529///
13530/// # let executor = hyper_util::rt::TokioExecutor::new();
13531/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13532/// #     secret,
13533/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13534/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13535/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13536/// #     ),
13537/// # ).build().await.unwrap();
13538///
13539/// # let client = hyper_util::client::legacy::Client::builder(
13540/// #     hyper_util::rt::TokioExecutor::new()
13541/// # )
13542/// # .build(
13543/// #     hyper_rustls::HttpsConnectorBuilder::new()
13544/// #         .with_native_roots()
13545/// #         .unwrap()
13546/// #         .https_or_http()
13547/// #         .enable_http2()
13548/// #         .build()
13549/// # );
13550/// # let mut hub = AccessContextManager::new(client, auth);
13551/// // You can configure optional parameters by calling the respective setters at will, and
13552/// // execute the final call using `doit()`.
13553/// // Values shown here are possibly random and not representative !
13554/// let result = hub.organizations().gcp_user_access_bindings_get("name")
13555///              .doit().await;
13556/// # }
13557/// ```
13558pub struct OrganizationGcpUserAccessBindingGetCall<'a, C>
13559where
13560    C: 'a,
13561{
13562    hub: &'a AccessContextManager<C>,
13563    _name: String,
13564    _delegate: Option<&'a mut dyn common::Delegate>,
13565    _additional_params: HashMap<String, String>,
13566    _scopes: BTreeSet<String>,
13567}
13568
13569impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingGetCall<'a, C> {}
13570
13571impl<'a, C> OrganizationGcpUserAccessBindingGetCall<'a, C>
13572where
13573    C: common::Connector,
13574{
13575    /// Perform the operation you have build so far.
13576    pub async fn doit(mut self) -> common::Result<(common::Response, GcpUserAccessBinding)> {
13577        use std::borrow::Cow;
13578        use std::io::{Read, Seek};
13579
13580        use common::{url::Params, ToParts};
13581        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13582
13583        let mut dd = common::DefaultDelegate;
13584        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13585        dlg.begin(common::MethodInfo {
13586            id: "accesscontextmanager.organizations.gcpUserAccessBindings.get",
13587            http_method: hyper::Method::GET,
13588        });
13589
13590        for &field in ["alt", "name"].iter() {
13591            if self._additional_params.contains_key(field) {
13592                dlg.finished(false);
13593                return Err(common::Error::FieldClash(field));
13594            }
13595        }
13596
13597        let mut params = Params::with_capacity(3 + self._additional_params.len());
13598        params.push("name", self._name);
13599
13600        params.extend(self._additional_params.iter());
13601
13602        params.push("alt", "json");
13603        let mut url = self.hub._base_url.clone() + "v1/{+name}";
13604        if self._scopes.is_empty() {
13605            self._scopes
13606                .insert(Scope::CloudPlatform.as_ref().to_string());
13607        }
13608
13609        #[allow(clippy::single_element_loop)]
13610        for &(find_this, param_name) in [("{+name}", "name")].iter() {
13611            url = params.uri_replacement(url, param_name, find_this, true);
13612        }
13613        {
13614            let to_remove = ["name"];
13615            params.remove_params(&to_remove);
13616        }
13617
13618        let url = params.parse_with_url(&url);
13619
13620        loop {
13621            let token = match self
13622                .hub
13623                .auth
13624                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13625                .await
13626            {
13627                Ok(token) => token,
13628                Err(e) => match dlg.token(e) {
13629                    Ok(token) => token,
13630                    Err(e) => {
13631                        dlg.finished(false);
13632                        return Err(common::Error::MissingToken(e));
13633                    }
13634                },
13635            };
13636            let mut req_result = {
13637                let client = &self.hub.client;
13638                dlg.pre_request();
13639                let mut req_builder = hyper::Request::builder()
13640                    .method(hyper::Method::GET)
13641                    .uri(url.as_str())
13642                    .header(USER_AGENT, self.hub._user_agent.clone());
13643
13644                if let Some(token) = token.as_ref() {
13645                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13646                }
13647
13648                let request = req_builder
13649                    .header(CONTENT_LENGTH, 0_u64)
13650                    .body(common::to_body::<String>(None));
13651
13652                client.request(request.unwrap()).await
13653            };
13654
13655            match req_result {
13656                Err(err) => {
13657                    if let common::Retry::After(d) = dlg.http_error(&err) {
13658                        sleep(d).await;
13659                        continue;
13660                    }
13661                    dlg.finished(false);
13662                    return Err(common::Error::HttpError(err));
13663                }
13664                Ok(res) => {
13665                    let (mut parts, body) = res.into_parts();
13666                    let mut body = common::Body::new(body);
13667                    if !parts.status.is_success() {
13668                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13669                        let error = serde_json::from_str(&common::to_string(&bytes));
13670                        let response = common::to_response(parts, bytes.into());
13671
13672                        if let common::Retry::After(d) =
13673                            dlg.http_failure(&response, error.as_ref().ok())
13674                        {
13675                            sleep(d).await;
13676                            continue;
13677                        }
13678
13679                        dlg.finished(false);
13680
13681                        return Err(match error {
13682                            Ok(value) => common::Error::BadRequest(value),
13683                            _ => common::Error::Failure(response),
13684                        });
13685                    }
13686                    let response = {
13687                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13688                        let encoded = common::to_string(&bytes);
13689                        match serde_json::from_str(&encoded) {
13690                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13691                            Err(error) => {
13692                                dlg.response_json_decode_error(&encoded, &error);
13693                                return Err(common::Error::JsonDecodeError(
13694                                    encoded.to_string(),
13695                                    error,
13696                                ));
13697                            }
13698                        }
13699                    };
13700
13701                    dlg.finished(true);
13702                    return Ok(response);
13703                }
13704            }
13705        }
13706    }
13707
13708    /// Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
13709    ///
13710    /// Sets the *name* path property to the given value.
13711    ///
13712    /// Even though the property as already been set when instantiating this call,
13713    /// we provide this method for API completeness.
13714    pub fn name(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
13715        self._name = new_value.to_string();
13716        self
13717    }
13718    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13719    /// while executing the actual API request.
13720    ///
13721    /// ````text
13722    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13723    /// ````
13724    ///
13725    /// Sets the *delegate* property to the given value.
13726    pub fn delegate(
13727        mut self,
13728        new_value: &'a mut dyn common::Delegate,
13729    ) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
13730        self._delegate = Some(new_value);
13731        self
13732    }
13733
13734    /// Set any additional parameter of the query string used in the request.
13735    /// It should be used to set parameters which are not yet available through their own
13736    /// setters.
13737    ///
13738    /// Please note that this method must not be used to set any of the known parameters
13739    /// which have their own setter method. If done anyway, the request will fail.
13740    ///
13741    /// # Additional Parameters
13742    ///
13743    /// * *$.xgafv* (query-string) - V1 error format.
13744    /// * *access_token* (query-string) - OAuth access token.
13745    /// * *alt* (query-string) - Data format for response.
13746    /// * *callback* (query-string) - JSONP
13747    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13748    /// * *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.
13749    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13750    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13751    /// * *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.
13752    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13753    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13754    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGcpUserAccessBindingGetCall<'a, C>
13755    where
13756        T: AsRef<str>,
13757    {
13758        self._additional_params
13759            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13760        self
13761    }
13762
13763    /// Identifies the authorization scope for the method you are building.
13764    ///
13765    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13766    /// [`Scope::CloudPlatform`].
13767    ///
13768    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13769    /// tokens for more than one scope.
13770    ///
13771    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13772    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13773    /// sufficient, a read-write scope will do as well.
13774    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingGetCall<'a, C>
13775    where
13776        St: AsRef<str>,
13777    {
13778        self._scopes.insert(String::from(scope.as_ref()));
13779        self
13780    }
13781    /// Identifies the authorization scope(s) for the method you are building.
13782    ///
13783    /// See [`Self::add_scope()`] for details.
13784    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGcpUserAccessBindingGetCall<'a, C>
13785    where
13786        I: IntoIterator<Item = St>,
13787        St: AsRef<str>,
13788    {
13789        self._scopes
13790            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13791        self
13792    }
13793
13794    /// Removes all scopes, and no default scope will be used either.
13795    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13796    /// for details).
13797    pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
13798        self._scopes.clear();
13799        self
13800    }
13801}
13802
13803/// Lists all GcpUserAccessBindings for a Google Cloud organization.
13804///
13805/// A builder for the *gcpUserAccessBindings.list* method supported by a *organization* resource.
13806/// It is not used directly, but through a [`OrganizationMethods`] instance.
13807///
13808/// # Example
13809///
13810/// Instantiate a resource method builder
13811///
13812/// ```test_harness,no_run
13813/// # extern crate hyper;
13814/// # extern crate hyper_rustls;
13815/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
13816/// # async fn dox() {
13817/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13818///
13819/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13820/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13821/// #     .with_native_roots()
13822/// #     .unwrap()
13823/// #     .https_only()
13824/// #     .enable_http2()
13825/// #     .build();
13826///
13827/// # let executor = hyper_util::rt::TokioExecutor::new();
13828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13829/// #     secret,
13830/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13831/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
13832/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
13833/// #     ),
13834/// # ).build().await.unwrap();
13835///
13836/// # let client = hyper_util::client::legacy::Client::builder(
13837/// #     hyper_util::rt::TokioExecutor::new()
13838/// # )
13839/// # .build(
13840/// #     hyper_rustls::HttpsConnectorBuilder::new()
13841/// #         .with_native_roots()
13842/// #         .unwrap()
13843/// #         .https_or_http()
13844/// #         .enable_http2()
13845/// #         .build()
13846/// # );
13847/// # let mut hub = AccessContextManager::new(client, auth);
13848/// // You can configure optional parameters by calling the respective setters at will, and
13849/// // execute the final call using `doit()`.
13850/// // Values shown here are possibly random and not representative !
13851/// let result = hub.organizations().gcp_user_access_bindings_list("parent")
13852///              .page_token("vero")
13853///              .page_size(-44)
13854///              .doit().await;
13855/// # }
13856/// ```
13857pub struct OrganizationGcpUserAccessBindingListCall<'a, C>
13858where
13859    C: 'a,
13860{
13861    hub: &'a AccessContextManager<C>,
13862    _parent: String,
13863    _page_token: Option<String>,
13864    _page_size: Option<i32>,
13865    _delegate: Option<&'a mut dyn common::Delegate>,
13866    _additional_params: HashMap<String, String>,
13867    _scopes: BTreeSet<String>,
13868}
13869
13870impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingListCall<'a, C> {}
13871
13872impl<'a, C> OrganizationGcpUserAccessBindingListCall<'a, C>
13873where
13874    C: common::Connector,
13875{
13876    /// Perform the operation you have build so far.
13877    pub async fn doit(
13878        mut self,
13879    ) -> common::Result<(common::Response, ListGcpUserAccessBindingsResponse)> {
13880        use std::borrow::Cow;
13881        use std::io::{Read, Seek};
13882
13883        use common::{url::Params, ToParts};
13884        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13885
13886        let mut dd = common::DefaultDelegate;
13887        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13888        dlg.begin(common::MethodInfo {
13889            id: "accesscontextmanager.organizations.gcpUserAccessBindings.list",
13890            http_method: hyper::Method::GET,
13891        });
13892
13893        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
13894            if self._additional_params.contains_key(field) {
13895                dlg.finished(false);
13896                return Err(common::Error::FieldClash(field));
13897            }
13898        }
13899
13900        let mut params = Params::with_capacity(5 + self._additional_params.len());
13901        params.push("parent", self._parent);
13902        if let Some(value) = self._page_token.as_ref() {
13903            params.push("pageToken", value);
13904        }
13905        if let Some(value) = self._page_size.as_ref() {
13906            params.push("pageSize", value.to_string());
13907        }
13908
13909        params.extend(self._additional_params.iter());
13910
13911        params.push("alt", "json");
13912        let mut url = self.hub._base_url.clone() + "v1/{+parent}/gcpUserAccessBindings";
13913        if self._scopes.is_empty() {
13914            self._scopes
13915                .insert(Scope::CloudPlatform.as_ref().to_string());
13916        }
13917
13918        #[allow(clippy::single_element_loop)]
13919        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13920            url = params.uri_replacement(url, param_name, find_this, true);
13921        }
13922        {
13923            let to_remove = ["parent"];
13924            params.remove_params(&to_remove);
13925        }
13926
13927        let url = params.parse_with_url(&url);
13928
13929        loop {
13930            let token = match self
13931                .hub
13932                .auth
13933                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13934                .await
13935            {
13936                Ok(token) => token,
13937                Err(e) => match dlg.token(e) {
13938                    Ok(token) => token,
13939                    Err(e) => {
13940                        dlg.finished(false);
13941                        return Err(common::Error::MissingToken(e));
13942                    }
13943                },
13944            };
13945            let mut req_result = {
13946                let client = &self.hub.client;
13947                dlg.pre_request();
13948                let mut req_builder = hyper::Request::builder()
13949                    .method(hyper::Method::GET)
13950                    .uri(url.as_str())
13951                    .header(USER_AGENT, self.hub._user_agent.clone());
13952
13953                if let Some(token) = token.as_ref() {
13954                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13955                }
13956
13957                let request = req_builder
13958                    .header(CONTENT_LENGTH, 0_u64)
13959                    .body(common::to_body::<String>(None));
13960
13961                client.request(request.unwrap()).await
13962            };
13963
13964            match req_result {
13965                Err(err) => {
13966                    if let common::Retry::After(d) = dlg.http_error(&err) {
13967                        sleep(d).await;
13968                        continue;
13969                    }
13970                    dlg.finished(false);
13971                    return Err(common::Error::HttpError(err));
13972                }
13973                Ok(res) => {
13974                    let (mut parts, body) = res.into_parts();
13975                    let mut body = common::Body::new(body);
13976                    if !parts.status.is_success() {
13977                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13978                        let error = serde_json::from_str(&common::to_string(&bytes));
13979                        let response = common::to_response(parts, bytes.into());
13980
13981                        if let common::Retry::After(d) =
13982                            dlg.http_failure(&response, error.as_ref().ok())
13983                        {
13984                            sleep(d).await;
13985                            continue;
13986                        }
13987
13988                        dlg.finished(false);
13989
13990                        return Err(match error {
13991                            Ok(value) => common::Error::BadRequest(value),
13992                            _ => common::Error::Failure(response),
13993                        });
13994                    }
13995                    let response = {
13996                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13997                        let encoded = common::to_string(&bytes);
13998                        match serde_json::from_str(&encoded) {
13999                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14000                            Err(error) => {
14001                                dlg.response_json_decode_error(&encoded, &error);
14002                                return Err(common::Error::JsonDecodeError(
14003                                    encoded.to_string(),
14004                                    error,
14005                                ));
14006                            }
14007                        }
14008                    };
14009
14010                    dlg.finished(true);
14011                    return Ok(response);
14012                }
14013            }
14014        }
14015    }
14016
14017    /// Required. Example: "organizations/256"
14018    ///
14019    /// Sets the *parent* path property to the given value.
14020    ///
14021    /// Even though the property as already been set when instantiating this call,
14022    /// we provide this method for API completeness.
14023    pub fn parent(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
14024        self._parent = new_value.to_string();
14025        self
14026    }
14027    /// Optional. If left blank, returns the first page. To enumerate all items, use the next_page_token from your previous list operation.
14028    ///
14029    /// Sets the *page token* query property to the given value.
14030    pub fn page_token(
14031        mut self,
14032        new_value: &str,
14033    ) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
14034        self._page_token = Some(new_value.to_string());
14035        self
14036    }
14037    /// Optional. Maximum number of items to return. The server may return fewer items. If left blank, the server may return any number of items.
14038    ///
14039    /// Sets the *page size* query property to the given value.
14040    pub fn page_size(mut self, new_value: i32) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
14041        self._page_size = Some(new_value);
14042        self
14043    }
14044    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14045    /// while executing the actual API request.
14046    ///
14047    /// ````text
14048    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14049    /// ````
14050    ///
14051    /// Sets the *delegate* property to the given value.
14052    pub fn delegate(
14053        mut self,
14054        new_value: &'a mut dyn common::Delegate,
14055    ) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
14056        self._delegate = Some(new_value);
14057        self
14058    }
14059
14060    /// Set any additional parameter of the query string used in the request.
14061    /// It should be used to set parameters which are not yet available through their own
14062    /// setters.
14063    ///
14064    /// Please note that this method must not be used to set any of the known parameters
14065    /// which have their own setter method. If done anyway, the request will fail.
14066    ///
14067    /// # Additional Parameters
14068    ///
14069    /// * *$.xgafv* (query-string) - V1 error format.
14070    /// * *access_token* (query-string) - OAuth access token.
14071    /// * *alt* (query-string) - Data format for response.
14072    /// * *callback* (query-string) - JSONP
14073    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14074    /// * *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.
14075    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14076    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14077    /// * *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.
14078    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14079    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14080    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGcpUserAccessBindingListCall<'a, C>
14081    where
14082        T: AsRef<str>,
14083    {
14084        self._additional_params
14085            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14086        self
14087    }
14088
14089    /// Identifies the authorization scope for the method you are building.
14090    ///
14091    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14092    /// [`Scope::CloudPlatform`].
14093    ///
14094    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14095    /// tokens for more than one scope.
14096    ///
14097    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14098    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14099    /// sufficient, a read-write scope will do as well.
14100    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingListCall<'a, C>
14101    where
14102        St: AsRef<str>,
14103    {
14104        self._scopes.insert(String::from(scope.as_ref()));
14105        self
14106    }
14107    /// Identifies the authorization scope(s) for the method you are building.
14108    ///
14109    /// See [`Self::add_scope()`] for details.
14110    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGcpUserAccessBindingListCall<'a, C>
14111    where
14112        I: IntoIterator<Item = St>,
14113        St: AsRef<str>,
14114    {
14115        self._scopes
14116            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14117        self
14118    }
14119
14120    /// Removes all scopes, and no default scope will be used either.
14121    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14122    /// for details).
14123    pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
14124        self._scopes.clear();
14125        self
14126    }
14127}
14128
14129/// Updates a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the changed binding is deployed onto all affected users, which may take more time.
14130///
14131/// A builder for the *gcpUserAccessBindings.patch* method supported by a *organization* resource.
14132/// It is not used directly, but through a [`OrganizationMethods`] instance.
14133///
14134/// # Example
14135///
14136/// Instantiate a resource method builder
14137///
14138/// ```test_harness,no_run
14139/// # extern crate hyper;
14140/// # extern crate hyper_rustls;
14141/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
14142/// use accesscontextmanager1::api::GcpUserAccessBinding;
14143/// # async fn dox() {
14144/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14145///
14146/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14147/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14148/// #     .with_native_roots()
14149/// #     .unwrap()
14150/// #     .https_only()
14151/// #     .enable_http2()
14152/// #     .build();
14153///
14154/// # let executor = hyper_util::rt::TokioExecutor::new();
14155/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14156/// #     secret,
14157/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14158/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14159/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14160/// #     ),
14161/// # ).build().await.unwrap();
14162///
14163/// # let client = hyper_util::client::legacy::Client::builder(
14164/// #     hyper_util::rt::TokioExecutor::new()
14165/// # )
14166/// # .build(
14167/// #     hyper_rustls::HttpsConnectorBuilder::new()
14168/// #         .with_native_roots()
14169/// #         .unwrap()
14170/// #         .https_or_http()
14171/// #         .enable_http2()
14172/// #         .build()
14173/// # );
14174/// # let mut hub = AccessContextManager::new(client, auth);
14175/// // As the method needs a request, you would usually fill it with the desired information
14176/// // into the respective structure. Some of the parts shown here might not be applicable !
14177/// // Values shown here are possibly random and not representative !
14178/// let mut req = GcpUserAccessBinding::default();
14179///
14180/// // You can configure optional parameters by calling the respective setters at will, and
14181/// // execute the final call using `doit()`.
14182/// // Values shown here are possibly random and not representative !
14183/// let result = hub.organizations().gcp_user_access_bindings_patch(req, "name")
14184///              .update_mask(FieldMask::new::<&str>(&[]))
14185///              .append(true)
14186///              .doit().await;
14187/// # }
14188/// ```
14189pub struct OrganizationGcpUserAccessBindingPatchCall<'a, C>
14190where
14191    C: 'a,
14192{
14193    hub: &'a AccessContextManager<C>,
14194    _request: GcpUserAccessBinding,
14195    _name: String,
14196    _update_mask: Option<common::FieldMask>,
14197    _append: Option<bool>,
14198    _delegate: Option<&'a mut dyn common::Delegate>,
14199    _additional_params: HashMap<String, String>,
14200    _scopes: BTreeSet<String>,
14201}
14202
14203impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingPatchCall<'a, C> {}
14204
14205impl<'a, C> OrganizationGcpUserAccessBindingPatchCall<'a, C>
14206where
14207    C: common::Connector,
14208{
14209    /// Perform the operation you have build so far.
14210    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14211        use std::borrow::Cow;
14212        use std::io::{Read, Seek};
14213
14214        use common::{url::Params, ToParts};
14215        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14216
14217        let mut dd = common::DefaultDelegate;
14218        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14219        dlg.begin(common::MethodInfo {
14220            id: "accesscontextmanager.organizations.gcpUserAccessBindings.patch",
14221            http_method: hyper::Method::PATCH,
14222        });
14223
14224        for &field in ["alt", "name", "updateMask", "append"].iter() {
14225            if self._additional_params.contains_key(field) {
14226                dlg.finished(false);
14227                return Err(common::Error::FieldClash(field));
14228            }
14229        }
14230
14231        let mut params = Params::with_capacity(6 + self._additional_params.len());
14232        params.push("name", self._name);
14233        if let Some(value) = self._update_mask.as_ref() {
14234            params.push("updateMask", value.to_string());
14235        }
14236        if let Some(value) = self._append.as_ref() {
14237            params.push("append", value.to_string());
14238        }
14239
14240        params.extend(self._additional_params.iter());
14241
14242        params.push("alt", "json");
14243        let mut url = self.hub._base_url.clone() + "v1/{+name}";
14244        if self._scopes.is_empty() {
14245            self._scopes
14246                .insert(Scope::CloudPlatform.as_ref().to_string());
14247        }
14248
14249        #[allow(clippy::single_element_loop)]
14250        for &(find_this, param_name) in [("{+name}", "name")].iter() {
14251            url = params.uri_replacement(url, param_name, find_this, true);
14252        }
14253        {
14254            let to_remove = ["name"];
14255            params.remove_params(&to_remove);
14256        }
14257
14258        let url = params.parse_with_url(&url);
14259
14260        let mut json_mime_type = mime::APPLICATION_JSON;
14261        let mut request_value_reader = {
14262            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14263            common::remove_json_null_values(&mut value);
14264            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14265            serde_json::to_writer(&mut dst, &value).unwrap();
14266            dst
14267        };
14268        let request_size = request_value_reader
14269            .seek(std::io::SeekFrom::End(0))
14270            .unwrap();
14271        request_value_reader
14272            .seek(std::io::SeekFrom::Start(0))
14273            .unwrap();
14274
14275        loop {
14276            let token = match self
14277                .hub
14278                .auth
14279                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14280                .await
14281            {
14282                Ok(token) => token,
14283                Err(e) => match dlg.token(e) {
14284                    Ok(token) => token,
14285                    Err(e) => {
14286                        dlg.finished(false);
14287                        return Err(common::Error::MissingToken(e));
14288                    }
14289                },
14290            };
14291            request_value_reader
14292                .seek(std::io::SeekFrom::Start(0))
14293                .unwrap();
14294            let mut req_result = {
14295                let client = &self.hub.client;
14296                dlg.pre_request();
14297                let mut req_builder = hyper::Request::builder()
14298                    .method(hyper::Method::PATCH)
14299                    .uri(url.as_str())
14300                    .header(USER_AGENT, self.hub._user_agent.clone());
14301
14302                if let Some(token) = token.as_ref() {
14303                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14304                }
14305
14306                let request = req_builder
14307                    .header(CONTENT_TYPE, json_mime_type.to_string())
14308                    .header(CONTENT_LENGTH, request_size as u64)
14309                    .body(common::to_body(
14310                        request_value_reader.get_ref().clone().into(),
14311                    ));
14312
14313                client.request(request.unwrap()).await
14314            };
14315
14316            match req_result {
14317                Err(err) => {
14318                    if let common::Retry::After(d) = dlg.http_error(&err) {
14319                        sleep(d).await;
14320                        continue;
14321                    }
14322                    dlg.finished(false);
14323                    return Err(common::Error::HttpError(err));
14324                }
14325                Ok(res) => {
14326                    let (mut parts, body) = res.into_parts();
14327                    let mut body = common::Body::new(body);
14328                    if !parts.status.is_success() {
14329                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14330                        let error = serde_json::from_str(&common::to_string(&bytes));
14331                        let response = common::to_response(parts, bytes.into());
14332
14333                        if let common::Retry::After(d) =
14334                            dlg.http_failure(&response, error.as_ref().ok())
14335                        {
14336                            sleep(d).await;
14337                            continue;
14338                        }
14339
14340                        dlg.finished(false);
14341
14342                        return Err(match error {
14343                            Ok(value) => common::Error::BadRequest(value),
14344                            _ => common::Error::Failure(response),
14345                        });
14346                    }
14347                    let response = {
14348                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14349                        let encoded = common::to_string(&bytes);
14350                        match serde_json::from_str(&encoded) {
14351                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14352                            Err(error) => {
14353                                dlg.response_json_decode_error(&encoded, &error);
14354                                return Err(common::Error::JsonDecodeError(
14355                                    encoded.to_string(),
14356                                    error,
14357                                ));
14358                            }
14359                        }
14360                    };
14361
14362                    dlg.finished(true);
14363                    return Ok(response);
14364                }
14365            }
14366        }
14367    }
14368
14369    ///
14370    /// Sets the *request* property to the given value.
14371    ///
14372    /// Even though the property as already been set when instantiating this call,
14373    /// we provide this method for API completeness.
14374    pub fn request(
14375        mut self,
14376        new_value: GcpUserAccessBinding,
14377    ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
14378        self._request = new_value;
14379        self
14380    }
14381    /// Immutable. Assigned by the server during creation. The last segment has an arbitrary length and has only URI unreserved characters (as defined by [RFC 3986 Section 2.3](https://tools.ietf.org/html/rfc3986#section-2.3)). Should not be specified by the client during creation. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
14382    ///
14383    /// Sets the *name* path property to the given value.
14384    ///
14385    /// Even though the property as already been set when instantiating this call,
14386    /// we provide this method for API completeness.
14387    pub fn name(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
14388        self._name = new_value.to_string();
14389        self
14390    }
14391    /// Required. Only the fields specified in this mask are updated. Because name and group_key cannot be changed, update_mask is required and may only contain the following fields: `access_levels`, `dry_run_access_levels`, `session_settings`, `scoped_access_settings`. update_mask { paths: "access_levels" }
14392    ///
14393    /// Sets the *update mask* query property to the given value.
14394    pub fn update_mask(
14395        mut self,
14396        new_value: common::FieldMask,
14397    ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
14398        self._update_mask = Some(new_value);
14399        self
14400    }
14401    /// Optional. This field controls whether or not certain repeated settings in the update request overwrite or append to existing settings on the binding. If true, then append. Otherwise overwrite. So far, only scoped_access_settings with session_settings supports appending. Global access_levels, access_levels in scoped_access_settings, dry_run_access_levels, and session_settings are not compatible with append functionality, and the request will return an error if append=true when these settings are in the update_mask. The request will also return an error if append=true when "scoped_access_settings" is not set in the update_mask.
14402    ///
14403    /// Sets the *append* query property to the given value.
14404    pub fn append(mut self, new_value: bool) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
14405        self._append = Some(new_value);
14406        self
14407    }
14408    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14409    /// while executing the actual API request.
14410    ///
14411    /// ````text
14412    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14413    /// ````
14414    ///
14415    /// Sets the *delegate* property to the given value.
14416    pub fn delegate(
14417        mut self,
14418        new_value: &'a mut dyn common::Delegate,
14419    ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
14420        self._delegate = Some(new_value);
14421        self
14422    }
14423
14424    /// Set any additional parameter of the query string used in the request.
14425    /// It should be used to set parameters which are not yet available through their own
14426    /// setters.
14427    ///
14428    /// Please note that this method must not be used to set any of the known parameters
14429    /// which have their own setter method. If done anyway, the request will fail.
14430    ///
14431    /// # Additional Parameters
14432    ///
14433    /// * *$.xgafv* (query-string) - V1 error format.
14434    /// * *access_token* (query-string) - OAuth access token.
14435    /// * *alt* (query-string) - Data format for response.
14436    /// * *callback* (query-string) - JSONP
14437    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14438    /// * *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.
14439    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14440    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14441    /// * *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.
14442    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14443    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14444    pub fn param<T>(mut self, name: T, value: T) -> OrganizationGcpUserAccessBindingPatchCall<'a, C>
14445    where
14446        T: AsRef<str>,
14447    {
14448        self._additional_params
14449            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14450        self
14451    }
14452
14453    /// Identifies the authorization scope for the method you are building.
14454    ///
14455    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14456    /// [`Scope::CloudPlatform`].
14457    ///
14458    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14459    /// tokens for more than one scope.
14460    ///
14461    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14462    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14463    /// sufficient, a read-write scope will do as well.
14464    pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingPatchCall<'a, C>
14465    where
14466        St: AsRef<str>,
14467    {
14468        self._scopes.insert(String::from(scope.as_ref()));
14469        self
14470    }
14471    /// Identifies the authorization scope(s) for the method you are building.
14472    ///
14473    /// See [`Self::add_scope()`] for details.
14474    pub fn add_scopes<I, St>(
14475        mut self,
14476        scopes: I,
14477    ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C>
14478    where
14479        I: IntoIterator<Item = St>,
14480        St: AsRef<str>,
14481    {
14482        self._scopes
14483            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14484        self
14485    }
14486
14487    /// Removes all scopes, and no default scope will be used either.
14488    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14489    /// for details).
14490    pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
14491        self._scopes.clear();
14492        self
14493    }
14494}
14495
14496/// Returns a VPC-SC supported service based on the service name.
14497///
14498/// A builder for the *get* method supported by a *service* resource.
14499/// It is not used directly, but through a [`ServiceMethods`] instance.
14500///
14501/// # Example
14502///
14503/// Instantiate a resource method builder
14504///
14505/// ```test_harness,no_run
14506/// # extern crate hyper;
14507/// # extern crate hyper_rustls;
14508/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
14509/// # async fn dox() {
14510/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14511///
14512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14513/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14514/// #     .with_native_roots()
14515/// #     .unwrap()
14516/// #     .https_only()
14517/// #     .enable_http2()
14518/// #     .build();
14519///
14520/// # let executor = hyper_util::rt::TokioExecutor::new();
14521/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14522/// #     secret,
14523/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14524/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14525/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14526/// #     ),
14527/// # ).build().await.unwrap();
14528///
14529/// # let client = hyper_util::client::legacy::Client::builder(
14530/// #     hyper_util::rt::TokioExecutor::new()
14531/// # )
14532/// # .build(
14533/// #     hyper_rustls::HttpsConnectorBuilder::new()
14534/// #         .with_native_roots()
14535/// #         .unwrap()
14536/// #         .https_or_http()
14537/// #         .enable_http2()
14538/// #         .build()
14539/// # );
14540/// # let mut hub = AccessContextManager::new(client, auth);
14541/// // You can configure optional parameters by calling the respective setters at will, and
14542/// // execute the final call using `doit()`.
14543/// // Values shown here are possibly random and not representative !
14544/// let result = hub.services().get("name")
14545///              .doit().await;
14546/// # }
14547/// ```
14548pub struct ServiceGetCall<'a, C>
14549where
14550    C: 'a,
14551{
14552    hub: &'a AccessContextManager<C>,
14553    _name: String,
14554    _delegate: Option<&'a mut dyn common::Delegate>,
14555    _additional_params: HashMap<String, String>,
14556    _scopes: BTreeSet<String>,
14557}
14558
14559impl<'a, C> common::CallBuilder for ServiceGetCall<'a, C> {}
14560
14561impl<'a, C> ServiceGetCall<'a, C>
14562where
14563    C: common::Connector,
14564{
14565    /// Perform the operation you have build so far.
14566    pub async fn doit(mut self) -> common::Result<(common::Response, SupportedService)> {
14567        use std::borrow::Cow;
14568        use std::io::{Read, Seek};
14569
14570        use common::{url::Params, ToParts};
14571        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14572
14573        let mut dd = common::DefaultDelegate;
14574        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14575        dlg.begin(common::MethodInfo {
14576            id: "accesscontextmanager.services.get",
14577            http_method: hyper::Method::GET,
14578        });
14579
14580        for &field in ["alt", "name"].iter() {
14581            if self._additional_params.contains_key(field) {
14582                dlg.finished(false);
14583                return Err(common::Error::FieldClash(field));
14584            }
14585        }
14586
14587        let mut params = Params::with_capacity(3 + self._additional_params.len());
14588        params.push("name", self._name);
14589
14590        params.extend(self._additional_params.iter());
14591
14592        params.push("alt", "json");
14593        let mut url = self.hub._base_url.clone() + "v1/services/{name}";
14594        if self._scopes.is_empty() {
14595            self._scopes
14596                .insert(Scope::CloudPlatform.as_ref().to_string());
14597        }
14598
14599        #[allow(clippy::single_element_loop)]
14600        for &(find_this, param_name) in [("{name}", "name")].iter() {
14601            url = params.uri_replacement(url, param_name, find_this, false);
14602        }
14603        {
14604            let to_remove = ["name"];
14605            params.remove_params(&to_remove);
14606        }
14607
14608        let url = params.parse_with_url(&url);
14609
14610        loop {
14611            let token = match self
14612                .hub
14613                .auth
14614                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14615                .await
14616            {
14617                Ok(token) => token,
14618                Err(e) => match dlg.token(e) {
14619                    Ok(token) => token,
14620                    Err(e) => {
14621                        dlg.finished(false);
14622                        return Err(common::Error::MissingToken(e));
14623                    }
14624                },
14625            };
14626            let mut req_result = {
14627                let client = &self.hub.client;
14628                dlg.pre_request();
14629                let mut req_builder = hyper::Request::builder()
14630                    .method(hyper::Method::GET)
14631                    .uri(url.as_str())
14632                    .header(USER_AGENT, self.hub._user_agent.clone());
14633
14634                if let Some(token) = token.as_ref() {
14635                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14636                }
14637
14638                let request = req_builder
14639                    .header(CONTENT_LENGTH, 0_u64)
14640                    .body(common::to_body::<String>(None));
14641
14642                client.request(request.unwrap()).await
14643            };
14644
14645            match req_result {
14646                Err(err) => {
14647                    if let common::Retry::After(d) = dlg.http_error(&err) {
14648                        sleep(d).await;
14649                        continue;
14650                    }
14651                    dlg.finished(false);
14652                    return Err(common::Error::HttpError(err));
14653                }
14654                Ok(res) => {
14655                    let (mut parts, body) = res.into_parts();
14656                    let mut body = common::Body::new(body);
14657                    if !parts.status.is_success() {
14658                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14659                        let error = serde_json::from_str(&common::to_string(&bytes));
14660                        let response = common::to_response(parts, bytes.into());
14661
14662                        if let common::Retry::After(d) =
14663                            dlg.http_failure(&response, error.as_ref().ok())
14664                        {
14665                            sleep(d).await;
14666                            continue;
14667                        }
14668
14669                        dlg.finished(false);
14670
14671                        return Err(match error {
14672                            Ok(value) => common::Error::BadRequest(value),
14673                            _ => common::Error::Failure(response),
14674                        });
14675                    }
14676                    let response = {
14677                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14678                        let encoded = common::to_string(&bytes);
14679                        match serde_json::from_str(&encoded) {
14680                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14681                            Err(error) => {
14682                                dlg.response_json_decode_error(&encoded, &error);
14683                                return Err(common::Error::JsonDecodeError(
14684                                    encoded.to_string(),
14685                                    error,
14686                                ));
14687                            }
14688                        }
14689                    };
14690
14691                    dlg.finished(true);
14692                    return Ok(response);
14693                }
14694            }
14695        }
14696    }
14697
14698    /// The name of the service to get information about. The names must be in the same format as used in defining a service perimeter, for example, `storage.googleapis.com`.
14699    ///
14700    /// Sets the *name* path property to the given value.
14701    ///
14702    /// Even though the property as already been set when instantiating this call,
14703    /// we provide this method for API completeness.
14704    pub fn name(mut self, new_value: &str) -> ServiceGetCall<'a, C> {
14705        self._name = new_value.to_string();
14706        self
14707    }
14708    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14709    /// while executing the actual API request.
14710    ///
14711    /// ````text
14712    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14713    /// ````
14714    ///
14715    /// Sets the *delegate* property to the given value.
14716    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceGetCall<'a, C> {
14717        self._delegate = Some(new_value);
14718        self
14719    }
14720
14721    /// Set any additional parameter of the query string used in the request.
14722    /// It should be used to set parameters which are not yet available through their own
14723    /// setters.
14724    ///
14725    /// Please note that this method must not be used to set any of the known parameters
14726    /// which have their own setter method. If done anyway, the request will fail.
14727    ///
14728    /// # Additional Parameters
14729    ///
14730    /// * *$.xgafv* (query-string) - V1 error format.
14731    /// * *access_token* (query-string) - OAuth access token.
14732    /// * *alt* (query-string) - Data format for response.
14733    /// * *callback* (query-string) - JSONP
14734    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14735    /// * *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.
14736    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14737    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14738    /// * *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.
14739    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14740    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14741    pub fn param<T>(mut self, name: T, value: T) -> ServiceGetCall<'a, C>
14742    where
14743        T: AsRef<str>,
14744    {
14745        self._additional_params
14746            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14747        self
14748    }
14749
14750    /// Identifies the authorization scope for the method you are building.
14751    ///
14752    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14753    /// [`Scope::CloudPlatform`].
14754    ///
14755    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14756    /// tokens for more than one scope.
14757    ///
14758    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14759    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14760    /// sufficient, a read-write scope will do as well.
14761    pub fn add_scope<St>(mut self, scope: St) -> ServiceGetCall<'a, C>
14762    where
14763        St: AsRef<str>,
14764    {
14765        self._scopes.insert(String::from(scope.as_ref()));
14766        self
14767    }
14768    /// Identifies the authorization scope(s) for the method you are building.
14769    ///
14770    /// See [`Self::add_scope()`] for details.
14771    pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceGetCall<'a, C>
14772    where
14773        I: IntoIterator<Item = St>,
14774        St: AsRef<str>,
14775    {
14776        self._scopes
14777            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14778        self
14779    }
14780
14781    /// Removes all scopes, and no default scope will be used either.
14782    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14783    /// for details).
14784    pub fn clear_scopes(mut self) -> ServiceGetCall<'a, C> {
14785        self._scopes.clear();
14786        self
14787    }
14788}
14789
14790/// Lists all VPC-SC supported services.
14791///
14792/// A builder for the *list* method supported by a *service* resource.
14793/// It is not used directly, but through a [`ServiceMethods`] instance.
14794///
14795/// # Example
14796///
14797/// Instantiate a resource method builder
14798///
14799/// ```test_harness,no_run
14800/// # extern crate hyper;
14801/// # extern crate hyper_rustls;
14802/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
14803/// # async fn dox() {
14804/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14805///
14806/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14807/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14808/// #     .with_native_roots()
14809/// #     .unwrap()
14810/// #     .https_only()
14811/// #     .enable_http2()
14812/// #     .build();
14813///
14814/// # let executor = hyper_util::rt::TokioExecutor::new();
14815/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14816/// #     secret,
14817/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14818/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
14819/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
14820/// #     ),
14821/// # ).build().await.unwrap();
14822///
14823/// # let client = hyper_util::client::legacy::Client::builder(
14824/// #     hyper_util::rt::TokioExecutor::new()
14825/// # )
14826/// # .build(
14827/// #     hyper_rustls::HttpsConnectorBuilder::new()
14828/// #         .with_native_roots()
14829/// #         .unwrap()
14830/// #         .https_or_http()
14831/// #         .enable_http2()
14832/// #         .build()
14833/// # );
14834/// # let mut hub = AccessContextManager::new(client, auth);
14835/// // You can configure optional parameters by calling the respective setters at will, and
14836/// // execute the final call using `doit()`.
14837/// // Values shown here are possibly random and not representative !
14838/// let result = hub.services().list()
14839///              .page_token("accusam")
14840///              .page_size(-59)
14841///              .doit().await;
14842/// # }
14843/// ```
14844pub struct ServiceListCall<'a, C>
14845where
14846    C: 'a,
14847{
14848    hub: &'a AccessContextManager<C>,
14849    _page_token: Option<String>,
14850    _page_size: Option<i32>,
14851    _delegate: Option<&'a mut dyn common::Delegate>,
14852    _additional_params: HashMap<String, String>,
14853    _scopes: BTreeSet<String>,
14854}
14855
14856impl<'a, C> common::CallBuilder for ServiceListCall<'a, C> {}
14857
14858impl<'a, C> ServiceListCall<'a, C>
14859where
14860    C: common::Connector,
14861{
14862    /// Perform the operation you have build so far.
14863    pub async fn doit(
14864        mut self,
14865    ) -> common::Result<(common::Response, ListSupportedServicesResponse)> {
14866        use std::borrow::Cow;
14867        use std::io::{Read, Seek};
14868
14869        use common::{url::Params, ToParts};
14870        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14871
14872        let mut dd = common::DefaultDelegate;
14873        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14874        dlg.begin(common::MethodInfo {
14875            id: "accesscontextmanager.services.list",
14876            http_method: hyper::Method::GET,
14877        });
14878
14879        for &field in ["alt", "pageToken", "pageSize"].iter() {
14880            if self._additional_params.contains_key(field) {
14881                dlg.finished(false);
14882                return Err(common::Error::FieldClash(field));
14883            }
14884        }
14885
14886        let mut params = Params::with_capacity(4 + self._additional_params.len());
14887        if let Some(value) = self._page_token.as_ref() {
14888            params.push("pageToken", value);
14889        }
14890        if let Some(value) = self._page_size.as_ref() {
14891            params.push("pageSize", value.to_string());
14892        }
14893
14894        params.extend(self._additional_params.iter());
14895
14896        params.push("alt", "json");
14897        let mut url = self.hub._base_url.clone() + "v1/services";
14898        if self._scopes.is_empty() {
14899            self._scopes
14900                .insert(Scope::CloudPlatform.as_ref().to_string());
14901        }
14902
14903        let url = params.parse_with_url(&url);
14904
14905        loop {
14906            let token = match self
14907                .hub
14908                .auth
14909                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14910                .await
14911            {
14912                Ok(token) => token,
14913                Err(e) => match dlg.token(e) {
14914                    Ok(token) => token,
14915                    Err(e) => {
14916                        dlg.finished(false);
14917                        return Err(common::Error::MissingToken(e));
14918                    }
14919                },
14920            };
14921            let mut req_result = {
14922                let client = &self.hub.client;
14923                dlg.pre_request();
14924                let mut req_builder = hyper::Request::builder()
14925                    .method(hyper::Method::GET)
14926                    .uri(url.as_str())
14927                    .header(USER_AGENT, self.hub._user_agent.clone());
14928
14929                if let Some(token) = token.as_ref() {
14930                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14931                }
14932
14933                let request = req_builder
14934                    .header(CONTENT_LENGTH, 0_u64)
14935                    .body(common::to_body::<String>(None));
14936
14937                client.request(request.unwrap()).await
14938            };
14939
14940            match req_result {
14941                Err(err) => {
14942                    if let common::Retry::After(d) = dlg.http_error(&err) {
14943                        sleep(d).await;
14944                        continue;
14945                    }
14946                    dlg.finished(false);
14947                    return Err(common::Error::HttpError(err));
14948                }
14949                Ok(res) => {
14950                    let (mut parts, body) = res.into_parts();
14951                    let mut body = common::Body::new(body);
14952                    if !parts.status.is_success() {
14953                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14954                        let error = serde_json::from_str(&common::to_string(&bytes));
14955                        let response = common::to_response(parts, bytes.into());
14956
14957                        if let common::Retry::After(d) =
14958                            dlg.http_failure(&response, error.as_ref().ok())
14959                        {
14960                            sleep(d).await;
14961                            continue;
14962                        }
14963
14964                        dlg.finished(false);
14965
14966                        return Err(match error {
14967                            Ok(value) => common::Error::BadRequest(value),
14968                            _ => common::Error::Failure(response),
14969                        });
14970                    }
14971                    let response = {
14972                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14973                        let encoded = common::to_string(&bytes);
14974                        match serde_json::from_str(&encoded) {
14975                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14976                            Err(error) => {
14977                                dlg.response_json_decode_error(&encoded, &error);
14978                                return Err(common::Error::JsonDecodeError(
14979                                    encoded.to_string(),
14980                                    error,
14981                                ));
14982                            }
14983                        }
14984                    };
14985
14986                    dlg.finished(true);
14987                    return Ok(response);
14988                }
14989            }
14990        }
14991    }
14992
14993    /// Token to start on a later page. Default is the first page.
14994    ///
14995    /// Sets the *page token* query property to the given value.
14996    pub fn page_token(mut self, new_value: &str) -> ServiceListCall<'a, C> {
14997        self._page_token = Some(new_value.to_string());
14998        self
14999    }
15000    /// This flag specifies the maximum number of services to return per page. Default is 100.
15001    ///
15002    /// Sets the *page size* query property to the given value.
15003    pub fn page_size(mut self, new_value: i32) -> ServiceListCall<'a, C> {
15004        self._page_size = Some(new_value);
15005        self
15006    }
15007    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15008    /// while executing the actual API request.
15009    ///
15010    /// ````text
15011    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15012    /// ````
15013    ///
15014    /// Sets the *delegate* property to the given value.
15015    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceListCall<'a, C> {
15016        self._delegate = Some(new_value);
15017        self
15018    }
15019
15020    /// Set any additional parameter of the query string used in the request.
15021    /// It should be used to set parameters which are not yet available through their own
15022    /// setters.
15023    ///
15024    /// Please note that this method must not be used to set any of the known parameters
15025    /// which have their own setter method. If done anyway, the request will fail.
15026    ///
15027    /// # Additional Parameters
15028    ///
15029    /// * *$.xgafv* (query-string) - V1 error format.
15030    /// * *access_token* (query-string) - OAuth access token.
15031    /// * *alt* (query-string) - Data format for response.
15032    /// * *callback* (query-string) - JSONP
15033    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15034    /// * *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.
15035    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15036    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15037    /// * *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.
15038    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15039    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15040    pub fn param<T>(mut self, name: T, value: T) -> ServiceListCall<'a, C>
15041    where
15042        T: AsRef<str>,
15043    {
15044        self._additional_params
15045            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15046        self
15047    }
15048
15049    /// Identifies the authorization scope for the method you are building.
15050    ///
15051    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15052    /// [`Scope::CloudPlatform`].
15053    ///
15054    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15055    /// tokens for more than one scope.
15056    ///
15057    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15058    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15059    /// sufficient, a read-write scope will do as well.
15060    pub fn add_scope<St>(mut self, scope: St) -> ServiceListCall<'a, C>
15061    where
15062        St: AsRef<str>,
15063    {
15064        self._scopes.insert(String::from(scope.as_ref()));
15065        self
15066    }
15067    /// Identifies the authorization scope(s) for the method you are building.
15068    ///
15069    /// See [`Self::add_scope()`] for details.
15070    pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceListCall<'a, C>
15071    where
15072        I: IntoIterator<Item = St>,
15073        St: AsRef<str>,
15074    {
15075        self._scopes
15076            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15077        self
15078    }
15079
15080    /// Removes all scopes, and no default scope will be used either.
15081    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15082    /// for details).
15083    pub fn clear_scopes(mut self) -> ServiceListCall<'a, C> {
15084        self._scopes.clear();
15085        self
15086    }
15087}