google_accesscontextmanager1_beta/
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_beta as accesscontextmanager1_beta;
49/// use accesscontextmanager1_beta::api::AccessLevel;
50/// use accesscontextmanager1_beta::{Result, Error};
51/// # async fn dox() {
52/// use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63///     secret,
64///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68///     hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71///     hyper_rustls::HttpsConnectorBuilder::new()
72///         .with_native_roots()
73///         .unwrap()
74///         .https_or_http()
75///         .enable_http1()
76///         .build()
77/// );
78/// let mut hub = AccessContextManager::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = AccessLevel::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.access_policies().access_levels_patch(req, "name")
88///              .update_mask(FieldMask::new::<&str>(&[]))
89///              .doit().await;
90///
91/// match result {
92///     Err(e) => match e {
93///         // The Error enum provides details about what exactly happened.
94///         // You can also just use its `Debug`, `Display` or `Error` traits
95///          Error::HttpError(_)
96///         |Error::Io(_)
97///         |Error::MissingAPIKey
98///         |Error::MissingToken(_)
99///         |Error::Cancelled
100///         |Error::UploadSizeLimitExceeded(_, _)
101///         |Error::Failure(_)
102///         |Error::BadRequest(_)
103///         |Error::FieldClash(_)
104///         |Error::JsonDecodeError(_, _) => println!("{}", e),
105///     },
106///     Ok(res) => println!("Success: {:?}", res),
107/// }
108/// # }
109/// ```
110#[derive(Clone)]
111pub struct AccessContextManager<C> {
112    pub client: common::Client<C>,
113    pub auth: Box<dyn common::GetToken>,
114    _user_agent: String,
115    _base_url: String,
116    _root_url: String,
117}
118
119impl<C> common::Hub for AccessContextManager<C> {}
120
121impl<'a, C> AccessContextManager<C> {
122    pub fn new<A: 'static + common::GetToken>(
123        client: common::Client<C>,
124        auth: A,
125    ) -> AccessContextManager<C> {
126        AccessContextManager {
127            client,
128            auth: Box::new(auth),
129            _user_agent: "google-api-rust-client/6.0.0".to_string(),
130            _base_url: "https://accesscontextmanager.googleapis.com/".to_string(),
131            _root_url: "https://accesscontextmanager.googleapis.com/".to_string(),
132        }
133    }
134
135    pub fn access_policies(&'a self) -> AccessPolicyMethods<'a, C> {
136        AccessPolicyMethods { hub: self }
137    }
138    pub fn operations(&'a self) -> OperationMethods<'a, C> {
139        OperationMethods { hub: self }
140    }
141
142    /// Set the user-agent header field to use in all requests to the server.
143    /// It defaults to `google-api-rust-client/6.0.0`.
144    ///
145    /// Returns the previously set user-agent.
146    pub fn user_agent(&mut self, agent_name: String) -> String {
147        std::mem::replace(&mut self._user_agent, agent_name)
148    }
149
150    /// Set the base url to use in all requests to the server.
151    /// It defaults to `https://accesscontextmanager.googleapis.com/`.
152    ///
153    /// Returns the previously set base url.
154    pub fn base_url(&mut self, new_base_url: String) -> String {
155        std::mem::replace(&mut self._base_url, new_base_url)
156    }
157
158    /// Set the root url to use in all requests to the server.
159    /// It defaults to `https://accesscontextmanager.googleapis.com/`.
160    ///
161    /// Returns the previously set root url.
162    pub fn root_url(&mut self, new_root_url: String) -> String {
163        std::mem::replace(&mut self._root_url, new_root_url)
164    }
165}
166
167// ############
168// SCHEMAS ###
169// ##########
170/// 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.
171///
172/// # Activities
173///
174/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
175/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
176///
177/// * [access levels create access policies](AccessPolicyAccessLevelCreateCall) (request)
178/// * [access levels get access policies](AccessPolicyAccessLevelGetCall) (response)
179/// * [access levels patch access policies](AccessPolicyAccessLevelPatchCall) (request)
180#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
181#[serde_with::serde_as]
182#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
183pub struct AccessLevel {
184    /// A `BasicLevel` composed of `Conditions`.
185    pub basic: Option<BasicLevel>,
186    /// A `CustomLevel` written in the Common Expression Language.
187    pub custom: Option<CustomLevel>,
188    /// Description of the `AccessLevel` and its use. Does not affect behavior.
189    pub description: Option<String>,
190    /// 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`.
191    pub name: Option<String>,
192    /// Human readable title. Must be unique within the Policy.
193    pub title: Option<String>,
194}
195
196impl common::RequestValue for AccessLevel {}
197impl common::ResponseResult for AccessLevel {}
198
199/// `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.
200///
201/// # Activities
202///
203/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
204/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
205///
206/// * [create access policies](AccessPolicyCreateCall) (request)
207/// * [get access policies](AccessPolicyGetCall) (response)
208/// * [patch access policies](AccessPolicyPatchCall) (request)
209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
210#[serde_with::serde_as]
211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
212pub struct AccessPolicy {
213    /// Output only. Resource name of the `AccessPolicy`. Format: `accessPolicies/{policy_id}`
214    pub name: Option<String>,
215    /// Required. The parent of this `AccessPolicy` in the Cloud Resource Hierarchy. Currently immutable once created. Format: `organizations/{organization_id}`
216    pub parent: Option<String>,
217    /// Required. Human readable title. Does not affect behavior.
218    pub title: Option<String>,
219}
220
221impl common::RequestValue for AccessPolicy {}
222impl common::ResponseResult for AccessPolicy {}
223
224/// `BasicLevel` is an `AccessLevel` using a set of recommended features.
225///
226/// This type is not used in any activity, and only used as *part* of another schema.
227///
228#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
229#[serde_with::serde_as]
230#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
231pub struct BasicLevel {
232    /// 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.
233    #[serde(rename = "combiningFunction")]
234    pub combining_function: Option<String>,
235    /// Required. A list of requirements for the `AccessLevel` to be granted.
236    pub conditions: Option<Vec<Condition>>,
237}
238
239impl common::Part for BasicLevel {}
240
241/// 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.
242///
243/// This type is not used in any activity, and only used as *part* of another schema.
244///
245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
246#[serde_with::serde_as]
247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
248pub struct Condition {
249    /// Device specific restrictions, all restrictions must hold for the Condition to be true. If not specified, all devices are allowed.
250    #[serde(rename = "devicePolicy")]
251    pub device_policy: Option<DevicePolicy>,
252    /// 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.
253    #[serde(rename = "ipSubnetworks")]
254    pub ip_subnetworks: Option<Vec<String>>,
255    /// 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.
256    pub members: Option<Vec<String>>,
257    /// Whether to negate the Condition. If true, the Condition becomes a NAND over its non-empty fields, each field must be false for the Condition overall to be satisfied. Defaults to false.
258    pub negate: Option<bool>,
259    /// The request must originate from one of the provided countries/regions. Must be valid ISO 3166-1 alpha-2 codes.
260    pub regions: Option<Vec<String>>,
261    /// 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"`
262    #[serde(rename = "requiredAccessLevels")]
263    pub required_access_levels: Option<Vec<String>>,
264}
265
266impl common::Part for Condition {}
267
268/// `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
269///
270/// This type is not used in any activity, and only used as *part* of another schema.
271///
272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
273#[serde_with::serde_as]
274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
275pub struct CustomLevel {
276    /// Required. A Cloud CEL expression evaluating to a boolean.
277    pub expr: Option<Expr>,
278}
279
280impl common::Part for CustomLevel {}
281
282/// `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.
283///
284/// This type is not used in any activity, and only used as *part* of another schema.
285///
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct DevicePolicy {
290    /// Allowed device management levels, an empty list allows all management levels.
291    #[serde(rename = "allowedDeviceManagementLevels")]
292    pub allowed_device_management_levels: Option<Vec<String>>,
293    /// Allowed encryptions statuses, an empty list allows all statuses.
294    #[serde(rename = "allowedEncryptionStatuses")]
295    pub allowed_encryption_statuses: Option<Vec<String>>,
296    /// Allowed OS versions, an empty list allows all types and all versions.
297    #[serde(rename = "osConstraints")]
298    pub os_constraints: Option<Vec<OsConstraint>>,
299    /// Whether the device needs to be approved by the customer admin.
300    #[serde(rename = "requireAdminApproval")]
301    pub require_admin_approval: Option<bool>,
302    /// Whether the device needs to be corp owned.
303    #[serde(rename = "requireCorpOwned")]
304    pub require_corp_owned: Option<bool>,
305    /// Whether or not screenlock is required for the DevicePolicy to be true. Defaults to `false`.
306    #[serde(rename = "requireScreenlock")]
307    pub require_screenlock: Option<bool>,
308}
309
310impl common::Part for DevicePolicy {}
311
312/// 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.
313///
314/// This type is not used in any activity, and only used as *part* of another schema.
315///
316#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
317#[serde_with::serde_as]
318#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
319pub struct Expr {
320    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
321    pub description: Option<String>,
322    /// Textual representation of an expression in Common Expression Language syntax.
323    pub expression: Option<String>,
324    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
325    pub location: Option<String>,
326    /// 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.
327    pub title: Option<String>,
328}
329
330impl common::Part for Expr {}
331
332/// A response to `ListAccessLevelsRequest`.
333///
334/// # Activities
335///
336/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
337/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
338///
339/// * [access levels list access policies](AccessPolicyAccessLevelListCall) (response)
340#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
341#[serde_with::serde_as]
342#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
343pub struct ListAccessLevelsResponse {
344    /// List of the Access Level instances.
345    #[serde(rename = "accessLevels")]
346    pub access_levels: Option<Vec<AccessLevel>>,
347    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
348    #[serde(rename = "nextPageToken")]
349    pub next_page_token: Option<String>,
350}
351
352impl common::ResponseResult for ListAccessLevelsResponse {}
353
354/// A response to `ListAccessPoliciesRequest`.
355///
356/// # Activities
357///
358/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
359/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
360///
361/// * [list access policies](AccessPolicyListCall) (response)
362#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
363#[serde_with::serde_as]
364#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
365pub struct ListAccessPoliciesResponse {
366    /// List of the AccessPolicy instances.
367    #[serde(rename = "accessPolicies")]
368    pub access_policies: Option<Vec<AccessPolicy>>,
369    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
370    #[serde(rename = "nextPageToken")]
371    pub next_page_token: Option<String>,
372}
373
374impl common::ResponseResult for ListAccessPoliciesResponse {}
375
376/// A response to `ListServicePerimetersRequest`.
377///
378/// # Activities
379///
380/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
381/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
382///
383/// * [service perimeters list access policies](AccessPolicyServicePerimeterListCall) (response)
384#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
385#[serde_with::serde_as]
386#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
387pub struct ListServicePerimetersResponse {
388    /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
389    #[serde(rename = "nextPageToken")]
390    pub next_page_token: Option<String>,
391    /// List of the Service Perimeter instances.
392    #[serde(rename = "servicePerimeters")]
393    pub service_perimeters: Option<Vec<ServicePerimeter>>,
394}
395
396impl common::ResponseResult for ListServicePerimetersResponse {}
397
398/// This resource represents a long-running operation that is the result of a network API call.
399///
400/// # Activities
401///
402/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
403/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
404///
405/// * [access levels create access policies](AccessPolicyAccessLevelCreateCall) (response)
406/// * [access levels delete access policies](AccessPolicyAccessLevelDeleteCall) (response)
407/// * [access levels patch access policies](AccessPolicyAccessLevelPatchCall) (response)
408/// * [service perimeters create access policies](AccessPolicyServicePerimeterCreateCall) (response)
409/// * [service perimeters delete access policies](AccessPolicyServicePerimeterDeleteCall) (response)
410/// * [service perimeters patch access policies](AccessPolicyServicePerimeterPatchCall) (response)
411/// * [create access policies](AccessPolicyCreateCall) (response)
412/// * [delete access policies](AccessPolicyDeleteCall) (response)
413/// * [patch access policies](AccessPolicyPatchCall) (response)
414/// * [get operations](OperationGetCall) (response)
415#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
416#[serde_with::serde_as]
417#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
418pub struct Operation {
419    /// 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.
420    pub done: Option<bool>,
421    /// The error result of the operation in case of failure or cancellation.
422    pub error: Option<Status>,
423    /// 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.
424    pub metadata: Option<HashMap<String, serde_json::Value>>,
425    /// 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}`.
426    pub name: Option<String>,
427    /// The normal response of the operation in case of success. 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`.
428    pub response: Option<HashMap<String, serde_json::Value>>,
429}
430
431impl common::Resource for Operation {}
432impl common::ResponseResult for Operation {}
433
434/// A restriction on the OS type and version of devices making requests.
435///
436/// This type is not used in any activity, and only used as *part* of another schema.
437///
438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
439#[serde_with::serde_as]
440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
441pub struct OsConstraint {
442    /// 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"`.
443    #[serde(rename = "minimumVersion")]
444    pub minimum_version: Option<String>,
445    /// Required. The allowed OS type.
446    #[serde(rename = "osType")]
447    pub os_type: Option<String>,
448    /// 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.
449    #[serde(rename = "requireVerifiedChromeOs")]
450    pub require_verified_chrome_os: Option<bool>,
451}
452
453impl common::Part for OsConstraint {}
454
455/// `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 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.
456///
457/// # Activities
458///
459/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
460/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
461///
462/// * [service perimeters create access policies](AccessPolicyServicePerimeterCreateCall) (request)
463/// * [service perimeters get access policies](AccessPolicyServicePerimeterGetCall) (response)
464/// * [service perimeters patch access policies](AccessPolicyServicePerimeterPatchCall) (request)
465#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
466#[serde_with::serde_as]
467#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
468pub struct ServicePerimeter {
469    /// Description of the `ServicePerimeter` and its use. Does not affect behavior.
470    pub description: Option<String>,
471    /// 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`.
472    pub name: Option<String>,
473    /// Perimeter type indicator. A single project 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, restricted/unrestricted service lists as well as access lists must be empty.
474    #[serde(rename = "perimeterType")]
475    pub perimeter_type: Option<String>,
476    /// Current ServicePerimeter configuration. Specifies sets of resources, restricted/unrestricted services and access levels that determine perimeter content and boundaries.
477    pub status: Option<ServicePerimeterConfig>,
478    /// Human readable title. Must be unique within the Policy.
479    pub title: Option<String>,
480}
481
482impl common::RequestValue for ServicePerimeter {}
483impl common::ResponseResult for ServicePerimeter {}
484
485/// `ServicePerimeterConfig` specifies a set of Google Cloud resources that describe specific Service Perimeter configuration.
486///
487/// This type is not used in any activity, and only used as *part* of another schema.
488///
489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
490#[serde_with::serde_as]
491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
492pub struct ServicePerimeterConfig {
493    /// 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.
494    #[serde(rename = "accessLevels")]
495    pub access_levels: Option<Vec<String>>,
496    /// A list of Google Cloud resources that are inside of the service perimeter. Currently only projects are allowed. Format: `projects/{project_number}`
497    pub resources: Option<Vec<String>>,
498    /// Google Cloud services that are subject to the Service Perimeter restrictions. Must contain a list of services. For example, if `storage.googleapis.com` is specified, access to the storage buckets inside the perimeter must meet the perimeter's access restrictions.
499    #[serde(rename = "restrictedServices")]
500    pub restricted_services: Option<Vec<String>>,
501    /// Google Cloud services that are not subject to the Service Perimeter restrictions. Deprecated. Must be set to a single wildcard "*". The wildcard means that unless explicitly specified by "restricted_services" list, any service is treated as unrestricted.
502    #[serde(rename = "unrestrictedServices")]
503    pub unrestricted_services: Option<Vec<String>>,
504    /// Beta. Configuration for APIs allowed within Perimeter.
505    #[serde(rename = "vpcAccessibleServices")]
506    pub vpc_accessible_services: Option<VpcAccessibleServices>,
507}
508
509impl common::Part for ServicePerimeterConfig {}
510
511/// 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).
512///
513/// This type is not used in any activity, and only used as *part* of another schema.
514///
515#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
516#[serde_with::serde_as]
517#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
518pub struct Status {
519    /// The status code, which should be an enum value of google.rpc.Code.
520    pub code: Option<i32>,
521    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
522    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
523    /// 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.
524    pub message: Option<String>,
525}
526
527impl common::Part for Status {}
528
529/// Specifies how APIs are allowed to communicate within the Service Perimeter.
530///
531/// This type is not used in any activity, and only used as *part* of another schema.
532///
533#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
534#[serde_with::serde_as]
535#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
536pub struct VpcAccessibleServices {
537    /// 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.
538    #[serde(rename = "allowedServices")]
539    pub allowed_services: Option<Vec<String>>,
540    /// Whether to restrict API calls within the Service Perimeter to the list of APIs specified in 'allowed_services'.
541    #[serde(rename = "enableRestriction")]
542    pub enable_restriction: Option<bool>,
543}
544
545impl common::Part for VpcAccessibleServices {}
546
547// ###################
548// MethodBuilders ###
549// #################
550
551/// A builder providing access to all methods supported on *accessPolicy* resources.
552/// It is not used directly, but through the [`AccessContextManager`] hub.
553///
554/// # Example
555///
556/// Instantiate a resource builder
557///
558/// ```test_harness,no_run
559/// extern crate hyper;
560/// extern crate hyper_rustls;
561/// extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
562///
563/// # async fn dox() {
564/// use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
565///
566/// let secret: yup_oauth2::ApplicationSecret = Default::default();
567/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
568///     secret,
569///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
570/// ).build().await.unwrap();
571///
572/// let client = hyper_util::client::legacy::Client::builder(
573///     hyper_util::rt::TokioExecutor::new()
574/// )
575/// .build(
576///     hyper_rustls::HttpsConnectorBuilder::new()
577///         .with_native_roots()
578///         .unwrap()
579///         .https_or_http()
580///         .enable_http1()
581///         .build()
582/// );
583/// let mut hub = AccessContextManager::new(client, auth);
584/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
585/// // like `access_levels_create(...)`, `access_levels_delete(...)`, `access_levels_get(...)`, `access_levels_list(...)`, `access_levels_patch(...)`, `create(...)`, `delete(...)`, `get(...)`, `list(...)`, `patch(...)`, `service_perimeters_create(...)`, `service_perimeters_delete(...)`, `service_perimeters_get(...)`, `service_perimeters_list(...)` and `service_perimeters_patch(...)`
586/// // to build up your call.
587/// let rb = hub.access_policies();
588/// # }
589/// ```
590pub struct AccessPolicyMethods<'a, C>
591where
592    C: 'a,
593{
594    hub: &'a AccessContextManager<C>,
595}
596
597impl<'a, C> common::MethodsBuilder for AccessPolicyMethods<'a, C> {}
598
599impl<'a, C> AccessPolicyMethods<'a, C> {
600    /// Create a builder to help you perform the following task:
601    ///
602    /// Create an Access Level. The longrunning operation from this RPC will have a successful status once the Access Level has propagated to long-lasting storage. Access Levels containing errors will result in an error response for the first error encountered.
603    ///
604    /// # Arguments
605    ///
606    /// * `request` - No description provided.
607    /// * `parent` - Required. Resource name for the access policy which owns this Access Level. Format: `accessPolicies/{policy_id}`
608    pub fn access_levels_create(
609        &self,
610        request: AccessLevel,
611        parent: &str,
612    ) -> AccessPolicyAccessLevelCreateCall<'a, C> {
613        AccessPolicyAccessLevelCreateCall {
614            hub: self.hub,
615            _request: request,
616            _parent: parent.to_string(),
617            _delegate: Default::default(),
618            _additional_params: Default::default(),
619            _scopes: Default::default(),
620        }
621    }
622
623    /// Create a builder to help you perform the following task:
624    ///
625    /// Delete an Access Level by resource name. The longrunning operation from this RPC will have a successful status once the Access Level has been removed from long-lasting storage.
626    ///
627    /// # Arguments
628    ///
629    /// * `name` - Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
630    pub fn access_levels_delete(&self, name: &str) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
631        AccessPolicyAccessLevelDeleteCall {
632            hub: self.hub,
633            _name: name.to_string(),
634            _delegate: Default::default(),
635            _additional_params: Default::default(),
636            _scopes: Default::default(),
637        }
638    }
639
640    /// Create a builder to help you perform the following task:
641    ///
642    /// Get an Access Level by resource name.
643    ///
644    /// # Arguments
645    ///
646    /// * `name` - Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
647    pub fn access_levels_get(&self, name: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
648        AccessPolicyAccessLevelGetCall {
649            hub: self.hub,
650            _name: name.to_string(),
651            _access_level_format: Default::default(),
652            _delegate: Default::default(),
653            _additional_params: Default::default(),
654            _scopes: Default::default(),
655        }
656    }
657
658    /// Create a builder to help you perform the following task:
659    ///
660    /// List all Access Levels for an access policy.
661    ///
662    /// # Arguments
663    ///
664    /// * `parent` - Required. Resource name for the access policy to list Access Levels from. Format: `accessPolicies/{policy_id}`
665    pub fn access_levels_list(&self, parent: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
666        AccessPolicyAccessLevelListCall {
667            hub: self.hub,
668            _parent: parent.to_string(),
669            _page_token: Default::default(),
670            _page_size: Default::default(),
671            _access_level_format: Default::default(),
672            _delegate: Default::default(),
673            _additional_params: Default::default(),
674            _scopes: Default::default(),
675        }
676    }
677
678    /// Create a builder to help you perform the following task:
679    ///
680    /// Update an Access Level. The longrunning operation from this RPC will have a successful status once the changes to the Access Level have propagated to long-lasting storage. Access Levels containing errors will result in an error response for the first error encountered.
681    ///
682    /// # Arguments
683    ///
684    /// * `request` - No description provided.
685    /// * `name` - 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`.
686    pub fn access_levels_patch(
687        &self,
688        request: AccessLevel,
689        name: &str,
690    ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
691        AccessPolicyAccessLevelPatchCall {
692            hub: self.hub,
693            _request: request,
694            _name: name.to_string(),
695            _update_mask: Default::default(),
696            _delegate: Default::default(),
697            _additional_params: Default::default(),
698            _scopes: Default::default(),
699        }
700    }
701
702    /// Create a builder to help you perform the following task:
703    ///
704    /// Create a Service Perimeter. The longrunning operation from this RPC will have a successful status once the Service Perimeter has propagated to long-lasting storage. Service Perimeters containing errors will result in an error response for the first error encountered.
705    ///
706    /// # Arguments
707    ///
708    /// * `request` - No description provided.
709    /// * `parent` - Required. Resource name for the access policy which owns this Service Perimeter. Format: `accessPolicies/{policy_id}`
710    pub fn service_perimeters_create(
711        &self,
712        request: ServicePerimeter,
713        parent: &str,
714    ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
715        AccessPolicyServicePerimeterCreateCall {
716            hub: self.hub,
717            _request: request,
718            _parent: parent.to_string(),
719            _delegate: Default::default(),
720            _additional_params: Default::default(),
721            _scopes: Default::default(),
722        }
723    }
724
725    /// Create a builder to help you perform the following task:
726    ///
727    /// Delete a Service Perimeter by resource name. The longrunning operation from this RPC will have a successful status once the Service Perimeter has been removed from long-lasting storage.
728    ///
729    /// # Arguments
730    ///
731    /// * `name` - Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeter_id}`
732    pub fn service_perimeters_delete(
733        &self,
734        name: &str,
735    ) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
736        AccessPolicyServicePerimeterDeleteCall {
737            hub: self.hub,
738            _name: name.to_string(),
739            _delegate: Default::default(),
740            _additional_params: Default::default(),
741            _scopes: Default::default(),
742        }
743    }
744
745    /// Create a builder to help you perform the following task:
746    ///
747    /// Get a Service Perimeter by resource name.
748    ///
749    /// # Arguments
750    ///
751    /// * `name` - Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeters_id}`
752    pub fn service_perimeters_get(&self, name: &str) -> AccessPolicyServicePerimeterGetCall<'a, C> {
753        AccessPolicyServicePerimeterGetCall {
754            hub: self.hub,
755            _name: name.to_string(),
756            _delegate: Default::default(),
757            _additional_params: Default::default(),
758            _scopes: Default::default(),
759        }
760    }
761
762    /// Create a builder to help you perform the following task:
763    ///
764    /// List all Service Perimeters for an access policy.
765    ///
766    /// # Arguments
767    ///
768    /// * `parent` - Required. Resource name for the access policy to list Service Perimeters from. Format: `accessPolicies/{policy_id}`
769    pub fn service_perimeters_list(
770        &self,
771        parent: &str,
772    ) -> AccessPolicyServicePerimeterListCall<'a, C> {
773        AccessPolicyServicePerimeterListCall {
774            hub: self.hub,
775            _parent: parent.to_string(),
776            _page_token: Default::default(),
777            _page_size: Default::default(),
778            _delegate: Default::default(),
779            _additional_params: Default::default(),
780            _scopes: Default::default(),
781        }
782    }
783
784    /// Create a builder to help you perform the following task:
785    ///
786    /// Update a Service Perimeter. The longrunning operation from this RPC will have a successful status once the changes to the Service Perimeter have propagated to long-lasting storage. Service Perimeter containing errors will result in an error response for the first error encountered.
787    ///
788    /// # Arguments
789    ///
790    /// * `request` - No description provided.
791    /// * `name` - 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`.
792    pub fn service_perimeters_patch(
793        &self,
794        request: ServicePerimeter,
795        name: &str,
796    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
797        AccessPolicyServicePerimeterPatchCall {
798            hub: self.hub,
799            _request: request,
800            _name: name.to_string(),
801            _update_mask: Default::default(),
802            _delegate: Default::default(),
803            _additional_params: Default::default(),
804            _scopes: Default::default(),
805        }
806    }
807
808    /// Create a builder to help you perform the following task:
809    ///
810    /// Create an `AccessPolicy`. Fails if this organization already has a `AccessPolicy`. The longrunning Operation will have a successful status once the `AccessPolicy` has propagated to long-lasting storage. Syntactic and basic semantic errors will be returned in `metadata` as a BadRequest proto.
811    ///
812    /// # Arguments
813    ///
814    /// * `request` - No description provided.
815    pub fn create(&self, request: AccessPolicy) -> AccessPolicyCreateCall<'a, C> {
816        AccessPolicyCreateCall {
817            hub: self.hub,
818            _request: request,
819            _delegate: Default::default(),
820            _additional_params: Default::default(),
821            _scopes: Default::default(),
822        }
823    }
824
825    /// Create a builder to help you perform the following task:
826    ///
827    /// Delete an AccessPolicy by resource name. The longrunning Operation will have a successful status once the AccessPolicy has been removed from long-lasting storage.
828    ///
829    /// # Arguments
830    ///
831    /// * `name` - Required. Resource name for the access policy to delete. Format `accessPolicies/{policy_id}`
832    pub fn delete(&self, name: &str) -> AccessPolicyDeleteCall<'a, C> {
833        AccessPolicyDeleteCall {
834            hub: self.hub,
835            _name: name.to_string(),
836            _delegate: Default::default(),
837            _additional_params: Default::default(),
838            _scopes: Default::default(),
839        }
840    }
841
842    /// Create a builder to help you perform the following task:
843    ///
844    /// Get an AccessPolicy by name.
845    ///
846    /// # Arguments
847    ///
848    /// * `name` - Required. Resource name for the access policy to get. Format `accessPolicies/{policy_id}`
849    pub fn get(&self, name: &str) -> AccessPolicyGetCall<'a, C> {
850        AccessPolicyGetCall {
851            hub: self.hub,
852            _name: name.to_string(),
853            _delegate: Default::default(),
854            _additional_params: Default::default(),
855            _scopes: Default::default(),
856        }
857    }
858
859    /// Create a builder to help you perform the following task:
860    ///
861    /// List all AccessPolicies under a container.
862    pub fn list(&self) -> AccessPolicyListCall<'a, C> {
863        AccessPolicyListCall {
864            hub: self.hub,
865            _parent: Default::default(),
866            _page_token: Default::default(),
867            _page_size: Default::default(),
868            _delegate: Default::default(),
869            _additional_params: Default::default(),
870            _scopes: Default::default(),
871        }
872    }
873
874    /// Create a builder to help you perform the following task:
875    ///
876    /// Update an AccessPolicy. The longrunning Operation from this RPC will have a successful status once the changes to the AccessPolicy have propagated to long-lasting storage. Syntactic and basic semantic errors will be returned in `metadata` as a BadRequest proto.
877    ///
878    /// # Arguments
879    ///
880    /// * `request` - No description provided.
881    /// * `name` - Output only. Resource name of the `AccessPolicy`. Format: `accessPolicies/{policy_id}`
882    pub fn patch(&self, request: AccessPolicy, name: &str) -> AccessPolicyPatchCall<'a, C> {
883        AccessPolicyPatchCall {
884            hub: self.hub,
885            _request: request,
886            _name: name.to_string(),
887            _update_mask: Default::default(),
888            _delegate: Default::default(),
889            _additional_params: Default::default(),
890            _scopes: Default::default(),
891        }
892    }
893}
894
895/// A builder providing access to all methods supported on *operation* resources.
896/// It is not used directly, but through the [`AccessContextManager`] hub.
897///
898/// # Example
899///
900/// Instantiate a resource builder
901///
902/// ```test_harness,no_run
903/// extern crate hyper;
904/// extern crate hyper_rustls;
905/// extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
906///
907/// # async fn dox() {
908/// use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
909///
910/// let secret: yup_oauth2::ApplicationSecret = Default::default();
911/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
912///     secret,
913///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
914/// ).build().await.unwrap();
915///
916/// let client = hyper_util::client::legacy::Client::builder(
917///     hyper_util::rt::TokioExecutor::new()
918/// )
919/// .build(
920///     hyper_rustls::HttpsConnectorBuilder::new()
921///         .with_native_roots()
922///         .unwrap()
923///         .https_or_http()
924///         .enable_http1()
925///         .build()
926/// );
927/// let mut hub = AccessContextManager::new(client, auth);
928/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
929/// // like `get(...)`
930/// // to build up your call.
931/// let rb = hub.operations();
932/// # }
933/// ```
934pub struct OperationMethods<'a, C>
935where
936    C: 'a,
937{
938    hub: &'a AccessContextManager<C>,
939}
940
941impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
942
943impl<'a, C> OperationMethods<'a, C> {
944    /// Create a builder to help you perform the following task:
945    ///
946    /// 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.
947    ///
948    /// # Arguments
949    ///
950    /// * `name` - The name of the operation resource.
951    pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
952        OperationGetCall {
953            hub: self.hub,
954            _name: name.to_string(),
955            _delegate: Default::default(),
956            _additional_params: Default::default(),
957            _scopes: Default::default(),
958        }
959    }
960}
961
962// ###################
963// CallBuilders   ###
964// #################
965
966/// Create an Access Level. The longrunning operation from this RPC will have a successful status once the Access Level has propagated to long-lasting storage. Access Levels containing errors will result in an error response for the first error encountered.
967///
968/// A builder for the *accessLevels.create* method supported by a *accessPolicy* resource.
969/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
970///
971/// # Example
972///
973/// Instantiate a resource method builder
974///
975/// ```test_harness,no_run
976/// # extern crate hyper;
977/// # extern crate hyper_rustls;
978/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
979/// use accesscontextmanager1_beta::api::AccessLevel;
980/// # async fn dox() {
981/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
982///
983/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
984/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
985/// #     secret,
986/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
987/// # ).build().await.unwrap();
988///
989/// # let client = hyper_util::client::legacy::Client::builder(
990/// #     hyper_util::rt::TokioExecutor::new()
991/// # )
992/// # .build(
993/// #     hyper_rustls::HttpsConnectorBuilder::new()
994/// #         .with_native_roots()
995/// #         .unwrap()
996/// #         .https_or_http()
997/// #         .enable_http1()
998/// #         .build()
999/// # );
1000/// # let mut hub = AccessContextManager::new(client, auth);
1001/// // As the method needs a request, you would usually fill it with the desired information
1002/// // into the respective structure. Some of the parts shown here might not be applicable !
1003/// // Values shown here are possibly random and not representative !
1004/// let mut req = AccessLevel::default();
1005///
1006/// // You can configure optional parameters by calling the respective setters at will, and
1007/// // execute the final call using `doit()`.
1008/// // Values shown here are possibly random and not representative !
1009/// let result = hub.access_policies().access_levels_create(req, "parent")
1010///              .doit().await;
1011/// # }
1012/// ```
1013pub struct AccessPolicyAccessLevelCreateCall<'a, C>
1014where
1015    C: 'a,
1016{
1017    hub: &'a AccessContextManager<C>,
1018    _request: AccessLevel,
1019    _parent: String,
1020    _delegate: Option<&'a mut dyn common::Delegate>,
1021    _additional_params: HashMap<String, String>,
1022    _scopes: BTreeSet<String>,
1023}
1024
1025impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelCreateCall<'a, C> {}
1026
1027impl<'a, C> AccessPolicyAccessLevelCreateCall<'a, C>
1028where
1029    C: common::Connector,
1030{
1031    /// Perform the operation you have build so far.
1032    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1033        use std::borrow::Cow;
1034        use std::io::{Read, Seek};
1035
1036        use common::{url::Params, ToParts};
1037        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1038
1039        let mut dd = common::DefaultDelegate;
1040        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1041        dlg.begin(common::MethodInfo {
1042            id: "accesscontextmanager.accessPolicies.accessLevels.create",
1043            http_method: hyper::Method::POST,
1044        });
1045
1046        for &field in ["alt", "parent"].iter() {
1047            if self._additional_params.contains_key(field) {
1048                dlg.finished(false);
1049                return Err(common::Error::FieldClash(field));
1050            }
1051        }
1052
1053        let mut params = Params::with_capacity(4 + self._additional_params.len());
1054        params.push("parent", self._parent);
1055
1056        params.extend(self._additional_params.iter());
1057
1058        params.push("alt", "json");
1059        let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/accessLevels";
1060        if self._scopes.is_empty() {
1061            self._scopes
1062                .insert(Scope::CloudPlatform.as_ref().to_string());
1063        }
1064
1065        #[allow(clippy::single_element_loop)]
1066        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1067            url = params.uri_replacement(url, param_name, find_this, true);
1068        }
1069        {
1070            let to_remove = ["parent"];
1071            params.remove_params(&to_remove);
1072        }
1073
1074        let url = params.parse_with_url(&url);
1075
1076        let mut json_mime_type = mime::APPLICATION_JSON;
1077        let mut request_value_reader = {
1078            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1079            common::remove_json_null_values(&mut value);
1080            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1081            serde_json::to_writer(&mut dst, &value).unwrap();
1082            dst
1083        };
1084        let request_size = request_value_reader
1085            .seek(std::io::SeekFrom::End(0))
1086            .unwrap();
1087        request_value_reader
1088            .seek(std::io::SeekFrom::Start(0))
1089            .unwrap();
1090
1091        loop {
1092            let token = match self
1093                .hub
1094                .auth
1095                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1096                .await
1097            {
1098                Ok(token) => token,
1099                Err(e) => match dlg.token(e) {
1100                    Ok(token) => token,
1101                    Err(e) => {
1102                        dlg.finished(false);
1103                        return Err(common::Error::MissingToken(e));
1104                    }
1105                },
1106            };
1107            request_value_reader
1108                .seek(std::io::SeekFrom::Start(0))
1109                .unwrap();
1110            let mut req_result = {
1111                let client = &self.hub.client;
1112                dlg.pre_request();
1113                let mut req_builder = hyper::Request::builder()
1114                    .method(hyper::Method::POST)
1115                    .uri(url.as_str())
1116                    .header(USER_AGENT, self.hub._user_agent.clone());
1117
1118                if let Some(token) = token.as_ref() {
1119                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1120                }
1121
1122                let request = req_builder
1123                    .header(CONTENT_TYPE, json_mime_type.to_string())
1124                    .header(CONTENT_LENGTH, request_size as u64)
1125                    .body(common::to_body(
1126                        request_value_reader.get_ref().clone().into(),
1127                    ));
1128
1129                client.request(request.unwrap()).await
1130            };
1131
1132            match req_result {
1133                Err(err) => {
1134                    if let common::Retry::After(d) = dlg.http_error(&err) {
1135                        sleep(d).await;
1136                        continue;
1137                    }
1138                    dlg.finished(false);
1139                    return Err(common::Error::HttpError(err));
1140                }
1141                Ok(res) => {
1142                    let (mut parts, body) = res.into_parts();
1143                    let mut body = common::Body::new(body);
1144                    if !parts.status.is_success() {
1145                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1146                        let error = serde_json::from_str(&common::to_string(&bytes));
1147                        let response = common::to_response(parts, bytes.into());
1148
1149                        if let common::Retry::After(d) =
1150                            dlg.http_failure(&response, error.as_ref().ok())
1151                        {
1152                            sleep(d).await;
1153                            continue;
1154                        }
1155
1156                        dlg.finished(false);
1157
1158                        return Err(match error {
1159                            Ok(value) => common::Error::BadRequest(value),
1160                            _ => common::Error::Failure(response),
1161                        });
1162                    }
1163                    let response = {
1164                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1165                        let encoded = common::to_string(&bytes);
1166                        match serde_json::from_str(&encoded) {
1167                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1168                            Err(error) => {
1169                                dlg.response_json_decode_error(&encoded, &error);
1170                                return Err(common::Error::JsonDecodeError(
1171                                    encoded.to_string(),
1172                                    error,
1173                                ));
1174                            }
1175                        }
1176                    };
1177
1178                    dlg.finished(true);
1179                    return Ok(response);
1180                }
1181            }
1182        }
1183    }
1184
1185    ///
1186    /// Sets the *request* property to the given value.
1187    ///
1188    /// Even though the property as already been set when instantiating this call,
1189    /// we provide this method for API completeness.
1190    pub fn request(mut self, new_value: AccessLevel) -> AccessPolicyAccessLevelCreateCall<'a, C> {
1191        self._request = new_value;
1192        self
1193    }
1194    /// Required. Resource name for the access policy which owns this Access Level. Format: `accessPolicies/{policy_id}`
1195    ///
1196    /// Sets the *parent* path property to the given value.
1197    ///
1198    /// Even though the property as already been set when instantiating this call,
1199    /// we provide this method for API completeness.
1200    pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelCreateCall<'a, C> {
1201        self._parent = new_value.to_string();
1202        self
1203    }
1204    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1205    /// while executing the actual API request.
1206    ///
1207    /// ````text
1208    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1209    /// ````
1210    ///
1211    /// Sets the *delegate* property to the given value.
1212    pub fn delegate(
1213        mut self,
1214        new_value: &'a mut dyn common::Delegate,
1215    ) -> AccessPolicyAccessLevelCreateCall<'a, C> {
1216        self._delegate = Some(new_value);
1217        self
1218    }
1219
1220    /// Set any additional parameter of the query string used in the request.
1221    /// It should be used to set parameters which are not yet available through their own
1222    /// setters.
1223    ///
1224    /// Please note that this method must not be used to set any of the known parameters
1225    /// which have their own setter method. If done anyway, the request will fail.
1226    ///
1227    /// # Additional Parameters
1228    ///
1229    /// * *$.xgafv* (query-string) - V1 error format.
1230    /// * *access_token* (query-string) - OAuth access token.
1231    /// * *alt* (query-string) - Data format for response.
1232    /// * *callback* (query-string) - JSONP
1233    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1234    /// * *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.
1235    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1236    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1237    /// * *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.
1238    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1239    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1240    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelCreateCall<'a, C>
1241    where
1242        T: AsRef<str>,
1243    {
1244        self._additional_params
1245            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1246        self
1247    }
1248
1249    /// Identifies the authorization scope for the method you are building.
1250    ///
1251    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1252    /// [`Scope::CloudPlatform`].
1253    ///
1254    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1255    /// tokens for more than one scope.
1256    ///
1257    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1258    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1259    /// sufficient, a read-write scope will do as well.
1260    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelCreateCall<'a, C>
1261    where
1262        St: AsRef<str>,
1263    {
1264        self._scopes.insert(String::from(scope.as_ref()));
1265        self
1266    }
1267    /// Identifies the authorization scope(s) for the method you are building.
1268    ///
1269    /// See [`Self::add_scope()`] for details.
1270    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelCreateCall<'a, C>
1271    where
1272        I: IntoIterator<Item = St>,
1273        St: AsRef<str>,
1274    {
1275        self._scopes
1276            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1277        self
1278    }
1279
1280    /// Removes all scopes, and no default scope will be used either.
1281    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1282    /// for details).
1283    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelCreateCall<'a, C> {
1284        self._scopes.clear();
1285        self
1286    }
1287}
1288
1289/// Delete an Access Level by resource name. The longrunning operation from this RPC will have a successful status once the Access Level has been removed from long-lasting storage.
1290///
1291/// A builder for the *accessLevels.delete* method supported by a *accessPolicy* resource.
1292/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
1293///
1294/// # Example
1295///
1296/// Instantiate a resource method builder
1297///
1298/// ```test_harness,no_run
1299/// # extern crate hyper;
1300/// # extern crate hyper_rustls;
1301/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
1302/// # async fn dox() {
1303/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1304///
1305/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1306/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1307/// #     secret,
1308/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1309/// # ).build().await.unwrap();
1310///
1311/// # let client = hyper_util::client::legacy::Client::builder(
1312/// #     hyper_util::rt::TokioExecutor::new()
1313/// # )
1314/// # .build(
1315/// #     hyper_rustls::HttpsConnectorBuilder::new()
1316/// #         .with_native_roots()
1317/// #         .unwrap()
1318/// #         .https_or_http()
1319/// #         .enable_http1()
1320/// #         .build()
1321/// # );
1322/// # let mut hub = AccessContextManager::new(client, auth);
1323/// // You can configure optional parameters by calling the respective setters at will, and
1324/// // execute the final call using `doit()`.
1325/// // Values shown here are possibly random and not representative !
1326/// let result = hub.access_policies().access_levels_delete("name")
1327///              .doit().await;
1328/// # }
1329/// ```
1330pub struct AccessPolicyAccessLevelDeleteCall<'a, C>
1331where
1332    C: 'a,
1333{
1334    hub: &'a AccessContextManager<C>,
1335    _name: String,
1336    _delegate: Option<&'a mut dyn common::Delegate>,
1337    _additional_params: HashMap<String, String>,
1338    _scopes: BTreeSet<String>,
1339}
1340
1341impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelDeleteCall<'a, C> {}
1342
1343impl<'a, C> AccessPolicyAccessLevelDeleteCall<'a, C>
1344where
1345    C: common::Connector,
1346{
1347    /// Perform the operation you have build so far.
1348    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1349        use std::borrow::Cow;
1350        use std::io::{Read, Seek};
1351
1352        use common::{url::Params, ToParts};
1353        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1354
1355        let mut dd = common::DefaultDelegate;
1356        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1357        dlg.begin(common::MethodInfo {
1358            id: "accesscontextmanager.accessPolicies.accessLevels.delete",
1359            http_method: hyper::Method::DELETE,
1360        });
1361
1362        for &field in ["alt", "name"].iter() {
1363            if self._additional_params.contains_key(field) {
1364                dlg.finished(false);
1365                return Err(common::Error::FieldClash(field));
1366            }
1367        }
1368
1369        let mut params = Params::with_capacity(3 + self._additional_params.len());
1370        params.push("name", self._name);
1371
1372        params.extend(self._additional_params.iter());
1373
1374        params.push("alt", "json");
1375        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
1376        if self._scopes.is_empty() {
1377            self._scopes
1378                .insert(Scope::CloudPlatform.as_ref().to_string());
1379        }
1380
1381        #[allow(clippy::single_element_loop)]
1382        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1383            url = params.uri_replacement(url, param_name, find_this, true);
1384        }
1385        {
1386            let to_remove = ["name"];
1387            params.remove_params(&to_remove);
1388        }
1389
1390        let url = params.parse_with_url(&url);
1391
1392        loop {
1393            let token = match self
1394                .hub
1395                .auth
1396                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1397                .await
1398            {
1399                Ok(token) => token,
1400                Err(e) => match dlg.token(e) {
1401                    Ok(token) => token,
1402                    Err(e) => {
1403                        dlg.finished(false);
1404                        return Err(common::Error::MissingToken(e));
1405                    }
1406                },
1407            };
1408            let mut req_result = {
1409                let client = &self.hub.client;
1410                dlg.pre_request();
1411                let mut req_builder = hyper::Request::builder()
1412                    .method(hyper::Method::DELETE)
1413                    .uri(url.as_str())
1414                    .header(USER_AGENT, self.hub._user_agent.clone());
1415
1416                if let Some(token) = token.as_ref() {
1417                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1418                }
1419
1420                let request = req_builder
1421                    .header(CONTENT_LENGTH, 0_u64)
1422                    .body(common::to_body::<String>(None));
1423
1424                client.request(request.unwrap()).await
1425            };
1426
1427            match req_result {
1428                Err(err) => {
1429                    if let common::Retry::After(d) = dlg.http_error(&err) {
1430                        sleep(d).await;
1431                        continue;
1432                    }
1433                    dlg.finished(false);
1434                    return Err(common::Error::HttpError(err));
1435                }
1436                Ok(res) => {
1437                    let (mut parts, body) = res.into_parts();
1438                    let mut body = common::Body::new(body);
1439                    if !parts.status.is_success() {
1440                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1441                        let error = serde_json::from_str(&common::to_string(&bytes));
1442                        let response = common::to_response(parts, bytes.into());
1443
1444                        if let common::Retry::After(d) =
1445                            dlg.http_failure(&response, error.as_ref().ok())
1446                        {
1447                            sleep(d).await;
1448                            continue;
1449                        }
1450
1451                        dlg.finished(false);
1452
1453                        return Err(match error {
1454                            Ok(value) => common::Error::BadRequest(value),
1455                            _ => common::Error::Failure(response),
1456                        });
1457                    }
1458                    let response = {
1459                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1460                        let encoded = common::to_string(&bytes);
1461                        match serde_json::from_str(&encoded) {
1462                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1463                            Err(error) => {
1464                                dlg.response_json_decode_error(&encoded, &error);
1465                                return Err(common::Error::JsonDecodeError(
1466                                    encoded.to_string(),
1467                                    error,
1468                                ));
1469                            }
1470                        }
1471                    };
1472
1473                    dlg.finished(true);
1474                    return Ok(response);
1475                }
1476            }
1477        }
1478    }
1479
1480    /// Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
1481    ///
1482    /// Sets the *name* path property to the given value.
1483    ///
1484    /// Even though the property as already been set when instantiating this call,
1485    /// we provide this method for API completeness.
1486    pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
1487        self._name = new_value.to_string();
1488        self
1489    }
1490    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1491    /// while executing the actual API request.
1492    ///
1493    /// ````text
1494    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1495    /// ````
1496    ///
1497    /// Sets the *delegate* property to the given value.
1498    pub fn delegate(
1499        mut self,
1500        new_value: &'a mut dyn common::Delegate,
1501    ) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
1502        self._delegate = Some(new_value);
1503        self
1504    }
1505
1506    /// Set any additional parameter of the query string used in the request.
1507    /// It should be used to set parameters which are not yet available through their own
1508    /// setters.
1509    ///
1510    /// Please note that this method must not be used to set any of the known parameters
1511    /// which have their own setter method. If done anyway, the request will fail.
1512    ///
1513    /// # Additional Parameters
1514    ///
1515    /// * *$.xgafv* (query-string) - V1 error format.
1516    /// * *access_token* (query-string) - OAuth access token.
1517    /// * *alt* (query-string) - Data format for response.
1518    /// * *callback* (query-string) - JSONP
1519    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1520    /// * *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.
1521    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1522    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1523    /// * *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.
1524    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1525    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1526    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelDeleteCall<'a, C>
1527    where
1528        T: AsRef<str>,
1529    {
1530        self._additional_params
1531            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1532        self
1533    }
1534
1535    /// Identifies the authorization scope for the method you are building.
1536    ///
1537    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1538    /// [`Scope::CloudPlatform`].
1539    ///
1540    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1541    /// tokens for more than one scope.
1542    ///
1543    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1544    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1545    /// sufficient, a read-write scope will do as well.
1546    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelDeleteCall<'a, C>
1547    where
1548        St: AsRef<str>,
1549    {
1550        self._scopes.insert(String::from(scope.as_ref()));
1551        self
1552    }
1553    /// Identifies the authorization scope(s) for the method you are building.
1554    ///
1555    /// See [`Self::add_scope()`] for details.
1556    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelDeleteCall<'a, C>
1557    where
1558        I: IntoIterator<Item = St>,
1559        St: AsRef<str>,
1560    {
1561        self._scopes
1562            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1563        self
1564    }
1565
1566    /// Removes all scopes, and no default scope will be used either.
1567    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1568    /// for details).
1569    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
1570        self._scopes.clear();
1571        self
1572    }
1573}
1574
1575/// Get an Access Level by resource name.
1576///
1577/// A builder for the *accessLevels.get* method supported by a *accessPolicy* resource.
1578/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
1579///
1580/// # Example
1581///
1582/// Instantiate a resource method builder
1583///
1584/// ```test_harness,no_run
1585/// # extern crate hyper;
1586/// # extern crate hyper_rustls;
1587/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
1588/// # async fn dox() {
1589/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1590///
1591/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1592/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1593/// #     secret,
1594/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1595/// # ).build().await.unwrap();
1596///
1597/// # let client = hyper_util::client::legacy::Client::builder(
1598/// #     hyper_util::rt::TokioExecutor::new()
1599/// # )
1600/// # .build(
1601/// #     hyper_rustls::HttpsConnectorBuilder::new()
1602/// #         .with_native_roots()
1603/// #         .unwrap()
1604/// #         .https_or_http()
1605/// #         .enable_http1()
1606/// #         .build()
1607/// # );
1608/// # let mut hub = AccessContextManager::new(client, auth);
1609/// // You can configure optional parameters by calling the respective setters at will, and
1610/// // execute the final call using `doit()`.
1611/// // Values shown here are possibly random and not representative !
1612/// let result = hub.access_policies().access_levels_get("name")
1613///              .access_level_format("sanctus")
1614///              .doit().await;
1615/// # }
1616/// ```
1617pub struct AccessPolicyAccessLevelGetCall<'a, C>
1618where
1619    C: 'a,
1620{
1621    hub: &'a AccessContextManager<C>,
1622    _name: String,
1623    _access_level_format: Option<String>,
1624    _delegate: Option<&'a mut dyn common::Delegate>,
1625    _additional_params: HashMap<String, String>,
1626    _scopes: BTreeSet<String>,
1627}
1628
1629impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelGetCall<'a, C> {}
1630
1631impl<'a, C> AccessPolicyAccessLevelGetCall<'a, C>
1632where
1633    C: common::Connector,
1634{
1635    /// Perform the operation you have build so far.
1636    pub async fn doit(mut self) -> common::Result<(common::Response, AccessLevel)> {
1637        use std::borrow::Cow;
1638        use std::io::{Read, Seek};
1639
1640        use common::{url::Params, ToParts};
1641        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1642
1643        let mut dd = common::DefaultDelegate;
1644        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1645        dlg.begin(common::MethodInfo {
1646            id: "accesscontextmanager.accessPolicies.accessLevels.get",
1647            http_method: hyper::Method::GET,
1648        });
1649
1650        for &field in ["alt", "name", "accessLevelFormat"].iter() {
1651            if self._additional_params.contains_key(field) {
1652                dlg.finished(false);
1653                return Err(common::Error::FieldClash(field));
1654            }
1655        }
1656
1657        let mut params = Params::with_capacity(4 + self._additional_params.len());
1658        params.push("name", self._name);
1659        if let Some(value) = self._access_level_format.as_ref() {
1660            params.push("accessLevelFormat", value);
1661        }
1662
1663        params.extend(self._additional_params.iter());
1664
1665        params.push("alt", "json");
1666        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
1667        if self._scopes.is_empty() {
1668            self._scopes
1669                .insert(Scope::CloudPlatform.as_ref().to_string());
1670        }
1671
1672        #[allow(clippy::single_element_loop)]
1673        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1674            url = params.uri_replacement(url, param_name, find_this, true);
1675        }
1676        {
1677            let to_remove = ["name"];
1678            params.remove_params(&to_remove);
1679        }
1680
1681        let url = params.parse_with_url(&url);
1682
1683        loop {
1684            let token = match self
1685                .hub
1686                .auth
1687                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1688                .await
1689            {
1690                Ok(token) => token,
1691                Err(e) => match dlg.token(e) {
1692                    Ok(token) => token,
1693                    Err(e) => {
1694                        dlg.finished(false);
1695                        return Err(common::Error::MissingToken(e));
1696                    }
1697                },
1698            };
1699            let mut req_result = {
1700                let client = &self.hub.client;
1701                dlg.pre_request();
1702                let mut req_builder = hyper::Request::builder()
1703                    .method(hyper::Method::GET)
1704                    .uri(url.as_str())
1705                    .header(USER_AGENT, self.hub._user_agent.clone());
1706
1707                if let Some(token) = token.as_ref() {
1708                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1709                }
1710
1711                let request = req_builder
1712                    .header(CONTENT_LENGTH, 0_u64)
1713                    .body(common::to_body::<String>(None));
1714
1715                client.request(request.unwrap()).await
1716            };
1717
1718            match req_result {
1719                Err(err) => {
1720                    if let common::Retry::After(d) = dlg.http_error(&err) {
1721                        sleep(d).await;
1722                        continue;
1723                    }
1724                    dlg.finished(false);
1725                    return Err(common::Error::HttpError(err));
1726                }
1727                Ok(res) => {
1728                    let (mut parts, body) = res.into_parts();
1729                    let mut body = common::Body::new(body);
1730                    if !parts.status.is_success() {
1731                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1732                        let error = serde_json::from_str(&common::to_string(&bytes));
1733                        let response = common::to_response(parts, bytes.into());
1734
1735                        if let common::Retry::After(d) =
1736                            dlg.http_failure(&response, error.as_ref().ok())
1737                        {
1738                            sleep(d).await;
1739                            continue;
1740                        }
1741
1742                        dlg.finished(false);
1743
1744                        return Err(match error {
1745                            Ok(value) => common::Error::BadRequest(value),
1746                            _ => common::Error::Failure(response),
1747                        });
1748                    }
1749                    let response = {
1750                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1751                        let encoded = common::to_string(&bytes);
1752                        match serde_json::from_str(&encoded) {
1753                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1754                            Err(error) => {
1755                                dlg.response_json_decode_error(&encoded, &error);
1756                                return Err(common::Error::JsonDecodeError(
1757                                    encoded.to_string(),
1758                                    error,
1759                                ));
1760                            }
1761                        }
1762                    };
1763
1764                    dlg.finished(true);
1765                    return Ok(response);
1766                }
1767            }
1768        }
1769    }
1770
1771    /// Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
1772    ///
1773    /// Sets the *name* path property to the given value.
1774    ///
1775    /// Even though the property as already been set when instantiating this call,
1776    /// we provide this method for API completeness.
1777    pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
1778        self._name = new_value.to_string();
1779        self
1780    }
1781    /// 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`.
1782    ///
1783    /// Sets the *access level format* query property to the given value.
1784    pub fn access_level_format(mut self, new_value: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
1785        self._access_level_format = Some(new_value.to_string());
1786        self
1787    }
1788    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1789    /// while executing the actual API request.
1790    ///
1791    /// ````text
1792    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1793    /// ````
1794    ///
1795    /// Sets the *delegate* property to the given value.
1796    pub fn delegate(
1797        mut self,
1798        new_value: &'a mut dyn common::Delegate,
1799    ) -> AccessPolicyAccessLevelGetCall<'a, C> {
1800        self._delegate = Some(new_value);
1801        self
1802    }
1803
1804    /// Set any additional parameter of the query string used in the request.
1805    /// It should be used to set parameters which are not yet available through their own
1806    /// setters.
1807    ///
1808    /// Please note that this method must not be used to set any of the known parameters
1809    /// which have their own setter method. If done anyway, the request will fail.
1810    ///
1811    /// # Additional Parameters
1812    ///
1813    /// * *$.xgafv* (query-string) - V1 error format.
1814    /// * *access_token* (query-string) - OAuth access token.
1815    /// * *alt* (query-string) - Data format for response.
1816    /// * *callback* (query-string) - JSONP
1817    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1818    /// * *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.
1819    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1820    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1821    /// * *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.
1822    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1823    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1824    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelGetCall<'a, C>
1825    where
1826        T: AsRef<str>,
1827    {
1828        self._additional_params
1829            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1830        self
1831    }
1832
1833    /// Identifies the authorization scope for the method you are building.
1834    ///
1835    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1836    /// [`Scope::CloudPlatform`].
1837    ///
1838    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1839    /// tokens for more than one scope.
1840    ///
1841    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1842    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1843    /// sufficient, a read-write scope will do as well.
1844    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelGetCall<'a, C>
1845    where
1846        St: AsRef<str>,
1847    {
1848        self._scopes.insert(String::from(scope.as_ref()));
1849        self
1850    }
1851    /// Identifies the authorization scope(s) for the method you are building.
1852    ///
1853    /// See [`Self::add_scope()`] for details.
1854    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelGetCall<'a, C>
1855    where
1856        I: IntoIterator<Item = St>,
1857        St: AsRef<str>,
1858    {
1859        self._scopes
1860            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1861        self
1862    }
1863
1864    /// Removes all scopes, and no default scope will be used either.
1865    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1866    /// for details).
1867    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelGetCall<'a, C> {
1868        self._scopes.clear();
1869        self
1870    }
1871}
1872
1873/// List all Access Levels for an access policy.
1874///
1875/// A builder for the *accessLevels.list* method supported by a *accessPolicy* resource.
1876/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
1877///
1878/// # Example
1879///
1880/// Instantiate a resource method builder
1881///
1882/// ```test_harness,no_run
1883/// # extern crate hyper;
1884/// # extern crate hyper_rustls;
1885/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
1886/// # async fn dox() {
1887/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1888///
1889/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1890/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1891/// #     secret,
1892/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1893/// # ).build().await.unwrap();
1894///
1895/// # let client = hyper_util::client::legacy::Client::builder(
1896/// #     hyper_util::rt::TokioExecutor::new()
1897/// # )
1898/// # .build(
1899/// #     hyper_rustls::HttpsConnectorBuilder::new()
1900/// #         .with_native_roots()
1901/// #         .unwrap()
1902/// #         .https_or_http()
1903/// #         .enable_http1()
1904/// #         .build()
1905/// # );
1906/// # let mut hub = AccessContextManager::new(client, auth);
1907/// // You can configure optional parameters by calling the respective setters at will, and
1908/// // execute the final call using `doit()`.
1909/// // Values shown here are possibly random and not representative !
1910/// let result = hub.access_policies().access_levels_list("parent")
1911///              .page_token("amet.")
1912///              .page_size(-59)
1913///              .access_level_format("amet.")
1914///              .doit().await;
1915/// # }
1916/// ```
1917pub struct AccessPolicyAccessLevelListCall<'a, C>
1918where
1919    C: 'a,
1920{
1921    hub: &'a AccessContextManager<C>,
1922    _parent: String,
1923    _page_token: Option<String>,
1924    _page_size: Option<i32>,
1925    _access_level_format: Option<String>,
1926    _delegate: Option<&'a mut dyn common::Delegate>,
1927    _additional_params: HashMap<String, String>,
1928    _scopes: BTreeSet<String>,
1929}
1930
1931impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelListCall<'a, C> {}
1932
1933impl<'a, C> AccessPolicyAccessLevelListCall<'a, C>
1934where
1935    C: common::Connector,
1936{
1937    /// Perform the operation you have build so far.
1938    pub async fn doit(mut self) -> common::Result<(common::Response, ListAccessLevelsResponse)> {
1939        use std::borrow::Cow;
1940        use std::io::{Read, Seek};
1941
1942        use common::{url::Params, ToParts};
1943        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1944
1945        let mut dd = common::DefaultDelegate;
1946        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1947        dlg.begin(common::MethodInfo {
1948            id: "accesscontextmanager.accessPolicies.accessLevels.list",
1949            http_method: hyper::Method::GET,
1950        });
1951
1952        for &field in [
1953            "alt",
1954            "parent",
1955            "pageToken",
1956            "pageSize",
1957            "accessLevelFormat",
1958        ]
1959        .iter()
1960        {
1961            if self._additional_params.contains_key(field) {
1962                dlg.finished(false);
1963                return Err(common::Error::FieldClash(field));
1964            }
1965        }
1966
1967        let mut params = Params::with_capacity(6 + self._additional_params.len());
1968        params.push("parent", self._parent);
1969        if let Some(value) = self._page_token.as_ref() {
1970            params.push("pageToken", value);
1971        }
1972        if let Some(value) = self._page_size.as_ref() {
1973            params.push("pageSize", value.to_string());
1974        }
1975        if let Some(value) = self._access_level_format.as_ref() {
1976            params.push("accessLevelFormat", value);
1977        }
1978
1979        params.extend(self._additional_params.iter());
1980
1981        params.push("alt", "json");
1982        let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/accessLevels";
1983        if self._scopes.is_empty() {
1984            self._scopes
1985                .insert(Scope::CloudPlatform.as_ref().to_string());
1986        }
1987
1988        #[allow(clippy::single_element_loop)]
1989        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1990            url = params.uri_replacement(url, param_name, find_this, true);
1991        }
1992        {
1993            let to_remove = ["parent"];
1994            params.remove_params(&to_remove);
1995        }
1996
1997        let url = params.parse_with_url(&url);
1998
1999        loop {
2000            let token = match self
2001                .hub
2002                .auth
2003                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2004                .await
2005            {
2006                Ok(token) => token,
2007                Err(e) => match dlg.token(e) {
2008                    Ok(token) => token,
2009                    Err(e) => {
2010                        dlg.finished(false);
2011                        return Err(common::Error::MissingToken(e));
2012                    }
2013                },
2014            };
2015            let mut req_result = {
2016                let client = &self.hub.client;
2017                dlg.pre_request();
2018                let mut req_builder = hyper::Request::builder()
2019                    .method(hyper::Method::GET)
2020                    .uri(url.as_str())
2021                    .header(USER_AGENT, self.hub._user_agent.clone());
2022
2023                if let Some(token) = token.as_ref() {
2024                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2025                }
2026
2027                let request = req_builder
2028                    .header(CONTENT_LENGTH, 0_u64)
2029                    .body(common::to_body::<String>(None));
2030
2031                client.request(request.unwrap()).await
2032            };
2033
2034            match req_result {
2035                Err(err) => {
2036                    if let common::Retry::After(d) = dlg.http_error(&err) {
2037                        sleep(d).await;
2038                        continue;
2039                    }
2040                    dlg.finished(false);
2041                    return Err(common::Error::HttpError(err));
2042                }
2043                Ok(res) => {
2044                    let (mut parts, body) = res.into_parts();
2045                    let mut body = common::Body::new(body);
2046                    if !parts.status.is_success() {
2047                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2048                        let error = serde_json::from_str(&common::to_string(&bytes));
2049                        let response = common::to_response(parts, bytes.into());
2050
2051                        if let common::Retry::After(d) =
2052                            dlg.http_failure(&response, error.as_ref().ok())
2053                        {
2054                            sleep(d).await;
2055                            continue;
2056                        }
2057
2058                        dlg.finished(false);
2059
2060                        return Err(match error {
2061                            Ok(value) => common::Error::BadRequest(value),
2062                            _ => common::Error::Failure(response),
2063                        });
2064                    }
2065                    let response = {
2066                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2067                        let encoded = common::to_string(&bytes);
2068                        match serde_json::from_str(&encoded) {
2069                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2070                            Err(error) => {
2071                                dlg.response_json_decode_error(&encoded, &error);
2072                                return Err(common::Error::JsonDecodeError(
2073                                    encoded.to_string(),
2074                                    error,
2075                                ));
2076                            }
2077                        }
2078                    };
2079
2080                    dlg.finished(true);
2081                    return Ok(response);
2082                }
2083            }
2084        }
2085    }
2086
2087    /// Required. Resource name for the access policy to list Access Levels from. Format: `accessPolicies/{policy_id}`
2088    ///
2089    /// Sets the *parent* path property to the given value.
2090    ///
2091    /// Even though the property as already been set when instantiating this call,
2092    /// we provide this method for API completeness.
2093    pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
2094        self._parent = new_value.to_string();
2095        self
2096    }
2097    /// Next page token for the next batch of Access Level instances. Defaults to the first page of results.
2098    ///
2099    /// Sets the *page token* query property to the given value.
2100    pub fn page_token(mut self, new_value: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
2101        self._page_token = Some(new_value.to_string());
2102        self
2103    }
2104    /// Number of Access Levels to include in the list. Default 100.
2105    ///
2106    /// Sets the *page size* query property to the given value.
2107    pub fn page_size(mut self, new_value: i32) -> AccessPolicyAccessLevelListCall<'a, C> {
2108        self._page_size = Some(new_value);
2109        self
2110    }
2111    /// 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.
2112    ///
2113    /// Sets the *access level format* query property to the given value.
2114    pub fn access_level_format(
2115        mut self,
2116        new_value: &str,
2117    ) -> AccessPolicyAccessLevelListCall<'a, C> {
2118        self._access_level_format = Some(new_value.to_string());
2119        self
2120    }
2121    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2122    /// while executing the actual API request.
2123    ///
2124    /// ````text
2125    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2126    /// ````
2127    ///
2128    /// Sets the *delegate* property to the given value.
2129    pub fn delegate(
2130        mut self,
2131        new_value: &'a mut dyn common::Delegate,
2132    ) -> AccessPolicyAccessLevelListCall<'a, C> {
2133        self._delegate = Some(new_value);
2134        self
2135    }
2136
2137    /// Set any additional parameter of the query string used in the request.
2138    /// It should be used to set parameters which are not yet available through their own
2139    /// setters.
2140    ///
2141    /// Please note that this method must not be used to set any of the known parameters
2142    /// which have their own setter method. If done anyway, the request will fail.
2143    ///
2144    /// # Additional Parameters
2145    ///
2146    /// * *$.xgafv* (query-string) - V1 error format.
2147    /// * *access_token* (query-string) - OAuth access token.
2148    /// * *alt* (query-string) - Data format for response.
2149    /// * *callback* (query-string) - JSONP
2150    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2151    /// * *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.
2152    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2153    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2154    /// * *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.
2155    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2156    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2157    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelListCall<'a, C>
2158    where
2159        T: AsRef<str>,
2160    {
2161        self._additional_params
2162            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2163        self
2164    }
2165
2166    /// Identifies the authorization scope for the method you are building.
2167    ///
2168    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2169    /// [`Scope::CloudPlatform`].
2170    ///
2171    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2172    /// tokens for more than one scope.
2173    ///
2174    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2175    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2176    /// sufficient, a read-write scope will do as well.
2177    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelListCall<'a, C>
2178    where
2179        St: AsRef<str>,
2180    {
2181        self._scopes.insert(String::from(scope.as_ref()));
2182        self
2183    }
2184    /// Identifies the authorization scope(s) for the method you are building.
2185    ///
2186    /// See [`Self::add_scope()`] for details.
2187    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelListCall<'a, C>
2188    where
2189        I: IntoIterator<Item = St>,
2190        St: AsRef<str>,
2191    {
2192        self._scopes
2193            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2194        self
2195    }
2196
2197    /// Removes all scopes, and no default scope will be used either.
2198    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2199    /// for details).
2200    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelListCall<'a, C> {
2201        self._scopes.clear();
2202        self
2203    }
2204}
2205
2206/// Update an Access Level. The longrunning operation from this RPC will have a successful status once the changes to the Access Level have propagated to long-lasting storage. Access Levels containing errors will result in an error response for the first error encountered.
2207///
2208/// A builder for the *accessLevels.patch* method supported by a *accessPolicy* resource.
2209/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2210///
2211/// # Example
2212///
2213/// Instantiate a resource method builder
2214///
2215/// ```test_harness,no_run
2216/// # extern crate hyper;
2217/// # extern crate hyper_rustls;
2218/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
2219/// use accesscontextmanager1_beta::api::AccessLevel;
2220/// # async fn dox() {
2221/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2222///
2223/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2224/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2225/// #     secret,
2226/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2227/// # ).build().await.unwrap();
2228///
2229/// # let client = hyper_util::client::legacy::Client::builder(
2230/// #     hyper_util::rt::TokioExecutor::new()
2231/// # )
2232/// # .build(
2233/// #     hyper_rustls::HttpsConnectorBuilder::new()
2234/// #         .with_native_roots()
2235/// #         .unwrap()
2236/// #         .https_or_http()
2237/// #         .enable_http1()
2238/// #         .build()
2239/// # );
2240/// # let mut hub = AccessContextManager::new(client, auth);
2241/// // As the method needs a request, you would usually fill it with the desired information
2242/// // into the respective structure. Some of the parts shown here might not be applicable !
2243/// // Values shown here are possibly random and not representative !
2244/// let mut req = AccessLevel::default();
2245///
2246/// // You can configure optional parameters by calling the respective setters at will, and
2247/// // execute the final call using `doit()`.
2248/// // Values shown here are possibly random and not representative !
2249/// let result = hub.access_policies().access_levels_patch(req, "name")
2250///              .update_mask(FieldMask::new::<&str>(&[]))
2251///              .doit().await;
2252/// # }
2253/// ```
2254pub struct AccessPolicyAccessLevelPatchCall<'a, C>
2255where
2256    C: 'a,
2257{
2258    hub: &'a AccessContextManager<C>,
2259    _request: AccessLevel,
2260    _name: String,
2261    _update_mask: Option<common::FieldMask>,
2262    _delegate: Option<&'a mut dyn common::Delegate>,
2263    _additional_params: HashMap<String, String>,
2264    _scopes: BTreeSet<String>,
2265}
2266
2267impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelPatchCall<'a, C> {}
2268
2269impl<'a, C> AccessPolicyAccessLevelPatchCall<'a, C>
2270where
2271    C: common::Connector,
2272{
2273    /// Perform the operation you have build so far.
2274    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2275        use std::borrow::Cow;
2276        use std::io::{Read, Seek};
2277
2278        use common::{url::Params, ToParts};
2279        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2280
2281        let mut dd = common::DefaultDelegate;
2282        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2283        dlg.begin(common::MethodInfo {
2284            id: "accesscontextmanager.accessPolicies.accessLevels.patch",
2285            http_method: hyper::Method::PATCH,
2286        });
2287
2288        for &field in ["alt", "name", "updateMask"].iter() {
2289            if self._additional_params.contains_key(field) {
2290                dlg.finished(false);
2291                return Err(common::Error::FieldClash(field));
2292            }
2293        }
2294
2295        let mut params = Params::with_capacity(5 + self._additional_params.len());
2296        params.push("name", self._name);
2297        if let Some(value) = self._update_mask.as_ref() {
2298            params.push("updateMask", value.to_string());
2299        }
2300
2301        params.extend(self._additional_params.iter());
2302
2303        params.push("alt", "json");
2304        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
2305        if self._scopes.is_empty() {
2306            self._scopes
2307                .insert(Scope::CloudPlatform.as_ref().to_string());
2308        }
2309
2310        #[allow(clippy::single_element_loop)]
2311        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2312            url = params.uri_replacement(url, param_name, find_this, true);
2313        }
2314        {
2315            let to_remove = ["name"];
2316            params.remove_params(&to_remove);
2317        }
2318
2319        let url = params.parse_with_url(&url);
2320
2321        let mut json_mime_type = mime::APPLICATION_JSON;
2322        let mut request_value_reader = {
2323            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2324            common::remove_json_null_values(&mut value);
2325            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2326            serde_json::to_writer(&mut dst, &value).unwrap();
2327            dst
2328        };
2329        let request_size = request_value_reader
2330            .seek(std::io::SeekFrom::End(0))
2331            .unwrap();
2332        request_value_reader
2333            .seek(std::io::SeekFrom::Start(0))
2334            .unwrap();
2335
2336        loop {
2337            let token = match self
2338                .hub
2339                .auth
2340                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2341                .await
2342            {
2343                Ok(token) => token,
2344                Err(e) => match dlg.token(e) {
2345                    Ok(token) => token,
2346                    Err(e) => {
2347                        dlg.finished(false);
2348                        return Err(common::Error::MissingToken(e));
2349                    }
2350                },
2351            };
2352            request_value_reader
2353                .seek(std::io::SeekFrom::Start(0))
2354                .unwrap();
2355            let mut req_result = {
2356                let client = &self.hub.client;
2357                dlg.pre_request();
2358                let mut req_builder = hyper::Request::builder()
2359                    .method(hyper::Method::PATCH)
2360                    .uri(url.as_str())
2361                    .header(USER_AGENT, self.hub._user_agent.clone());
2362
2363                if let Some(token) = token.as_ref() {
2364                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2365                }
2366
2367                let request = req_builder
2368                    .header(CONTENT_TYPE, json_mime_type.to_string())
2369                    .header(CONTENT_LENGTH, request_size as u64)
2370                    .body(common::to_body(
2371                        request_value_reader.get_ref().clone().into(),
2372                    ));
2373
2374                client.request(request.unwrap()).await
2375            };
2376
2377            match req_result {
2378                Err(err) => {
2379                    if let common::Retry::After(d) = dlg.http_error(&err) {
2380                        sleep(d).await;
2381                        continue;
2382                    }
2383                    dlg.finished(false);
2384                    return Err(common::Error::HttpError(err));
2385                }
2386                Ok(res) => {
2387                    let (mut parts, body) = res.into_parts();
2388                    let mut body = common::Body::new(body);
2389                    if !parts.status.is_success() {
2390                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2391                        let error = serde_json::from_str(&common::to_string(&bytes));
2392                        let response = common::to_response(parts, bytes.into());
2393
2394                        if let common::Retry::After(d) =
2395                            dlg.http_failure(&response, error.as_ref().ok())
2396                        {
2397                            sleep(d).await;
2398                            continue;
2399                        }
2400
2401                        dlg.finished(false);
2402
2403                        return Err(match error {
2404                            Ok(value) => common::Error::BadRequest(value),
2405                            _ => common::Error::Failure(response),
2406                        });
2407                    }
2408                    let response = {
2409                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2410                        let encoded = common::to_string(&bytes);
2411                        match serde_json::from_str(&encoded) {
2412                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2413                            Err(error) => {
2414                                dlg.response_json_decode_error(&encoded, &error);
2415                                return Err(common::Error::JsonDecodeError(
2416                                    encoded.to_string(),
2417                                    error,
2418                                ));
2419                            }
2420                        }
2421                    };
2422
2423                    dlg.finished(true);
2424                    return Ok(response);
2425                }
2426            }
2427        }
2428    }
2429
2430    ///
2431    /// Sets the *request* property to the given value.
2432    ///
2433    /// Even though the property as already been set when instantiating this call,
2434    /// we provide this method for API completeness.
2435    pub fn request(mut self, new_value: AccessLevel) -> AccessPolicyAccessLevelPatchCall<'a, C> {
2436        self._request = new_value;
2437        self
2438    }
2439    /// 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`.
2440    ///
2441    /// Sets the *name* path property to the given value.
2442    ///
2443    /// Even though the property as already been set when instantiating this call,
2444    /// we provide this method for API completeness.
2445    pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelPatchCall<'a, C> {
2446        self._name = new_value.to_string();
2447        self
2448    }
2449    /// Required. Mask to control which fields get updated. Must be non-empty.
2450    ///
2451    /// Sets the *update mask* query property to the given value.
2452    pub fn update_mask(
2453        mut self,
2454        new_value: common::FieldMask,
2455    ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
2456        self._update_mask = Some(new_value);
2457        self
2458    }
2459    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2460    /// while executing the actual API request.
2461    ///
2462    /// ````text
2463    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2464    /// ````
2465    ///
2466    /// Sets the *delegate* property to the given value.
2467    pub fn delegate(
2468        mut self,
2469        new_value: &'a mut dyn common::Delegate,
2470    ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
2471        self._delegate = Some(new_value);
2472        self
2473    }
2474
2475    /// Set any additional parameter of the query string used in the request.
2476    /// It should be used to set parameters which are not yet available through their own
2477    /// setters.
2478    ///
2479    /// Please note that this method must not be used to set any of the known parameters
2480    /// which have their own setter method. If done anyway, the request will fail.
2481    ///
2482    /// # Additional Parameters
2483    ///
2484    /// * *$.xgafv* (query-string) - V1 error format.
2485    /// * *access_token* (query-string) - OAuth access token.
2486    /// * *alt* (query-string) - Data format for response.
2487    /// * *callback* (query-string) - JSONP
2488    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2489    /// * *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.
2490    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2491    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2492    /// * *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.
2493    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2494    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2495    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelPatchCall<'a, C>
2496    where
2497        T: AsRef<str>,
2498    {
2499        self._additional_params
2500            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2501        self
2502    }
2503
2504    /// Identifies the authorization scope for the method you are building.
2505    ///
2506    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2507    /// [`Scope::CloudPlatform`].
2508    ///
2509    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2510    /// tokens for more than one scope.
2511    ///
2512    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2513    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2514    /// sufficient, a read-write scope will do as well.
2515    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelPatchCall<'a, C>
2516    where
2517        St: AsRef<str>,
2518    {
2519        self._scopes.insert(String::from(scope.as_ref()));
2520        self
2521    }
2522    /// Identifies the authorization scope(s) for the method you are building.
2523    ///
2524    /// See [`Self::add_scope()`] for details.
2525    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelPatchCall<'a, C>
2526    where
2527        I: IntoIterator<Item = St>,
2528        St: AsRef<str>,
2529    {
2530        self._scopes
2531            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2532        self
2533    }
2534
2535    /// Removes all scopes, and no default scope will be used either.
2536    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2537    /// for details).
2538    pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelPatchCall<'a, C> {
2539        self._scopes.clear();
2540        self
2541    }
2542}
2543
2544/// Create a Service Perimeter. The longrunning operation from this RPC will have a successful status once the Service Perimeter has propagated to long-lasting storage. Service Perimeters containing errors will result in an error response for the first error encountered.
2545///
2546/// A builder for the *servicePerimeters.create* method supported by a *accessPolicy* resource.
2547/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2548///
2549/// # Example
2550///
2551/// Instantiate a resource method builder
2552///
2553/// ```test_harness,no_run
2554/// # extern crate hyper;
2555/// # extern crate hyper_rustls;
2556/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
2557/// use accesscontextmanager1_beta::api::ServicePerimeter;
2558/// # async fn dox() {
2559/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2560///
2561/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2562/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2563/// #     secret,
2564/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2565/// # ).build().await.unwrap();
2566///
2567/// # let client = hyper_util::client::legacy::Client::builder(
2568/// #     hyper_util::rt::TokioExecutor::new()
2569/// # )
2570/// # .build(
2571/// #     hyper_rustls::HttpsConnectorBuilder::new()
2572/// #         .with_native_roots()
2573/// #         .unwrap()
2574/// #         .https_or_http()
2575/// #         .enable_http1()
2576/// #         .build()
2577/// # );
2578/// # let mut hub = AccessContextManager::new(client, auth);
2579/// // As the method needs a request, you would usually fill it with the desired information
2580/// // into the respective structure. Some of the parts shown here might not be applicable !
2581/// // Values shown here are possibly random and not representative !
2582/// let mut req = ServicePerimeter::default();
2583///
2584/// // You can configure optional parameters by calling the respective setters at will, and
2585/// // execute the final call using `doit()`.
2586/// // Values shown here are possibly random and not representative !
2587/// let result = hub.access_policies().service_perimeters_create(req, "parent")
2588///              .doit().await;
2589/// # }
2590/// ```
2591pub struct AccessPolicyServicePerimeterCreateCall<'a, C>
2592where
2593    C: 'a,
2594{
2595    hub: &'a AccessContextManager<C>,
2596    _request: ServicePerimeter,
2597    _parent: String,
2598    _delegate: Option<&'a mut dyn common::Delegate>,
2599    _additional_params: HashMap<String, String>,
2600    _scopes: BTreeSet<String>,
2601}
2602
2603impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterCreateCall<'a, C> {}
2604
2605impl<'a, C> AccessPolicyServicePerimeterCreateCall<'a, C>
2606where
2607    C: common::Connector,
2608{
2609    /// Perform the operation you have build so far.
2610    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2611        use std::borrow::Cow;
2612        use std::io::{Read, Seek};
2613
2614        use common::{url::Params, ToParts};
2615        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2616
2617        let mut dd = common::DefaultDelegate;
2618        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2619        dlg.begin(common::MethodInfo {
2620            id: "accesscontextmanager.accessPolicies.servicePerimeters.create",
2621            http_method: hyper::Method::POST,
2622        });
2623
2624        for &field in ["alt", "parent"].iter() {
2625            if self._additional_params.contains_key(field) {
2626                dlg.finished(false);
2627                return Err(common::Error::FieldClash(field));
2628            }
2629        }
2630
2631        let mut params = Params::with_capacity(4 + self._additional_params.len());
2632        params.push("parent", self._parent);
2633
2634        params.extend(self._additional_params.iter());
2635
2636        params.push("alt", "json");
2637        let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/servicePerimeters";
2638        if self._scopes.is_empty() {
2639            self._scopes
2640                .insert(Scope::CloudPlatform.as_ref().to_string());
2641        }
2642
2643        #[allow(clippy::single_element_loop)]
2644        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2645            url = params.uri_replacement(url, param_name, find_this, true);
2646        }
2647        {
2648            let to_remove = ["parent"];
2649            params.remove_params(&to_remove);
2650        }
2651
2652        let url = params.parse_with_url(&url);
2653
2654        let mut json_mime_type = mime::APPLICATION_JSON;
2655        let mut request_value_reader = {
2656            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2657            common::remove_json_null_values(&mut value);
2658            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2659            serde_json::to_writer(&mut dst, &value).unwrap();
2660            dst
2661        };
2662        let request_size = request_value_reader
2663            .seek(std::io::SeekFrom::End(0))
2664            .unwrap();
2665        request_value_reader
2666            .seek(std::io::SeekFrom::Start(0))
2667            .unwrap();
2668
2669        loop {
2670            let token = match self
2671                .hub
2672                .auth
2673                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2674                .await
2675            {
2676                Ok(token) => token,
2677                Err(e) => match dlg.token(e) {
2678                    Ok(token) => token,
2679                    Err(e) => {
2680                        dlg.finished(false);
2681                        return Err(common::Error::MissingToken(e));
2682                    }
2683                },
2684            };
2685            request_value_reader
2686                .seek(std::io::SeekFrom::Start(0))
2687                .unwrap();
2688            let mut req_result = {
2689                let client = &self.hub.client;
2690                dlg.pre_request();
2691                let mut req_builder = hyper::Request::builder()
2692                    .method(hyper::Method::POST)
2693                    .uri(url.as_str())
2694                    .header(USER_AGENT, self.hub._user_agent.clone());
2695
2696                if let Some(token) = token.as_ref() {
2697                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2698                }
2699
2700                let request = req_builder
2701                    .header(CONTENT_TYPE, json_mime_type.to_string())
2702                    .header(CONTENT_LENGTH, request_size as u64)
2703                    .body(common::to_body(
2704                        request_value_reader.get_ref().clone().into(),
2705                    ));
2706
2707                client.request(request.unwrap()).await
2708            };
2709
2710            match req_result {
2711                Err(err) => {
2712                    if let common::Retry::After(d) = dlg.http_error(&err) {
2713                        sleep(d).await;
2714                        continue;
2715                    }
2716                    dlg.finished(false);
2717                    return Err(common::Error::HttpError(err));
2718                }
2719                Ok(res) => {
2720                    let (mut parts, body) = res.into_parts();
2721                    let mut body = common::Body::new(body);
2722                    if !parts.status.is_success() {
2723                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2724                        let error = serde_json::from_str(&common::to_string(&bytes));
2725                        let response = common::to_response(parts, bytes.into());
2726
2727                        if let common::Retry::After(d) =
2728                            dlg.http_failure(&response, error.as_ref().ok())
2729                        {
2730                            sleep(d).await;
2731                            continue;
2732                        }
2733
2734                        dlg.finished(false);
2735
2736                        return Err(match error {
2737                            Ok(value) => common::Error::BadRequest(value),
2738                            _ => common::Error::Failure(response),
2739                        });
2740                    }
2741                    let response = {
2742                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2743                        let encoded = common::to_string(&bytes);
2744                        match serde_json::from_str(&encoded) {
2745                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2746                            Err(error) => {
2747                                dlg.response_json_decode_error(&encoded, &error);
2748                                return Err(common::Error::JsonDecodeError(
2749                                    encoded.to_string(),
2750                                    error,
2751                                ));
2752                            }
2753                        }
2754                    };
2755
2756                    dlg.finished(true);
2757                    return Ok(response);
2758                }
2759            }
2760        }
2761    }
2762
2763    ///
2764    /// Sets the *request* property to the given value.
2765    ///
2766    /// Even though the property as already been set when instantiating this call,
2767    /// we provide this method for API completeness.
2768    pub fn request(
2769        mut self,
2770        new_value: ServicePerimeter,
2771    ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
2772        self._request = new_value;
2773        self
2774    }
2775    /// Required. Resource name for the access policy which owns this Service Perimeter. Format: `accessPolicies/{policy_id}`
2776    ///
2777    /// Sets the *parent* path property to the given value.
2778    ///
2779    /// Even though the property as already been set when instantiating this call,
2780    /// we provide this method for API completeness.
2781    pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
2782        self._parent = new_value.to_string();
2783        self
2784    }
2785    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2786    /// while executing the actual API request.
2787    ///
2788    /// ````text
2789    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2790    /// ````
2791    ///
2792    /// Sets the *delegate* property to the given value.
2793    pub fn delegate(
2794        mut self,
2795        new_value: &'a mut dyn common::Delegate,
2796    ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
2797        self._delegate = Some(new_value);
2798        self
2799    }
2800
2801    /// Set any additional parameter of the query string used in the request.
2802    /// It should be used to set parameters which are not yet available through their own
2803    /// setters.
2804    ///
2805    /// Please note that this method must not be used to set any of the known parameters
2806    /// which have their own setter method. If done anyway, the request will fail.
2807    ///
2808    /// # Additional Parameters
2809    ///
2810    /// * *$.xgafv* (query-string) - V1 error format.
2811    /// * *access_token* (query-string) - OAuth access token.
2812    /// * *alt* (query-string) - Data format for response.
2813    /// * *callback* (query-string) - JSONP
2814    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2815    /// * *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.
2816    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2817    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2818    /// * *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.
2819    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2820    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2821    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterCreateCall<'a, C>
2822    where
2823        T: AsRef<str>,
2824    {
2825        self._additional_params
2826            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2827        self
2828    }
2829
2830    /// Identifies the authorization scope for the method you are building.
2831    ///
2832    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2833    /// [`Scope::CloudPlatform`].
2834    ///
2835    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2836    /// tokens for more than one scope.
2837    ///
2838    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2839    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2840    /// sufficient, a read-write scope will do as well.
2841    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterCreateCall<'a, C>
2842    where
2843        St: AsRef<str>,
2844    {
2845        self._scopes.insert(String::from(scope.as_ref()));
2846        self
2847    }
2848    /// Identifies the authorization scope(s) for the method you are building.
2849    ///
2850    /// See [`Self::add_scope()`] for details.
2851    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterCreateCall<'a, C>
2852    where
2853        I: IntoIterator<Item = St>,
2854        St: AsRef<str>,
2855    {
2856        self._scopes
2857            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2858        self
2859    }
2860
2861    /// Removes all scopes, and no default scope will be used either.
2862    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2863    /// for details).
2864    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
2865        self._scopes.clear();
2866        self
2867    }
2868}
2869
2870/// Delete a Service Perimeter by resource name. The longrunning operation from this RPC will have a successful status once the Service Perimeter has been removed from long-lasting storage.
2871///
2872/// A builder for the *servicePerimeters.delete* method supported by a *accessPolicy* resource.
2873/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2874///
2875/// # Example
2876///
2877/// Instantiate a resource method builder
2878///
2879/// ```test_harness,no_run
2880/// # extern crate hyper;
2881/// # extern crate hyper_rustls;
2882/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
2883/// # async fn dox() {
2884/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2885///
2886/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2887/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2888/// #     secret,
2889/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2890/// # ).build().await.unwrap();
2891///
2892/// # let client = hyper_util::client::legacy::Client::builder(
2893/// #     hyper_util::rt::TokioExecutor::new()
2894/// # )
2895/// # .build(
2896/// #     hyper_rustls::HttpsConnectorBuilder::new()
2897/// #         .with_native_roots()
2898/// #         .unwrap()
2899/// #         .https_or_http()
2900/// #         .enable_http1()
2901/// #         .build()
2902/// # );
2903/// # let mut hub = AccessContextManager::new(client, auth);
2904/// // You can configure optional parameters by calling the respective setters at will, and
2905/// // execute the final call using `doit()`.
2906/// // Values shown here are possibly random and not representative !
2907/// let result = hub.access_policies().service_perimeters_delete("name")
2908///              .doit().await;
2909/// # }
2910/// ```
2911pub struct AccessPolicyServicePerimeterDeleteCall<'a, C>
2912where
2913    C: 'a,
2914{
2915    hub: &'a AccessContextManager<C>,
2916    _name: String,
2917    _delegate: Option<&'a mut dyn common::Delegate>,
2918    _additional_params: HashMap<String, String>,
2919    _scopes: BTreeSet<String>,
2920}
2921
2922impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterDeleteCall<'a, C> {}
2923
2924impl<'a, C> AccessPolicyServicePerimeterDeleteCall<'a, C>
2925where
2926    C: common::Connector,
2927{
2928    /// Perform the operation you have build so far.
2929    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2930        use std::borrow::Cow;
2931        use std::io::{Read, Seek};
2932
2933        use common::{url::Params, ToParts};
2934        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2935
2936        let mut dd = common::DefaultDelegate;
2937        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2938        dlg.begin(common::MethodInfo {
2939            id: "accesscontextmanager.accessPolicies.servicePerimeters.delete",
2940            http_method: hyper::Method::DELETE,
2941        });
2942
2943        for &field in ["alt", "name"].iter() {
2944            if self._additional_params.contains_key(field) {
2945                dlg.finished(false);
2946                return Err(common::Error::FieldClash(field));
2947            }
2948        }
2949
2950        let mut params = Params::with_capacity(3 + self._additional_params.len());
2951        params.push("name", self._name);
2952
2953        params.extend(self._additional_params.iter());
2954
2955        params.push("alt", "json");
2956        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
2957        if self._scopes.is_empty() {
2958            self._scopes
2959                .insert(Scope::CloudPlatform.as_ref().to_string());
2960        }
2961
2962        #[allow(clippy::single_element_loop)]
2963        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2964            url = params.uri_replacement(url, param_name, find_this, true);
2965        }
2966        {
2967            let to_remove = ["name"];
2968            params.remove_params(&to_remove);
2969        }
2970
2971        let url = params.parse_with_url(&url);
2972
2973        loop {
2974            let token = match self
2975                .hub
2976                .auth
2977                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2978                .await
2979            {
2980                Ok(token) => token,
2981                Err(e) => match dlg.token(e) {
2982                    Ok(token) => token,
2983                    Err(e) => {
2984                        dlg.finished(false);
2985                        return Err(common::Error::MissingToken(e));
2986                    }
2987                },
2988            };
2989            let mut req_result = {
2990                let client = &self.hub.client;
2991                dlg.pre_request();
2992                let mut req_builder = hyper::Request::builder()
2993                    .method(hyper::Method::DELETE)
2994                    .uri(url.as_str())
2995                    .header(USER_AGENT, self.hub._user_agent.clone());
2996
2997                if let Some(token) = token.as_ref() {
2998                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2999                }
3000
3001                let request = req_builder
3002                    .header(CONTENT_LENGTH, 0_u64)
3003                    .body(common::to_body::<String>(None));
3004
3005                client.request(request.unwrap()).await
3006            };
3007
3008            match req_result {
3009                Err(err) => {
3010                    if let common::Retry::After(d) = dlg.http_error(&err) {
3011                        sleep(d).await;
3012                        continue;
3013                    }
3014                    dlg.finished(false);
3015                    return Err(common::Error::HttpError(err));
3016                }
3017                Ok(res) => {
3018                    let (mut parts, body) = res.into_parts();
3019                    let mut body = common::Body::new(body);
3020                    if !parts.status.is_success() {
3021                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3022                        let error = serde_json::from_str(&common::to_string(&bytes));
3023                        let response = common::to_response(parts, bytes.into());
3024
3025                        if let common::Retry::After(d) =
3026                            dlg.http_failure(&response, error.as_ref().ok())
3027                        {
3028                            sleep(d).await;
3029                            continue;
3030                        }
3031
3032                        dlg.finished(false);
3033
3034                        return Err(match error {
3035                            Ok(value) => common::Error::BadRequest(value),
3036                            _ => common::Error::Failure(response),
3037                        });
3038                    }
3039                    let response = {
3040                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3041                        let encoded = common::to_string(&bytes);
3042                        match serde_json::from_str(&encoded) {
3043                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3044                            Err(error) => {
3045                                dlg.response_json_decode_error(&encoded, &error);
3046                                return Err(common::Error::JsonDecodeError(
3047                                    encoded.to_string(),
3048                                    error,
3049                                ));
3050                            }
3051                        }
3052                    };
3053
3054                    dlg.finished(true);
3055                    return Ok(response);
3056                }
3057            }
3058        }
3059    }
3060
3061    /// Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeter_id}`
3062    ///
3063    /// Sets the *name* path property to the given value.
3064    ///
3065    /// Even though the property as already been set when instantiating this call,
3066    /// we provide this method for API completeness.
3067    pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
3068        self._name = new_value.to_string();
3069        self
3070    }
3071    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3072    /// while executing the actual API request.
3073    ///
3074    /// ````text
3075    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3076    /// ````
3077    ///
3078    /// Sets the *delegate* property to the given value.
3079    pub fn delegate(
3080        mut self,
3081        new_value: &'a mut dyn common::Delegate,
3082    ) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
3083        self._delegate = Some(new_value);
3084        self
3085    }
3086
3087    /// Set any additional parameter of the query string used in the request.
3088    /// It should be used to set parameters which are not yet available through their own
3089    /// setters.
3090    ///
3091    /// Please note that this method must not be used to set any of the known parameters
3092    /// which have their own setter method. If done anyway, the request will fail.
3093    ///
3094    /// # Additional Parameters
3095    ///
3096    /// * *$.xgafv* (query-string) - V1 error format.
3097    /// * *access_token* (query-string) - OAuth access token.
3098    /// * *alt* (query-string) - Data format for response.
3099    /// * *callback* (query-string) - JSONP
3100    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3101    /// * *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.
3102    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3103    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3104    /// * *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.
3105    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3106    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3107    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
3108    where
3109        T: AsRef<str>,
3110    {
3111        self._additional_params
3112            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3113        self
3114    }
3115
3116    /// Identifies the authorization scope for the method you are building.
3117    ///
3118    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3119    /// [`Scope::CloudPlatform`].
3120    ///
3121    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3122    /// tokens for more than one scope.
3123    ///
3124    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3125    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3126    /// sufficient, a read-write scope will do as well.
3127    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
3128    where
3129        St: AsRef<str>,
3130    {
3131        self._scopes.insert(String::from(scope.as_ref()));
3132        self
3133    }
3134    /// Identifies the authorization scope(s) for the method you are building.
3135    ///
3136    /// See [`Self::add_scope()`] for details.
3137    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
3138    where
3139        I: IntoIterator<Item = St>,
3140        St: AsRef<str>,
3141    {
3142        self._scopes
3143            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3144        self
3145    }
3146
3147    /// Removes all scopes, and no default scope will be used either.
3148    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3149    /// for details).
3150    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
3151        self._scopes.clear();
3152        self
3153    }
3154}
3155
3156/// Get a Service Perimeter by resource name.
3157///
3158/// A builder for the *servicePerimeters.get* method supported by a *accessPolicy* resource.
3159/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3160///
3161/// # Example
3162///
3163/// Instantiate a resource method builder
3164///
3165/// ```test_harness,no_run
3166/// # extern crate hyper;
3167/// # extern crate hyper_rustls;
3168/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
3169/// # async fn dox() {
3170/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3171///
3172/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3173/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3174/// #     secret,
3175/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3176/// # ).build().await.unwrap();
3177///
3178/// # let client = hyper_util::client::legacy::Client::builder(
3179/// #     hyper_util::rt::TokioExecutor::new()
3180/// # )
3181/// # .build(
3182/// #     hyper_rustls::HttpsConnectorBuilder::new()
3183/// #         .with_native_roots()
3184/// #         .unwrap()
3185/// #         .https_or_http()
3186/// #         .enable_http1()
3187/// #         .build()
3188/// # );
3189/// # let mut hub = AccessContextManager::new(client, auth);
3190/// // You can configure optional parameters by calling the respective setters at will, and
3191/// // execute the final call using `doit()`.
3192/// // Values shown here are possibly random and not representative !
3193/// let result = hub.access_policies().service_perimeters_get("name")
3194///              .doit().await;
3195/// # }
3196/// ```
3197pub struct AccessPolicyServicePerimeterGetCall<'a, C>
3198where
3199    C: 'a,
3200{
3201    hub: &'a AccessContextManager<C>,
3202    _name: String,
3203    _delegate: Option<&'a mut dyn common::Delegate>,
3204    _additional_params: HashMap<String, String>,
3205    _scopes: BTreeSet<String>,
3206}
3207
3208impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterGetCall<'a, C> {}
3209
3210impl<'a, C> AccessPolicyServicePerimeterGetCall<'a, C>
3211where
3212    C: common::Connector,
3213{
3214    /// Perform the operation you have build so far.
3215    pub async fn doit(mut self) -> common::Result<(common::Response, ServicePerimeter)> {
3216        use std::borrow::Cow;
3217        use std::io::{Read, Seek};
3218
3219        use common::{url::Params, ToParts};
3220        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3221
3222        let mut dd = common::DefaultDelegate;
3223        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3224        dlg.begin(common::MethodInfo {
3225            id: "accesscontextmanager.accessPolicies.servicePerimeters.get",
3226            http_method: hyper::Method::GET,
3227        });
3228
3229        for &field in ["alt", "name"].iter() {
3230            if self._additional_params.contains_key(field) {
3231                dlg.finished(false);
3232                return Err(common::Error::FieldClash(field));
3233            }
3234        }
3235
3236        let mut params = Params::with_capacity(3 + self._additional_params.len());
3237        params.push("name", self._name);
3238
3239        params.extend(self._additional_params.iter());
3240
3241        params.push("alt", "json");
3242        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
3243        if self._scopes.is_empty() {
3244            self._scopes
3245                .insert(Scope::CloudPlatform.as_ref().to_string());
3246        }
3247
3248        #[allow(clippy::single_element_loop)]
3249        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3250            url = params.uri_replacement(url, param_name, find_this, true);
3251        }
3252        {
3253            let to_remove = ["name"];
3254            params.remove_params(&to_remove);
3255        }
3256
3257        let url = params.parse_with_url(&url);
3258
3259        loop {
3260            let token = match self
3261                .hub
3262                .auth
3263                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3264                .await
3265            {
3266                Ok(token) => token,
3267                Err(e) => match dlg.token(e) {
3268                    Ok(token) => token,
3269                    Err(e) => {
3270                        dlg.finished(false);
3271                        return Err(common::Error::MissingToken(e));
3272                    }
3273                },
3274            };
3275            let mut req_result = {
3276                let client = &self.hub.client;
3277                dlg.pre_request();
3278                let mut req_builder = hyper::Request::builder()
3279                    .method(hyper::Method::GET)
3280                    .uri(url.as_str())
3281                    .header(USER_AGENT, self.hub._user_agent.clone());
3282
3283                if let Some(token) = token.as_ref() {
3284                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3285                }
3286
3287                let request = req_builder
3288                    .header(CONTENT_LENGTH, 0_u64)
3289                    .body(common::to_body::<String>(None));
3290
3291                client.request(request.unwrap()).await
3292            };
3293
3294            match req_result {
3295                Err(err) => {
3296                    if let common::Retry::After(d) = dlg.http_error(&err) {
3297                        sleep(d).await;
3298                        continue;
3299                    }
3300                    dlg.finished(false);
3301                    return Err(common::Error::HttpError(err));
3302                }
3303                Ok(res) => {
3304                    let (mut parts, body) = res.into_parts();
3305                    let mut body = common::Body::new(body);
3306                    if !parts.status.is_success() {
3307                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3308                        let error = serde_json::from_str(&common::to_string(&bytes));
3309                        let response = common::to_response(parts, bytes.into());
3310
3311                        if let common::Retry::After(d) =
3312                            dlg.http_failure(&response, error.as_ref().ok())
3313                        {
3314                            sleep(d).await;
3315                            continue;
3316                        }
3317
3318                        dlg.finished(false);
3319
3320                        return Err(match error {
3321                            Ok(value) => common::Error::BadRequest(value),
3322                            _ => common::Error::Failure(response),
3323                        });
3324                    }
3325                    let response = {
3326                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3327                        let encoded = common::to_string(&bytes);
3328                        match serde_json::from_str(&encoded) {
3329                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3330                            Err(error) => {
3331                                dlg.response_json_decode_error(&encoded, &error);
3332                                return Err(common::Error::JsonDecodeError(
3333                                    encoded.to_string(),
3334                                    error,
3335                                ));
3336                            }
3337                        }
3338                    };
3339
3340                    dlg.finished(true);
3341                    return Ok(response);
3342                }
3343            }
3344        }
3345    }
3346
3347    /// Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeters_id}`
3348    ///
3349    /// Sets the *name* path property to the given value.
3350    ///
3351    /// Even though the property as already been set when instantiating this call,
3352    /// we provide this method for API completeness.
3353    pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterGetCall<'a, C> {
3354        self._name = new_value.to_string();
3355        self
3356    }
3357    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3358    /// while executing the actual API request.
3359    ///
3360    /// ````text
3361    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3362    /// ````
3363    ///
3364    /// Sets the *delegate* property to the given value.
3365    pub fn delegate(
3366        mut self,
3367        new_value: &'a mut dyn common::Delegate,
3368    ) -> AccessPolicyServicePerimeterGetCall<'a, C> {
3369        self._delegate = Some(new_value);
3370        self
3371    }
3372
3373    /// Set any additional parameter of the query string used in the request.
3374    /// It should be used to set parameters which are not yet available through their own
3375    /// setters.
3376    ///
3377    /// Please note that this method must not be used to set any of the known parameters
3378    /// which have their own setter method. If done anyway, the request will fail.
3379    ///
3380    /// # Additional Parameters
3381    ///
3382    /// * *$.xgafv* (query-string) - V1 error format.
3383    /// * *access_token* (query-string) - OAuth access token.
3384    /// * *alt* (query-string) - Data format for response.
3385    /// * *callback* (query-string) - JSONP
3386    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3387    /// * *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.
3388    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3389    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3390    /// * *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.
3391    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3392    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3393    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterGetCall<'a, C>
3394    where
3395        T: AsRef<str>,
3396    {
3397        self._additional_params
3398            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3399        self
3400    }
3401
3402    /// Identifies the authorization scope for the method you are building.
3403    ///
3404    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3405    /// [`Scope::CloudPlatform`].
3406    ///
3407    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3408    /// tokens for more than one scope.
3409    ///
3410    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3411    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3412    /// sufficient, a read-write scope will do as well.
3413    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterGetCall<'a, C>
3414    where
3415        St: AsRef<str>,
3416    {
3417        self._scopes.insert(String::from(scope.as_ref()));
3418        self
3419    }
3420    /// Identifies the authorization scope(s) for the method you are building.
3421    ///
3422    /// See [`Self::add_scope()`] for details.
3423    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterGetCall<'a, C>
3424    where
3425        I: IntoIterator<Item = St>,
3426        St: AsRef<str>,
3427    {
3428        self._scopes
3429            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3430        self
3431    }
3432
3433    /// Removes all scopes, and no default scope will be used either.
3434    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3435    /// for details).
3436    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterGetCall<'a, C> {
3437        self._scopes.clear();
3438        self
3439    }
3440}
3441
3442/// List all Service Perimeters for an access policy.
3443///
3444/// A builder for the *servicePerimeters.list* method supported by a *accessPolicy* resource.
3445/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3446///
3447/// # Example
3448///
3449/// Instantiate a resource method builder
3450///
3451/// ```test_harness,no_run
3452/// # extern crate hyper;
3453/// # extern crate hyper_rustls;
3454/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
3455/// # async fn dox() {
3456/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3457///
3458/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3459/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3460/// #     secret,
3461/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3462/// # ).build().await.unwrap();
3463///
3464/// # let client = hyper_util::client::legacy::Client::builder(
3465/// #     hyper_util::rt::TokioExecutor::new()
3466/// # )
3467/// # .build(
3468/// #     hyper_rustls::HttpsConnectorBuilder::new()
3469/// #         .with_native_roots()
3470/// #         .unwrap()
3471/// #         .https_or_http()
3472/// #         .enable_http1()
3473/// #         .build()
3474/// # );
3475/// # let mut hub = AccessContextManager::new(client, auth);
3476/// // You can configure optional parameters by calling the respective setters at will, and
3477/// // execute the final call using `doit()`.
3478/// // Values shown here are possibly random and not representative !
3479/// let result = hub.access_policies().service_perimeters_list("parent")
3480///              .page_token("eos")
3481///              .page_size(-4)
3482///              .doit().await;
3483/// # }
3484/// ```
3485pub struct AccessPolicyServicePerimeterListCall<'a, C>
3486where
3487    C: 'a,
3488{
3489    hub: &'a AccessContextManager<C>,
3490    _parent: String,
3491    _page_token: Option<String>,
3492    _page_size: Option<i32>,
3493    _delegate: Option<&'a mut dyn common::Delegate>,
3494    _additional_params: HashMap<String, String>,
3495    _scopes: BTreeSet<String>,
3496}
3497
3498impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterListCall<'a, C> {}
3499
3500impl<'a, C> AccessPolicyServicePerimeterListCall<'a, C>
3501where
3502    C: common::Connector,
3503{
3504    /// Perform the operation you have build so far.
3505    pub async fn doit(
3506        mut self,
3507    ) -> common::Result<(common::Response, ListServicePerimetersResponse)> {
3508        use std::borrow::Cow;
3509        use std::io::{Read, Seek};
3510
3511        use common::{url::Params, ToParts};
3512        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3513
3514        let mut dd = common::DefaultDelegate;
3515        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3516        dlg.begin(common::MethodInfo {
3517            id: "accesscontextmanager.accessPolicies.servicePerimeters.list",
3518            http_method: hyper::Method::GET,
3519        });
3520
3521        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
3522            if self._additional_params.contains_key(field) {
3523                dlg.finished(false);
3524                return Err(common::Error::FieldClash(field));
3525            }
3526        }
3527
3528        let mut params = Params::with_capacity(5 + self._additional_params.len());
3529        params.push("parent", self._parent);
3530        if let Some(value) = self._page_token.as_ref() {
3531            params.push("pageToken", value);
3532        }
3533        if let Some(value) = self._page_size.as_ref() {
3534            params.push("pageSize", value.to_string());
3535        }
3536
3537        params.extend(self._additional_params.iter());
3538
3539        params.push("alt", "json");
3540        let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/servicePerimeters";
3541        if self._scopes.is_empty() {
3542            self._scopes
3543                .insert(Scope::CloudPlatform.as_ref().to_string());
3544        }
3545
3546        #[allow(clippy::single_element_loop)]
3547        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3548            url = params.uri_replacement(url, param_name, find_this, true);
3549        }
3550        {
3551            let to_remove = ["parent"];
3552            params.remove_params(&to_remove);
3553        }
3554
3555        let url = params.parse_with_url(&url);
3556
3557        loop {
3558            let token = match self
3559                .hub
3560                .auth
3561                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3562                .await
3563            {
3564                Ok(token) => token,
3565                Err(e) => match dlg.token(e) {
3566                    Ok(token) => token,
3567                    Err(e) => {
3568                        dlg.finished(false);
3569                        return Err(common::Error::MissingToken(e));
3570                    }
3571                },
3572            };
3573            let mut req_result = {
3574                let client = &self.hub.client;
3575                dlg.pre_request();
3576                let mut req_builder = hyper::Request::builder()
3577                    .method(hyper::Method::GET)
3578                    .uri(url.as_str())
3579                    .header(USER_AGENT, self.hub._user_agent.clone());
3580
3581                if let Some(token) = token.as_ref() {
3582                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3583                }
3584
3585                let request = req_builder
3586                    .header(CONTENT_LENGTH, 0_u64)
3587                    .body(common::to_body::<String>(None));
3588
3589                client.request(request.unwrap()).await
3590            };
3591
3592            match req_result {
3593                Err(err) => {
3594                    if let common::Retry::After(d) = dlg.http_error(&err) {
3595                        sleep(d).await;
3596                        continue;
3597                    }
3598                    dlg.finished(false);
3599                    return Err(common::Error::HttpError(err));
3600                }
3601                Ok(res) => {
3602                    let (mut parts, body) = res.into_parts();
3603                    let mut body = common::Body::new(body);
3604                    if !parts.status.is_success() {
3605                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3606                        let error = serde_json::from_str(&common::to_string(&bytes));
3607                        let response = common::to_response(parts, bytes.into());
3608
3609                        if let common::Retry::After(d) =
3610                            dlg.http_failure(&response, error.as_ref().ok())
3611                        {
3612                            sleep(d).await;
3613                            continue;
3614                        }
3615
3616                        dlg.finished(false);
3617
3618                        return Err(match error {
3619                            Ok(value) => common::Error::BadRequest(value),
3620                            _ => common::Error::Failure(response),
3621                        });
3622                    }
3623                    let response = {
3624                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3625                        let encoded = common::to_string(&bytes);
3626                        match serde_json::from_str(&encoded) {
3627                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3628                            Err(error) => {
3629                                dlg.response_json_decode_error(&encoded, &error);
3630                                return Err(common::Error::JsonDecodeError(
3631                                    encoded.to_string(),
3632                                    error,
3633                                ));
3634                            }
3635                        }
3636                    };
3637
3638                    dlg.finished(true);
3639                    return Ok(response);
3640                }
3641            }
3642        }
3643    }
3644
3645    /// Required. Resource name for the access policy to list Service Perimeters from. Format: `accessPolicies/{policy_id}`
3646    ///
3647    /// Sets the *parent* path property to the given value.
3648    ///
3649    /// Even though the property as already been set when instantiating this call,
3650    /// we provide this method for API completeness.
3651    pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterListCall<'a, C> {
3652        self._parent = new_value.to_string();
3653        self
3654    }
3655    /// Next page token for the next batch of Service Perimeter instances. Defaults to the first page of results.
3656    ///
3657    /// Sets the *page token* query property to the given value.
3658    pub fn page_token(mut self, new_value: &str) -> AccessPolicyServicePerimeterListCall<'a, C> {
3659        self._page_token = Some(new_value.to_string());
3660        self
3661    }
3662    /// Number of Service Perimeters to include in the list. Default 100.
3663    ///
3664    /// Sets the *page size* query property to the given value.
3665    pub fn page_size(mut self, new_value: i32) -> AccessPolicyServicePerimeterListCall<'a, C> {
3666        self._page_size = Some(new_value);
3667        self
3668    }
3669    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3670    /// while executing the actual API request.
3671    ///
3672    /// ````text
3673    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3674    /// ````
3675    ///
3676    /// Sets the *delegate* property to the given value.
3677    pub fn delegate(
3678        mut self,
3679        new_value: &'a mut dyn common::Delegate,
3680    ) -> AccessPolicyServicePerimeterListCall<'a, C> {
3681        self._delegate = Some(new_value);
3682        self
3683    }
3684
3685    /// Set any additional parameter of the query string used in the request.
3686    /// It should be used to set parameters which are not yet available through their own
3687    /// setters.
3688    ///
3689    /// Please note that this method must not be used to set any of the known parameters
3690    /// which have their own setter method. If done anyway, the request will fail.
3691    ///
3692    /// # Additional Parameters
3693    ///
3694    /// * *$.xgafv* (query-string) - V1 error format.
3695    /// * *access_token* (query-string) - OAuth access token.
3696    /// * *alt* (query-string) - Data format for response.
3697    /// * *callback* (query-string) - JSONP
3698    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3699    /// * *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.
3700    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3701    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3702    /// * *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.
3703    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3704    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3705    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterListCall<'a, C>
3706    where
3707        T: AsRef<str>,
3708    {
3709        self._additional_params
3710            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3711        self
3712    }
3713
3714    /// Identifies the authorization scope for the method you are building.
3715    ///
3716    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3717    /// [`Scope::CloudPlatform`].
3718    ///
3719    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3720    /// tokens for more than one scope.
3721    ///
3722    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3723    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3724    /// sufficient, a read-write scope will do as well.
3725    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterListCall<'a, C>
3726    where
3727        St: AsRef<str>,
3728    {
3729        self._scopes.insert(String::from(scope.as_ref()));
3730        self
3731    }
3732    /// Identifies the authorization scope(s) for the method you are building.
3733    ///
3734    /// See [`Self::add_scope()`] for details.
3735    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterListCall<'a, C>
3736    where
3737        I: IntoIterator<Item = St>,
3738        St: AsRef<str>,
3739    {
3740        self._scopes
3741            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3742        self
3743    }
3744
3745    /// Removes all scopes, and no default scope will be used either.
3746    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3747    /// for details).
3748    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterListCall<'a, C> {
3749        self._scopes.clear();
3750        self
3751    }
3752}
3753
3754/// Update a Service Perimeter. The longrunning operation from this RPC will have a successful status once the changes to the Service Perimeter have propagated to long-lasting storage. Service Perimeter containing errors will result in an error response for the first error encountered.
3755///
3756/// A builder for the *servicePerimeters.patch* method supported by a *accessPolicy* resource.
3757/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3758///
3759/// # Example
3760///
3761/// Instantiate a resource method builder
3762///
3763/// ```test_harness,no_run
3764/// # extern crate hyper;
3765/// # extern crate hyper_rustls;
3766/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
3767/// use accesscontextmanager1_beta::api::ServicePerimeter;
3768/// # async fn dox() {
3769/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3770///
3771/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3772/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3773/// #     secret,
3774/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3775/// # ).build().await.unwrap();
3776///
3777/// # let client = hyper_util::client::legacy::Client::builder(
3778/// #     hyper_util::rt::TokioExecutor::new()
3779/// # )
3780/// # .build(
3781/// #     hyper_rustls::HttpsConnectorBuilder::new()
3782/// #         .with_native_roots()
3783/// #         .unwrap()
3784/// #         .https_or_http()
3785/// #         .enable_http1()
3786/// #         .build()
3787/// # );
3788/// # let mut hub = AccessContextManager::new(client, auth);
3789/// // As the method needs a request, you would usually fill it with the desired information
3790/// // into the respective structure. Some of the parts shown here might not be applicable !
3791/// // Values shown here are possibly random and not representative !
3792/// let mut req = ServicePerimeter::default();
3793///
3794/// // You can configure optional parameters by calling the respective setters at will, and
3795/// // execute the final call using `doit()`.
3796/// // Values shown here are possibly random and not representative !
3797/// let result = hub.access_policies().service_perimeters_patch(req, "name")
3798///              .update_mask(FieldMask::new::<&str>(&[]))
3799///              .doit().await;
3800/// # }
3801/// ```
3802pub struct AccessPolicyServicePerimeterPatchCall<'a, C>
3803where
3804    C: 'a,
3805{
3806    hub: &'a AccessContextManager<C>,
3807    _request: ServicePerimeter,
3808    _name: String,
3809    _update_mask: Option<common::FieldMask>,
3810    _delegate: Option<&'a mut dyn common::Delegate>,
3811    _additional_params: HashMap<String, String>,
3812    _scopes: BTreeSet<String>,
3813}
3814
3815impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterPatchCall<'a, C> {}
3816
3817impl<'a, C> AccessPolicyServicePerimeterPatchCall<'a, C>
3818where
3819    C: common::Connector,
3820{
3821    /// Perform the operation you have build so far.
3822    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3823        use std::borrow::Cow;
3824        use std::io::{Read, Seek};
3825
3826        use common::{url::Params, ToParts};
3827        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3828
3829        let mut dd = common::DefaultDelegate;
3830        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3831        dlg.begin(common::MethodInfo {
3832            id: "accesscontextmanager.accessPolicies.servicePerimeters.patch",
3833            http_method: hyper::Method::PATCH,
3834        });
3835
3836        for &field in ["alt", "name", "updateMask"].iter() {
3837            if self._additional_params.contains_key(field) {
3838                dlg.finished(false);
3839                return Err(common::Error::FieldClash(field));
3840            }
3841        }
3842
3843        let mut params = Params::with_capacity(5 + self._additional_params.len());
3844        params.push("name", self._name);
3845        if let Some(value) = self._update_mask.as_ref() {
3846            params.push("updateMask", value.to_string());
3847        }
3848
3849        params.extend(self._additional_params.iter());
3850
3851        params.push("alt", "json");
3852        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
3853        if self._scopes.is_empty() {
3854            self._scopes
3855                .insert(Scope::CloudPlatform.as_ref().to_string());
3856        }
3857
3858        #[allow(clippy::single_element_loop)]
3859        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3860            url = params.uri_replacement(url, param_name, find_this, true);
3861        }
3862        {
3863            let to_remove = ["name"];
3864            params.remove_params(&to_remove);
3865        }
3866
3867        let url = params.parse_with_url(&url);
3868
3869        let mut json_mime_type = mime::APPLICATION_JSON;
3870        let mut request_value_reader = {
3871            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3872            common::remove_json_null_values(&mut value);
3873            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3874            serde_json::to_writer(&mut dst, &value).unwrap();
3875            dst
3876        };
3877        let request_size = request_value_reader
3878            .seek(std::io::SeekFrom::End(0))
3879            .unwrap();
3880        request_value_reader
3881            .seek(std::io::SeekFrom::Start(0))
3882            .unwrap();
3883
3884        loop {
3885            let token = match self
3886                .hub
3887                .auth
3888                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3889                .await
3890            {
3891                Ok(token) => token,
3892                Err(e) => match dlg.token(e) {
3893                    Ok(token) => token,
3894                    Err(e) => {
3895                        dlg.finished(false);
3896                        return Err(common::Error::MissingToken(e));
3897                    }
3898                },
3899            };
3900            request_value_reader
3901                .seek(std::io::SeekFrom::Start(0))
3902                .unwrap();
3903            let mut req_result = {
3904                let client = &self.hub.client;
3905                dlg.pre_request();
3906                let mut req_builder = hyper::Request::builder()
3907                    .method(hyper::Method::PATCH)
3908                    .uri(url.as_str())
3909                    .header(USER_AGENT, self.hub._user_agent.clone());
3910
3911                if let Some(token) = token.as_ref() {
3912                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3913                }
3914
3915                let request = req_builder
3916                    .header(CONTENT_TYPE, json_mime_type.to_string())
3917                    .header(CONTENT_LENGTH, request_size as u64)
3918                    .body(common::to_body(
3919                        request_value_reader.get_ref().clone().into(),
3920                    ));
3921
3922                client.request(request.unwrap()).await
3923            };
3924
3925            match req_result {
3926                Err(err) => {
3927                    if let common::Retry::After(d) = dlg.http_error(&err) {
3928                        sleep(d).await;
3929                        continue;
3930                    }
3931                    dlg.finished(false);
3932                    return Err(common::Error::HttpError(err));
3933                }
3934                Ok(res) => {
3935                    let (mut parts, body) = res.into_parts();
3936                    let mut body = common::Body::new(body);
3937                    if !parts.status.is_success() {
3938                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3939                        let error = serde_json::from_str(&common::to_string(&bytes));
3940                        let response = common::to_response(parts, bytes.into());
3941
3942                        if let common::Retry::After(d) =
3943                            dlg.http_failure(&response, error.as_ref().ok())
3944                        {
3945                            sleep(d).await;
3946                            continue;
3947                        }
3948
3949                        dlg.finished(false);
3950
3951                        return Err(match error {
3952                            Ok(value) => common::Error::BadRequest(value),
3953                            _ => common::Error::Failure(response),
3954                        });
3955                    }
3956                    let response = {
3957                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3958                        let encoded = common::to_string(&bytes);
3959                        match serde_json::from_str(&encoded) {
3960                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3961                            Err(error) => {
3962                                dlg.response_json_decode_error(&encoded, &error);
3963                                return Err(common::Error::JsonDecodeError(
3964                                    encoded.to_string(),
3965                                    error,
3966                                ));
3967                            }
3968                        }
3969                    };
3970
3971                    dlg.finished(true);
3972                    return Ok(response);
3973                }
3974            }
3975        }
3976    }
3977
3978    ///
3979    /// Sets the *request* property to the given value.
3980    ///
3981    /// Even though the property as already been set when instantiating this call,
3982    /// we provide this method for API completeness.
3983    pub fn request(
3984        mut self,
3985        new_value: ServicePerimeter,
3986    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
3987        self._request = new_value;
3988        self
3989    }
3990    /// 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`.
3991    ///
3992    /// Sets the *name* path property to the given value.
3993    ///
3994    /// Even though the property as already been set when instantiating this call,
3995    /// we provide this method for API completeness.
3996    pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
3997        self._name = new_value.to_string();
3998        self
3999    }
4000    /// Required. Mask to control which fields get updated. Must be non-empty.
4001    ///
4002    /// Sets the *update mask* query property to the given value.
4003    pub fn update_mask(
4004        mut self,
4005        new_value: common::FieldMask,
4006    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
4007        self._update_mask = Some(new_value);
4008        self
4009    }
4010    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4011    /// while executing the actual API request.
4012    ///
4013    /// ````text
4014    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4015    /// ````
4016    ///
4017    /// Sets the *delegate* property to the given value.
4018    pub fn delegate(
4019        mut self,
4020        new_value: &'a mut dyn common::Delegate,
4021    ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
4022        self._delegate = Some(new_value);
4023        self
4024    }
4025
4026    /// Set any additional parameter of the query string used in the request.
4027    /// It should be used to set parameters which are not yet available through their own
4028    /// setters.
4029    ///
4030    /// Please note that this method must not be used to set any of the known parameters
4031    /// which have their own setter method. If done anyway, the request will fail.
4032    ///
4033    /// # Additional Parameters
4034    ///
4035    /// * *$.xgafv* (query-string) - V1 error format.
4036    /// * *access_token* (query-string) - OAuth access token.
4037    /// * *alt* (query-string) - Data format for response.
4038    /// * *callback* (query-string) - JSONP
4039    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4040    /// * *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.
4041    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4042    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4043    /// * *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.
4044    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4045    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4046    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterPatchCall<'a, C>
4047    where
4048        T: AsRef<str>,
4049    {
4050        self._additional_params
4051            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4052        self
4053    }
4054
4055    /// Identifies the authorization scope for the method you are building.
4056    ///
4057    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4058    /// [`Scope::CloudPlatform`].
4059    ///
4060    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4061    /// tokens for more than one scope.
4062    ///
4063    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4064    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4065    /// sufficient, a read-write scope will do as well.
4066    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterPatchCall<'a, C>
4067    where
4068        St: AsRef<str>,
4069    {
4070        self._scopes.insert(String::from(scope.as_ref()));
4071        self
4072    }
4073    /// Identifies the authorization scope(s) for the method you are building.
4074    ///
4075    /// See [`Self::add_scope()`] for details.
4076    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterPatchCall<'a, C>
4077    where
4078        I: IntoIterator<Item = St>,
4079        St: AsRef<str>,
4080    {
4081        self._scopes
4082            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4083        self
4084    }
4085
4086    /// Removes all scopes, and no default scope will be used either.
4087    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4088    /// for details).
4089    pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
4090        self._scopes.clear();
4091        self
4092    }
4093}
4094
4095/// Create an `AccessPolicy`. Fails if this organization already has a `AccessPolicy`. The longrunning Operation will have a successful status once the `AccessPolicy` has propagated to long-lasting storage. Syntactic and basic semantic errors will be returned in `metadata` as a BadRequest proto.
4096///
4097/// A builder for the *create* method supported by a *accessPolicy* resource.
4098/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4099///
4100/// # Example
4101///
4102/// Instantiate a resource method builder
4103///
4104/// ```test_harness,no_run
4105/// # extern crate hyper;
4106/// # extern crate hyper_rustls;
4107/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
4108/// use accesscontextmanager1_beta::api::AccessPolicy;
4109/// # async fn dox() {
4110/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4111///
4112/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4113/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4114/// #     secret,
4115/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4116/// # ).build().await.unwrap();
4117///
4118/// # let client = hyper_util::client::legacy::Client::builder(
4119/// #     hyper_util::rt::TokioExecutor::new()
4120/// # )
4121/// # .build(
4122/// #     hyper_rustls::HttpsConnectorBuilder::new()
4123/// #         .with_native_roots()
4124/// #         .unwrap()
4125/// #         .https_or_http()
4126/// #         .enable_http1()
4127/// #         .build()
4128/// # );
4129/// # let mut hub = AccessContextManager::new(client, auth);
4130/// // As the method needs a request, you would usually fill it with the desired information
4131/// // into the respective structure. Some of the parts shown here might not be applicable !
4132/// // Values shown here are possibly random and not representative !
4133/// let mut req = AccessPolicy::default();
4134///
4135/// // You can configure optional parameters by calling the respective setters at will, and
4136/// // execute the final call using `doit()`.
4137/// // Values shown here are possibly random and not representative !
4138/// let result = hub.access_policies().create(req)
4139///              .doit().await;
4140/// # }
4141/// ```
4142pub struct AccessPolicyCreateCall<'a, C>
4143where
4144    C: 'a,
4145{
4146    hub: &'a AccessContextManager<C>,
4147    _request: AccessPolicy,
4148    _delegate: Option<&'a mut dyn common::Delegate>,
4149    _additional_params: HashMap<String, String>,
4150    _scopes: BTreeSet<String>,
4151}
4152
4153impl<'a, C> common::CallBuilder for AccessPolicyCreateCall<'a, C> {}
4154
4155impl<'a, C> AccessPolicyCreateCall<'a, C>
4156where
4157    C: common::Connector,
4158{
4159    /// Perform the operation you have build so far.
4160    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4161        use std::borrow::Cow;
4162        use std::io::{Read, Seek};
4163
4164        use common::{url::Params, ToParts};
4165        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4166
4167        let mut dd = common::DefaultDelegate;
4168        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4169        dlg.begin(common::MethodInfo {
4170            id: "accesscontextmanager.accessPolicies.create",
4171            http_method: hyper::Method::POST,
4172        });
4173
4174        for &field in ["alt"].iter() {
4175            if self._additional_params.contains_key(field) {
4176                dlg.finished(false);
4177                return Err(common::Error::FieldClash(field));
4178            }
4179        }
4180
4181        let mut params = Params::with_capacity(3 + self._additional_params.len());
4182
4183        params.extend(self._additional_params.iter());
4184
4185        params.push("alt", "json");
4186        let mut url = self.hub._base_url.clone() + "v1beta/accessPolicies";
4187        if self._scopes.is_empty() {
4188            self._scopes
4189                .insert(Scope::CloudPlatform.as_ref().to_string());
4190        }
4191
4192        let url = params.parse_with_url(&url);
4193
4194        let mut json_mime_type = mime::APPLICATION_JSON;
4195        let mut request_value_reader = {
4196            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4197            common::remove_json_null_values(&mut value);
4198            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4199            serde_json::to_writer(&mut dst, &value).unwrap();
4200            dst
4201        };
4202        let request_size = request_value_reader
4203            .seek(std::io::SeekFrom::End(0))
4204            .unwrap();
4205        request_value_reader
4206            .seek(std::io::SeekFrom::Start(0))
4207            .unwrap();
4208
4209        loop {
4210            let token = match self
4211                .hub
4212                .auth
4213                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4214                .await
4215            {
4216                Ok(token) => token,
4217                Err(e) => match dlg.token(e) {
4218                    Ok(token) => token,
4219                    Err(e) => {
4220                        dlg.finished(false);
4221                        return Err(common::Error::MissingToken(e));
4222                    }
4223                },
4224            };
4225            request_value_reader
4226                .seek(std::io::SeekFrom::Start(0))
4227                .unwrap();
4228            let mut req_result = {
4229                let client = &self.hub.client;
4230                dlg.pre_request();
4231                let mut req_builder = hyper::Request::builder()
4232                    .method(hyper::Method::POST)
4233                    .uri(url.as_str())
4234                    .header(USER_AGENT, self.hub._user_agent.clone());
4235
4236                if let Some(token) = token.as_ref() {
4237                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4238                }
4239
4240                let request = req_builder
4241                    .header(CONTENT_TYPE, json_mime_type.to_string())
4242                    .header(CONTENT_LENGTH, request_size as u64)
4243                    .body(common::to_body(
4244                        request_value_reader.get_ref().clone().into(),
4245                    ));
4246
4247                client.request(request.unwrap()).await
4248            };
4249
4250            match req_result {
4251                Err(err) => {
4252                    if let common::Retry::After(d) = dlg.http_error(&err) {
4253                        sleep(d).await;
4254                        continue;
4255                    }
4256                    dlg.finished(false);
4257                    return Err(common::Error::HttpError(err));
4258                }
4259                Ok(res) => {
4260                    let (mut parts, body) = res.into_parts();
4261                    let mut body = common::Body::new(body);
4262                    if !parts.status.is_success() {
4263                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4264                        let error = serde_json::from_str(&common::to_string(&bytes));
4265                        let response = common::to_response(parts, bytes.into());
4266
4267                        if let common::Retry::After(d) =
4268                            dlg.http_failure(&response, error.as_ref().ok())
4269                        {
4270                            sleep(d).await;
4271                            continue;
4272                        }
4273
4274                        dlg.finished(false);
4275
4276                        return Err(match error {
4277                            Ok(value) => common::Error::BadRequest(value),
4278                            _ => common::Error::Failure(response),
4279                        });
4280                    }
4281                    let response = {
4282                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4283                        let encoded = common::to_string(&bytes);
4284                        match serde_json::from_str(&encoded) {
4285                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4286                            Err(error) => {
4287                                dlg.response_json_decode_error(&encoded, &error);
4288                                return Err(common::Error::JsonDecodeError(
4289                                    encoded.to_string(),
4290                                    error,
4291                                ));
4292                            }
4293                        }
4294                    };
4295
4296                    dlg.finished(true);
4297                    return Ok(response);
4298                }
4299            }
4300        }
4301    }
4302
4303    ///
4304    /// Sets the *request* property to the given value.
4305    ///
4306    /// Even though the property as already been set when instantiating this call,
4307    /// we provide this method for API completeness.
4308    pub fn request(mut self, new_value: AccessPolicy) -> AccessPolicyCreateCall<'a, C> {
4309        self._request = new_value;
4310        self
4311    }
4312    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4313    /// while executing the actual API request.
4314    ///
4315    /// ````text
4316    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4317    /// ````
4318    ///
4319    /// Sets the *delegate* property to the given value.
4320    pub fn delegate(
4321        mut self,
4322        new_value: &'a mut dyn common::Delegate,
4323    ) -> AccessPolicyCreateCall<'a, C> {
4324        self._delegate = Some(new_value);
4325        self
4326    }
4327
4328    /// Set any additional parameter of the query string used in the request.
4329    /// It should be used to set parameters which are not yet available through their own
4330    /// setters.
4331    ///
4332    /// Please note that this method must not be used to set any of the known parameters
4333    /// which have their own setter method. If done anyway, the request will fail.
4334    ///
4335    /// # Additional Parameters
4336    ///
4337    /// * *$.xgafv* (query-string) - V1 error format.
4338    /// * *access_token* (query-string) - OAuth access token.
4339    /// * *alt* (query-string) - Data format for response.
4340    /// * *callback* (query-string) - JSONP
4341    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4342    /// * *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.
4343    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4344    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4345    /// * *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.
4346    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4347    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4348    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyCreateCall<'a, C>
4349    where
4350        T: AsRef<str>,
4351    {
4352        self._additional_params
4353            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4354        self
4355    }
4356
4357    /// Identifies the authorization scope for the method you are building.
4358    ///
4359    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4360    /// [`Scope::CloudPlatform`].
4361    ///
4362    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4363    /// tokens for more than one scope.
4364    ///
4365    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4366    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4367    /// sufficient, a read-write scope will do as well.
4368    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyCreateCall<'a, C>
4369    where
4370        St: AsRef<str>,
4371    {
4372        self._scopes.insert(String::from(scope.as_ref()));
4373        self
4374    }
4375    /// Identifies the authorization scope(s) for the method you are building.
4376    ///
4377    /// See [`Self::add_scope()`] for details.
4378    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyCreateCall<'a, C>
4379    where
4380        I: IntoIterator<Item = St>,
4381        St: AsRef<str>,
4382    {
4383        self._scopes
4384            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4385        self
4386    }
4387
4388    /// Removes all scopes, and no default scope will be used either.
4389    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4390    /// for details).
4391    pub fn clear_scopes(mut self) -> AccessPolicyCreateCall<'a, C> {
4392        self._scopes.clear();
4393        self
4394    }
4395}
4396
4397/// Delete an AccessPolicy by resource name. The longrunning Operation will have a successful status once the AccessPolicy has been removed from long-lasting storage.
4398///
4399/// A builder for the *delete* method supported by a *accessPolicy* resource.
4400/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4401///
4402/// # Example
4403///
4404/// Instantiate a resource method builder
4405///
4406/// ```test_harness,no_run
4407/// # extern crate hyper;
4408/// # extern crate hyper_rustls;
4409/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
4410/// # async fn dox() {
4411/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4412///
4413/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4414/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4415/// #     secret,
4416/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4417/// # ).build().await.unwrap();
4418///
4419/// # let client = hyper_util::client::legacy::Client::builder(
4420/// #     hyper_util::rt::TokioExecutor::new()
4421/// # )
4422/// # .build(
4423/// #     hyper_rustls::HttpsConnectorBuilder::new()
4424/// #         .with_native_roots()
4425/// #         .unwrap()
4426/// #         .https_or_http()
4427/// #         .enable_http1()
4428/// #         .build()
4429/// # );
4430/// # let mut hub = AccessContextManager::new(client, auth);
4431/// // You can configure optional parameters by calling the respective setters at will, and
4432/// // execute the final call using `doit()`.
4433/// // Values shown here are possibly random and not representative !
4434/// let result = hub.access_policies().delete("name")
4435///              .doit().await;
4436/// # }
4437/// ```
4438pub struct AccessPolicyDeleteCall<'a, C>
4439where
4440    C: 'a,
4441{
4442    hub: &'a AccessContextManager<C>,
4443    _name: String,
4444    _delegate: Option<&'a mut dyn common::Delegate>,
4445    _additional_params: HashMap<String, String>,
4446    _scopes: BTreeSet<String>,
4447}
4448
4449impl<'a, C> common::CallBuilder for AccessPolicyDeleteCall<'a, C> {}
4450
4451impl<'a, C> AccessPolicyDeleteCall<'a, C>
4452where
4453    C: common::Connector,
4454{
4455    /// Perform the operation you have build so far.
4456    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4457        use std::borrow::Cow;
4458        use std::io::{Read, Seek};
4459
4460        use common::{url::Params, ToParts};
4461        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4462
4463        let mut dd = common::DefaultDelegate;
4464        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4465        dlg.begin(common::MethodInfo {
4466            id: "accesscontextmanager.accessPolicies.delete",
4467            http_method: hyper::Method::DELETE,
4468        });
4469
4470        for &field in ["alt", "name"].iter() {
4471            if self._additional_params.contains_key(field) {
4472                dlg.finished(false);
4473                return Err(common::Error::FieldClash(field));
4474            }
4475        }
4476
4477        let mut params = Params::with_capacity(3 + self._additional_params.len());
4478        params.push("name", self._name);
4479
4480        params.extend(self._additional_params.iter());
4481
4482        params.push("alt", "json");
4483        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
4484        if self._scopes.is_empty() {
4485            self._scopes
4486                .insert(Scope::CloudPlatform.as_ref().to_string());
4487        }
4488
4489        #[allow(clippy::single_element_loop)]
4490        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4491            url = params.uri_replacement(url, param_name, find_this, true);
4492        }
4493        {
4494            let to_remove = ["name"];
4495            params.remove_params(&to_remove);
4496        }
4497
4498        let url = params.parse_with_url(&url);
4499
4500        loop {
4501            let token = match self
4502                .hub
4503                .auth
4504                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4505                .await
4506            {
4507                Ok(token) => token,
4508                Err(e) => match dlg.token(e) {
4509                    Ok(token) => token,
4510                    Err(e) => {
4511                        dlg.finished(false);
4512                        return Err(common::Error::MissingToken(e));
4513                    }
4514                },
4515            };
4516            let mut req_result = {
4517                let client = &self.hub.client;
4518                dlg.pre_request();
4519                let mut req_builder = hyper::Request::builder()
4520                    .method(hyper::Method::DELETE)
4521                    .uri(url.as_str())
4522                    .header(USER_AGENT, self.hub._user_agent.clone());
4523
4524                if let Some(token) = token.as_ref() {
4525                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4526                }
4527
4528                let request = req_builder
4529                    .header(CONTENT_LENGTH, 0_u64)
4530                    .body(common::to_body::<String>(None));
4531
4532                client.request(request.unwrap()).await
4533            };
4534
4535            match req_result {
4536                Err(err) => {
4537                    if let common::Retry::After(d) = dlg.http_error(&err) {
4538                        sleep(d).await;
4539                        continue;
4540                    }
4541                    dlg.finished(false);
4542                    return Err(common::Error::HttpError(err));
4543                }
4544                Ok(res) => {
4545                    let (mut parts, body) = res.into_parts();
4546                    let mut body = common::Body::new(body);
4547                    if !parts.status.is_success() {
4548                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4549                        let error = serde_json::from_str(&common::to_string(&bytes));
4550                        let response = common::to_response(parts, bytes.into());
4551
4552                        if let common::Retry::After(d) =
4553                            dlg.http_failure(&response, error.as_ref().ok())
4554                        {
4555                            sleep(d).await;
4556                            continue;
4557                        }
4558
4559                        dlg.finished(false);
4560
4561                        return Err(match error {
4562                            Ok(value) => common::Error::BadRequest(value),
4563                            _ => common::Error::Failure(response),
4564                        });
4565                    }
4566                    let response = {
4567                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4568                        let encoded = common::to_string(&bytes);
4569                        match serde_json::from_str(&encoded) {
4570                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4571                            Err(error) => {
4572                                dlg.response_json_decode_error(&encoded, &error);
4573                                return Err(common::Error::JsonDecodeError(
4574                                    encoded.to_string(),
4575                                    error,
4576                                ));
4577                            }
4578                        }
4579                    };
4580
4581                    dlg.finished(true);
4582                    return Ok(response);
4583                }
4584            }
4585        }
4586    }
4587
4588    /// Required. Resource name for the access policy to delete. Format `accessPolicies/{policy_id}`
4589    ///
4590    /// Sets the *name* path property to the given value.
4591    ///
4592    /// Even though the property as already been set when instantiating this call,
4593    /// we provide this method for API completeness.
4594    pub fn name(mut self, new_value: &str) -> AccessPolicyDeleteCall<'a, C> {
4595        self._name = new_value.to_string();
4596        self
4597    }
4598    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4599    /// while executing the actual API request.
4600    ///
4601    /// ````text
4602    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4603    /// ````
4604    ///
4605    /// Sets the *delegate* property to the given value.
4606    pub fn delegate(
4607        mut self,
4608        new_value: &'a mut dyn common::Delegate,
4609    ) -> AccessPolicyDeleteCall<'a, C> {
4610        self._delegate = Some(new_value);
4611        self
4612    }
4613
4614    /// Set any additional parameter of the query string used in the request.
4615    /// It should be used to set parameters which are not yet available through their own
4616    /// setters.
4617    ///
4618    /// Please note that this method must not be used to set any of the known parameters
4619    /// which have their own setter method. If done anyway, the request will fail.
4620    ///
4621    /// # Additional Parameters
4622    ///
4623    /// * *$.xgafv* (query-string) - V1 error format.
4624    /// * *access_token* (query-string) - OAuth access token.
4625    /// * *alt* (query-string) - Data format for response.
4626    /// * *callback* (query-string) - JSONP
4627    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4628    /// * *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.
4629    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4630    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4631    /// * *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.
4632    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4633    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4634    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyDeleteCall<'a, C>
4635    where
4636        T: AsRef<str>,
4637    {
4638        self._additional_params
4639            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4640        self
4641    }
4642
4643    /// Identifies the authorization scope for the method you are building.
4644    ///
4645    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4646    /// [`Scope::CloudPlatform`].
4647    ///
4648    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4649    /// tokens for more than one scope.
4650    ///
4651    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4652    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4653    /// sufficient, a read-write scope will do as well.
4654    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyDeleteCall<'a, C>
4655    where
4656        St: AsRef<str>,
4657    {
4658        self._scopes.insert(String::from(scope.as_ref()));
4659        self
4660    }
4661    /// Identifies the authorization scope(s) for the method you are building.
4662    ///
4663    /// See [`Self::add_scope()`] for details.
4664    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyDeleteCall<'a, C>
4665    where
4666        I: IntoIterator<Item = St>,
4667        St: AsRef<str>,
4668    {
4669        self._scopes
4670            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4671        self
4672    }
4673
4674    /// Removes all scopes, and no default scope will be used either.
4675    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4676    /// for details).
4677    pub fn clear_scopes(mut self) -> AccessPolicyDeleteCall<'a, C> {
4678        self._scopes.clear();
4679        self
4680    }
4681}
4682
4683/// Get an AccessPolicy by name.
4684///
4685/// A builder for the *get* method supported by a *accessPolicy* resource.
4686/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4687///
4688/// # Example
4689///
4690/// Instantiate a resource method builder
4691///
4692/// ```test_harness,no_run
4693/// # extern crate hyper;
4694/// # extern crate hyper_rustls;
4695/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
4696/// # async fn dox() {
4697/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4698///
4699/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4701/// #     secret,
4702/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4703/// # ).build().await.unwrap();
4704///
4705/// # let client = hyper_util::client::legacy::Client::builder(
4706/// #     hyper_util::rt::TokioExecutor::new()
4707/// # )
4708/// # .build(
4709/// #     hyper_rustls::HttpsConnectorBuilder::new()
4710/// #         .with_native_roots()
4711/// #         .unwrap()
4712/// #         .https_or_http()
4713/// #         .enable_http1()
4714/// #         .build()
4715/// # );
4716/// # let mut hub = AccessContextManager::new(client, auth);
4717/// // You can configure optional parameters by calling the respective setters at will, and
4718/// // execute the final call using `doit()`.
4719/// // Values shown here are possibly random and not representative !
4720/// let result = hub.access_policies().get("name")
4721///              .doit().await;
4722/// # }
4723/// ```
4724pub struct AccessPolicyGetCall<'a, C>
4725where
4726    C: 'a,
4727{
4728    hub: &'a AccessContextManager<C>,
4729    _name: String,
4730    _delegate: Option<&'a mut dyn common::Delegate>,
4731    _additional_params: HashMap<String, String>,
4732    _scopes: BTreeSet<String>,
4733}
4734
4735impl<'a, C> common::CallBuilder for AccessPolicyGetCall<'a, C> {}
4736
4737impl<'a, C> AccessPolicyGetCall<'a, C>
4738where
4739    C: common::Connector,
4740{
4741    /// Perform the operation you have build so far.
4742    pub async fn doit(mut self) -> common::Result<(common::Response, AccessPolicy)> {
4743        use std::borrow::Cow;
4744        use std::io::{Read, Seek};
4745
4746        use common::{url::Params, ToParts};
4747        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4748
4749        let mut dd = common::DefaultDelegate;
4750        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4751        dlg.begin(common::MethodInfo {
4752            id: "accesscontextmanager.accessPolicies.get",
4753            http_method: hyper::Method::GET,
4754        });
4755
4756        for &field in ["alt", "name"].iter() {
4757            if self._additional_params.contains_key(field) {
4758                dlg.finished(false);
4759                return Err(common::Error::FieldClash(field));
4760            }
4761        }
4762
4763        let mut params = Params::with_capacity(3 + self._additional_params.len());
4764        params.push("name", self._name);
4765
4766        params.extend(self._additional_params.iter());
4767
4768        params.push("alt", "json");
4769        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
4770        if self._scopes.is_empty() {
4771            self._scopes
4772                .insert(Scope::CloudPlatform.as_ref().to_string());
4773        }
4774
4775        #[allow(clippy::single_element_loop)]
4776        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4777            url = params.uri_replacement(url, param_name, find_this, true);
4778        }
4779        {
4780            let to_remove = ["name"];
4781            params.remove_params(&to_remove);
4782        }
4783
4784        let url = params.parse_with_url(&url);
4785
4786        loop {
4787            let token = match self
4788                .hub
4789                .auth
4790                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4791                .await
4792            {
4793                Ok(token) => token,
4794                Err(e) => match dlg.token(e) {
4795                    Ok(token) => token,
4796                    Err(e) => {
4797                        dlg.finished(false);
4798                        return Err(common::Error::MissingToken(e));
4799                    }
4800                },
4801            };
4802            let mut req_result = {
4803                let client = &self.hub.client;
4804                dlg.pre_request();
4805                let mut req_builder = hyper::Request::builder()
4806                    .method(hyper::Method::GET)
4807                    .uri(url.as_str())
4808                    .header(USER_AGENT, self.hub._user_agent.clone());
4809
4810                if let Some(token) = token.as_ref() {
4811                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4812                }
4813
4814                let request = req_builder
4815                    .header(CONTENT_LENGTH, 0_u64)
4816                    .body(common::to_body::<String>(None));
4817
4818                client.request(request.unwrap()).await
4819            };
4820
4821            match req_result {
4822                Err(err) => {
4823                    if let common::Retry::After(d) = dlg.http_error(&err) {
4824                        sleep(d).await;
4825                        continue;
4826                    }
4827                    dlg.finished(false);
4828                    return Err(common::Error::HttpError(err));
4829                }
4830                Ok(res) => {
4831                    let (mut parts, body) = res.into_parts();
4832                    let mut body = common::Body::new(body);
4833                    if !parts.status.is_success() {
4834                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4835                        let error = serde_json::from_str(&common::to_string(&bytes));
4836                        let response = common::to_response(parts, bytes.into());
4837
4838                        if let common::Retry::After(d) =
4839                            dlg.http_failure(&response, error.as_ref().ok())
4840                        {
4841                            sleep(d).await;
4842                            continue;
4843                        }
4844
4845                        dlg.finished(false);
4846
4847                        return Err(match error {
4848                            Ok(value) => common::Error::BadRequest(value),
4849                            _ => common::Error::Failure(response),
4850                        });
4851                    }
4852                    let response = {
4853                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4854                        let encoded = common::to_string(&bytes);
4855                        match serde_json::from_str(&encoded) {
4856                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4857                            Err(error) => {
4858                                dlg.response_json_decode_error(&encoded, &error);
4859                                return Err(common::Error::JsonDecodeError(
4860                                    encoded.to_string(),
4861                                    error,
4862                                ));
4863                            }
4864                        }
4865                    };
4866
4867                    dlg.finished(true);
4868                    return Ok(response);
4869                }
4870            }
4871        }
4872    }
4873
4874    /// Required. Resource name for the access policy to get. Format `accessPolicies/{policy_id}`
4875    ///
4876    /// Sets the *name* path property to the given value.
4877    ///
4878    /// Even though the property as already been set when instantiating this call,
4879    /// we provide this method for API completeness.
4880    pub fn name(mut self, new_value: &str) -> AccessPolicyGetCall<'a, C> {
4881        self._name = new_value.to_string();
4882        self
4883    }
4884    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4885    /// while executing the actual API request.
4886    ///
4887    /// ````text
4888    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4889    /// ````
4890    ///
4891    /// Sets the *delegate* property to the given value.
4892    pub fn delegate(
4893        mut self,
4894        new_value: &'a mut dyn common::Delegate,
4895    ) -> AccessPolicyGetCall<'a, C> {
4896        self._delegate = Some(new_value);
4897        self
4898    }
4899
4900    /// Set any additional parameter of the query string used in the request.
4901    /// It should be used to set parameters which are not yet available through their own
4902    /// setters.
4903    ///
4904    /// Please note that this method must not be used to set any of the known parameters
4905    /// which have their own setter method. If done anyway, the request will fail.
4906    ///
4907    /// # Additional Parameters
4908    ///
4909    /// * *$.xgafv* (query-string) - V1 error format.
4910    /// * *access_token* (query-string) - OAuth access token.
4911    /// * *alt* (query-string) - Data format for response.
4912    /// * *callback* (query-string) - JSONP
4913    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4914    /// * *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.
4915    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4916    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4917    /// * *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.
4918    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4919    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4920    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyGetCall<'a, C>
4921    where
4922        T: AsRef<str>,
4923    {
4924        self._additional_params
4925            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4926        self
4927    }
4928
4929    /// Identifies the authorization scope for the method you are building.
4930    ///
4931    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4932    /// [`Scope::CloudPlatform`].
4933    ///
4934    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4935    /// tokens for more than one scope.
4936    ///
4937    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4938    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4939    /// sufficient, a read-write scope will do as well.
4940    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyGetCall<'a, C>
4941    where
4942        St: AsRef<str>,
4943    {
4944        self._scopes.insert(String::from(scope.as_ref()));
4945        self
4946    }
4947    /// Identifies the authorization scope(s) for the method you are building.
4948    ///
4949    /// See [`Self::add_scope()`] for details.
4950    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyGetCall<'a, C>
4951    where
4952        I: IntoIterator<Item = St>,
4953        St: AsRef<str>,
4954    {
4955        self._scopes
4956            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4957        self
4958    }
4959
4960    /// Removes all scopes, and no default scope will be used either.
4961    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4962    /// for details).
4963    pub fn clear_scopes(mut self) -> AccessPolicyGetCall<'a, C> {
4964        self._scopes.clear();
4965        self
4966    }
4967}
4968
4969/// List all AccessPolicies under a container.
4970///
4971/// A builder for the *list* method supported by a *accessPolicy* resource.
4972/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4973///
4974/// # Example
4975///
4976/// Instantiate a resource method builder
4977///
4978/// ```test_harness,no_run
4979/// # extern crate hyper;
4980/// # extern crate hyper_rustls;
4981/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
4982/// # async fn dox() {
4983/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4984///
4985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4987/// #     secret,
4988/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4989/// # ).build().await.unwrap();
4990///
4991/// # let client = hyper_util::client::legacy::Client::builder(
4992/// #     hyper_util::rt::TokioExecutor::new()
4993/// # )
4994/// # .build(
4995/// #     hyper_rustls::HttpsConnectorBuilder::new()
4996/// #         .with_native_roots()
4997/// #         .unwrap()
4998/// #         .https_or_http()
4999/// #         .enable_http1()
5000/// #         .build()
5001/// # );
5002/// # let mut hub = AccessContextManager::new(client, auth);
5003/// // You can configure optional parameters by calling the respective setters at will, and
5004/// // execute the final call using `doit()`.
5005/// // Values shown here are possibly random and not representative !
5006/// let result = hub.access_policies().list()
5007///              .parent("amet")
5008///              .page_token("duo")
5009///              .page_size(-50)
5010///              .doit().await;
5011/// # }
5012/// ```
5013pub struct AccessPolicyListCall<'a, C>
5014where
5015    C: 'a,
5016{
5017    hub: &'a AccessContextManager<C>,
5018    _parent: Option<String>,
5019    _page_token: Option<String>,
5020    _page_size: Option<i32>,
5021    _delegate: Option<&'a mut dyn common::Delegate>,
5022    _additional_params: HashMap<String, String>,
5023    _scopes: BTreeSet<String>,
5024}
5025
5026impl<'a, C> common::CallBuilder for AccessPolicyListCall<'a, C> {}
5027
5028impl<'a, C> AccessPolicyListCall<'a, C>
5029where
5030    C: common::Connector,
5031{
5032    /// Perform the operation you have build so far.
5033    pub async fn doit(mut self) -> common::Result<(common::Response, ListAccessPoliciesResponse)> {
5034        use std::borrow::Cow;
5035        use std::io::{Read, Seek};
5036
5037        use common::{url::Params, ToParts};
5038        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5039
5040        let mut dd = common::DefaultDelegate;
5041        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5042        dlg.begin(common::MethodInfo {
5043            id: "accesscontextmanager.accessPolicies.list",
5044            http_method: hyper::Method::GET,
5045        });
5046
5047        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5048            if self._additional_params.contains_key(field) {
5049                dlg.finished(false);
5050                return Err(common::Error::FieldClash(field));
5051            }
5052        }
5053
5054        let mut params = Params::with_capacity(5 + self._additional_params.len());
5055        if let Some(value) = self._parent.as_ref() {
5056            params.push("parent", value);
5057        }
5058        if let Some(value) = self._page_token.as_ref() {
5059            params.push("pageToken", value);
5060        }
5061        if let Some(value) = self._page_size.as_ref() {
5062            params.push("pageSize", value.to_string());
5063        }
5064
5065        params.extend(self._additional_params.iter());
5066
5067        params.push("alt", "json");
5068        let mut url = self.hub._base_url.clone() + "v1beta/accessPolicies";
5069        if self._scopes.is_empty() {
5070            self._scopes
5071                .insert(Scope::CloudPlatform.as_ref().to_string());
5072        }
5073
5074        let url = params.parse_with_url(&url);
5075
5076        loop {
5077            let token = match self
5078                .hub
5079                .auth
5080                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5081                .await
5082            {
5083                Ok(token) => token,
5084                Err(e) => match dlg.token(e) {
5085                    Ok(token) => token,
5086                    Err(e) => {
5087                        dlg.finished(false);
5088                        return Err(common::Error::MissingToken(e));
5089                    }
5090                },
5091            };
5092            let mut req_result = {
5093                let client = &self.hub.client;
5094                dlg.pre_request();
5095                let mut req_builder = hyper::Request::builder()
5096                    .method(hyper::Method::GET)
5097                    .uri(url.as_str())
5098                    .header(USER_AGENT, self.hub._user_agent.clone());
5099
5100                if let Some(token) = token.as_ref() {
5101                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5102                }
5103
5104                let request = req_builder
5105                    .header(CONTENT_LENGTH, 0_u64)
5106                    .body(common::to_body::<String>(None));
5107
5108                client.request(request.unwrap()).await
5109            };
5110
5111            match req_result {
5112                Err(err) => {
5113                    if let common::Retry::After(d) = dlg.http_error(&err) {
5114                        sleep(d).await;
5115                        continue;
5116                    }
5117                    dlg.finished(false);
5118                    return Err(common::Error::HttpError(err));
5119                }
5120                Ok(res) => {
5121                    let (mut parts, body) = res.into_parts();
5122                    let mut body = common::Body::new(body);
5123                    if !parts.status.is_success() {
5124                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5125                        let error = serde_json::from_str(&common::to_string(&bytes));
5126                        let response = common::to_response(parts, bytes.into());
5127
5128                        if let common::Retry::After(d) =
5129                            dlg.http_failure(&response, error.as_ref().ok())
5130                        {
5131                            sleep(d).await;
5132                            continue;
5133                        }
5134
5135                        dlg.finished(false);
5136
5137                        return Err(match error {
5138                            Ok(value) => common::Error::BadRequest(value),
5139                            _ => common::Error::Failure(response),
5140                        });
5141                    }
5142                    let response = {
5143                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5144                        let encoded = common::to_string(&bytes);
5145                        match serde_json::from_str(&encoded) {
5146                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5147                            Err(error) => {
5148                                dlg.response_json_decode_error(&encoded, &error);
5149                                return Err(common::Error::JsonDecodeError(
5150                                    encoded.to_string(),
5151                                    error,
5152                                ));
5153                            }
5154                        }
5155                    };
5156
5157                    dlg.finished(true);
5158                    return Ok(response);
5159                }
5160            }
5161        }
5162    }
5163
5164    /// Required. Resource name for the container to list AccessPolicy instances from. Format: `organizations/{org_id}`
5165    ///
5166    /// Sets the *parent* query property to the given value.
5167    pub fn parent(mut self, new_value: &str) -> AccessPolicyListCall<'a, C> {
5168        self._parent = Some(new_value.to_string());
5169        self
5170    }
5171    /// Next page token for the next batch of AccessPolicy instances. Defaults to the first page of results.
5172    ///
5173    /// Sets the *page token* query property to the given value.
5174    pub fn page_token(mut self, new_value: &str) -> AccessPolicyListCall<'a, C> {
5175        self._page_token = Some(new_value.to_string());
5176        self
5177    }
5178    /// Number of AccessPolicy instances to include in the list. Default 100.
5179    ///
5180    /// Sets the *page size* query property to the given value.
5181    pub fn page_size(mut self, new_value: i32) -> AccessPolicyListCall<'a, C> {
5182        self._page_size = Some(new_value);
5183        self
5184    }
5185    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5186    /// while executing the actual API request.
5187    ///
5188    /// ````text
5189    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5190    /// ````
5191    ///
5192    /// Sets the *delegate* property to the given value.
5193    pub fn delegate(
5194        mut self,
5195        new_value: &'a mut dyn common::Delegate,
5196    ) -> AccessPolicyListCall<'a, C> {
5197        self._delegate = Some(new_value);
5198        self
5199    }
5200
5201    /// Set any additional parameter of the query string used in the request.
5202    /// It should be used to set parameters which are not yet available through their own
5203    /// setters.
5204    ///
5205    /// Please note that this method must not be used to set any of the known parameters
5206    /// which have their own setter method. If done anyway, the request will fail.
5207    ///
5208    /// # Additional Parameters
5209    ///
5210    /// * *$.xgafv* (query-string) - V1 error format.
5211    /// * *access_token* (query-string) - OAuth access token.
5212    /// * *alt* (query-string) - Data format for response.
5213    /// * *callback* (query-string) - JSONP
5214    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5215    /// * *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.
5216    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5217    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5218    /// * *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.
5219    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5220    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5221    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyListCall<'a, C>
5222    where
5223        T: AsRef<str>,
5224    {
5225        self._additional_params
5226            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5227        self
5228    }
5229
5230    /// Identifies the authorization scope for the method you are building.
5231    ///
5232    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5233    /// [`Scope::CloudPlatform`].
5234    ///
5235    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5236    /// tokens for more than one scope.
5237    ///
5238    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5239    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5240    /// sufficient, a read-write scope will do as well.
5241    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyListCall<'a, C>
5242    where
5243        St: AsRef<str>,
5244    {
5245        self._scopes.insert(String::from(scope.as_ref()));
5246        self
5247    }
5248    /// Identifies the authorization scope(s) for the method you are building.
5249    ///
5250    /// See [`Self::add_scope()`] for details.
5251    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyListCall<'a, C>
5252    where
5253        I: IntoIterator<Item = St>,
5254        St: AsRef<str>,
5255    {
5256        self._scopes
5257            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5258        self
5259    }
5260
5261    /// Removes all scopes, and no default scope will be used either.
5262    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5263    /// for details).
5264    pub fn clear_scopes(mut self) -> AccessPolicyListCall<'a, C> {
5265        self._scopes.clear();
5266        self
5267    }
5268}
5269
5270/// Update an AccessPolicy. The longrunning Operation from this RPC will have a successful status once the changes to the AccessPolicy have propagated to long-lasting storage. Syntactic and basic semantic errors will be returned in `metadata` as a BadRequest proto.
5271///
5272/// A builder for the *patch* method supported by a *accessPolicy* resource.
5273/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
5274///
5275/// # Example
5276///
5277/// Instantiate a resource method builder
5278///
5279/// ```test_harness,no_run
5280/// # extern crate hyper;
5281/// # extern crate hyper_rustls;
5282/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
5283/// use accesscontextmanager1_beta::api::AccessPolicy;
5284/// # async fn dox() {
5285/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5286///
5287/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5288/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5289/// #     secret,
5290/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5291/// # ).build().await.unwrap();
5292///
5293/// # let client = hyper_util::client::legacy::Client::builder(
5294/// #     hyper_util::rt::TokioExecutor::new()
5295/// # )
5296/// # .build(
5297/// #     hyper_rustls::HttpsConnectorBuilder::new()
5298/// #         .with_native_roots()
5299/// #         .unwrap()
5300/// #         .https_or_http()
5301/// #         .enable_http1()
5302/// #         .build()
5303/// # );
5304/// # let mut hub = AccessContextManager::new(client, auth);
5305/// // As the method needs a request, you would usually fill it with the desired information
5306/// // into the respective structure. Some of the parts shown here might not be applicable !
5307/// // Values shown here are possibly random and not representative !
5308/// let mut req = AccessPolicy::default();
5309///
5310/// // You can configure optional parameters by calling the respective setters at will, and
5311/// // execute the final call using `doit()`.
5312/// // Values shown here are possibly random and not representative !
5313/// let result = hub.access_policies().patch(req, "name")
5314///              .update_mask(FieldMask::new::<&str>(&[]))
5315///              .doit().await;
5316/// # }
5317/// ```
5318pub struct AccessPolicyPatchCall<'a, C>
5319where
5320    C: 'a,
5321{
5322    hub: &'a AccessContextManager<C>,
5323    _request: AccessPolicy,
5324    _name: String,
5325    _update_mask: Option<common::FieldMask>,
5326    _delegate: Option<&'a mut dyn common::Delegate>,
5327    _additional_params: HashMap<String, String>,
5328    _scopes: BTreeSet<String>,
5329}
5330
5331impl<'a, C> common::CallBuilder for AccessPolicyPatchCall<'a, C> {}
5332
5333impl<'a, C> AccessPolicyPatchCall<'a, C>
5334where
5335    C: common::Connector,
5336{
5337    /// Perform the operation you have build so far.
5338    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5339        use std::borrow::Cow;
5340        use std::io::{Read, Seek};
5341
5342        use common::{url::Params, ToParts};
5343        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5344
5345        let mut dd = common::DefaultDelegate;
5346        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5347        dlg.begin(common::MethodInfo {
5348            id: "accesscontextmanager.accessPolicies.patch",
5349            http_method: hyper::Method::PATCH,
5350        });
5351
5352        for &field in ["alt", "name", "updateMask"].iter() {
5353            if self._additional_params.contains_key(field) {
5354                dlg.finished(false);
5355                return Err(common::Error::FieldClash(field));
5356            }
5357        }
5358
5359        let mut params = Params::with_capacity(5 + self._additional_params.len());
5360        params.push("name", self._name);
5361        if let Some(value) = self._update_mask.as_ref() {
5362            params.push("updateMask", value.to_string());
5363        }
5364
5365        params.extend(self._additional_params.iter());
5366
5367        params.push("alt", "json");
5368        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
5369        if self._scopes.is_empty() {
5370            self._scopes
5371                .insert(Scope::CloudPlatform.as_ref().to_string());
5372        }
5373
5374        #[allow(clippy::single_element_loop)]
5375        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5376            url = params.uri_replacement(url, param_name, find_this, true);
5377        }
5378        {
5379            let to_remove = ["name"];
5380            params.remove_params(&to_remove);
5381        }
5382
5383        let url = params.parse_with_url(&url);
5384
5385        let mut json_mime_type = mime::APPLICATION_JSON;
5386        let mut request_value_reader = {
5387            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5388            common::remove_json_null_values(&mut value);
5389            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5390            serde_json::to_writer(&mut dst, &value).unwrap();
5391            dst
5392        };
5393        let request_size = request_value_reader
5394            .seek(std::io::SeekFrom::End(0))
5395            .unwrap();
5396        request_value_reader
5397            .seek(std::io::SeekFrom::Start(0))
5398            .unwrap();
5399
5400        loop {
5401            let token = match self
5402                .hub
5403                .auth
5404                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5405                .await
5406            {
5407                Ok(token) => token,
5408                Err(e) => match dlg.token(e) {
5409                    Ok(token) => token,
5410                    Err(e) => {
5411                        dlg.finished(false);
5412                        return Err(common::Error::MissingToken(e));
5413                    }
5414                },
5415            };
5416            request_value_reader
5417                .seek(std::io::SeekFrom::Start(0))
5418                .unwrap();
5419            let mut req_result = {
5420                let client = &self.hub.client;
5421                dlg.pre_request();
5422                let mut req_builder = hyper::Request::builder()
5423                    .method(hyper::Method::PATCH)
5424                    .uri(url.as_str())
5425                    .header(USER_AGENT, self.hub._user_agent.clone());
5426
5427                if let Some(token) = token.as_ref() {
5428                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5429                }
5430
5431                let request = req_builder
5432                    .header(CONTENT_TYPE, json_mime_type.to_string())
5433                    .header(CONTENT_LENGTH, request_size as u64)
5434                    .body(common::to_body(
5435                        request_value_reader.get_ref().clone().into(),
5436                    ));
5437
5438                client.request(request.unwrap()).await
5439            };
5440
5441            match req_result {
5442                Err(err) => {
5443                    if let common::Retry::After(d) = dlg.http_error(&err) {
5444                        sleep(d).await;
5445                        continue;
5446                    }
5447                    dlg.finished(false);
5448                    return Err(common::Error::HttpError(err));
5449                }
5450                Ok(res) => {
5451                    let (mut parts, body) = res.into_parts();
5452                    let mut body = common::Body::new(body);
5453                    if !parts.status.is_success() {
5454                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5455                        let error = serde_json::from_str(&common::to_string(&bytes));
5456                        let response = common::to_response(parts, bytes.into());
5457
5458                        if let common::Retry::After(d) =
5459                            dlg.http_failure(&response, error.as_ref().ok())
5460                        {
5461                            sleep(d).await;
5462                            continue;
5463                        }
5464
5465                        dlg.finished(false);
5466
5467                        return Err(match error {
5468                            Ok(value) => common::Error::BadRequest(value),
5469                            _ => common::Error::Failure(response),
5470                        });
5471                    }
5472                    let response = {
5473                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5474                        let encoded = common::to_string(&bytes);
5475                        match serde_json::from_str(&encoded) {
5476                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5477                            Err(error) => {
5478                                dlg.response_json_decode_error(&encoded, &error);
5479                                return Err(common::Error::JsonDecodeError(
5480                                    encoded.to_string(),
5481                                    error,
5482                                ));
5483                            }
5484                        }
5485                    };
5486
5487                    dlg.finished(true);
5488                    return Ok(response);
5489                }
5490            }
5491        }
5492    }
5493
5494    ///
5495    /// Sets the *request* property to the given value.
5496    ///
5497    /// Even though the property as already been set when instantiating this call,
5498    /// we provide this method for API completeness.
5499    pub fn request(mut self, new_value: AccessPolicy) -> AccessPolicyPatchCall<'a, C> {
5500        self._request = new_value;
5501        self
5502    }
5503    /// Output only. Resource name of the `AccessPolicy`. Format: `accessPolicies/{policy_id}`
5504    ///
5505    /// Sets the *name* path property to the given value.
5506    ///
5507    /// Even though the property as already been set when instantiating this call,
5508    /// we provide this method for API completeness.
5509    pub fn name(mut self, new_value: &str) -> AccessPolicyPatchCall<'a, C> {
5510        self._name = new_value.to_string();
5511        self
5512    }
5513    /// Required. Mask to control which fields get updated. Must be non-empty.
5514    ///
5515    /// Sets the *update mask* query property to the given value.
5516    pub fn update_mask(mut self, new_value: common::FieldMask) -> AccessPolicyPatchCall<'a, C> {
5517        self._update_mask = Some(new_value);
5518        self
5519    }
5520    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5521    /// while executing the actual API request.
5522    ///
5523    /// ````text
5524    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5525    /// ````
5526    ///
5527    /// Sets the *delegate* property to the given value.
5528    pub fn delegate(
5529        mut self,
5530        new_value: &'a mut dyn common::Delegate,
5531    ) -> AccessPolicyPatchCall<'a, C> {
5532        self._delegate = Some(new_value);
5533        self
5534    }
5535
5536    /// Set any additional parameter of the query string used in the request.
5537    /// It should be used to set parameters which are not yet available through their own
5538    /// setters.
5539    ///
5540    /// Please note that this method must not be used to set any of the known parameters
5541    /// which have their own setter method. If done anyway, the request will fail.
5542    ///
5543    /// # Additional Parameters
5544    ///
5545    /// * *$.xgafv* (query-string) - V1 error format.
5546    /// * *access_token* (query-string) - OAuth access token.
5547    /// * *alt* (query-string) - Data format for response.
5548    /// * *callback* (query-string) - JSONP
5549    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5550    /// * *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.
5551    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5552    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5553    /// * *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.
5554    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5555    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5556    pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyPatchCall<'a, C>
5557    where
5558        T: AsRef<str>,
5559    {
5560        self._additional_params
5561            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5562        self
5563    }
5564
5565    /// Identifies the authorization scope for the method you are building.
5566    ///
5567    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5568    /// [`Scope::CloudPlatform`].
5569    ///
5570    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5571    /// tokens for more than one scope.
5572    ///
5573    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5574    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5575    /// sufficient, a read-write scope will do as well.
5576    pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyPatchCall<'a, C>
5577    where
5578        St: AsRef<str>,
5579    {
5580        self._scopes.insert(String::from(scope.as_ref()));
5581        self
5582    }
5583    /// Identifies the authorization scope(s) for the method you are building.
5584    ///
5585    /// See [`Self::add_scope()`] for details.
5586    pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyPatchCall<'a, C>
5587    where
5588        I: IntoIterator<Item = St>,
5589        St: AsRef<str>,
5590    {
5591        self._scopes
5592            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5593        self
5594    }
5595
5596    /// Removes all scopes, and no default scope will be used either.
5597    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5598    /// for details).
5599    pub fn clear_scopes(mut self) -> AccessPolicyPatchCall<'a, C> {
5600        self._scopes.clear();
5601        self
5602    }
5603}
5604
5605/// 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.
5606///
5607/// A builder for the *get* method supported by a *operation* resource.
5608/// It is not used directly, but through a [`OperationMethods`] instance.
5609///
5610/// # Example
5611///
5612/// Instantiate a resource method builder
5613///
5614/// ```test_harness,no_run
5615/// # extern crate hyper;
5616/// # extern crate hyper_rustls;
5617/// # extern crate google_accesscontextmanager1_beta as accesscontextmanager1_beta;
5618/// # async fn dox() {
5619/// # use accesscontextmanager1_beta::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5620///
5621/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5622/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5623/// #     secret,
5624/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5625/// # ).build().await.unwrap();
5626///
5627/// # let client = hyper_util::client::legacy::Client::builder(
5628/// #     hyper_util::rt::TokioExecutor::new()
5629/// # )
5630/// # .build(
5631/// #     hyper_rustls::HttpsConnectorBuilder::new()
5632/// #         .with_native_roots()
5633/// #         .unwrap()
5634/// #         .https_or_http()
5635/// #         .enable_http1()
5636/// #         .build()
5637/// # );
5638/// # let mut hub = AccessContextManager::new(client, auth);
5639/// // You can configure optional parameters by calling the respective setters at will, and
5640/// // execute the final call using `doit()`.
5641/// // Values shown here are possibly random and not representative !
5642/// let result = hub.operations().get("name")
5643///              .doit().await;
5644/// # }
5645/// ```
5646pub struct OperationGetCall<'a, C>
5647where
5648    C: 'a,
5649{
5650    hub: &'a AccessContextManager<C>,
5651    _name: String,
5652    _delegate: Option<&'a mut dyn common::Delegate>,
5653    _additional_params: HashMap<String, String>,
5654    _scopes: BTreeSet<String>,
5655}
5656
5657impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
5658
5659impl<'a, C> OperationGetCall<'a, C>
5660where
5661    C: common::Connector,
5662{
5663    /// Perform the operation you have build so far.
5664    pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5665        use std::borrow::Cow;
5666        use std::io::{Read, Seek};
5667
5668        use common::{url::Params, ToParts};
5669        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5670
5671        let mut dd = common::DefaultDelegate;
5672        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5673        dlg.begin(common::MethodInfo {
5674            id: "accesscontextmanager.operations.get",
5675            http_method: hyper::Method::GET,
5676        });
5677
5678        for &field in ["alt", "name"].iter() {
5679            if self._additional_params.contains_key(field) {
5680                dlg.finished(false);
5681                return Err(common::Error::FieldClash(field));
5682            }
5683        }
5684
5685        let mut params = Params::with_capacity(3 + self._additional_params.len());
5686        params.push("name", self._name);
5687
5688        params.extend(self._additional_params.iter());
5689
5690        params.push("alt", "json");
5691        let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
5692        if self._scopes.is_empty() {
5693            self._scopes
5694                .insert(Scope::CloudPlatform.as_ref().to_string());
5695        }
5696
5697        #[allow(clippy::single_element_loop)]
5698        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5699            url = params.uri_replacement(url, param_name, find_this, true);
5700        }
5701        {
5702            let to_remove = ["name"];
5703            params.remove_params(&to_remove);
5704        }
5705
5706        let url = params.parse_with_url(&url);
5707
5708        loop {
5709            let token = match self
5710                .hub
5711                .auth
5712                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5713                .await
5714            {
5715                Ok(token) => token,
5716                Err(e) => match dlg.token(e) {
5717                    Ok(token) => token,
5718                    Err(e) => {
5719                        dlg.finished(false);
5720                        return Err(common::Error::MissingToken(e));
5721                    }
5722                },
5723            };
5724            let mut req_result = {
5725                let client = &self.hub.client;
5726                dlg.pre_request();
5727                let mut req_builder = hyper::Request::builder()
5728                    .method(hyper::Method::GET)
5729                    .uri(url.as_str())
5730                    .header(USER_AGENT, self.hub._user_agent.clone());
5731
5732                if let Some(token) = token.as_ref() {
5733                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5734                }
5735
5736                let request = req_builder
5737                    .header(CONTENT_LENGTH, 0_u64)
5738                    .body(common::to_body::<String>(None));
5739
5740                client.request(request.unwrap()).await
5741            };
5742
5743            match req_result {
5744                Err(err) => {
5745                    if let common::Retry::After(d) = dlg.http_error(&err) {
5746                        sleep(d).await;
5747                        continue;
5748                    }
5749                    dlg.finished(false);
5750                    return Err(common::Error::HttpError(err));
5751                }
5752                Ok(res) => {
5753                    let (mut parts, body) = res.into_parts();
5754                    let mut body = common::Body::new(body);
5755                    if !parts.status.is_success() {
5756                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5757                        let error = serde_json::from_str(&common::to_string(&bytes));
5758                        let response = common::to_response(parts, bytes.into());
5759
5760                        if let common::Retry::After(d) =
5761                            dlg.http_failure(&response, error.as_ref().ok())
5762                        {
5763                            sleep(d).await;
5764                            continue;
5765                        }
5766
5767                        dlg.finished(false);
5768
5769                        return Err(match error {
5770                            Ok(value) => common::Error::BadRequest(value),
5771                            _ => common::Error::Failure(response),
5772                        });
5773                    }
5774                    let response = {
5775                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5776                        let encoded = common::to_string(&bytes);
5777                        match serde_json::from_str(&encoded) {
5778                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5779                            Err(error) => {
5780                                dlg.response_json_decode_error(&encoded, &error);
5781                                return Err(common::Error::JsonDecodeError(
5782                                    encoded.to_string(),
5783                                    error,
5784                                ));
5785                            }
5786                        }
5787                    };
5788
5789                    dlg.finished(true);
5790                    return Ok(response);
5791                }
5792            }
5793        }
5794    }
5795
5796    /// The name of the operation resource.
5797    ///
5798    /// Sets the *name* path property to the given value.
5799    ///
5800    /// Even though the property as already been set when instantiating this call,
5801    /// we provide this method for API completeness.
5802    pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
5803        self._name = new_value.to_string();
5804        self
5805    }
5806    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5807    /// while executing the actual API request.
5808    ///
5809    /// ````text
5810    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5811    /// ````
5812    ///
5813    /// Sets the *delegate* property to the given value.
5814    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
5815        self._delegate = Some(new_value);
5816        self
5817    }
5818
5819    /// Set any additional parameter of the query string used in the request.
5820    /// It should be used to set parameters which are not yet available through their own
5821    /// setters.
5822    ///
5823    /// Please note that this method must not be used to set any of the known parameters
5824    /// which have their own setter method. If done anyway, the request will fail.
5825    ///
5826    /// # Additional Parameters
5827    ///
5828    /// * *$.xgafv* (query-string) - V1 error format.
5829    /// * *access_token* (query-string) - OAuth access token.
5830    /// * *alt* (query-string) - Data format for response.
5831    /// * *callback* (query-string) - JSONP
5832    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5833    /// * *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.
5834    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5835    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5836    /// * *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.
5837    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5838    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5839    pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
5840    where
5841        T: AsRef<str>,
5842    {
5843        self._additional_params
5844            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5845        self
5846    }
5847
5848    /// Identifies the authorization scope for the method you are building.
5849    ///
5850    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5851    /// [`Scope::CloudPlatform`].
5852    ///
5853    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5854    /// tokens for more than one scope.
5855    ///
5856    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5857    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5858    /// sufficient, a read-write scope will do as well.
5859    pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
5860    where
5861        St: AsRef<str>,
5862    {
5863        self._scopes.insert(String::from(scope.as_ref()));
5864        self
5865    }
5866    /// Identifies the authorization scope(s) for the method you are building.
5867    ///
5868    /// See [`Self::add_scope()`] for details.
5869    pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
5870    where
5871        I: IntoIterator<Item = St>,
5872        St: AsRef<str>,
5873    {
5874        self._scopes
5875            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5876        self
5877    }
5878
5879    /// Removes all scopes, and no default scope will be used either.
5880    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5881    /// for details).
5882    pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
5883        self._scopes.clear();
5884        self
5885    }
5886}