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