google_accesscontextmanager1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::CloudPlatform
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all AccessContextManager related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
49/// use accesscontextmanager1::{Result, Error};
50/// # async fn dox() {
51/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
62/// secret,
63/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
64/// ).build().await.unwrap();
65///
66/// let client = hyper_util::client::legacy::Client::builder(
67/// hyper_util::rt::TokioExecutor::new()
68/// )
69/// .build(
70/// hyper_rustls::HttpsConnectorBuilder::new()
71/// .with_native_roots()
72/// .unwrap()
73/// .https_or_http()
74/// .enable_http1()
75/// .build()
76/// );
77/// let mut hub = AccessContextManager::new(client, auth);
78/// // You can configure optional parameters by calling the respective setters at will, and
79/// // execute the final call using `doit()`.
80/// // Values shown here are possibly random and not representative !
81/// let result = hub.operations().list("name")
82/// .page_token("takimata")
83/// .page_size(-52)
84/// .filter("duo")
85/// .doit().await;
86///
87/// match result {
88/// Err(e) => match e {
89/// // The Error enum provides details about what exactly happened.
90/// // You can also just use its `Debug`, `Display` or `Error` traits
91/// Error::HttpError(_)
92/// |Error::Io(_)
93/// |Error::MissingAPIKey
94/// |Error::MissingToken(_)
95/// |Error::Cancelled
96/// |Error::UploadSizeLimitExceeded(_, _)
97/// |Error::Failure(_)
98/// |Error::BadRequest(_)
99/// |Error::FieldClash(_)
100/// |Error::JsonDecodeError(_, _) => println!("{}", e),
101/// },
102/// Ok(res) => println!("Success: {:?}", res),
103/// }
104/// # }
105/// ```
106#[derive(Clone)]
107pub struct AccessContextManager<C> {
108 pub client: common::Client<C>,
109 pub auth: Box<dyn common::GetToken>,
110 _user_agent: String,
111 _base_url: String,
112 _root_url: String,
113}
114
115impl<C> common::Hub for AccessContextManager<C> {}
116
117impl<'a, C> AccessContextManager<C> {
118 pub fn new<A: 'static + common::GetToken>(
119 client: common::Client<C>,
120 auth: A,
121 ) -> AccessContextManager<C> {
122 AccessContextManager {
123 client,
124 auth: Box::new(auth),
125 _user_agent: "google-api-rust-client/6.0.0".to_string(),
126 _base_url: "https://accesscontextmanager.googleapis.com/".to_string(),
127 _root_url: "https://accesscontextmanager.googleapis.com/".to_string(),
128 }
129 }
130
131 pub fn access_policies(&'a self) -> AccessPolicyMethods<'a, C> {
132 AccessPolicyMethods { hub: self }
133 }
134 pub fn operations(&'a self) -> OperationMethods<'a, C> {
135 OperationMethods { hub: self }
136 }
137 pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
138 OrganizationMethods { hub: self }
139 }
140 pub fn services(&'a self) -> ServiceMethods<'a, C> {
141 ServiceMethods { hub: self }
142 }
143
144 /// Set the user-agent header field to use in all requests to the server.
145 /// It defaults to `google-api-rust-client/6.0.0`.
146 ///
147 /// Returns the previously set user-agent.
148 pub fn user_agent(&mut self, agent_name: String) -> String {
149 std::mem::replace(&mut self._user_agent, agent_name)
150 }
151
152 /// Set the base url to use in all requests to the server.
153 /// It defaults to `https://accesscontextmanager.googleapis.com/`.
154 ///
155 /// Returns the previously set base url.
156 pub fn base_url(&mut self, new_base_url: String) -> String {
157 std::mem::replace(&mut self._base_url, new_base_url)
158 }
159
160 /// Set the root url to use in all requests to the server.
161 /// It defaults to `https://accesscontextmanager.googleapis.com/`.
162 ///
163 /// Returns the previously set root url.
164 pub fn root_url(&mut self, new_root_url: String) -> String {
165 std::mem::replace(&mut self._root_url, new_root_url)
166 }
167}
168
169// ############
170// SCHEMAS ###
171// ##########
172/// 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.
173///
174/// # Activities
175///
176/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
177/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
178///
179/// * [access levels create access policies](AccessPolicyAccessLevelCreateCall) (request)
180/// * [access levels get access policies](AccessPolicyAccessLevelGetCall) (response)
181/// * [access levels patch access policies](AccessPolicyAccessLevelPatchCall) (request)
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct AccessLevel {
186 /// A `BasicLevel` composed of `Conditions`.
187 pub basic: Option<BasicLevel>,
188 /// A `CustomLevel` written in the Common Expression Language.
189 pub custom: Option<CustomLevel>,
190 /// Description of the `AccessLevel` and its use. Does not affect behavior.
191 pub description: Option<String>,
192 /// Identifier. Resource name for the `AccessLevel`. Format: `accessPolicies/{access_policy}/accessLevels/{access_level}`. The `access_level` component must begin with a letter, followed by alphanumeric characters or `_`. Its maximum length is 50 characters. After you create an `AccessLevel`, you cannot change its `name`.
193 pub name: Option<String>,
194 /// Human readable title. Must be unique within the Policy.
195 pub title: Option<String>,
196}
197
198impl common::RequestValue for AccessLevel {}
199impl common::ResponseResult for AccessLevel {}
200
201/// `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.
202///
203/// # Activities
204///
205/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
206/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
207///
208/// * [create access policies](AccessPolicyCreateCall) (request)
209/// * [get access policies](AccessPolicyGetCall) (response)
210/// * [patch access policies](AccessPolicyPatchCall) (request)
211#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
212#[serde_with::serde_as]
213#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
214pub struct AccessPolicy {
215 /// Output only. An opaque identifier for the current version of the `AccessPolicy`. This will always be a strongly validated etag, meaning that two Access Policies will be identical if and only if their etags are identical. Clients should not expect this to be in any specific format.
216 pub etag: Option<String>,
217 /// Output only. Identifier. Resource name of the `AccessPolicy`. Format: `accessPolicies/{access_policy}`
218 pub name: Option<String>,
219 /// Required. The parent of this `AccessPolicy` in the Cloud Resource Hierarchy. Currently immutable once created. Format: `organizations/{organization_id}`
220 pub parent: Option<String>,
221 /// The scopes of the AccessPolicy. Scopes define which resources a policy can restrict and where its resources can be referenced. For example, policy A with `scopes=["folders/123"]` has the following behavior: - ServicePerimeter can only restrict projects within `folders/123`. - ServicePerimeter within policy A can only reference access levels defined within policy A. - Only one policy can include a given scope; thus, attempting to create a second policy which includes `folders/123` will result in an error. If no scopes are provided, then any resource within the organization can be restricted. Scopes cannot be modified after a policy is created. Policies can only have a single scope. Format: list of `folders/{folder_number}` or `projects/{project_number}`
222 pub scopes: Option<Vec<String>>,
223 /// Required. Human readable title. Does not affect behavior.
224 pub title: Option<String>,
225}
226
227impl common::RequestValue for AccessPolicy {}
228impl common::ResponseResult for AccessPolicy {}
229
230/// Identification for an API Operation.
231///
232/// This type is not used in any activity, and only used as *part* of another schema.
233///
234#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
235#[serde_with::serde_as]
236#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
237pub struct ApiOperation {
238 /// API methods or permissions to allow. Method or permission must belong to the service specified by `service_name` field. A single MethodSelector entry with `*` specified for the `method` field will allow all methods AND permissions for the service specified in `service_name`.
239 #[serde(rename = "methodSelectors")]
240 pub method_selectors: Option<Vec<MethodSelector>>,
241 /// The name of the API whose methods or permissions the IngressPolicy or EgressPolicy want to allow. A single ApiOperation with `service_name` field set to `*` will allow all methods AND permissions for all services.
242 #[serde(rename = "serviceName")]
243 pub service_name: Option<String>,
244}
245
246impl common::Part for ApiOperation {}
247
248/// An application that accesses Google Cloud APIs.
249///
250/// This type is not used in any activity, and only used as *part* of another schema.
251///
252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
253#[serde_with::serde_as]
254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
255pub struct Application {
256 /// The OAuth client ID of the application.
257 #[serde(rename = "clientId")]
258 pub client_id: Option<String>,
259 /// The name of the application. Example: "Cloud Console"
260 pub name: Option<String>,
261}
262
263impl common::Part for Application {}
264
265/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
266///
267/// This type is not used in any activity, and only used as *part* of another schema.
268///
269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
270#[serde_with::serde_as]
271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
272pub struct AuditConfig {
273 /// The configuration for logging of each type of permission.
274 #[serde(rename = "auditLogConfigs")]
275 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
276 /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
277 pub service: Option<String>,
278}
279
280impl common::Part for AuditConfig {}
281
282/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
283///
284/// This type is not used in any activity, and only used as *part* of another schema.
285///
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct AuditLogConfig {
290 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
291 #[serde(rename = "exemptedMembers")]
292 pub exempted_members: Option<Vec<String>>,
293 /// The log type that this config enables.
294 #[serde(rename = "logType")]
295 pub log_type: Option<String>,
296}
297
298impl common::Part for AuditLogConfig {}
299
300/// `AuthorizedOrgsDesc` contains data for an organization’s authorization policy.
301///
302/// # Activities
303///
304/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
305/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
306///
307/// * [authorized orgs descs create access policies](AccessPolicyAuthorizedOrgsDescCreateCall) (request)
308/// * [authorized orgs descs get access policies](AccessPolicyAuthorizedOrgsDescGetCall) (response)
309/// * [authorized orgs descs patch access policies](AccessPolicyAuthorizedOrgsDescPatchCall) (request)
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct AuthorizedOrgsDesc {
314 /// The asset type of this authorized orgs desc. Valid values are `ASSET_TYPE_DEVICE`, and `ASSET_TYPE_CREDENTIAL_STRENGTH`.
315 #[serde(rename = "assetType")]
316 pub asset_type: Option<String>,
317 /// The direction of the authorization relationship between this organization and the organizations listed in the `orgs` field. The valid values for this field include the following: `AUTHORIZATION_DIRECTION_FROM`: Allows this organization to evaluate traffic in the organizations listed in the `orgs` field. `AUTHORIZATION_DIRECTION_TO`: Allows the organizations listed in the `orgs` field to evaluate the traffic in this organization. For the authorization relationship to take effect, all of the organizations must authorize and specify the appropriate relationship direction. For example, if organization A authorized organization B and C to evaluate its traffic, by specifying `AUTHORIZATION_DIRECTION_TO` as the authorization direction, organizations B and C must specify `AUTHORIZATION_DIRECTION_FROM` as the authorization direction in their `AuthorizedOrgsDesc` resource.
318 #[serde(rename = "authorizationDirection")]
319 pub authorization_direction: Option<String>,
320 /// A granular control type for authorization levels. Valid value is `AUTHORIZATION_TYPE_TRUST`.
321 #[serde(rename = "authorizationType")]
322 pub authorization_type: Option<String>,
323 /// Identifier. Resource name for the `AuthorizedOrgsDesc`. Format: `accessPolicies/{access_policy}/authorizedOrgsDescs/{authorized_orgs_desc}`. The `authorized_orgs_desc` component must begin with a letter, followed by alphanumeric characters or `_`. After you create an `AuthorizedOrgsDesc`, you cannot change its `name`.
324 pub name: Option<String>,
325 /// The list of organization ids in this AuthorizedOrgsDesc. Format: `organizations/` Example: `organizations/123456`
326 pub orgs: Option<Vec<String>>,
327}
328
329impl common::RequestValue for AuthorizedOrgsDesc {}
330impl common::ResponseResult for AuthorizedOrgsDesc {}
331
332/// `BasicLevel` is an `AccessLevel` using a set of recommended features.
333///
334/// This type is not used in any activity, and only used as *part* of another schema.
335///
336#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
337#[serde_with::serde_as]
338#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
339pub struct BasicLevel {
340 /// 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.
341 #[serde(rename = "combiningFunction")]
342 pub combining_function: Option<String>,
343 /// Required. A list of requirements for the `AccessLevel` to be granted.
344 pub conditions: Option<Vec<Condition>>,
345}
346
347impl common::Part for BasicLevel {}
348
349/// Associates `members`, or principals, with a `role`.
350///
351/// This type is not used in any activity, and only used as *part* of another schema.
352///
353#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
354#[serde_with::serde_as]
355#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
356pub struct Binding {
357 /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
358 pub condition: Option<Expr>,
359 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
360 pub members: Option<Vec<String>>,
361 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
362 pub role: Option<String>,
363}
364
365impl common::Part for Binding {}
366
367/// The request message for Operations.CancelOperation.
368///
369/// # Activities
370///
371/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
372/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
373///
374/// * [cancel operations](OperationCancelCall) (request)
375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
376#[serde_with::serde_as]
377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
378pub struct CancelOperationRequest {
379 _never_set: Option<bool>,
380}
381
382impl common::RequestValue for CancelOperationRequest {}
383
384/// A request to commit dry-run specs in all Service Perimeters belonging to an Access Policy.
385///
386/// # Activities
387///
388/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
389/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
390///
391/// * [service perimeters commit access policies](AccessPolicyServicePerimeterCommitCall) (request)
392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
393#[serde_with::serde_as]
394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
395pub struct CommitServicePerimetersRequest {
396 /// Optional. The etag for the version of the Access Policy that this commit operation is to be performed on. If, at the time of commit, the etag for the Access Policy stored in Access Context Manager is different from the specified etag, then the commit operation will not be performed and the call will fail. This field is not required. If etag is not provided, the operation will be performed as if a valid etag is provided.
397 pub etag: Option<String>,
398}
399
400impl common::RequestValue for CommitServicePerimetersRequest {}
401
402/// 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.
403///
404/// This type is not used in any activity, and only used as *part* of another schema.
405///
406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
407#[serde_with::serde_as]
408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
409pub struct Condition {
410 /// Device specific restrictions, all restrictions must hold for the Condition to be true. If not specified, all devices are allowed.
411 #[serde(rename = "devicePolicy")]
412 pub device_policy: Option<DevicePolicy>,
413 /// 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.
414 #[serde(rename = "ipSubnetworks")]
415 pub ip_subnetworks: Option<Vec<String>>,
416 /// 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.
417 pub members: Option<Vec<String>>,
418 /// Whether to negate the Condition. If true, the Condition becomes a NAND over its non-empty fields. Any non-empty field criteria evaluating to false will result in the Condition to be satisfied. Defaults to false.
419 pub negate: Option<bool>,
420 /// The request must originate from one of the provided countries/regions. Must be valid ISO 3166-1 alpha-2 codes.
421 pub regions: Option<Vec<String>>,
422 /// 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"`
423 #[serde(rename = "requiredAccessLevels")]
424 pub required_access_levels: Option<Vec<String>>,
425 /// The request must originate from one of the provided VPC networks in Google Cloud. Cannot specify this field together with `ip_subnetworks`.
426 #[serde(rename = "vpcNetworkSources")]
427 pub vpc_network_sources: Option<Vec<VpcNetworkSource>>,
428}
429
430impl common::Part for Condition {}
431
432/// `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
433///
434/// This type is not used in any activity, and only used as *part* of another schema.
435///
436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
437#[serde_with::serde_as]
438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
439pub struct CustomLevel {
440 /// Required. A Cloud CEL expression evaluating to a boolean.
441 pub expr: Option<Expr>,
442}
443
444impl common::Part for CustomLevel {}
445
446/// `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.
447///
448/// This type is not used in any activity, and only used as *part* of another schema.
449///
450#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
451#[serde_with::serde_as]
452#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
453pub struct DevicePolicy {
454 /// Allowed device management levels, an empty list allows all management levels.
455 #[serde(rename = "allowedDeviceManagementLevels")]
456 pub allowed_device_management_levels: Option<Vec<String>>,
457 /// Allowed encryptions statuses, an empty list allows all statuses.
458 #[serde(rename = "allowedEncryptionStatuses")]
459 pub allowed_encryption_statuses: Option<Vec<String>>,
460 /// Allowed OS versions, an empty list allows all types and all versions.
461 #[serde(rename = "osConstraints")]
462 pub os_constraints: Option<Vec<OsConstraint>>,
463 /// Whether the device needs to be approved by the customer admin.
464 #[serde(rename = "requireAdminApproval")]
465 pub require_admin_approval: Option<bool>,
466 /// Whether the device needs to be corp owned.
467 #[serde(rename = "requireCorpOwned")]
468 pub require_corp_owned: Option<bool>,
469 /// Whether or not screenlock is required for the DevicePolicy to be true. Defaults to `false`.
470 #[serde(rename = "requireScreenlock")]
471 pub require_screenlock: Option<bool>,
472}
473
474impl common::Part for DevicePolicy {}
475
476/// Defines the conditions under which an EgressPolicy matches a request. Conditions based on information about the source of the request. Note that if the destination of the request is also protected by a ServicePerimeter, then that ServicePerimeter must have an IngressPolicy which allows access in order for this request to succeed.
477///
478/// This type is not used in any activity, and only used as *part* of another schema.
479///
480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
481#[serde_with::serde_as]
482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
483pub struct EgressFrom {
484 /// A list of identities that are allowed access through [EgressPolicy]. Identities can be an individual user, service account, Google group, or third-party identity. The `v1` identities that have the prefix `user`, `group`, `serviceAccount`, `principal`, and `principalSet` in https://cloud.google.com/iam/docs/principal-identifiers#v1 are supported.
485 pub identities: Option<Vec<String>>,
486 /// Specifies the type of identities that are allowed access to outside the perimeter. If left unspecified, then members of `identities` field will be allowed access.
487 #[serde(rename = "identityType")]
488 pub identity_type: Option<String>,
489 /// Whether to enforce traffic restrictions based on `sources` field. If the `sources` fields is non-empty, then this field must be set to `SOURCE_RESTRICTION_ENABLED`.
490 #[serde(rename = "sourceRestriction")]
491 pub source_restriction: Option<String>,
492 /// Sources that this EgressPolicy authorizes access from. If this field is not empty, then `source_restriction` must be set to `SOURCE_RESTRICTION_ENABLED`.
493 pub sources: Option<Vec<EgressSource>>,
494}
495
496impl common::Part for EgressFrom {}
497
498/// Policy for egress from perimeter. EgressPolicies match requests based on `egress_from` and `egress_to` stanzas. For an EgressPolicy to match, both `egress_from` and `egress_to` stanzas must be matched. If an EgressPolicy matches a request, the request is allowed to span the ServicePerimeter boundary. For example, an EgressPolicy can be used to allow VMs on networks within the ServicePerimeter to access a defined set of projects outside the perimeter in certain contexts (e.g. to read data from a Cloud Storage bucket or query against a BigQuery dataset). EgressPolicies are concerned with the *resources* that a request relates as well as the API services and API actions being used. They do not related to the direction of data movement. More detailed documentation for this concept can be found in the descriptions of EgressFrom and EgressTo.
499///
500/// This type is not used in any activity, and only used as *part* of another schema.
501///
502#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
503#[serde_with::serde_as]
504#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
505pub struct EgressPolicy {
506 /// Defines conditions on the source of a request causing this EgressPolicy to apply.
507 #[serde(rename = "egressFrom")]
508 pub egress_from: Option<EgressFrom>,
509 /// Defines the conditions on the ApiOperation and destination resources that cause this EgressPolicy to apply.
510 #[serde(rename = "egressTo")]
511 pub egress_to: Option<EgressTo>,
512}
513
514impl common::Part for EgressPolicy {}
515
516/// The source that EgressPolicy authorizes access from inside the ServicePerimeter to somewhere outside the ServicePerimeter boundaries.
517///
518/// This type is not used in any activity, and only used as *part* of another schema.
519///
520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
521#[serde_with::serde_as]
522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
523pub struct EgressSource {
524 /// An AccessLevel resource name that allows protected resources inside the ServicePerimeters to access outside the ServicePerimeter boundaries. AccessLevels listed must be in the same policy as this ServicePerimeter. Referencing a nonexistent AccessLevel will cause an error. If an AccessLevel name is not specified, only resources within the perimeter can be accessed through Google Cloud calls with request origins within the perimeter. Example: `accessPolicies/MY_POLICY/accessLevels/MY_LEVEL`. If a single `*` is specified for `access_level`, then all EgressSources will be allowed.
525 #[serde(rename = "accessLevel")]
526 pub access_level: Option<String>,
527}
528
529impl common::Part for EgressSource {}
530
531/// Defines the conditions under which an EgressPolicy matches a request. Conditions are based on information about the ApiOperation intended to be performed on the `resources` specified. Note that if the destination of the request is also protected by a ServicePerimeter, then that ServicePerimeter must have an IngressPolicy which allows access in order for this request to succeed. The request must match `operations` AND `resources` fields in order to be allowed egress out of the perimeter.
532///
533/// This type is not used in any activity, and only used as *part* of another schema.
534///
535#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
536#[serde_with::serde_as]
537#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
538pub struct EgressTo {
539 /// A list of external resources that are allowed to be accessed. Only AWS and Azure resources are supported. For Amazon S3, the supported formats are s3://BUCKET_NAME, s3a://BUCKET_NAME, and s3n://BUCKET_NAME. For Azure Storage, the supported format is azure://myaccount.blob.core.windows.net/CONTAINER_NAME. A request matches if it contains an external resource in this list (Example: s3://bucket/path). Currently '*' is not allowed.
540 #[serde(rename = "externalResources")]
541 pub external_resources: Option<Vec<String>>,
542 /// A list of ApiOperations allowed to be performed by the sources specified in the corresponding EgressFrom. A request matches if it uses an operation/service in this list.
543 pub operations: Option<Vec<ApiOperation>>,
544 /// A list of resources, currently only projects in the form `projects/`, that are allowed to be accessed by sources defined in the corresponding EgressFrom. A request matches if it contains a resource in this list. If `*` is specified for `resources`, then this EgressTo rule will authorize access to all resources outside the perimeter.
545 pub resources: Option<Vec<String>>,
546}
547
548impl common::Part for EgressTo {}
549
550/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
551///
552/// # Activities
553///
554/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
555/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
556///
557/// * [cancel operations](OperationCancelCall) (response)
558/// * [delete operations](OperationDeleteCall) (response)
559#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
560#[serde_with::serde_as]
561#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
562pub struct Empty {
563 _never_set: Option<bool>,
564}
565
566impl common::ResponseResult for Empty {}
567
568/// 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.
569///
570/// This type is not used in any activity, and only used as *part* of another schema.
571///
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct Expr {
576 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
577 pub description: Option<String>,
578 /// Textual representation of an expression in Common Expression Language syntax.
579 pub expression: Option<String>,
580 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
581 pub location: Option<String>,
582 /// 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.
583 pub title: Option<String>,
584}
585
586impl common::Part for Expr {}
587
588/// Restricts access to Cloud Console and Google Cloud APIs for a set of users using Context-Aware Access.
589///
590/// # Activities
591///
592/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
593/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
594///
595/// * [gcp user access bindings create organizations](OrganizationGcpUserAccessBindingCreateCall) (request)
596/// * [gcp user access bindings get organizations](OrganizationGcpUserAccessBindingGetCall) (response)
597/// * [gcp user access bindings patch organizations](OrganizationGcpUserAccessBindingPatchCall) (request)
598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
599#[serde_with::serde_as]
600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
601pub struct GcpUserAccessBinding {
602 /// Optional. Access level that a user must have to be granted access. Only one access level is supported, not multiple. This repeated field must have exactly one element. Example: "accessPolicies/9522/accessLevels/device_trusted"
603 #[serde(rename = "accessLevels")]
604 pub access_levels: Option<Vec<String>>,
605 /// Optional. Dry run access level that will be evaluated but will not be enforced. The access denial based on dry run policy will be logged. Only one access level is supported, not multiple. This list must have exactly one element. Example: "accessPolicies/9522/accessLevels/device_trusted"
606 #[serde(rename = "dryRunAccessLevels")]
607 pub dry_run_access_levels: Option<Vec<String>>,
608 /// Required. Immutable. Google Group id whose members are subject to this binding's restrictions. See "id" in the [G Suite Directory API's Groups resource] (https://developers.google.com/admin-sdk/directory/v1/reference/groups#resource). If a group's email address/alias is changed, this resource will continue to point at the changed group. This field does not accept group email addresses or aliases. Example: "01d520gv4vjcrht"
609 #[serde(rename = "groupKey")]
610 pub group_key: Option<String>,
611 /// Immutable. Assigned by the server during creation. The last segment has an arbitrary length and has only URI unreserved characters (as defined by [RFC 3986 Section 2.3](https://tools.ietf.org/html/rfc3986#section-2.3)). Should not be specified by the client during creation. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
612 pub name: Option<String>,
613 /// Optional. A list of applications that are subject to this binding's restrictions. If the list is empty, the binding restrictions will universally apply to all applications.
614 #[serde(rename = "restrictedClientApplications")]
615 pub restricted_client_applications: Option<Vec<Application>>,
616}
617
618impl common::RequestValue for GcpUserAccessBinding {}
619impl common::ResponseResult for GcpUserAccessBinding {}
620
621/// Request message for `GetIamPolicy` method.
622///
623/// # Activities
624///
625/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
626/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
627///
628/// * [get iam policy access policies](AccessPolicyGetIamPolicyCall) (request)
629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
630#[serde_with::serde_as]
631#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
632pub struct GetIamPolicyRequest {
633 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
634 pub options: Option<GetPolicyOptions>,
635}
636
637impl common::RequestValue for GetIamPolicyRequest {}
638
639/// Encapsulates settings provided to GetIamPolicy.
640///
641/// This type is not used in any activity, and only used as *part* of another schema.
642///
643#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
644#[serde_with::serde_as]
645#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
646pub struct GetPolicyOptions {
647 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
648 #[serde(rename = "requestedPolicyVersion")]
649 pub requested_policy_version: Option<i32>,
650}
651
652impl common::Part for GetPolicyOptions {}
653
654/// Defines the conditions under which an IngressPolicy matches a request. Conditions are based on information about the source of the request. The request must satisfy what is defined in `sources` AND identity related fields in order to match.
655///
656/// This type is not used in any activity, and only used as *part* of another schema.
657///
658#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
659#[serde_with::serde_as]
660#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
661pub struct IngressFrom {
662 /// A list of identities that are allowed access through [IngressPolicy]. Identities can be an individual user, service account, Google group, or third-party identity. The `v1` identities that have the prefix `user`, `group`, `serviceAccount`, `principal`, and `principalSet` in https://cloud.google.com/iam/docs/principal-identifiers#v1 are supported.
663 pub identities: Option<Vec<String>>,
664 /// Specifies the type of identities that are allowed access from outside the perimeter. If left unspecified, then members of `identities` field will be allowed access.
665 #[serde(rename = "identityType")]
666 pub identity_type: Option<String>,
667 /// Sources that this IngressPolicy authorizes access from.
668 pub sources: Option<Vec<IngressSource>>,
669}
670
671impl common::Part for IngressFrom {}
672
673/// Policy for ingress into ServicePerimeter. IngressPolicies match requests based on `ingress_from` and `ingress_to` stanzas. For an ingress policy to match, both the `ingress_from` and `ingress_to` stanzas must be matched. If an IngressPolicy matches a request, the request is allowed through the perimeter boundary from outside the perimeter. For example, access from the internet can be allowed either based on an AccessLevel or, for traffic hosted on Google Cloud, the project of the source network. For access from private networks, using the project of the hosting network is required. Individual ingress policies can be limited by restricting which services and/or actions they match using the `ingress_to` field.
674///
675/// This type is not used in any activity, and only used as *part* of another schema.
676///
677#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
678#[serde_with::serde_as]
679#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
680pub struct IngressPolicy {
681 /// Defines the conditions on the source of a request causing this IngressPolicy to apply.
682 #[serde(rename = "ingressFrom")]
683 pub ingress_from: Option<IngressFrom>,
684 /// Defines the conditions on the ApiOperation and request destination that cause this IngressPolicy to apply.
685 #[serde(rename = "ingressTo")]
686 pub ingress_to: Option<IngressTo>,
687}
688
689impl common::Part for IngressPolicy {}
690
691/// The source that IngressPolicy authorizes access from.
692///
693/// This type is not used in any activity, and only used as *part* of another schema.
694///
695#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
696#[serde_with::serde_as]
697#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
698pub struct IngressSource {
699 /// An AccessLevel resource name that allow resources within the ServicePerimeters to be accessed from the internet. AccessLevels listed must be in the same policy as this ServicePerimeter. Referencing a nonexistent AccessLevel will cause an error. If no AccessLevel names are listed, resources within the perimeter can only be accessed via Google Cloud calls with request origins within the perimeter. Example: `accessPolicies/MY_POLICY/accessLevels/MY_LEVEL`. If a single `*` is specified for `access_level`, then all IngressSources will be allowed.
700 #[serde(rename = "accessLevel")]
701 pub access_level: Option<String>,
702 /// A Google Cloud resource that is allowed to ingress the perimeter. Requests from these resources will be allowed to access perimeter data. Currently only projects and VPCs are allowed. Project format: `projects/{project_number}` VPC network format: `//compute.googleapis.com/projects/{PROJECT_ID}/global/networks/{NAME}`. The project may be in any Google Cloud organization, not just the organization that the perimeter is defined in. `*` is not allowed, the case of allowing all Google Cloud resources only is not supported.
703 pub resource: Option<String>,
704}
705
706impl common::Part for IngressSource {}
707
708/// Defines the conditions under which an IngressPolicy matches a request. Conditions are based on information about the ApiOperation intended to be performed on the target resource of the request. The request must satisfy what is defined in `operations` AND `resources` in order to match.
709///
710/// This type is not used in any activity, and only used as *part* of another schema.
711///
712#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
713#[serde_with::serde_as]
714#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
715pub struct IngressTo {
716 /// A list of ApiOperations allowed to be performed by the sources specified in corresponding IngressFrom in this ServicePerimeter.
717 pub operations: Option<Vec<ApiOperation>>,
718 /// A list of resources, currently only projects in the form `projects/`, protected by this ServicePerimeter that are allowed to be accessed by sources defined in the corresponding IngressFrom. If a single `*` is specified, then access to all resources inside the perimeter are allowed.
719 pub resources: Option<Vec<String>>,
720}
721
722impl common::Part for IngressTo {}
723
724/// A response to `ListAccessLevelsRequest`.
725///
726/// # Activities
727///
728/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
729/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
730///
731/// * [access levels list access policies](AccessPolicyAccessLevelListCall) (response)
732#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
733#[serde_with::serde_as]
734#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
735pub struct ListAccessLevelsResponse {
736 /// List of the Access Level instances.
737 #[serde(rename = "accessLevels")]
738 pub access_levels: Option<Vec<AccessLevel>>,
739 /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
740 #[serde(rename = "nextPageToken")]
741 pub next_page_token: Option<String>,
742}
743
744impl common::ResponseResult for ListAccessLevelsResponse {}
745
746/// A response to `ListAccessPoliciesRequest`.
747///
748/// # Activities
749///
750/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
751/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
752///
753/// * [list access policies](AccessPolicyListCall) (response)
754#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
755#[serde_with::serde_as]
756#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
757pub struct ListAccessPoliciesResponse {
758 /// List of the AccessPolicy instances.
759 #[serde(rename = "accessPolicies")]
760 pub access_policies: Option<Vec<AccessPolicy>>,
761 /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
762 #[serde(rename = "nextPageToken")]
763 pub next_page_token: Option<String>,
764}
765
766impl common::ResponseResult for ListAccessPoliciesResponse {}
767
768/// A response to `ListAuthorizedOrgsDescsRequest`.
769///
770/// # Activities
771///
772/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
773/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
774///
775/// * [authorized orgs descs list access policies](AccessPolicyAuthorizedOrgsDescListCall) (response)
776#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
777#[serde_with::serde_as]
778#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
779pub struct ListAuthorizedOrgsDescsResponse {
780 /// List of all the Authorized Orgs Desc instances.
781 #[serde(rename = "authorizedOrgsDescs")]
782 pub authorized_orgs_descs: Option<Vec<AuthorizedOrgsDesc>>,
783 /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
784 #[serde(rename = "nextPageToken")]
785 pub next_page_token: Option<String>,
786}
787
788impl common::ResponseResult for ListAuthorizedOrgsDescsResponse {}
789
790/// Response of ListGcpUserAccessBindings.
791///
792/// # Activities
793///
794/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
795/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
796///
797/// * [gcp user access bindings list organizations](OrganizationGcpUserAccessBindingListCall) (response)
798#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
799#[serde_with::serde_as]
800#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
801pub struct ListGcpUserAccessBindingsResponse {
802 /// GcpUserAccessBinding
803 #[serde(rename = "gcpUserAccessBindings")]
804 pub gcp_user_access_bindings: Option<Vec<GcpUserAccessBinding>>,
805 /// Token to get the next page of items. If blank, there are no more items.
806 #[serde(rename = "nextPageToken")]
807 pub next_page_token: Option<String>,
808}
809
810impl common::ResponseResult for ListGcpUserAccessBindingsResponse {}
811
812/// The response message for Operations.ListOperations.
813///
814/// # Activities
815///
816/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
817/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
818///
819/// * [list operations](OperationListCall) (response)
820#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
821#[serde_with::serde_as]
822#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
823pub struct ListOperationsResponse {
824 /// The standard List next-page token.
825 #[serde(rename = "nextPageToken")]
826 pub next_page_token: Option<String>,
827 /// A list of operations that matches the specified filter in the request.
828 pub operations: Option<Vec<Operation>>,
829}
830
831impl common::ResponseResult for ListOperationsResponse {}
832
833/// A response to `ListServicePerimetersRequest`.
834///
835/// # Activities
836///
837/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
838/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
839///
840/// * [service perimeters list access policies](AccessPolicyServicePerimeterListCall) (response)
841#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
842#[serde_with::serde_as]
843#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
844pub struct ListServicePerimetersResponse {
845 /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
846 #[serde(rename = "nextPageToken")]
847 pub next_page_token: Option<String>,
848 /// List of the Service Perimeter instances.
849 #[serde(rename = "servicePerimeters")]
850 pub service_perimeters: Option<Vec<ServicePerimeter>>,
851}
852
853impl common::ResponseResult for ListServicePerimetersResponse {}
854
855/// A response to `ListSupportedServicesRequest`.
856///
857/// # Activities
858///
859/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
860/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
861///
862/// * [list services](ServiceListCall) (response)
863#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
864#[serde_with::serde_as]
865#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
866pub struct ListSupportedServicesResponse {
867 /// The pagination token to retrieve the next page of results. If the value is empty, no further results remain.
868 #[serde(rename = "nextPageToken")]
869 pub next_page_token: Option<String>,
870 /// List of services supported by VPC Service Controls instances.
871 #[serde(rename = "supportedServices")]
872 pub supported_services: Option<Vec<SupportedService>>,
873}
874
875impl common::ResponseResult for ListSupportedServicesResponse {}
876
877/// An allowed method or permission of a service specified in ApiOperation.
878///
879/// This type is not used in any activity, and only used as *part* of another schema.
880///
881#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
882#[serde_with::serde_as]
883#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
884pub struct MethodSelector {
885 /// A valid method name for the corresponding `service_name` in ApiOperation. If `*` is used as the value for the `method`, then ALL methods and permissions are allowed.
886 pub method: Option<String>,
887 /// A valid Cloud IAM permission for the corresponding `service_name` in ApiOperation.
888 pub permission: Option<String>,
889}
890
891impl common::Part for MethodSelector {}
892
893/// This resource represents a long-running operation that is the result of a network API call.
894///
895/// # Activities
896///
897/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
898/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
899///
900/// * [access levels create access policies](AccessPolicyAccessLevelCreateCall) (response)
901/// * [access levels delete access policies](AccessPolicyAccessLevelDeleteCall) (response)
902/// * [access levels patch access policies](AccessPolicyAccessLevelPatchCall) (response)
903/// * [access levels replace all access policies](AccessPolicyAccessLevelReplaceAllCall) (response)
904/// * [authorized orgs descs create access policies](AccessPolicyAuthorizedOrgsDescCreateCall) (response)
905/// * [authorized orgs descs delete access policies](AccessPolicyAuthorizedOrgsDescDeleteCall) (response)
906/// * [authorized orgs descs patch access policies](AccessPolicyAuthorizedOrgsDescPatchCall) (response)
907/// * [service perimeters commit access policies](AccessPolicyServicePerimeterCommitCall) (response)
908/// * [service perimeters create access policies](AccessPolicyServicePerimeterCreateCall) (response)
909/// * [service perimeters delete access policies](AccessPolicyServicePerimeterDeleteCall) (response)
910/// * [service perimeters patch access policies](AccessPolicyServicePerimeterPatchCall) (response)
911/// * [service perimeters replace all access policies](AccessPolicyServicePerimeterReplaceAllCall) (response)
912/// * [create access policies](AccessPolicyCreateCall) (response)
913/// * [delete access policies](AccessPolicyDeleteCall) (response)
914/// * [patch access policies](AccessPolicyPatchCall) (response)
915/// * [cancel operations](OperationCancelCall) (none)
916/// * [delete operations](OperationDeleteCall) (none)
917/// * [get operations](OperationGetCall) (response)
918/// * [list operations](OperationListCall) (none)
919/// * [gcp user access bindings create organizations](OrganizationGcpUserAccessBindingCreateCall) (response)
920/// * [gcp user access bindings delete organizations](OrganizationGcpUserAccessBindingDeleteCall) (response)
921/// * [gcp user access bindings patch organizations](OrganizationGcpUserAccessBindingPatchCall) (response)
922#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
923#[serde_with::serde_as]
924#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
925pub struct Operation {
926 /// 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.
927 pub done: Option<bool>,
928 /// The error result of the operation in case of failure or cancellation.
929 pub error: Option<Status>,
930 /// 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.
931 pub metadata: Option<HashMap<String, serde_json::Value>>,
932 /// 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}`.
933 pub name: Option<String>,
934 /// The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
935 pub response: Option<HashMap<String, serde_json::Value>>,
936}
937
938impl common::Resource for Operation {}
939impl common::ResponseResult for Operation {}
940
941/// A restriction on the OS type and version of devices making requests.
942///
943/// This type is not used in any activity, and only used as *part* of another schema.
944///
945#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
946#[serde_with::serde_as]
947#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
948pub struct OsConstraint {
949 /// 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"`.
950 #[serde(rename = "minimumVersion")]
951 pub minimum_version: Option<String>,
952 /// Required. The allowed OS type.
953 #[serde(rename = "osType")]
954 pub os_type: Option<String>,
955 /// 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.
956 #[serde(rename = "requireVerifiedChromeOs")]
957 pub require_verified_chrome_os: Option<bool>,
958}
959
960impl common::Part for OsConstraint {}
961
962/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
963///
964/// # Activities
965///
966/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
967/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
968///
969/// * [get iam policy access policies](AccessPolicyGetIamPolicyCall) (response)
970/// * [set iam policy access policies](AccessPolicySetIamPolicyCall) (response)
971#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
972#[serde_with::serde_as]
973#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
974pub struct Policy {
975 /// Specifies cloud audit logging configuration for this policy.
976 #[serde(rename = "auditConfigs")]
977 pub audit_configs: Option<Vec<AuditConfig>>,
978 /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
979 pub bindings: Option<Vec<Binding>>,
980 /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
981 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
982 pub etag: Option<Vec<u8>>,
983 /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
984 pub version: Option<i32>,
985}
986
987impl common::ResponseResult for Policy {}
988
989/// A request to replace all existing Access Levels in an Access Policy with the Access Levels provided. This is done atomically.
990///
991/// # Activities
992///
993/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
994/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
995///
996/// * [access levels replace all access policies](AccessPolicyAccessLevelReplaceAllCall) (request)
997#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
998#[serde_with::serde_as]
999#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1000pub struct ReplaceAccessLevelsRequest {
1001 /// Required. The desired Access Levels that should replace all existing Access Levels in the Access Policy.
1002 #[serde(rename = "accessLevels")]
1003 pub access_levels: Option<Vec<AccessLevel>>,
1004 /// Optional. The etag for the version of the Access Policy that this replace operation is to be performed on. If, at the time of replace, the etag for the Access Policy stored in Access Context Manager is different from the specified etag, then the replace operation will not be performed and the call will fail. This field is not required. If etag is not provided, the operation will be performed as if a valid etag is provided.
1005 pub etag: Option<String>,
1006}
1007
1008impl common::RequestValue for ReplaceAccessLevelsRequest {}
1009
1010/// A request to replace all existing Service Perimeters in an Access Policy with the Service Perimeters provided. This is done atomically.
1011///
1012/// # Activities
1013///
1014/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1015/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1016///
1017/// * [service perimeters replace all access policies](AccessPolicyServicePerimeterReplaceAllCall) (request)
1018#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1019#[serde_with::serde_as]
1020#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1021pub struct ReplaceServicePerimetersRequest {
1022 /// Optional. The etag for the version of the Access Policy that this replace operation is to be performed on. If, at the time of replace, the etag for the Access Policy stored in Access Context Manager is different from the specified etag, then the replace operation will not be performed and the call will fail. This field is not required. If etag is not provided, the operation will be performed as if a valid etag is provided.
1023 pub etag: Option<String>,
1024 /// Required. The desired Service Perimeters that should replace all existing Service Perimeters in the Access Policy.
1025 #[serde(rename = "servicePerimeters")]
1026 pub service_perimeters: Option<Vec<ServicePerimeter>>,
1027}
1028
1029impl common::RequestValue for ReplaceServicePerimetersRequest {}
1030
1031/// `ServicePerimeter` describes a set of Google Cloud resources which can freely import and export data amongst themselves, but not export outside of the `ServicePerimeter`. If a request with a source within this `ServicePerimeter` has a target outside of the `ServicePerimeter`, the request will be blocked. Otherwise the request is allowed. There are two types of Service Perimeter - Regular and Bridge. Regular Service Perimeters cannot overlap, a single Google Cloud project or VPC network can only belong to a single regular Service Perimeter. Service Perimeter Bridges can contain only Google Cloud projects as members, a single Google Cloud project may belong to multiple Service Perimeter Bridges.
1032///
1033/// # Activities
1034///
1035/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1036/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1037///
1038/// * [service perimeters create access policies](AccessPolicyServicePerimeterCreateCall) (request)
1039/// * [service perimeters get access policies](AccessPolicyServicePerimeterGetCall) (response)
1040/// * [service perimeters patch access policies](AccessPolicyServicePerimeterPatchCall) (request)
1041#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1042#[serde_with::serde_as]
1043#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1044pub struct ServicePerimeter {
1045 /// Description of the `ServicePerimeter` and its use. Does not affect behavior.
1046 pub description: Option<String>,
1047 /// Identifier. Resource name for the `ServicePerimeter`. Format: `accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}`. The `service_perimeter` component must begin with a letter, followed by alphanumeric characters or `_`. After you create a `ServicePerimeter`, you cannot change its `name`.
1048 pub name: Option<String>,
1049 /// Perimeter type indicator. A single project or VPC network is allowed to be a member of single regular perimeter, but multiple service perimeter bridges. A project cannot be a included in a perimeter bridge without being included in regular perimeter. For perimeter bridges, the restricted service list as well as access level lists must be empty.
1050 #[serde(rename = "perimeterType")]
1051 pub perimeter_type: Option<String>,
1052 /// Proposed (or dry run) ServicePerimeter configuration. This configuration allows to specify and test ServicePerimeter configuration without enforcing actual access restrictions. Only allowed to be set when the "use_explicit_dry_run_spec" flag is set.
1053 pub spec: Option<ServicePerimeterConfig>,
1054 /// Current ServicePerimeter configuration. Specifies sets of resources, restricted services and access levels that determine perimeter content and boundaries.
1055 pub status: Option<ServicePerimeterConfig>,
1056 /// Human readable title. Must be unique within the Policy.
1057 pub title: Option<String>,
1058 /// Use explicit dry run spec flag. Ordinarily, a dry-run spec implicitly exists for all Service Perimeters, and that spec is identical to the status for those Service Perimeters. When this flag is set, it inhibits the generation of the implicit spec, thereby allowing the user to explicitly provide a configuration ("spec") to use in a dry-run version of the Service Perimeter. This allows the user to test changes to the enforced config ("status") without actually enforcing them. This testing is done through analyzing the differences between currently enforced and suggested restrictions. use_explicit_dry_run_spec must bet set to True if any of the fields in the spec are set to non-default values.
1059 #[serde(rename = "useExplicitDryRunSpec")]
1060 pub use_explicit_dry_run_spec: Option<bool>,
1061}
1062
1063impl common::RequestValue for ServicePerimeter {}
1064impl common::ResponseResult for ServicePerimeter {}
1065
1066/// `ServicePerimeterConfig` specifies a set of Google Cloud resources that describe specific Service Perimeter configuration.
1067///
1068/// This type is not used in any activity, and only used as *part* of another schema.
1069///
1070#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1071#[serde_with::serde_as]
1072#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1073pub struct ServicePerimeterConfig {
1074 /// 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.
1075 #[serde(rename = "accessLevels")]
1076 pub access_levels: Option<Vec<String>>,
1077 /// List of EgressPolicies to apply to the perimeter. A perimeter may have multiple EgressPolicies, each of which is evaluated separately. Access is granted if any EgressPolicy grants it. Must be empty for a perimeter bridge.
1078 #[serde(rename = "egressPolicies")]
1079 pub egress_policies: Option<Vec<EgressPolicy>>,
1080 /// List of IngressPolicies to apply to the perimeter. A perimeter may have multiple IngressPolicies, each of which is evaluated separately. Access is granted if any Ingress Policy grants it. Must be empty for a perimeter bridge.
1081 #[serde(rename = "ingressPolicies")]
1082 pub ingress_policies: Option<Vec<IngressPolicy>>,
1083 /// A list of Google Cloud resources that are inside of the service perimeter. Currently only projects and VPCs are allowed. Project format: `projects/{project_number}` VPC network format: `//compute.googleapis.com/projects/{PROJECT_ID}/global/networks/{NAME}`.
1084 pub resources: Option<Vec<String>>,
1085 /// Google Cloud services that are subject to the Service Perimeter restrictions. For example, if `storage.googleapis.com` is specified, access to the storage buckets inside the perimeter must meet the perimeter's access restrictions.
1086 #[serde(rename = "restrictedServices")]
1087 pub restricted_services: Option<Vec<String>>,
1088 /// Configuration for APIs allowed within Perimeter.
1089 #[serde(rename = "vpcAccessibleServices")]
1090 pub vpc_accessible_services: Option<VpcAccessibleServices>,
1091}
1092
1093impl common::Part for ServicePerimeterConfig {}
1094
1095/// Request message for `SetIamPolicy` method.
1096///
1097/// # Activities
1098///
1099/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1100/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1101///
1102/// * [set iam policy access policies](AccessPolicySetIamPolicyCall) (request)
1103#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1104#[serde_with::serde_as]
1105#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1106pub struct SetIamPolicyRequest {
1107 /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
1108 pub policy: Option<Policy>,
1109 /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
1110 #[serde(rename = "updateMask")]
1111 pub update_mask: Option<common::FieldMask>,
1112}
1113
1114impl common::RequestValue for SetIamPolicyRequest {}
1115
1116/// 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).
1117///
1118/// This type is not used in any activity, and only used as *part* of another schema.
1119///
1120#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1121#[serde_with::serde_as]
1122#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1123pub struct Status {
1124 /// The status code, which should be an enum value of google.rpc.Code.
1125 pub code: Option<i32>,
1126 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1127 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1128 /// 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.
1129 pub message: Option<String>,
1130}
1131
1132impl common::Part for Status {}
1133
1134/// `SupportedService` specifies the VPC Service Controls and its properties.
1135///
1136/// # Activities
1137///
1138/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1139/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1140///
1141/// * [get services](ServiceGetCall) (response)
1142#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1143#[serde_with::serde_as]
1144#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1145pub struct SupportedService {
1146 /// True if the service is available on the restricted VIP. Services on the restricted VIP typically either support VPC Service Controls or are core infrastructure services required for the functioning of Google Cloud.
1147 #[serde(rename = "availableOnRestrictedVip")]
1148 pub available_on_restricted_vip: Option<bool>,
1149 /// True if the service is supported with some limitations. Check [documentation](https://cloud.google.com/vpc-service-controls/docs/supported-products) for details.
1150 #[serde(rename = "knownLimitations")]
1151 pub known_limitations: Option<bool>,
1152 /// The service name or address of the supported service, such as `service.googleapis.com`.
1153 pub name: Option<String>,
1154 /// The support stage of the service.
1155 #[serde(rename = "serviceSupportStage")]
1156 pub service_support_stage: Option<String>,
1157 /// The support stage of the service.
1158 #[serde(rename = "supportStage")]
1159 pub support_stage: Option<String>,
1160 /// The list of the supported methods. This field exists only in response to GetSupportedService
1161 #[serde(rename = "supportedMethods")]
1162 pub supported_methods: Option<Vec<MethodSelector>>,
1163 /// The name of the supported product, such as 'Cloud Product API'.
1164 pub title: Option<String>,
1165}
1166
1167impl common::ResponseResult for SupportedService {}
1168
1169/// Request message for `TestIamPermissions` method.
1170///
1171/// # Activities
1172///
1173/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1174/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1175///
1176/// * [access levels test iam permissions access policies](AccessPolicyAccessLevelTestIamPermissionCall) (request)
1177/// * [service perimeters test iam permissions access policies](AccessPolicyServicePerimeterTestIamPermissionCall) (request)
1178/// * [test iam permissions access policies](AccessPolicyTestIamPermissionCall) (request)
1179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1180#[serde_with::serde_as]
1181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1182pub struct TestIamPermissionsRequest {
1183 /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
1184 pub permissions: Option<Vec<String>>,
1185}
1186
1187impl common::RequestValue for TestIamPermissionsRequest {}
1188
1189/// Response message for `TestIamPermissions` method.
1190///
1191/// # Activities
1192///
1193/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1194/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1195///
1196/// * [access levels test iam permissions access policies](AccessPolicyAccessLevelTestIamPermissionCall) (response)
1197/// * [service perimeters test iam permissions access policies](AccessPolicyServicePerimeterTestIamPermissionCall) (response)
1198/// * [test iam permissions access policies](AccessPolicyTestIamPermissionCall) (response)
1199#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1200#[serde_with::serde_as]
1201#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1202pub struct TestIamPermissionsResponse {
1203 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
1204 pub permissions: Option<Vec<String>>,
1205}
1206
1207impl common::ResponseResult for TestIamPermissionsResponse {}
1208
1209/// Specifies how APIs are allowed to communicate within the Service Perimeter.
1210///
1211/// This type is not used in any activity, and only used as *part* of another schema.
1212///
1213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1214#[serde_with::serde_as]
1215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1216pub struct VpcAccessibleServices {
1217 /// 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.
1218 #[serde(rename = "allowedServices")]
1219 pub allowed_services: Option<Vec<String>>,
1220 /// Whether to restrict API calls within the Service Perimeter to the list of APIs specified in 'allowed_services'.
1221 #[serde(rename = "enableRestriction")]
1222 pub enable_restriction: Option<bool>,
1223}
1224
1225impl common::Part for VpcAccessibleServices {}
1226
1227/// The originating network source in Google Cloud.
1228///
1229/// This type is not used in any activity, and only used as *part* of another schema.
1230///
1231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1232#[serde_with::serde_as]
1233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1234pub struct VpcNetworkSource {
1235 /// Sub-segment ranges of a VPC network.
1236 #[serde(rename = "vpcSubnetwork")]
1237 pub vpc_subnetwork: Option<VpcSubNetwork>,
1238}
1239
1240impl common::Part for VpcNetworkSource {}
1241
1242/// Sub-segment ranges inside of a VPC Network.
1243///
1244/// This type is not used in any activity, and only used as *part* of another schema.
1245///
1246#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1247#[serde_with::serde_as]
1248#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1249pub struct VpcSubNetwork {
1250 /// Required. Network name. If the network is not part of the organization, the `compute.network.get` permission must be granted to the caller. Format: `//compute.googleapis.com/projects/{PROJECT_ID}/global/networks/{NETWORK_NAME}` Example: `//compute.googleapis.com/projects/my-project/global/networks/network-1`
1251 pub network: Option<String>,
1252 /// CIDR block IP subnetwork specification. The IP address must be an IPv4 address and can be a public or private IP address. Note that for a CIDR IP address block, the specified IP address portion must be properly truncated (i.e. all the host bits must be zero) or the input is considered malformed. For example, "192.0.2.0/24" is accepted but "192.0.2.1/24" is not. If empty, all IP addresses are allowed.
1253 #[serde(rename = "vpcIpSubnetworks")]
1254 pub vpc_ip_subnetworks: Option<Vec<String>>,
1255}
1256
1257impl common::Part for VpcSubNetwork {}
1258
1259// ###################
1260// MethodBuilders ###
1261// #################
1262
1263/// A builder providing access to all methods supported on *accessPolicy* resources.
1264/// It is not used directly, but through the [`AccessContextManager`] hub.
1265///
1266/// # Example
1267///
1268/// Instantiate a resource builder
1269///
1270/// ```test_harness,no_run
1271/// extern crate hyper;
1272/// extern crate hyper_rustls;
1273/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
1274///
1275/// # async fn dox() {
1276/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1277///
1278/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1279/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1280/// secret,
1281/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1282/// ).build().await.unwrap();
1283///
1284/// let client = hyper_util::client::legacy::Client::builder(
1285/// hyper_util::rt::TokioExecutor::new()
1286/// )
1287/// .build(
1288/// hyper_rustls::HttpsConnectorBuilder::new()
1289/// .with_native_roots()
1290/// .unwrap()
1291/// .https_or_http()
1292/// .enable_http1()
1293/// .build()
1294/// );
1295/// let mut hub = AccessContextManager::new(client, auth);
1296/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1297/// // like `access_levels_create(...)`, `access_levels_delete(...)`, `access_levels_get(...)`, `access_levels_list(...)`, `access_levels_patch(...)`, `access_levels_replace_all(...)`, `access_levels_test_iam_permissions(...)`, `authorized_orgs_descs_create(...)`, `authorized_orgs_descs_delete(...)`, `authorized_orgs_descs_get(...)`, `authorized_orgs_descs_list(...)`, `authorized_orgs_descs_patch(...)`, `create(...)`, `delete(...)`, `get(...)`, `get_iam_policy(...)`, `list(...)`, `patch(...)`, `service_perimeters_commit(...)`, `service_perimeters_create(...)`, `service_perimeters_delete(...)`, `service_perimeters_get(...)`, `service_perimeters_list(...)`, `service_perimeters_patch(...)`, `service_perimeters_replace_all(...)`, `service_perimeters_test_iam_permissions(...)`, `set_iam_policy(...)` and `test_iam_permissions(...)`
1298/// // to build up your call.
1299/// let rb = hub.access_policies();
1300/// # }
1301/// ```
1302pub struct AccessPolicyMethods<'a, C>
1303where
1304 C: 'a,
1305{
1306 hub: &'a AccessContextManager<C>,
1307}
1308
1309impl<'a, C> common::MethodsBuilder for AccessPolicyMethods<'a, C> {}
1310
1311impl<'a, C> AccessPolicyMethods<'a, C> {
1312 /// Create a builder to help you perform the following task:
1313 ///
1314 /// Creates an access level. The long-running operation from this RPC has a successful status after the access level propagates to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
1315 ///
1316 /// # Arguments
1317 ///
1318 /// * `request` - No description provided.
1319 /// * `parent` - Required. Resource name for the access policy which owns this Access Level. Format: `accessPolicies/{policy_id}`
1320 pub fn access_levels_create(
1321 &self,
1322 request: AccessLevel,
1323 parent: &str,
1324 ) -> AccessPolicyAccessLevelCreateCall<'a, C> {
1325 AccessPolicyAccessLevelCreateCall {
1326 hub: self.hub,
1327 _request: request,
1328 _parent: parent.to_string(),
1329 _delegate: Default::default(),
1330 _additional_params: Default::default(),
1331 _scopes: Default::default(),
1332 }
1333 }
1334
1335 /// Create a builder to help you perform the following task:
1336 ///
1337 /// Deletes an access level based on the resource name. The long-running operation from this RPC has a successful status after the access level has been removed from long-lasting storage.
1338 ///
1339 /// # Arguments
1340 ///
1341 /// * `name` - Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
1342 pub fn access_levels_delete(&self, name: &str) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
1343 AccessPolicyAccessLevelDeleteCall {
1344 hub: self.hub,
1345 _name: name.to_string(),
1346 _delegate: Default::default(),
1347 _additional_params: Default::default(),
1348 _scopes: Default::default(),
1349 }
1350 }
1351
1352 /// Create a builder to help you perform the following task:
1353 ///
1354 /// Gets an access level based on the resource name.
1355 ///
1356 /// # Arguments
1357 ///
1358 /// * `name` - Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
1359 pub fn access_levels_get(&self, name: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
1360 AccessPolicyAccessLevelGetCall {
1361 hub: self.hub,
1362 _name: name.to_string(),
1363 _access_level_format: Default::default(),
1364 _delegate: Default::default(),
1365 _additional_params: Default::default(),
1366 _scopes: Default::default(),
1367 }
1368 }
1369
1370 /// Create a builder to help you perform the following task:
1371 ///
1372 /// Lists all access levels for an access policy.
1373 ///
1374 /// # Arguments
1375 ///
1376 /// * `parent` - Required. Resource name for the access policy to list Access Levels from. Format: `accessPolicies/{policy_id}`
1377 pub fn access_levels_list(&self, parent: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
1378 AccessPolicyAccessLevelListCall {
1379 hub: self.hub,
1380 _parent: parent.to_string(),
1381 _page_token: Default::default(),
1382 _page_size: Default::default(),
1383 _access_level_format: Default::default(),
1384 _delegate: Default::default(),
1385 _additional_params: Default::default(),
1386 _scopes: Default::default(),
1387 }
1388 }
1389
1390 /// Create a builder to help you perform the following task:
1391 ///
1392 /// Updates an access level. The long-running operation from this RPC has a successful status after the changes to the access level propagate to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
1393 ///
1394 /// # Arguments
1395 ///
1396 /// * `request` - No description provided.
1397 /// * `name` - Identifier. Resource name for the `AccessLevel`. Format: `accessPolicies/{access_policy}/accessLevels/{access_level}`. The `access_level` component must begin with a letter, followed by alphanumeric characters or `_`. Its maximum length is 50 characters. After you create an `AccessLevel`, you cannot change its `name`.
1398 pub fn access_levels_patch(
1399 &self,
1400 request: AccessLevel,
1401 name: &str,
1402 ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
1403 AccessPolicyAccessLevelPatchCall {
1404 hub: self.hub,
1405 _request: request,
1406 _name: name.to_string(),
1407 _update_mask: Default::default(),
1408 _delegate: Default::default(),
1409 _additional_params: Default::default(),
1410 _scopes: Default::default(),
1411 }
1412 }
1413
1414 /// Create a builder to help you perform the following task:
1415 ///
1416 /// Replaces all existing access levels in an access policy with the access levels provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. If the replacement contains errors, an error response is returned for the first error encountered. Upon error, the replacement is cancelled, and existing access levels are not affected. The Operation.response field contains ReplaceAccessLevelsResponse. Removing access levels contained in existing service perimeters result in an error.
1417 ///
1418 /// # Arguments
1419 ///
1420 /// * `request` - No description provided.
1421 /// * `parent` - Required. Resource name for the access policy which owns these Access Levels. Format: `accessPolicies/{policy_id}`
1422 pub fn access_levels_replace_all(
1423 &self,
1424 request: ReplaceAccessLevelsRequest,
1425 parent: &str,
1426 ) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
1427 AccessPolicyAccessLevelReplaceAllCall {
1428 hub: self.hub,
1429 _request: request,
1430 _parent: parent.to_string(),
1431 _delegate: Default::default(),
1432 _additional_params: Default::default(),
1433 _scopes: Default::default(),
1434 }
1435 }
1436
1437 /// Create a builder to help you perform the following task:
1438 ///
1439 /// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
1440 ///
1441 /// # Arguments
1442 ///
1443 /// * `request` - No description provided.
1444 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1445 pub fn access_levels_test_iam_permissions(
1446 &self,
1447 request: TestIamPermissionsRequest,
1448 resource: &str,
1449 ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
1450 AccessPolicyAccessLevelTestIamPermissionCall {
1451 hub: self.hub,
1452 _request: request,
1453 _resource: resource.to_string(),
1454 _delegate: Default::default(),
1455 _additional_params: Default::default(),
1456 _scopes: Default::default(),
1457 }
1458 }
1459
1460 /// Create a builder to help you perform the following task:
1461 ///
1462 /// Creates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. The name of this `AuthorizedOrgsDesc` will be assigned during creation.
1463 ///
1464 /// # Arguments
1465 ///
1466 /// * `request` - No description provided.
1467 /// * `parent` - Required. Resource name for the access policy which owns this Authorized Orgs Desc. Format: `accessPolicies/{policy_id}`
1468 pub fn authorized_orgs_descs_create(
1469 &self,
1470 request: AuthorizedOrgsDesc,
1471 parent: &str,
1472 ) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
1473 AccessPolicyAuthorizedOrgsDescCreateCall {
1474 hub: self.hub,
1475 _request: request,
1476 _parent: parent.to_string(),
1477 _delegate: Default::default(),
1478 _additional_params: Default::default(),
1479 _scopes: Default::default(),
1480 }
1481 }
1482
1483 /// Create a builder to help you perform the following task:
1484 ///
1485 /// Deletes an authorized orgs desc based on the resource name. The long-running operation from this RPC has a successful status after the authorized orgs desc is removed from long-lasting storage.
1486 ///
1487 /// # Arguments
1488 ///
1489 /// * `name` - Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDesc/{authorized_orgs_desc_id}`
1490 pub fn authorized_orgs_descs_delete(
1491 &self,
1492 name: &str,
1493 ) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
1494 AccessPolicyAuthorizedOrgsDescDeleteCall {
1495 hub: self.hub,
1496 _name: name.to_string(),
1497 _delegate: Default::default(),
1498 _additional_params: Default::default(),
1499 _scopes: Default::default(),
1500 }
1501 }
1502
1503 /// Create a builder to help you perform the following task:
1504 ///
1505 /// Gets an authorized orgs desc based on the resource name.
1506 ///
1507 /// # Arguments
1508 ///
1509 /// * `name` - Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDescs/{authorized_orgs_descs_id}`
1510 pub fn authorized_orgs_descs_get(
1511 &self,
1512 name: &str,
1513 ) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
1514 AccessPolicyAuthorizedOrgsDescGetCall {
1515 hub: self.hub,
1516 _name: name.to_string(),
1517 _delegate: Default::default(),
1518 _additional_params: Default::default(),
1519 _scopes: Default::default(),
1520 }
1521 }
1522
1523 /// Create a builder to help you perform the following task:
1524 ///
1525 /// Lists all authorized orgs descs for an access policy.
1526 ///
1527 /// # Arguments
1528 ///
1529 /// * `parent` - Required. Resource name for the access policy to list Authorized Orgs Desc from. Format: `accessPolicies/{policy_id}`
1530 pub fn authorized_orgs_descs_list(
1531 &self,
1532 parent: &str,
1533 ) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
1534 AccessPolicyAuthorizedOrgsDescListCall {
1535 hub: self.hub,
1536 _parent: parent.to_string(),
1537 _page_token: Default::default(),
1538 _page_size: Default::default(),
1539 _delegate: Default::default(),
1540 _additional_params: Default::default(),
1541 _scopes: Default::default(),
1542 }
1543 }
1544
1545 /// Create a builder to help you perform the following task:
1546 ///
1547 /// Updates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. Only the organization list in `AuthorizedOrgsDesc` can be updated. The name, authorization_type, asset_type and authorization_direction cannot be updated.
1548 ///
1549 /// # Arguments
1550 ///
1551 /// * `request` - No description provided.
1552 /// * `name` - Identifier. Resource name for the `AuthorizedOrgsDesc`. Format: `accessPolicies/{access_policy}/authorizedOrgsDescs/{authorized_orgs_desc}`. The `authorized_orgs_desc` component must begin with a letter, followed by alphanumeric characters or `_`. After you create an `AuthorizedOrgsDesc`, you cannot change its `name`.
1553 pub fn authorized_orgs_descs_patch(
1554 &self,
1555 request: AuthorizedOrgsDesc,
1556 name: &str,
1557 ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
1558 AccessPolicyAuthorizedOrgsDescPatchCall {
1559 hub: self.hub,
1560 _request: request,
1561 _name: name.to_string(),
1562 _update_mask: Default::default(),
1563 _delegate: Default::default(),
1564 _additional_params: Default::default(),
1565 _scopes: Default::default(),
1566 }
1567 }
1568
1569 /// Create a builder to help you perform the following task:
1570 ///
1571 /// Commits the dry-run specification for all the service perimeters in an access policy. A commit operation on a service perimeter involves copying its `spec` field to the `status` field of the service perimeter. Only service perimeters with `use_explicit_dry_run_spec` field set to true are affected by a commit operation. The long-running operation from this RPC has a successful status after the dry-run specifications for all the service perimeters have been committed. If a commit fails, it causes the long-running operation to return an error response and the entire commit operation is cancelled. When successful, the Operation.response field contains CommitServicePerimetersResponse. The `dry_run` and the `spec` fields are cleared after a successful commit operation.
1572 ///
1573 /// # Arguments
1574 ///
1575 /// * `request` - No description provided.
1576 /// * `parent` - Required. Resource name for the parent Access Policy which owns all Service Perimeters in scope for the commit operation. Format: `accessPolicies/{policy_id}`
1577 pub fn service_perimeters_commit(
1578 &self,
1579 request: CommitServicePerimetersRequest,
1580 parent: &str,
1581 ) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
1582 AccessPolicyServicePerimeterCommitCall {
1583 hub: self.hub,
1584 _request: request,
1585 _parent: parent.to_string(),
1586 _delegate: Default::default(),
1587 _additional_params: Default::default(),
1588 _scopes: Default::default(),
1589 }
1590 }
1591
1592 /// Create a builder to help you perform the following task:
1593 ///
1594 /// Creates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
1595 ///
1596 /// # Arguments
1597 ///
1598 /// * `request` - No description provided.
1599 /// * `parent` - Required. Resource name for the access policy which owns this Service Perimeter. Format: `accessPolicies/{policy_id}`
1600 pub fn service_perimeters_create(
1601 &self,
1602 request: ServicePerimeter,
1603 parent: &str,
1604 ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
1605 AccessPolicyServicePerimeterCreateCall {
1606 hub: self.hub,
1607 _request: request,
1608 _parent: parent.to_string(),
1609 _delegate: Default::default(),
1610 _additional_params: Default::default(),
1611 _scopes: Default::default(),
1612 }
1613 }
1614
1615 /// Create a builder to help you perform the following task:
1616 ///
1617 /// Deletes a service perimeter based on the resource name. The long-running operation from this RPC has a successful status after the service perimeter is removed from long-lasting storage.
1618 ///
1619 /// # Arguments
1620 ///
1621 /// * `name` - Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeter_id}`
1622 pub fn service_perimeters_delete(
1623 &self,
1624 name: &str,
1625 ) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
1626 AccessPolicyServicePerimeterDeleteCall {
1627 hub: self.hub,
1628 _name: name.to_string(),
1629 _delegate: Default::default(),
1630 _additional_params: Default::default(),
1631 _scopes: Default::default(),
1632 }
1633 }
1634
1635 /// Create a builder to help you perform the following task:
1636 ///
1637 /// Gets a service perimeter based on the resource name.
1638 ///
1639 /// # Arguments
1640 ///
1641 /// * `name` - Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeters_id}`
1642 pub fn service_perimeters_get(&self, name: &str) -> AccessPolicyServicePerimeterGetCall<'a, C> {
1643 AccessPolicyServicePerimeterGetCall {
1644 hub: self.hub,
1645 _name: name.to_string(),
1646 _delegate: Default::default(),
1647 _additional_params: Default::default(),
1648 _scopes: Default::default(),
1649 }
1650 }
1651
1652 /// Create a builder to help you perform the following task:
1653 ///
1654 /// Lists all service perimeters for an access policy.
1655 ///
1656 /// # Arguments
1657 ///
1658 /// * `parent` - Required. Resource name for the access policy to list Service Perimeters from. Format: `accessPolicies/{policy_id}`
1659 pub fn service_perimeters_list(
1660 &self,
1661 parent: &str,
1662 ) -> AccessPolicyServicePerimeterListCall<'a, C> {
1663 AccessPolicyServicePerimeterListCall {
1664 hub: self.hub,
1665 _parent: parent.to_string(),
1666 _page_token: Default::default(),
1667 _page_size: Default::default(),
1668 _delegate: Default::default(),
1669 _additional_params: Default::default(),
1670 _scopes: Default::default(),
1671 }
1672 }
1673
1674 /// Create a builder to help you perform the following task:
1675 ///
1676 /// Updates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
1677 ///
1678 /// # Arguments
1679 ///
1680 /// * `request` - No description provided.
1681 /// * `name` - Identifier. Resource name for the `ServicePerimeter`. Format: `accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}`. The `service_perimeter` component must begin with a letter, followed by alphanumeric characters or `_`. After you create a `ServicePerimeter`, you cannot change its `name`.
1682 pub fn service_perimeters_patch(
1683 &self,
1684 request: ServicePerimeter,
1685 name: &str,
1686 ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
1687 AccessPolicyServicePerimeterPatchCall {
1688 hub: self.hub,
1689 _request: request,
1690 _name: name.to_string(),
1691 _update_mask: Default::default(),
1692 _delegate: Default::default(),
1693 _additional_params: Default::default(),
1694 _scopes: Default::default(),
1695 }
1696 }
1697
1698 /// Create a builder to help you perform the following task:
1699 ///
1700 /// Replace all existing service perimeters in an access policy with the service perimeters provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. Replacements containing errors result in an error response for the first error encountered. Upon an error, replacement are cancelled and existing service perimeters are not affected. The Operation.response field contains ReplaceServicePerimetersResponse.
1701 ///
1702 /// # Arguments
1703 ///
1704 /// * `request` - No description provided.
1705 /// * `parent` - Required. Resource name for the access policy which owns these Service Perimeters. Format: `accessPolicies/{policy_id}`
1706 pub fn service_perimeters_replace_all(
1707 &self,
1708 request: ReplaceServicePerimetersRequest,
1709 parent: &str,
1710 ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
1711 AccessPolicyServicePerimeterReplaceAllCall {
1712 hub: self.hub,
1713 _request: request,
1714 _parent: parent.to_string(),
1715 _delegate: Default::default(),
1716 _additional_params: Default::default(),
1717 _scopes: Default::default(),
1718 }
1719 }
1720
1721 /// Create a builder to help you perform the following task:
1722 ///
1723 /// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
1724 ///
1725 /// # Arguments
1726 ///
1727 /// * `request` - No description provided.
1728 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1729 pub fn service_perimeters_test_iam_permissions(
1730 &self,
1731 request: TestIamPermissionsRequest,
1732 resource: &str,
1733 ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
1734 AccessPolicyServicePerimeterTestIamPermissionCall {
1735 hub: self.hub,
1736 _request: request,
1737 _resource: resource.to_string(),
1738 _delegate: Default::default(),
1739 _additional_params: Default::default(),
1740 _scopes: Default::default(),
1741 }
1742 }
1743
1744 /// Create a builder to help you perform the following task:
1745 ///
1746 /// Creates an access policy. This method fails if the organization already has an access policy. The long-running operation has a successful status after the access policy propagates to long-lasting storage. Syntactic and basic semantic errors are returned in `metadata` as a BadRequest proto.
1747 ///
1748 /// # Arguments
1749 ///
1750 /// * `request` - No description provided.
1751 pub fn create(&self, request: AccessPolicy) -> AccessPolicyCreateCall<'a, C> {
1752 AccessPolicyCreateCall {
1753 hub: self.hub,
1754 _request: request,
1755 _delegate: Default::default(),
1756 _additional_params: Default::default(),
1757 _scopes: Default::default(),
1758 }
1759 }
1760
1761 /// Create a builder to help you perform the following task:
1762 ///
1763 /// Deletes an access policy based on the resource name. The long-running operation has a successful status after the access policy is removed from long-lasting storage.
1764 ///
1765 /// # Arguments
1766 ///
1767 /// * `name` - Required. Resource name for the access policy to delete. Format `accessPolicies/{policy_id}`
1768 pub fn delete(&self, name: &str) -> AccessPolicyDeleteCall<'a, C> {
1769 AccessPolicyDeleteCall {
1770 hub: self.hub,
1771 _name: name.to_string(),
1772 _delegate: Default::default(),
1773 _additional_params: Default::default(),
1774 _scopes: Default::default(),
1775 }
1776 }
1777
1778 /// Create a builder to help you perform the following task:
1779 ///
1780 /// Returns an access policy based on the name.
1781 ///
1782 /// # Arguments
1783 ///
1784 /// * `name` - Required. Resource name for the access policy to get. Format `accessPolicies/{policy_id}`
1785 pub fn get(&self, name: &str) -> AccessPolicyGetCall<'a, C> {
1786 AccessPolicyGetCall {
1787 hub: self.hub,
1788 _name: name.to_string(),
1789 _delegate: Default::default(),
1790 _additional_params: Default::default(),
1791 _scopes: Default::default(),
1792 }
1793 }
1794
1795 /// Create a builder to help you perform the following task:
1796 ///
1797 /// Gets the IAM policy for the specified Access Context Manager access policy.
1798 ///
1799 /// # Arguments
1800 ///
1801 /// * `request` - No description provided.
1802 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1803 pub fn get_iam_policy(
1804 &self,
1805 request: GetIamPolicyRequest,
1806 resource: &str,
1807 ) -> AccessPolicyGetIamPolicyCall<'a, C> {
1808 AccessPolicyGetIamPolicyCall {
1809 hub: self.hub,
1810 _request: request,
1811 _resource: resource.to_string(),
1812 _delegate: Default::default(),
1813 _additional_params: Default::default(),
1814 _scopes: Default::default(),
1815 }
1816 }
1817
1818 /// Create a builder to help you perform the following task:
1819 ///
1820 /// Lists all access policies in an organization.
1821 pub fn list(&self) -> AccessPolicyListCall<'a, C> {
1822 AccessPolicyListCall {
1823 hub: self.hub,
1824 _parent: Default::default(),
1825 _page_token: Default::default(),
1826 _page_size: Default::default(),
1827 _delegate: Default::default(),
1828 _additional_params: Default::default(),
1829 _scopes: Default::default(),
1830 }
1831 }
1832
1833 /// Create a builder to help you perform the following task:
1834 ///
1835 /// Updates an access policy. The long-running operation from this RPC has a successful status after the changes to the access policy propagate to long-lasting storage.
1836 ///
1837 /// # Arguments
1838 ///
1839 /// * `request` - No description provided.
1840 /// * `name` - Output only. Identifier. Resource name of the `AccessPolicy`. Format: `accessPolicies/{access_policy}`
1841 pub fn patch(&self, request: AccessPolicy, name: &str) -> AccessPolicyPatchCall<'a, C> {
1842 AccessPolicyPatchCall {
1843 hub: self.hub,
1844 _request: request,
1845 _name: name.to_string(),
1846 _update_mask: Default::default(),
1847 _delegate: Default::default(),
1848 _additional_params: Default::default(),
1849 _scopes: Default::default(),
1850 }
1851 }
1852
1853 /// Create a builder to help you perform the following task:
1854 ///
1855 /// Sets the IAM policy for the specified Access Context Manager access policy. This method replaces the existing IAM policy on the access policy. The IAM policy controls the set of users who can perform specific operations on the Access Context Manager access policy.
1856 ///
1857 /// # Arguments
1858 ///
1859 /// * `request` - No description provided.
1860 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1861 pub fn set_iam_policy(
1862 &self,
1863 request: SetIamPolicyRequest,
1864 resource: &str,
1865 ) -> AccessPolicySetIamPolicyCall<'a, C> {
1866 AccessPolicySetIamPolicyCall {
1867 hub: self.hub,
1868 _request: request,
1869 _resource: resource.to_string(),
1870 _delegate: Default::default(),
1871 _additional_params: Default::default(),
1872 _scopes: Default::default(),
1873 }
1874 }
1875
1876 /// Create a builder to help you perform the following task:
1877 ///
1878 /// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
1879 ///
1880 /// # Arguments
1881 ///
1882 /// * `request` - No description provided.
1883 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
1884 pub fn test_iam_permissions(
1885 &self,
1886 request: TestIamPermissionsRequest,
1887 resource: &str,
1888 ) -> AccessPolicyTestIamPermissionCall<'a, C> {
1889 AccessPolicyTestIamPermissionCall {
1890 hub: self.hub,
1891 _request: request,
1892 _resource: resource.to_string(),
1893 _delegate: Default::default(),
1894 _additional_params: Default::default(),
1895 _scopes: Default::default(),
1896 }
1897 }
1898}
1899
1900/// A builder providing access to all methods supported on *operation* resources.
1901/// It is not used directly, but through the [`AccessContextManager`] hub.
1902///
1903/// # Example
1904///
1905/// Instantiate a resource builder
1906///
1907/// ```test_harness,no_run
1908/// extern crate hyper;
1909/// extern crate hyper_rustls;
1910/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
1911///
1912/// # async fn dox() {
1913/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1914///
1915/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1916/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1917/// secret,
1918/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1919/// ).build().await.unwrap();
1920///
1921/// let client = hyper_util::client::legacy::Client::builder(
1922/// hyper_util::rt::TokioExecutor::new()
1923/// )
1924/// .build(
1925/// hyper_rustls::HttpsConnectorBuilder::new()
1926/// .with_native_roots()
1927/// .unwrap()
1928/// .https_or_http()
1929/// .enable_http1()
1930/// .build()
1931/// );
1932/// let mut hub = AccessContextManager::new(client, auth);
1933/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1934/// // like `cancel(...)`, `delete(...)`, `get(...)` and `list(...)`
1935/// // to build up your call.
1936/// let rb = hub.operations();
1937/// # }
1938/// ```
1939pub struct OperationMethods<'a, C>
1940where
1941 C: 'a,
1942{
1943 hub: &'a AccessContextManager<C>,
1944}
1945
1946impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
1947
1948impl<'a, C> OperationMethods<'a, C> {
1949 /// Create a builder to help you perform the following task:
1950 ///
1951 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
1952 ///
1953 /// # Arguments
1954 ///
1955 /// * `request` - No description provided.
1956 /// * `name` - The name of the operation resource to be cancelled.
1957 pub fn cancel(
1958 &self,
1959 request: CancelOperationRequest,
1960 name: &str,
1961 ) -> OperationCancelCall<'a, C> {
1962 OperationCancelCall {
1963 hub: self.hub,
1964 _request: request,
1965 _name: name.to_string(),
1966 _delegate: Default::default(),
1967 _additional_params: Default::default(),
1968 _scopes: Default::default(),
1969 }
1970 }
1971
1972 /// Create a builder to help you perform the following task:
1973 ///
1974 /// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
1975 ///
1976 /// # Arguments
1977 ///
1978 /// * `name` - The name of the operation resource to be deleted.
1979 pub fn delete(&self, name: &str) -> OperationDeleteCall<'a, C> {
1980 OperationDeleteCall {
1981 hub: self.hub,
1982 _name: name.to_string(),
1983 _delegate: Default::default(),
1984 _additional_params: Default::default(),
1985 _scopes: Default::default(),
1986 }
1987 }
1988
1989 /// Create a builder to help you perform the following task:
1990 ///
1991 /// 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.
1992 ///
1993 /// # Arguments
1994 ///
1995 /// * `name` - The name of the operation resource.
1996 pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
1997 OperationGetCall {
1998 hub: self.hub,
1999 _name: name.to_string(),
2000 _delegate: Default::default(),
2001 _additional_params: Default::default(),
2002 _scopes: Default::default(),
2003 }
2004 }
2005
2006 /// Create a builder to help you perform the following task:
2007 ///
2008 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
2009 ///
2010 /// # Arguments
2011 ///
2012 /// * `name` - The name of the operation's parent resource.
2013 pub fn list(&self, name: &str) -> OperationListCall<'a, C> {
2014 OperationListCall {
2015 hub: self.hub,
2016 _name: name.to_string(),
2017 _page_token: Default::default(),
2018 _page_size: Default::default(),
2019 _filter: Default::default(),
2020 _delegate: Default::default(),
2021 _additional_params: Default::default(),
2022 _scopes: Default::default(),
2023 }
2024 }
2025}
2026
2027/// A builder providing access to all methods supported on *organization* resources.
2028/// It is not used directly, but through the [`AccessContextManager`] hub.
2029///
2030/// # Example
2031///
2032/// Instantiate a resource builder
2033///
2034/// ```test_harness,no_run
2035/// extern crate hyper;
2036/// extern crate hyper_rustls;
2037/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
2038///
2039/// # async fn dox() {
2040/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2041///
2042/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2043/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2044/// secret,
2045/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2046/// ).build().await.unwrap();
2047///
2048/// let client = hyper_util::client::legacy::Client::builder(
2049/// hyper_util::rt::TokioExecutor::new()
2050/// )
2051/// .build(
2052/// hyper_rustls::HttpsConnectorBuilder::new()
2053/// .with_native_roots()
2054/// .unwrap()
2055/// .https_or_http()
2056/// .enable_http1()
2057/// .build()
2058/// );
2059/// let mut hub = AccessContextManager::new(client, auth);
2060/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2061/// // like `gcp_user_access_bindings_create(...)`, `gcp_user_access_bindings_delete(...)`, `gcp_user_access_bindings_get(...)`, `gcp_user_access_bindings_list(...)` and `gcp_user_access_bindings_patch(...)`
2062/// // to build up your call.
2063/// let rb = hub.organizations();
2064/// # }
2065/// ```
2066pub struct OrganizationMethods<'a, C>
2067where
2068 C: 'a,
2069{
2070 hub: &'a AccessContextManager<C>,
2071}
2072
2073impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
2074
2075impl<'a, C> OrganizationMethods<'a, C> {
2076 /// Create a builder to help you perform the following task:
2077 ///
2078 /// Creates a GcpUserAccessBinding. If the client specifies a name, the server ignores it. Fails if a resource already exists with the same group_key. Completion of this long-running operation does not necessarily signify that the new binding is deployed onto all affected users, which may take more time.
2079 ///
2080 /// # Arguments
2081 ///
2082 /// * `request` - No description provided.
2083 /// * `parent` - Required. Example: "organizations/256"
2084 pub fn gcp_user_access_bindings_create(
2085 &self,
2086 request: GcpUserAccessBinding,
2087 parent: &str,
2088 ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
2089 OrganizationGcpUserAccessBindingCreateCall {
2090 hub: self.hub,
2091 _request: request,
2092 _parent: parent.to_string(),
2093 _delegate: Default::default(),
2094 _additional_params: Default::default(),
2095 _scopes: Default::default(),
2096 }
2097 }
2098
2099 /// Create a builder to help you perform the following task:
2100 ///
2101 /// Deletes a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the binding deletion is deployed onto all affected users, which may take more time.
2102 ///
2103 /// # Arguments
2104 ///
2105 /// * `name` - Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
2106 pub fn gcp_user_access_bindings_delete(
2107 &self,
2108 name: &str,
2109 ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
2110 OrganizationGcpUserAccessBindingDeleteCall {
2111 hub: self.hub,
2112 _name: name.to_string(),
2113 _delegate: Default::default(),
2114 _additional_params: Default::default(),
2115 _scopes: Default::default(),
2116 }
2117 }
2118
2119 /// Create a builder to help you perform the following task:
2120 ///
2121 /// Gets the GcpUserAccessBinding with the given name.
2122 ///
2123 /// # Arguments
2124 ///
2125 /// * `name` - Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
2126 pub fn gcp_user_access_bindings_get(
2127 &self,
2128 name: &str,
2129 ) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
2130 OrganizationGcpUserAccessBindingGetCall {
2131 hub: self.hub,
2132 _name: name.to_string(),
2133 _delegate: Default::default(),
2134 _additional_params: Default::default(),
2135 _scopes: Default::default(),
2136 }
2137 }
2138
2139 /// Create a builder to help you perform the following task:
2140 ///
2141 /// Lists all GcpUserAccessBindings for a Google Cloud organization.
2142 ///
2143 /// # Arguments
2144 ///
2145 /// * `parent` - Required. Example: "organizations/256"
2146 pub fn gcp_user_access_bindings_list(
2147 &self,
2148 parent: &str,
2149 ) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
2150 OrganizationGcpUserAccessBindingListCall {
2151 hub: self.hub,
2152 _parent: parent.to_string(),
2153 _page_token: Default::default(),
2154 _page_size: Default::default(),
2155 _delegate: Default::default(),
2156 _additional_params: Default::default(),
2157 _scopes: Default::default(),
2158 }
2159 }
2160
2161 /// Create a builder to help you perform the following task:
2162 ///
2163 /// Updates a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the changed binding is deployed onto all affected users, which may take more time.
2164 ///
2165 /// # Arguments
2166 ///
2167 /// * `request` - No description provided.
2168 /// * `name` - Immutable. Assigned by the server during creation. The last segment has an arbitrary length and has only URI unreserved characters (as defined by [RFC 3986 Section 2.3](https://tools.ietf.org/html/rfc3986#section-2.3)). Should not be specified by the client during creation. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
2169 pub fn gcp_user_access_bindings_patch(
2170 &self,
2171 request: GcpUserAccessBinding,
2172 name: &str,
2173 ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
2174 OrganizationGcpUserAccessBindingPatchCall {
2175 hub: self.hub,
2176 _request: request,
2177 _name: name.to_string(),
2178 _update_mask: Default::default(),
2179 _delegate: Default::default(),
2180 _additional_params: Default::default(),
2181 _scopes: Default::default(),
2182 }
2183 }
2184}
2185
2186/// A builder providing access to all methods supported on *service* resources.
2187/// It is not used directly, but through the [`AccessContextManager`] hub.
2188///
2189/// # Example
2190///
2191/// Instantiate a resource builder
2192///
2193/// ```test_harness,no_run
2194/// extern crate hyper;
2195/// extern crate hyper_rustls;
2196/// extern crate google_accesscontextmanager1 as accesscontextmanager1;
2197///
2198/// # async fn dox() {
2199/// use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2200///
2201/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2202/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2203/// secret,
2204/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2205/// ).build().await.unwrap();
2206///
2207/// let client = hyper_util::client::legacy::Client::builder(
2208/// hyper_util::rt::TokioExecutor::new()
2209/// )
2210/// .build(
2211/// hyper_rustls::HttpsConnectorBuilder::new()
2212/// .with_native_roots()
2213/// .unwrap()
2214/// .https_or_http()
2215/// .enable_http1()
2216/// .build()
2217/// );
2218/// let mut hub = AccessContextManager::new(client, auth);
2219/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2220/// // like `get(...)` and `list(...)`
2221/// // to build up your call.
2222/// let rb = hub.services();
2223/// # }
2224/// ```
2225pub struct ServiceMethods<'a, C>
2226where
2227 C: 'a,
2228{
2229 hub: &'a AccessContextManager<C>,
2230}
2231
2232impl<'a, C> common::MethodsBuilder for ServiceMethods<'a, C> {}
2233
2234impl<'a, C> ServiceMethods<'a, C> {
2235 /// Create a builder to help you perform the following task:
2236 ///
2237 /// Returns a VPC-SC supported service based on the service name.
2238 ///
2239 /// # Arguments
2240 ///
2241 /// * `name` - The name of the service to get information about. The names must be in the same format as used in defining a service perimeter, for example, `storage.googleapis.com`.
2242 pub fn get(&self, name: &str) -> ServiceGetCall<'a, C> {
2243 ServiceGetCall {
2244 hub: self.hub,
2245 _name: name.to_string(),
2246 _delegate: Default::default(),
2247 _additional_params: Default::default(),
2248 _scopes: Default::default(),
2249 }
2250 }
2251
2252 /// Create a builder to help you perform the following task:
2253 ///
2254 /// Lists all VPC-SC supported services.
2255 pub fn list(&self) -> ServiceListCall<'a, C> {
2256 ServiceListCall {
2257 hub: self.hub,
2258 _page_token: Default::default(),
2259 _page_size: Default::default(),
2260 _delegate: Default::default(),
2261 _additional_params: Default::default(),
2262 _scopes: Default::default(),
2263 }
2264 }
2265}
2266
2267// ###################
2268// CallBuilders ###
2269// #################
2270
2271/// Creates an access level. The long-running operation from this RPC has a successful status after the access level propagates to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
2272///
2273/// A builder for the *accessLevels.create* method supported by a *accessPolicy* resource.
2274/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2275///
2276/// # Example
2277///
2278/// Instantiate a resource method builder
2279///
2280/// ```test_harness,no_run
2281/// # extern crate hyper;
2282/// # extern crate hyper_rustls;
2283/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
2284/// use accesscontextmanager1::api::AccessLevel;
2285/// # async fn dox() {
2286/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2287///
2288/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2289/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2290/// # secret,
2291/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2292/// # ).build().await.unwrap();
2293///
2294/// # let client = hyper_util::client::legacy::Client::builder(
2295/// # hyper_util::rt::TokioExecutor::new()
2296/// # )
2297/// # .build(
2298/// # hyper_rustls::HttpsConnectorBuilder::new()
2299/// # .with_native_roots()
2300/// # .unwrap()
2301/// # .https_or_http()
2302/// # .enable_http1()
2303/// # .build()
2304/// # );
2305/// # let mut hub = AccessContextManager::new(client, auth);
2306/// // As the method needs a request, you would usually fill it with the desired information
2307/// // into the respective structure. Some of the parts shown here might not be applicable !
2308/// // Values shown here are possibly random and not representative !
2309/// let mut req = AccessLevel::default();
2310///
2311/// // You can configure optional parameters by calling the respective setters at will, and
2312/// // execute the final call using `doit()`.
2313/// // Values shown here are possibly random and not representative !
2314/// let result = hub.access_policies().access_levels_create(req, "parent")
2315/// .doit().await;
2316/// # }
2317/// ```
2318pub struct AccessPolicyAccessLevelCreateCall<'a, C>
2319where
2320 C: 'a,
2321{
2322 hub: &'a AccessContextManager<C>,
2323 _request: AccessLevel,
2324 _parent: String,
2325 _delegate: Option<&'a mut dyn common::Delegate>,
2326 _additional_params: HashMap<String, String>,
2327 _scopes: BTreeSet<String>,
2328}
2329
2330impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelCreateCall<'a, C> {}
2331
2332impl<'a, C> AccessPolicyAccessLevelCreateCall<'a, C>
2333where
2334 C: common::Connector,
2335{
2336 /// Perform the operation you have build so far.
2337 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2338 use std::borrow::Cow;
2339 use std::io::{Read, Seek};
2340
2341 use common::{url::Params, ToParts};
2342 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2343
2344 let mut dd = common::DefaultDelegate;
2345 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2346 dlg.begin(common::MethodInfo {
2347 id: "accesscontextmanager.accessPolicies.accessLevels.create",
2348 http_method: hyper::Method::POST,
2349 });
2350
2351 for &field in ["alt", "parent"].iter() {
2352 if self._additional_params.contains_key(field) {
2353 dlg.finished(false);
2354 return Err(common::Error::FieldClash(field));
2355 }
2356 }
2357
2358 let mut params = Params::with_capacity(4 + self._additional_params.len());
2359 params.push("parent", self._parent);
2360
2361 params.extend(self._additional_params.iter());
2362
2363 params.push("alt", "json");
2364 let mut url = self.hub._base_url.clone() + "v1/{+parent}/accessLevels";
2365 if self._scopes.is_empty() {
2366 self._scopes
2367 .insert(Scope::CloudPlatform.as_ref().to_string());
2368 }
2369
2370 #[allow(clippy::single_element_loop)]
2371 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2372 url = params.uri_replacement(url, param_name, find_this, true);
2373 }
2374 {
2375 let to_remove = ["parent"];
2376 params.remove_params(&to_remove);
2377 }
2378
2379 let url = params.parse_with_url(&url);
2380
2381 let mut json_mime_type = mime::APPLICATION_JSON;
2382 let mut request_value_reader = {
2383 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2384 common::remove_json_null_values(&mut value);
2385 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2386 serde_json::to_writer(&mut dst, &value).unwrap();
2387 dst
2388 };
2389 let request_size = request_value_reader
2390 .seek(std::io::SeekFrom::End(0))
2391 .unwrap();
2392 request_value_reader
2393 .seek(std::io::SeekFrom::Start(0))
2394 .unwrap();
2395
2396 loop {
2397 let token = match self
2398 .hub
2399 .auth
2400 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2401 .await
2402 {
2403 Ok(token) => token,
2404 Err(e) => match dlg.token(e) {
2405 Ok(token) => token,
2406 Err(e) => {
2407 dlg.finished(false);
2408 return Err(common::Error::MissingToken(e));
2409 }
2410 },
2411 };
2412 request_value_reader
2413 .seek(std::io::SeekFrom::Start(0))
2414 .unwrap();
2415 let mut req_result = {
2416 let client = &self.hub.client;
2417 dlg.pre_request();
2418 let mut req_builder = hyper::Request::builder()
2419 .method(hyper::Method::POST)
2420 .uri(url.as_str())
2421 .header(USER_AGENT, self.hub._user_agent.clone());
2422
2423 if let Some(token) = token.as_ref() {
2424 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2425 }
2426
2427 let request = req_builder
2428 .header(CONTENT_TYPE, json_mime_type.to_string())
2429 .header(CONTENT_LENGTH, request_size as u64)
2430 .body(common::to_body(
2431 request_value_reader.get_ref().clone().into(),
2432 ));
2433
2434 client.request(request.unwrap()).await
2435 };
2436
2437 match req_result {
2438 Err(err) => {
2439 if let common::Retry::After(d) = dlg.http_error(&err) {
2440 sleep(d).await;
2441 continue;
2442 }
2443 dlg.finished(false);
2444 return Err(common::Error::HttpError(err));
2445 }
2446 Ok(res) => {
2447 let (mut parts, body) = res.into_parts();
2448 let mut body = common::Body::new(body);
2449 if !parts.status.is_success() {
2450 let bytes = common::to_bytes(body).await.unwrap_or_default();
2451 let error = serde_json::from_str(&common::to_string(&bytes));
2452 let response = common::to_response(parts, bytes.into());
2453
2454 if let common::Retry::After(d) =
2455 dlg.http_failure(&response, error.as_ref().ok())
2456 {
2457 sleep(d).await;
2458 continue;
2459 }
2460
2461 dlg.finished(false);
2462
2463 return Err(match error {
2464 Ok(value) => common::Error::BadRequest(value),
2465 _ => common::Error::Failure(response),
2466 });
2467 }
2468 let response = {
2469 let bytes = common::to_bytes(body).await.unwrap_or_default();
2470 let encoded = common::to_string(&bytes);
2471 match serde_json::from_str(&encoded) {
2472 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2473 Err(error) => {
2474 dlg.response_json_decode_error(&encoded, &error);
2475 return Err(common::Error::JsonDecodeError(
2476 encoded.to_string(),
2477 error,
2478 ));
2479 }
2480 }
2481 };
2482
2483 dlg.finished(true);
2484 return Ok(response);
2485 }
2486 }
2487 }
2488 }
2489
2490 ///
2491 /// Sets the *request* property to the given value.
2492 ///
2493 /// Even though the property as already been set when instantiating this call,
2494 /// we provide this method for API completeness.
2495 pub fn request(mut self, new_value: AccessLevel) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2496 self._request = new_value;
2497 self
2498 }
2499 /// Required. Resource name for the access policy which owns this Access Level. Format: `accessPolicies/{policy_id}`
2500 ///
2501 /// Sets the *parent* path property to the given value.
2502 ///
2503 /// Even though the property as already been set when instantiating this call,
2504 /// we provide this method for API completeness.
2505 pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2506 self._parent = new_value.to_string();
2507 self
2508 }
2509 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2510 /// while executing the actual API request.
2511 ///
2512 /// ````text
2513 /// It should be used to handle progress information, and to implement a certain level of resilience.
2514 /// ````
2515 ///
2516 /// Sets the *delegate* property to the given value.
2517 pub fn delegate(
2518 mut self,
2519 new_value: &'a mut dyn common::Delegate,
2520 ) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2521 self._delegate = Some(new_value);
2522 self
2523 }
2524
2525 /// Set any additional parameter of the query string used in the request.
2526 /// It should be used to set parameters which are not yet available through their own
2527 /// setters.
2528 ///
2529 /// Please note that this method must not be used to set any of the known parameters
2530 /// which have their own setter method. If done anyway, the request will fail.
2531 ///
2532 /// # Additional Parameters
2533 ///
2534 /// * *$.xgafv* (query-string) - V1 error format.
2535 /// * *access_token* (query-string) - OAuth access token.
2536 /// * *alt* (query-string) - Data format for response.
2537 /// * *callback* (query-string) - JSONP
2538 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2539 /// * *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.
2540 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2541 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2542 /// * *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.
2543 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2544 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2545 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelCreateCall<'a, C>
2546 where
2547 T: AsRef<str>,
2548 {
2549 self._additional_params
2550 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2551 self
2552 }
2553
2554 /// Identifies the authorization scope for the method you are building.
2555 ///
2556 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2557 /// [`Scope::CloudPlatform`].
2558 ///
2559 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2560 /// tokens for more than one scope.
2561 ///
2562 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2563 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2564 /// sufficient, a read-write scope will do as well.
2565 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelCreateCall<'a, C>
2566 where
2567 St: AsRef<str>,
2568 {
2569 self._scopes.insert(String::from(scope.as_ref()));
2570 self
2571 }
2572 /// Identifies the authorization scope(s) for the method you are building.
2573 ///
2574 /// See [`Self::add_scope()`] for details.
2575 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelCreateCall<'a, C>
2576 where
2577 I: IntoIterator<Item = St>,
2578 St: AsRef<str>,
2579 {
2580 self._scopes
2581 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2582 self
2583 }
2584
2585 /// Removes all scopes, and no default scope will be used either.
2586 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2587 /// for details).
2588 pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelCreateCall<'a, C> {
2589 self._scopes.clear();
2590 self
2591 }
2592}
2593
2594/// Deletes an access level based on the resource name. The long-running operation from this RPC has a successful status after the access level has been removed from long-lasting storage.
2595///
2596/// A builder for the *accessLevels.delete* method supported by a *accessPolicy* resource.
2597/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2598///
2599/// # Example
2600///
2601/// Instantiate a resource method builder
2602///
2603/// ```test_harness,no_run
2604/// # extern crate hyper;
2605/// # extern crate hyper_rustls;
2606/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
2607/// # async fn dox() {
2608/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2609///
2610/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2611/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2612/// # secret,
2613/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2614/// # ).build().await.unwrap();
2615///
2616/// # let client = hyper_util::client::legacy::Client::builder(
2617/// # hyper_util::rt::TokioExecutor::new()
2618/// # )
2619/// # .build(
2620/// # hyper_rustls::HttpsConnectorBuilder::new()
2621/// # .with_native_roots()
2622/// # .unwrap()
2623/// # .https_or_http()
2624/// # .enable_http1()
2625/// # .build()
2626/// # );
2627/// # let mut hub = AccessContextManager::new(client, auth);
2628/// // You can configure optional parameters by calling the respective setters at will, and
2629/// // execute the final call using `doit()`.
2630/// // Values shown here are possibly random and not representative !
2631/// let result = hub.access_policies().access_levels_delete("name")
2632/// .doit().await;
2633/// # }
2634/// ```
2635pub struct AccessPolicyAccessLevelDeleteCall<'a, C>
2636where
2637 C: 'a,
2638{
2639 hub: &'a AccessContextManager<C>,
2640 _name: String,
2641 _delegate: Option<&'a mut dyn common::Delegate>,
2642 _additional_params: HashMap<String, String>,
2643 _scopes: BTreeSet<String>,
2644}
2645
2646impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelDeleteCall<'a, C> {}
2647
2648impl<'a, C> AccessPolicyAccessLevelDeleteCall<'a, C>
2649where
2650 C: common::Connector,
2651{
2652 /// Perform the operation you have build so far.
2653 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2654 use std::borrow::Cow;
2655 use std::io::{Read, Seek};
2656
2657 use common::{url::Params, ToParts};
2658 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2659
2660 let mut dd = common::DefaultDelegate;
2661 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2662 dlg.begin(common::MethodInfo {
2663 id: "accesscontextmanager.accessPolicies.accessLevels.delete",
2664 http_method: hyper::Method::DELETE,
2665 });
2666
2667 for &field in ["alt", "name"].iter() {
2668 if self._additional_params.contains_key(field) {
2669 dlg.finished(false);
2670 return Err(common::Error::FieldClash(field));
2671 }
2672 }
2673
2674 let mut params = Params::with_capacity(3 + self._additional_params.len());
2675 params.push("name", self._name);
2676
2677 params.extend(self._additional_params.iter());
2678
2679 params.push("alt", "json");
2680 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2681 if self._scopes.is_empty() {
2682 self._scopes
2683 .insert(Scope::CloudPlatform.as_ref().to_string());
2684 }
2685
2686 #[allow(clippy::single_element_loop)]
2687 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2688 url = params.uri_replacement(url, param_name, find_this, true);
2689 }
2690 {
2691 let to_remove = ["name"];
2692 params.remove_params(&to_remove);
2693 }
2694
2695 let url = params.parse_with_url(&url);
2696
2697 loop {
2698 let token = match self
2699 .hub
2700 .auth
2701 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2702 .await
2703 {
2704 Ok(token) => token,
2705 Err(e) => match dlg.token(e) {
2706 Ok(token) => token,
2707 Err(e) => {
2708 dlg.finished(false);
2709 return Err(common::Error::MissingToken(e));
2710 }
2711 },
2712 };
2713 let mut req_result = {
2714 let client = &self.hub.client;
2715 dlg.pre_request();
2716 let mut req_builder = hyper::Request::builder()
2717 .method(hyper::Method::DELETE)
2718 .uri(url.as_str())
2719 .header(USER_AGENT, self.hub._user_agent.clone());
2720
2721 if let Some(token) = token.as_ref() {
2722 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2723 }
2724
2725 let request = req_builder
2726 .header(CONTENT_LENGTH, 0_u64)
2727 .body(common::to_body::<String>(None));
2728
2729 client.request(request.unwrap()).await
2730 };
2731
2732 match req_result {
2733 Err(err) => {
2734 if let common::Retry::After(d) = dlg.http_error(&err) {
2735 sleep(d).await;
2736 continue;
2737 }
2738 dlg.finished(false);
2739 return Err(common::Error::HttpError(err));
2740 }
2741 Ok(res) => {
2742 let (mut parts, body) = res.into_parts();
2743 let mut body = common::Body::new(body);
2744 if !parts.status.is_success() {
2745 let bytes = common::to_bytes(body).await.unwrap_or_default();
2746 let error = serde_json::from_str(&common::to_string(&bytes));
2747 let response = common::to_response(parts, bytes.into());
2748
2749 if let common::Retry::After(d) =
2750 dlg.http_failure(&response, error.as_ref().ok())
2751 {
2752 sleep(d).await;
2753 continue;
2754 }
2755
2756 dlg.finished(false);
2757
2758 return Err(match error {
2759 Ok(value) => common::Error::BadRequest(value),
2760 _ => common::Error::Failure(response),
2761 });
2762 }
2763 let response = {
2764 let bytes = common::to_bytes(body).await.unwrap_or_default();
2765 let encoded = common::to_string(&bytes);
2766 match serde_json::from_str(&encoded) {
2767 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2768 Err(error) => {
2769 dlg.response_json_decode_error(&encoded, &error);
2770 return Err(common::Error::JsonDecodeError(
2771 encoded.to_string(),
2772 error,
2773 ));
2774 }
2775 }
2776 };
2777
2778 dlg.finished(true);
2779 return Ok(response);
2780 }
2781 }
2782 }
2783 }
2784
2785 /// Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
2786 ///
2787 /// Sets the *name* path property to the given value.
2788 ///
2789 /// Even though the property as already been set when instantiating this call,
2790 /// we provide this method for API completeness.
2791 pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
2792 self._name = new_value.to_string();
2793 self
2794 }
2795 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2796 /// while executing the actual API request.
2797 ///
2798 /// ````text
2799 /// It should be used to handle progress information, and to implement a certain level of resilience.
2800 /// ````
2801 ///
2802 /// Sets the *delegate* property to the given value.
2803 pub fn delegate(
2804 mut self,
2805 new_value: &'a mut dyn common::Delegate,
2806 ) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
2807 self._delegate = Some(new_value);
2808 self
2809 }
2810
2811 /// Set any additional parameter of the query string used in the request.
2812 /// It should be used to set parameters which are not yet available through their own
2813 /// setters.
2814 ///
2815 /// Please note that this method must not be used to set any of the known parameters
2816 /// which have their own setter method. If done anyway, the request will fail.
2817 ///
2818 /// # Additional Parameters
2819 ///
2820 /// * *$.xgafv* (query-string) - V1 error format.
2821 /// * *access_token* (query-string) - OAuth access token.
2822 /// * *alt* (query-string) - Data format for response.
2823 /// * *callback* (query-string) - JSONP
2824 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2825 /// * *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.
2826 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2827 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2828 /// * *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.
2829 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2830 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2831 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelDeleteCall<'a, C>
2832 where
2833 T: AsRef<str>,
2834 {
2835 self._additional_params
2836 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2837 self
2838 }
2839
2840 /// Identifies the authorization scope for the method you are building.
2841 ///
2842 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2843 /// [`Scope::CloudPlatform`].
2844 ///
2845 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2846 /// tokens for more than one scope.
2847 ///
2848 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2849 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2850 /// sufficient, a read-write scope will do as well.
2851 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelDeleteCall<'a, C>
2852 where
2853 St: AsRef<str>,
2854 {
2855 self._scopes.insert(String::from(scope.as_ref()));
2856 self
2857 }
2858 /// Identifies the authorization scope(s) for the method you are building.
2859 ///
2860 /// See [`Self::add_scope()`] for details.
2861 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelDeleteCall<'a, C>
2862 where
2863 I: IntoIterator<Item = St>,
2864 St: AsRef<str>,
2865 {
2866 self._scopes
2867 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2868 self
2869 }
2870
2871 /// Removes all scopes, and no default scope will be used either.
2872 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2873 /// for details).
2874 pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelDeleteCall<'a, C> {
2875 self._scopes.clear();
2876 self
2877 }
2878}
2879
2880/// Gets an access level based on the resource name.
2881///
2882/// A builder for the *accessLevels.get* method supported by a *accessPolicy* resource.
2883/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
2884///
2885/// # Example
2886///
2887/// Instantiate a resource method builder
2888///
2889/// ```test_harness,no_run
2890/// # extern crate hyper;
2891/// # extern crate hyper_rustls;
2892/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
2893/// # async fn dox() {
2894/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2895///
2896/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2897/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2898/// # secret,
2899/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2900/// # ).build().await.unwrap();
2901///
2902/// # let client = hyper_util::client::legacy::Client::builder(
2903/// # hyper_util::rt::TokioExecutor::new()
2904/// # )
2905/// # .build(
2906/// # hyper_rustls::HttpsConnectorBuilder::new()
2907/// # .with_native_roots()
2908/// # .unwrap()
2909/// # .https_or_http()
2910/// # .enable_http1()
2911/// # .build()
2912/// # );
2913/// # let mut hub = AccessContextManager::new(client, auth);
2914/// // You can configure optional parameters by calling the respective setters at will, and
2915/// // execute the final call using `doit()`.
2916/// // Values shown here are possibly random and not representative !
2917/// let result = hub.access_policies().access_levels_get("name")
2918/// .access_level_format("gubergren")
2919/// .doit().await;
2920/// # }
2921/// ```
2922pub struct AccessPolicyAccessLevelGetCall<'a, C>
2923where
2924 C: 'a,
2925{
2926 hub: &'a AccessContextManager<C>,
2927 _name: String,
2928 _access_level_format: Option<String>,
2929 _delegate: Option<&'a mut dyn common::Delegate>,
2930 _additional_params: HashMap<String, String>,
2931 _scopes: BTreeSet<String>,
2932}
2933
2934impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelGetCall<'a, C> {}
2935
2936impl<'a, C> AccessPolicyAccessLevelGetCall<'a, C>
2937where
2938 C: common::Connector,
2939{
2940 /// Perform the operation you have build so far.
2941 pub async fn doit(mut self) -> common::Result<(common::Response, AccessLevel)> {
2942 use std::borrow::Cow;
2943 use std::io::{Read, Seek};
2944
2945 use common::{url::Params, ToParts};
2946 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2947
2948 let mut dd = common::DefaultDelegate;
2949 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2950 dlg.begin(common::MethodInfo {
2951 id: "accesscontextmanager.accessPolicies.accessLevels.get",
2952 http_method: hyper::Method::GET,
2953 });
2954
2955 for &field in ["alt", "name", "accessLevelFormat"].iter() {
2956 if self._additional_params.contains_key(field) {
2957 dlg.finished(false);
2958 return Err(common::Error::FieldClash(field));
2959 }
2960 }
2961
2962 let mut params = Params::with_capacity(4 + self._additional_params.len());
2963 params.push("name", self._name);
2964 if let Some(value) = self._access_level_format.as_ref() {
2965 params.push("accessLevelFormat", value);
2966 }
2967
2968 params.extend(self._additional_params.iter());
2969
2970 params.push("alt", "json");
2971 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2972 if self._scopes.is_empty() {
2973 self._scopes
2974 .insert(Scope::CloudPlatform.as_ref().to_string());
2975 }
2976
2977 #[allow(clippy::single_element_loop)]
2978 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2979 url = params.uri_replacement(url, param_name, find_this, true);
2980 }
2981 {
2982 let to_remove = ["name"];
2983 params.remove_params(&to_remove);
2984 }
2985
2986 let url = params.parse_with_url(&url);
2987
2988 loop {
2989 let token = match self
2990 .hub
2991 .auth
2992 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2993 .await
2994 {
2995 Ok(token) => token,
2996 Err(e) => match dlg.token(e) {
2997 Ok(token) => token,
2998 Err(e) => {
2999 dlg.finished(false);
3000 return Err(common::Error::MissingToken(e));
3001 }
3002 },
3003 };
3004 let mut req_result = {
3005 let client = &self.hub.client;
3006 dlg.pre_request();
3007 let mut req_builder = hyper::Request::builder()
3008 .method(hyper::Method::GET)
3009 .uri(url.as_str())
3010 .header(USER_AGENT, self.hub._user_agent.clone());
3011
3012 if let Some(token) = token.as_ref() {
3013 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3014 }
3015
3016 let request = req_builder
3017 .header(CONTENT_LENGTH, 0_u64)
3018 .body(common::to_body::<String>(None));
3019
3020 client.request(request.unwrap()).await
3021 };
3022
3023 match req_result {
3024 Err(err) => {
3025 if let common::Retry::After(d) = dlg.http_error(&err) {
3026 sleep(d).await;
3027 continue;
3028 }
3029 dlg.finished(false);
3030 return Err(common::Error::HttpError(err));
3031 }
3032 Ok(res) => {
3033 let (mut parts, body) = res.into_parts();
3034 let mut body = common::Body::new(body);
3035 if !parts.status.is_success() {
3036 let bytes = common::to_bytes(body).await.unwrap_or_default();
3037 let error = serde_json::from_str(&common::to_string(&bytes));
3038 let response = common::to_response(parts, bytes.into());
3039
3040 if let common::Retry::After(d) =
3041 dlg.http_failure(&response, error.as_ref().ok())
3042 {
3043 sleep(d).await;
3044 continue;
3045 }
3046
3047 dlg.finished(false);
3048
3049 return Err(match error {
3050 Ok(value) => common::Error::BadRequest(value),
3051 _ => common::Error::Failure(response),
3052 });
3053 }
3054 let response = {
3055 let bytes = common::to_bytes(body).await.unwrap_or_default();
3056 let encoded = common::to_string(&bytes);
3057 match serde_json::from_str(&encoded) {
3058 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3059 Err(error) => {
3060 dlg.response_json_decode_error(&encoded, &error);
3061 return Err(common::Error::JsonDecodeError(
3062 encoded.to_string(),
3063 error,
3064 ));
3065 }
3066 }
3067 };
3068
3069 dlg.finished(true);
3070 return Ok(response);
3071 }
3072 }
3073 }
3074 }
3075
3076 /// Required. Resource name for the Access Level. Format: `accessPolicies/{policy_id}/accessLevels/{access_level_id}`
3077 ///
3078 /// Sets the *name* path property to the given value.
3079 ///
3080 /// Even though the property as already been set when instantiating this call,
3081 /// we provide this method for API completeness.
3082 pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
3083 self._name = new_value.to_string();
3084 self
3085 }
3086 /// 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`.
3087 ///
3088 /// Sets the *access level format* query property to the given value.
3089 pub fn access_level_format(mut self, new_value: &str) -> AccessPolicyAccessLevelGetCall<'a, C> {
3090 self._access_level_format = Some(new_value.to_string());
3091 self
3092 }
3093 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3094 /// while executing the actual API request.
3095 ///
3096 /// ````text
3097 /// It should be used to handle progress information, and to implement a certain level of resilience.
3098 /// ````
3099 ///
3100 /// Sets the *delegate* property to the given value.
3101 pub fn delegate(
3102 mut self,
3103 new_value: &'a mut dyn common::Delegate,
3104 ) -> AccessPolicyAccessLevelGetCall<'a, C> {
3105 self._delegate = Some(new_value);
3106 self
3107 }
3108
3109 /// Set any additional parameter of the query string used in the request.
3110 /// It should be used to set parameters which are not yet available through their own
3111 /// setters.
3112 ///
3113 /// Please note that this method must not be used to set any of the known parameters
3114 /// which have their own setter method. If done anyway, the request will fail.
3115 ///
3116 /// # Additional Parameters
3117 ///
3118 /// * *$.xgafv* (query-string) - V1 error format.
3119 /// * *access_token* (query-string) - OAuth access token.
3120 /// * *alt* (query-string) - Data format for response.
3121 /// * *callback* (query-string) - JSONP
3122 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3123 /// * *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.
3124 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3125 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3126 /// * *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.
3127 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3128 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3129 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelGetCall<'a, C>
3130 where
3131 T: AsRef<str>,
3132 {
3133 self._additional_params
3134 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3135 self
3136 }
3137
3138 /// Identifies the authorization scope for the method you are building.
3139 ///
3140 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3141 /// [`Scope::CloudPlatform`].
3142 ///
3143 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3144 /// tokens for more than one scope.
3145 ///
3146 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3147 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3148 /// sufficient, a read-write scope will do as well.
3149 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelGetCall<'a, C>
3150 where
3151 St: AsRef<str>,
3152 {
3153 self._scopes.insert(String::from(scope.as_ref()));
3154 self
3155 }
3156 /// Identifies the authorization scope(s) for the method you are building.
3157 ///
3158 /// See [`Self::add_scope()`] for details.
3159 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelGetCall<'a, C>
3160 where
3161 I: IntoIterator<Item = St>,
3162 St: AsRef<str>,
3163 {
3164 self._scopes
3165 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3166 self
3167 }
3168
3169 /// Removes all scopes, and no default scope will be used either.
3170 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3171 /// for details).
3172 pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelGetCall<'a, C> {
3173 self._scopes.clear();
3174 self
3175 }
3176}
3177
3178/// Lists all access levels for an access policy.
3179///
3180/// A builder for the *accessLevels.list* method supported by a *accessPolicy* resource.
3181/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3182///
3183/// # Example
3184///
3185/// Instantiate a resource method builder
3186///
3187/// ```test_harness,no_run
3188/// # extern crate hyper;
3189/// # extern crate hyper_rustls;
3190/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
3191/// # async fn dox() {
3192/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3193///
3194/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3195/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3196/// # secret,
3197/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3198/// # ).build().await.unwrap();
3199///
3200/// # let client = hyper_util::client::legacy::Client::builder(
3201/// # hyper_util::rt::TokioExecutor::new()
3202/// # )
3203/// # .build(
3204/// # hyper_rustls::HttpsConnectorBuilder::new()
3205/// # .with_native_roots()
3206/// # .unwrap()
3207/// # .https_or_http()
3208/// # .enable_http1()
3209/// # .build()
3210/// # );
3211/// # let mut hub = AccessContextManager::new(client, auth);
3212/// // You can configure optional parameters by calling the respective setters at will, and
3213/// // execute the final call using `doit()`.
3214/// // Values shown here are possibly random and not representative !
3215/// let result = hub.access_policies().access_levels_list("parent")
3216/// .page_token("dolor")
3217/// .page_size(-17)
3218/// .access_level_format("ipsum")
3219/// .doit().await;
3220/// # }
3221/// ```
3222pub struct AccessPolicyAccessLevelListCall<'a, C>
3223where
3224 C: 'a,
3225{
3226 hub: &'a AccessContextManager<C>,
3227 _parent: String,
3228 _page_token: Option<String>,
3229 _page_size: Option<i32>,
3230 _access_level_format: Option<String>,
3231 _delegate: Option<&'a mut dyn common::Delegate>,
3232 _additional_params: HashMap<String, String>,
3233 _scopes: BTreeSet<String>,
3234}
3235
3236impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelListCall<'a, C> {}
3237
3238impl<'a, C> AccessPolicyAccessLevelListCall<'a, C>
3239where
3240 C: common::Connector,
3241{
3242 /// Perform the operation you have build so far.
3243 pub async fn doit(mut self) -> common::Result<(common::Response, ListAccessLevelsResponse)> {
3244 use std::borrow::Cow;
3245 use std::io::{Read, Seek};
3246
3247 use common::{url::Params, ToParts};
3248 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3249
3250 let mut dd = common::DefaultDelegate;
3251 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3252 dlg.begin(common::MethodInfo {
3253 id: "accesscontextmanager.accessPolicies.accessLevels.list",
3254 http_method: hyper::Method::GET,
3255 });
3256
3257 for &field in [
3258 "alt",
3259 "parent",
3260 "pageToken",
3261 "pageSize",
3262 "accessLevelFormat",
3263 ]
3264 .iter()
3265 {
3266 if self._additional_params.contains_key(field) {
3267 dlg.finished(false);
3268 return Err(common::Error::FieldClash(field));
3269 }
3270 }
3271
3272 let mut params = Params::with_capacity(6 + self._additional_params.len());
3273 params.push("parent", self._parent);
3274 if let Some(value) = self._page_token.as_ref() {
3275 params.push("pageToken", value);
3276 }
3277 if let Some(value) = self._page_size.as_ref() {
3278 params.push("pageSize", value.to_string());
3279 }
3280 if let Some(value) = self._access_level_format.as_ref() {
3281 params.push("accessLevelFormat", value);
3282 }
3283
3284 params.extend(self._additional_params.iter());
3285
3286 params.push("alt", "json");
3287 let mut url = self.hub._base_url.clone() + "v1/{+parent}/accessLevels";
3288 if self._scopes.is_empty() {
3289 self._scopes
3290 .insert(Scope::CloudPlatform.as_ref().to_string());
3291 }
3292
3293 #[allow(clippy::single_element_loop)]
3294 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3295 url = params.uri_replacement(url, param_name, find_this, true);
3296 }
3297 {
3298 let to_remove = ["parent"];
3299 params.remove_params(&to_remove);
3300 }
3301
3302 let url = params.parse_with_url(&url);
3303
3304 loop {
3305 let token = match self
3306 .hub
3307 .auth
3308 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3309 .await
3310 {
3311 Ok(token) => token,
3312 Err(e) => match dlg.token(e) {
3313 Ok(token) => token,
3314 Err(e) => {
3315 dlg.finished(false);
3316 return Err(common::Error::MissingToken(e));
3317 }
3318 },
3319 };
3320 let mut req_result = {
3321 let client = &self.hub.client;
3322 dlg.pre_request();
3323 let mut req_builder = hyper::Request::builder()
3324 .method(hyper::Method::GET)
3325 .uri(url.as_str())
3326 .header(USER_AGENT, self.hub._user_agent.clone());
3327
3328 if let Some(token) = token.as_ref() {
3329 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3330 }
3331
3332 let request = req_builder
3333 .header(CONTENT_LENGTH, 0_u64)
3334 .body(common::to_body::<String>(None));
3335
3336 client.request(request.unwrap()).await
3337 };
3338
3339 match req_result {
3340 Err(err) => {
3341 if let common::Retry::After(d) = dlg.http_error(&err) {
3342 sleep(d).await;
3343 continue;
3344 }
3345 dlg.finished(false);
3346 return Err(common::Error::HttpError(err));
3347 }
3348 Ok(res) => {
3349 let (mut parts, body) = res.into_parts();
3350 let mut body = common::Body::new(body);
3351 if !parts.status.is_success() {
3352 let bytes = common::to_bytes(body).await.unwrap_or_default();
3353 let error = serde_json::from_str(&common::to_string(&bytes));
3354 let response = common::to_response(parts, bytes.into());
3355
3356 if let common::Retry::After(d) =
3357 dlg.http_failure(&response, error.as_ref().ok())
3358 {
3359 sleep(d).await;
3360 continue;
3361 }
3362
3363 dlg.finished(false);
3364
3365 return Err(match error {
3366 Ok(value) => common::Error::BadRequest(value),
3367 _ => common::Error::Failure(response),
3368 });
3369 }
3370 let response = {
3371 let bytes = common::to_bytes(body).await.unwrap_or_default();
3372 let encoded = common::to_string(&bytes);
3373 match serde_json::from_str(&encoded) {
3374 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3375 Err(error) => {
3376 dlg.response_json_decode_error(&encoded, &error);
3377 return Err(common::Error::JsonDecodeError(
3378 encoded.to_string(),
3379 error,
3380 ));
3381 }
3382 }
3383 };
3384
3385 dlg.finished(true);
3386 return Ok(response);
3387 }
3388 }
3389 }
3390 }
3391
3392 /// Required. Resource name for the access policy to list Access Levels from. Format: `accessPolicies/{policy_id}`
3393 ///
3394 /// Sets the *parent* path property to the given value.
3395 ///
3396 /// Even though the property as already been set when instantiating this call,
3397 /// we provide this method for API completeness.
3398 pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
3399 self._parent = new_value.to_string();
3400 self
3401 }
3402 /// Next page token for the next batch of Access Level instances. Defaults to the first page of results.
3403 ///
3404 /// Sets the *page token* query property to the given value.
3405 pub fn page_token(mut self, new_value: &str) -> AccessPolicyAccessLevelListCall<'a, C> {
3406 self._page_token = Some(new_value.to_string());
3407 self
3408 }
3409 /// Number of Access Levels to include in the list. Default 100.
3410 ///
3411 /// Sets the *page size* query property to the given value.
3412 pub fn page_size(mut self, new_value: i32) -> AccessPolicyAccessLevelListCall<'a, C> {
3413 self._page_size = Some(new_value);
3414 self
3415 }
3416 /// 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.
3417 ///
3418 /// Sets the *access level format* query property to the given value.
3419 pub fn access_level_format(
3420 mut self,
3421 new_value: &str,
3422 ) -> AccessPolicyAccessLevelListCall<'a, C> {
3423 self._access_level_format = Some(new_value.to_string());
3424 self
3425 }
3426 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3427 /// while executing the actual API request.
3428 ///
3429 /// ````text
3430 /// It should be used to handle progress information, and to implement a certain level of resilience.
3431 /// ````
3432 ///
3433 /// Sets the *delegate* property to the given value.
3434 pub fn delegate(
3435 mut self,
3436 new_value: &'a mut dyn common::Delegate,
3437 ) -> AccessPolicyAccessLevelListCall<'a, C> {
3438 self._delegate = Some(new_value);
3439 self
3440 }
3441
3442 /// Set any additional parameter of the query string used in the request.
3443 /// It should be used to set parameters which are not yet available through their own
3444 /// setters.
3445 ///
3446 /// Please note that this method must not be used to set any of the known parameters
3447 /// which have their own setter method. If done anyway, the request will fail.
3448 ///
3449 /// # Additional Parameters
3450 ///
3451 /// * *$.xgafv* (query-string) - V1 error format.
3452 /// * *access_token* (query-string) - OAuth access token.
3453 /// * *alt* (query-string) - Data format for response.
3454 /// * *callback* (query-string) - JSONP
3455 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3456 /// * *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.
3457 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3458 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3459 /// * *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.
3460 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3461 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3462 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelListCall<'a, C>
3463 where
3464 T: AsRef<str>,
3465 {
3466 self._additional_params
3467 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3468 self
3469 }
3470
3471 /// Identifies the authorization scope for the method you are building.
3472 ///
3473 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3474 /// [`Scope::CloudPlatform`].
3475 ///
3476 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3477 /// tokens for more than one scope.
3478 ///
3479 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3480 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3481 /// sufficient, a read-write scope will do as well.
3482 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelListCall<'a, C>
3483 where
3484 St: AsRef<str>,
3485 {
3486 self._scopes.insert(String::from(scope.as_ref()));
3487 self
3488 }
3489 /// Identifies the authorization scope(s) for the method you are building.
3490 ///
3491 /// See [`Self::add_scope()`] for details.
3492 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelListCall<'a, C>
3493 where
3494 I: IntoIterator<Item = St>,
3495 St: AsRef<str>,
3496 {
3497 self._scopes
3498 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3499 self
3500 }
3501
3502 /// Removes all scopes, and no default scope will be used either.
3503 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3504 /// for details).
3505 pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelListCall<'a, C> {
3506 self._scopes.clear();
3507 self
3508 }
3509}
3510
3511/// Updates an access level. The long-running operation from this RPC has a successful status after the changes to the access level propagate to long-lasting storage. If access levels contain errors, an error response is returned for the first error encountered.
3512///
3513/// A builder for the *accessLevels.patch* method supported by a *accessPolicy* resource.
3514/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3515///
3516/// # Example
3517///
3518/// Instantiate a resource method builder
3519///
3520/// ```test_harness,no_run
3521/// # extern crate hyper;
3522/// # extern crate hyper_rustls;
3523/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
3524/// use accesscontextmanager1::api::AccessLevel;
3525/// # async fn dox() {
3526/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3527///
3528/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3529/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3530/// # secret,
3531/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3532/// # ).build().await.unwrap();
3533///
3534/// # let client = hyper_util::client::legacy::Client::builder(
3535/// # hyper_util::rt::TokioExecutor::new()
3536/// # )
3537/// # .build(
3538/// # hyper_rustls::HttpsConnectorBuilder::new()
3539/// # .with_native_roots()
3540/// # .unwrap()
3541/// # .https_or_http()
3542/// # .enable_http1()
3543/// # .build()
3544/// # );
3545/// # let mut hub = AccessContextManager::new(client, auth);
3546/// // As the method needs a request, you would usually fill it with the desired information
3547/// // into the respective structure. Some of the parts shown here might not be applicable !
3548/// // Values shown here are possibly random and not representative !
3549/// let mut req = AccessLevel::default();
3550///
3551/// // You can configure optional parameters by calling the respective setters at will, and
3552/// // execute the final call using `doit()`.
3553/// // Values shown here are possibly random and not representative !
3554/// let result = hub.access_policies().access_levels_patch(req, "name")
3555/// .update_mask(FieldMask::new::<&str>(&[]))
3556/// .doit().await;
3557/// # }
3558/// ```
3559pub struct AccessPolicyAccessLevelPatchCall<'a, C>
3560where
3561 C: 'a,
3562{
3563 hub: &'a AccessContextManager<C>,
3564 _request: AccessLevel,
3565 _name: String,
3566 _update_mask: Option<common::FieldMask>,
3567 _delegate: Option<&'a mut dyn common::Delegate>,
3568 _additional_params: HashMap<String, String>,
3569 _scopes: BTreeSet<String>,
3570}
3571
3572impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelPatchCall<'a, C> {}
3573
3574impl<'a, C> AccessPolicyAccessLevelPatchCall<'a, C>
3575where
3576 C: common::Connector,
3577{
3578 /// Perform the operation you have build so far.
3579 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3580 use std::borrow::Cow;
3581 use std::io::{Read, Seek};
3582
3583 use common::{url::Params, ToParts};
3584 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3585
3586 let mut dd = common::DefaultDelegate;
3587 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3588 dlg.begin(common::MethodInfo {
3589 id: "accesscontextmanager.accessPolicies.accessLevels.patch",
3590 http_method: hyper::Method::PATCH,
3591 });
3592
3593 for &field in ["alt", "name", "updateMask"].iter() {
3594 if self._additional_params.contains_key(field) {
3595 dlg.finished(false);
3596 return Err(common::Error::FieldClash(field));
3597 }
3598 }
3599
3600 let mut params = Params::with_capacity(5 + self._additional_params.len());
3601 params.push("name", self._name);
3602 if let Some(value) = self._update_mask.as_ref() {
3603 params.push("updateMask", value.to_string());
3604 }
3605
3606 params.extend(self._additional_params.iter());
3607
3608 params.push("alt", "json");
3609 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3610 if self._scopes.is_empty() {
3611 self._scopes
3612 .insert(Scope::CloudPlatform.as_ref().to_string());
3613 }
3614
3615 #[allow(clippy::single_element_loop)]
3616 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3617 url = params.uri_replacement(url, param_name, find_this, true);
3618 }
3619 {
3620 let to_remove = ["name"];
3621 params.remove_params(&to_remove);
3622 }
3623
3624 let url = params.parse_with_url(&url);
3625
3626 let mut json_mime_type = mime::APPLICATION_JSON;
3627 let mut request_value_reader = {
3628 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3629 common::remove_json_null_values(&mut value);
3630 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3631 serde_json::to_writer(&mut dst, &value).unwrap();
3632 dst
3633 };
3634 let request_size = request_value_reader
3635 .seek(std::io::SeekFrom::End(0))
3636 .unwrap();
3637 request_value_reader
3638 .seek(std::io::SeekFrom::Start(0))
3639 .unwrap();
3640
3641 loop {
3642 let token = match self
3643 .hub
3644 .auth
3645 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3646 .await
3647 {
3648 Ok(token) => token,
3649 Err(e) => match dlg.token(e) {
3650 Ok(token) => token,
3651 Err(e) => {
3652 dlg.finished(false);
3653 return Err(common::Error::MissingToken(e));
3654 }
3655 },
3656 };
3657 request_value_reader
3658 .seek(std::io::SeekFrom::Start(0))
3659 .unwrap();
3660 let mut req_result = {
3661 let client = &self.hub.client;
3662 dlg.pre_request();
3663 let mut req_builder = hyper::Request::builder()
3664 .method(hyper::Method::PATCH)
3665 .uri(url.as_str())
3666 .header(USER_AGENT, self.hub._user_agent.clone());
3667
3668 if let Some(token) = token.as_ref() {
3669 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3670 }
3671
3672 let request = req_builder
3673 .header(CONTENT_TYPE, json_mime_type.to_string())
3674 .header(CONTENT_LENGTH, request_size as u64)
3675 .body(common::to_body(
3676 request_value_reader.get_ref().clone().into(),
3677 ));
3678
3679 client.request(request.unwrap()).await
3680 };
3681
3682 match req_result {
3683 Err(err) => {
3684 if let common::Retry::After(d) = dlg.http_error(&err) {
3685 sleep(d).await;
3686 continue;
3687 }
3688 dlg.finished(false);
3689 return Err(common::Error::HttpError(err));
3690 }
3691 Ok(res) => {
3692 let (mut parts, body) = res.into_parts();
3693 let mut body = common::Body::new(body);
3694 if !parts.status.is_success() {
3695 let bytes = common::to_bytes(body).await.unwrap_or_default();
3696 let error = serde_json::from_str(&common::to_string(&bytes));
3697 let response = common::to_response(parts, bytes.into());
3698
3699 if let common::Retry::After(d) =
3700 dlg.http_failure(&response, error.as_ref().ok())
3701 {
3702 sleep(d).await;
3703 continue;
3704 }
3705
3706 dlg.finished(false);
3707
3708 return Err(match error {
3709 Ok(value) => common::Error::BadRequest(value),
3710 _ => common::Error::Failure(response),
3711 });
3712 }
3713 let response = {
3714 let bytes = common::to_bytes(body).await.unwrap_or_default();
3715 let encoded = common::to_string(&bytes);
3716 match serde_json::from_str(&encoded) {
3717 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3718 Err(error) => {
3719 dlg.response_json_decode_error(&encoded, &error);
3720 return Err(common::Error::JsonDecodeError(
3721 encoded.to_string(),
3722 error,
3723 ));
3724 }
3725 }
3726 };
3727
3728 dlg.finished(true);
3729 return Ok(response);
3730 }
3731 }
3732 }
3733 }
3734
3735 ///
3736 /// Sets the *request* property to the given value.
3737 ///
3738 /// Even though the property as already been set when instantiating this call,
3739 /// we provide this method for API completeness.
3740 pub fn request(mut self, new_value: AccessLevel) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3741 self._request = new_value;
3742 self
3743 }
3744 /// Identifier. Resource name for the `AccessLevel`. Format: `accessPolicies/{access_policy}/accessLevels/{access_level}`. The `access_level` component must begin with a letter, followed by alphanumeric characters or `_`. Its maximum length is 50 characters. After you create an `AccessLevel`, you cannot change its `name`.
3745 ///
3746 /// Sets the *name* path property to the given value.
3747 ///
3748 /// Even though the property as already been set when instantiating this call,
3749 /// we provide this method for API completeness.
3750 pub fn name(mut self, new_value: &str) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3751 self._name = new_value.to_string();
3752 self
3753 }
3754 /// Required. Mask to control which fields get updated. Must be non-empty.
3755 ///
3756 /// Sets the *update mask* query property to the given value.
3757 pub fn update_mask(
3758 mut self,
3759 new_value: common::FieldMask,
3760 ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3761 self._update_mask = Some(new_value);
3762 self
3763 }
3764 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3765 /// while executing the actual API request.
3766 ///
3767 /// ````text
3768 /// It should be used to handle progress information, and to implement a certain level of resilience.
3769 /// ````
3770 ///
3771 /// Sets the *delegate* property to the given value.
3772 pub fn delegate(
3773 mut self,
3774 new_value: &'a mut dyn common::Delegate,
3775 ) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3776 self._delegate = Some(new_value);
3777 self
3778 }
3779
3780 /// Set any additional parameter of the query string used in the request.
3781 /// It should be used to set parameters which are not yet available through their own
3782 /// setters.
3783 ///
3784 /// Please note that this method must not be used to set any of the known parameters
3785 /// which have their own setter method. If done anyway, the request will fail.
3786 ///
3787 /// # Additional Parameters
3788 ///
3789 /// * *$.xgafv* (query-string) - V1 error format.
3790 /// * *access_token* (query-string) - OAuth access token.
3791 /// * *alt* (query-string) - Data format for response.
3792 /// * *callback* (query-string) - JSONP
3793 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3794 /// * *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.
3795 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3796 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3797 /// * *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.
3798 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3799 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3800 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelPatchCall<'a, C>
3801 where
3802 T: AsRef<str>,
3803 {
3804 self._additional_params
3805 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3806 self
3807 }
3808
3809 /// Identifies the authorization scope for the method you are building.
3810 ///
3811 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3812 /// [`Scope::CloudPlatform`].
3813 ///
3814 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3815 /// tokens for more than one scope.
3816 ///
3817 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3818 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3819 /// sufficient, a read-write scope will do as well.
3820 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelPatchCall<'a, C>
3821 where
3822 St: AsRef<str>,
3823 {
3824 self._scopes.insert(String::from(scope.as_ref()));
3825 self
3826 }
3827 /// Identifies the authorization scope(s) for the method you are building.
3828 ///
3829 /// See [`Self::add_scope()`] for details.
3830 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelPatchCall<'a, C>
3831 where
3832 I: IntoIterator<Item = St>,
3833 St: AsRef<str>,
3834 {
3835 self._scopes
3836 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3837 self
3838 }
3839
3840 /// Removes all scopes, and no default scope will be used either.
3841 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3842 /// for details).
3843 pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelPatchCall<'a, C> {
3844 self._scopes.clear();
3845 self
3846 }
3847}
3848
3849/// Replaces all existing access levels in an access policy with the access levels provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. If the replacement contains errors, an error response is returned for the first error encountered. Upon error, the replacement is cancelled, and existing access levels are not affected. The Operation.response field contains ReplaceAccessLevelsResponse. Removing access levels contained in existing service perimeters result in an error.
3850///
3851/// A builder for the *accessLevels.replaceAll* method supported by a *accessPolicy* resource.
3852/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
3853///
3854/// # Example
3855///
3856/// Instantiate a resource method builder
3857///
3858/// ```test_harness,no_run
3859/// # extern crate hyper;
3860/// # extern crate hyper_rustls;
3861/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
3862/// use accesscontextmanager1::api::ReplaceAccessLevelsRequest;
3863/// # async fn dox() {
3864/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3865///
3866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3867/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3868/// # secret,
3869/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3870/// # ).build().await.unwrap();
3871///
3872/// # let client = hyper_util::client::legacy::Client::builder(
3873/// # hyper_util::rt::TokioExecutor::new()
3874/// # )
3875/// # .build(
3876/// # hyper_rustls::HttpsConnectorBuilder::new()
3877/// # .with_native_roots()
3878/// # .unwrap()
3879/// # .https_or_http()
3880/// # .enable_http1()
3881/// # .build()
3882/// # );
3883/// # let mut hub = AccessContextManager::new(client, auth);
3884/// // As the method needs a request, you would usually fill it with the desired information
3885/// // into the respective structure. Some of the parts shown here might not be applicable !
3886/// // Values shown here are possibly random and not representative !
3887/// let mut req = ReplaceAccessLevelsRequest::default();
3888///
3889/// // You can configure optional parameters by calling the respective setters at will, and
3890/// // execute the final call using `doit()`.
3891/// // Values shown here are possibly random and not representative !
3892/// let result = hub.access_policies().access_levels_replace_all(req, "parent")
3893/// .doit().await;
3894/// # }
3895/// ```
3896pub struct AccessPolicyAccessLevelReplaceAllCall<'a, C>
3897where
3898 C: 'a,
3899{
3900 hub: &'a AccessContextManager<C>,
3901 _request: ReplaceAccessLevelsRequest,
3902 _parent: String,
3903 _delegate: Option<&'a mut dyn common::Delegate>,
3904 _additional_params: HashMap<String, String>,
3905 _scopes: BTreeSet<String>,
3906}
3907
3908impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelReplaceAllCall<'a, C> {}
3909
3910impl<'a, C> AccessPolicyAccessLevelReplaceAllCall<'a, C>
3911where
3912 C: common::Connector,
3913{
3914 /// Perform the operation you have build so far.
3915 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
3916 use std::borrow::Cow;
3917 use std::io::{Read, Seek};
3918
3919 use common::{url::Params, ToParts};
3920 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3921
3922 let mut dd = common::DefaultDelegate;
3923 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3924 dlg.begin(common::MethodInfo {
3925 id: "accesscontextmanager.accessPolicies.accessLevels.replaceAll",
3926 http_method: hyper::Method::POST,
3927 });
3928
3929 for &field in ["alt", "parent"].iter() {
3930 if self._additional_params.contains_key(field) {
3931 dlg.finished(false);
3932 return Err(common::Error::FieldClash(field));
3933 }
3934 }
3935
3936 let mut params = Params::with_capacity(4 + self._additional_params.len());
3937 params.push("parent", self._parent);
3938
3939 params.extend(self._additional_params.iter());
3940
3941 params.push("alt", "json");
3942 let mut url = self.hub._base_url.clone() + "v1/{+parent}/accessLevels:replaceAll";
3943 if self._scopes.is_empty() {
3944 self._scopes
3945 .insert(Scope::CloudPlatform.as_ref().to_string());
3946 }
3947
3948 #[allow(clippy::single_element_loop)]
3949 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3950 url = params.uri_replacement(url, param_name, find_this, true);
3951 }
3952 {
3953 let to_remove = ["parent"];
3954 params.remove_params(&to_remove);
3955 }
3956
3957 let url = params.parse_with_url(&url);
3958
3959 let mut json_mime_type = mime::APPLICATION_JSON;
3960 let mut request_value_reader = {
3961 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3962 common::remove_json_null_values(&mut value);
3963 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3964 serde_json::to_writer(&mut dst, &value).unwrap();
3965 dst
3966 };
3967 let request_size = request_value_reader
3968 .seek(std::io::SeekFrom::End(0))
3969 .unwrap();
3970 request_value_reader
3971 .seek(std::io::SeekFrom::Start(0))
3972 .unwrap();
3973
3974 loop {
3975 let token = match self
3976 .hub
3977 .auth
3978 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3979 .await
3980 {
3981 Ok(token) => token,
3982 Err(e) => match dlg.token(e) {
3983 Ok(token) => token,
3984 Err(e) => {
3985 dlg.finished(false);
3986 return Err(common::Error::MissingToken(e));
3987 }
3988 },
3989 };
3990 request_value_reader
3991 .seek(std::io::SeekFrom::Start(0))
3992 .unwrap();
3993 let mut req_result = {
3994 let client = &self.hub.client;
3995 dlg.pre_request();
3996 let mut req_builder = hyper::Request::builder()
3997 .method(hyper::Method::POST)
3998 .uri(url.as_str())
3999 .header(USER_AGENT, self.hub._user_agent.clone());
4000
4001 if let Some(token) = token.as_ref() {
4002 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4003 }
4004
4005 let request = req_builder
4006 .header(CONTENT_TYPE, json_mime_type.to_string())
4007 .header(CONTENT_LENGTH, request_size as u64)
4008 .body(common::to_body(
4009 request_value_reader.get_ref().clone().into(),
4010 ));
4011
4012 client.request(request.unwrap()).await
4013 };
4014
4015 match req_result {
4016 Err(err) => {
4017 if let common::Retry::After(d) = dlg.http_error(&err) {
4018 sleep(d).await;
4019 continue;
4020 }
4021 dlg.finished(false);
4022 return Err(common::Error::HttpError(err));
4023 }
4024 Ok(res) => {
4025 let (mut parts, body) = res.into_parts();
4026 let mut body = common::Body::new(body);
4027 if !parts.status.is_success() {
4028 let bytes = common::to_bytes(body).await.unwrap_or_default();
4029 let error = serde_json::from_str(&common::to_string(&bytes));
4030 let response = common::to_response(parts, bytes.into());
4031
4032 if let common::Retry::After(d) =
4033 dlg.http_failure(&response, error.as_ref().ok())
4034 {
4035 sleep(d).await;
4036 continue;
4037 }
4038
4039 dlg.finished(false);
4040
4041 return Err(match error {
4042 Ok(value) => common::Error::BadRequest(value),
4043 _ => common::Error::Failure(response),
4044 });
4045 }
4046 let response = {
4047 let bytes = common::to_bytes(body).await.unwrap_or_default();
4048 let encoded = common::to_string(&bytes);
4049 match serde_json::from_str(&encoded) {
4050 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4051 Err(error) => {
4052 dlg.response_json_decode_error(&encoded, &error);
4053 return Err(common::Error::JsonDecodeError(
4054 encoded.to_string(),
4055 error,
4056 ));
4057 }
4058 }
4059 };
4060
4061 dlg.finished(true);
4062 return Ok(response);
4063 }
4064 }
4065 }
4066 }
4067
4068 ///
4069 /// Sets the *request* property to the given value.
4070 ///
4071 /// Even though the property as already been set when instantiating this call,
4072 /// we provide this method for API completeness.
4073 pub fn request(
4074 mut self,
4075 new_value: ReplaceAccessLevelsRequest,
4076 ) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4077 self._request = new_value;
4078 self
4079 }
4080 /// Required. Resource name for the access policy which owns these Access Levels. Format: `accessPolicies/{policy_id}`
4081 ///
4082 /// Sets the *parent* path property to the given value.
4083 ///
4084 /// Even though the property as already been set when instantiating this call,
4085 /// we provide this method for API completeness.
4086 pub fn parent(mut self, new_value: &str) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4087 self._parent = new_value.to_string();
4088 self
4089 }
4090 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4091 /// while executing the actual API request.
4092 ///
4093 /// ````text
4094 /// It should be used to handle progress information, and to implement a certain level of resilience.
4095 /// ````
4096 ///
4097 /// Sets the *delegate* property to the given value.
4098 pub fn delegate(
4099 mut self,
4100 new_value: &'a mut dyn common::Delegate,
4101 ) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4102 self._delegate = Some(new_value);
4103 self
4104 }
4105
4106 /// Set any additional parameter of the query string used in the request.
4107 /// It should be used to set parameters which are not yet available through their own
4108 /// setters.
4109 ///
4110 /// Please note that this method must not be used to set any of the known parameters
4111 /// which have their own setter method. If done anyway, the request will fail.
4112 ///
4113 /// # Additional Parameters
4114 ///
4115 /// * *$.xgafv* (query-string) - V1 error format.
4116 /// * *access_token* (query-string) - OAuth access token.
4117 /// * *alt* (query-string) - Data format for response.
4118 /// * *callback* (query-string) - JSONP
4119 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4120 /// * *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.
4121 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4122 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4123 /// * *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.
4124 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4125 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4126 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAccessLevelReplaceAllCall<'a, C>
4127 where
4128 T: AsRef<str>,
4129 {
4130 self._additional_params
4131 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4132 self
4133 }
4134
4135 /// Identifies the authorization scope for the method you are building.
4136 ///
4137 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4138 /// [`Scope::CloudPlatform`].
4139 ///
4140 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4141 /// tokens for more than one scope.
4142 ///
4143 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4144 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4145 /// sufficient, a read-write scope will do as well.
4146 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelReplaceAllCall<'a, C>
4147 where
4148 St: AsRef<str>,
4149 {
4150 self._scopes.insert(String::from(scope.as_ref()));
4151 self
4152 }
4153 /// Identifies the authorization scope(s) for the method you are building.
4154 ///
4155 /// See [`Self::add_scope()`] for details.
4156 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAccessLevelReplaceAllCall<'a, C>
4157 where
4158 I: IntoIterator<Item = St>,
4159 St: AsRef<str>,
4160 {
4161 self._scopes
4162 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4163 self
4164 }
4165
4166 /// Removes all scopes, and no default scope will be used either.
4167 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4168 /// for details).
4169 pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelReplaceAllCall<'a, C> {
4170 self._scopes.clear();
4171 self
4172 }
4173}
4174
4175/// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
4176///
4177/// A builder for the *accessLevels.testIamPermissions* method supported by a *accessPolicy* resource.
4178/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4179///
4180/// # Example
4181///
4182/// Instantiate a resource method builder
4183///
4184/// ```test_harness,no_run
4185/// # extern crate hyper;
4186/// # extern crate hyper_rustls;
4187/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
4188/// use accesscontextmanager1::api::TestIamPermissionsRequest;
4189/// # async fn dox() {
4190/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4191///
4192/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4193/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4194/// # secret,
4195/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4196/// # ).build().await.unwrap();
4197///
4198/// # let client = hyper_util::client::legacy::Client::builder(
4199/// # hyper_util::rt::TokioExecutor::new()
4200/// # )
4201/// # .build(
4202/// # hyper_rustls::HttpsConnectorBuilder::new()
4203/// # .with_native_roots()
4204/// # .unwrap()
4205/// # .https_or_http()
4206/// # .enable_http1()
4207/// # .build()
4208/// # );
4209/// # let mut hub = AccessContextManager::new(client, auth);
4210/// // As the method needs a request, you would usually fill it with the desired information
4211/// // into the respective structure. Some of the parts shown here might not be applicable !
4212/// // Values shown here are possibly random and not representative !
4213/// let mut req = TestIamPermissionsRequest::default();
4214///
4215/// // You can configure optional parameters by calling the respective setters at will, and
4216/// // execute the final call using `doit()`.
4217/// // Values shown here are possibly random and not representative !
4218/// let result = hub.access_policies().access_levels_test_iam_permissions(req, "resource")
4219/// .doit().await;
4220/// # }
4221/// ```
4222pub struct AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4223where
4224 C: 'a,
4225{
4226 hub: &'a AccessContextManager<C>,
4227 _request: TestIamPermissionsRequest,
4228 _resource: String,
4229 _delegate: Option<&'a mut dyn common::Delegate>,
4230 _additional_params: HashMap<String, String>,
4231 _scopes: BTreeSet<String>,
4232}
4233
4234impl<'a, C> common::CallBuilder for AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {}
4235
4236impl<'a, C> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4237where
4238 C: common::Connector,
4239{
4240 /// Perform the operation you have build so far.
4241 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
4242 use std::borrow::Cow;
4243 use std::io::{Read, Seek};
4244
4245 use common::{url::Params, ToParts};
4246 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4247
4248 let mut dd = common::DefaultDelegate;
4249 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4250 dlg.begin(common::MethodInfo {
4251 id: "accesscontextmanager.accessPolicies.accessLevels.testIamPermissions",
4252 http_method: hyper::Method::POST,
4253 });
4254
4255 for &field in ["alt", "resource"].iter() {
4256 if self._additional_params.contains_key(field) {
4257 dlg.finished(false);
4258 return Err(common::Error::FieldClash(field));
4259 }
4260 }
4261
4262 let mut params = Params::with_capacity(4 + self._additional_params.len());
4263 params.push("resource", self._resource);
4264
4265 params.extend(self._additional_params.iter());
4266
4267 params.push("alt", "json");
4268 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
4269 if self._scopes.is_empty() {
4270 self._scopes
4271 .insert(Scope::CloudPlatform.as_ref().to_string());
4272 }
4273
4274 #[allow(clippy::single_element_loop)]
4275 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4276 url = params.uri_replacement(url, param_name, find_this, true);
4277 }
4278 {
4279 let to_remove = ["resource"];
4280 params.remove_params(&to_remove);
4281 }
4282
4283 let url = params.parse_with_url(&url);
4284
4285 let mut json_mime_type = mime::APPLICATION_JSON;
4286 let mut request_value_reader = {
4287 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4288 common::remove_json_null_values(&mut value);
4289 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4290 serde_json::to_writer(&mut dst, &value).unwrap();
4291 dst
4292 };
4293 let request_size = request_value_reader
4294 .seek(std::io::SeekFrom::End(0))
4295 .unwrap();
4296 request_value_reader
4297 .seek(std::io::SeekFrom::Start(0))
4298 .unwrap();
4299
4300 loop {
4301 let token = match self
4302 .hub
4303 .auth
4304 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4305 .await
4306 {
4307 Ok(token) => token,
4308 Err(e) => match dlg.token(e) {
4309 Ok(token) => token,
4310 Err(e) => {
4311 dlg.finished(false);
4312 return Err(common::Error::MissingToken(e));
4313 }
4314 },
4315 };
4316 request_value_reader
4317 .seek(std::io::SeekFrom::Start(0))
4318 .unwrap();
4319 let mut req_result = {
4320 let client = &self.hub.client;
4321 dlg.pre_request();
4322 let mut req_builder = hyper::Request::builder()
4323 .method(hyper::Method::POST)
4324 .uri(url.as_str())
4325 .header(USER_AGENT, self.hub._user_agent.clone());
4326
4327 if let Some(token) = token.as_ref() {
4328 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4329 }
4330
4331 let request = req_builder
4332 .header(CONTENT_TYPE, json_mime_type.to_string())
4333 .header(CONTENT_LENGTH, request_size as u64)
4334 .body(common::to_body(
4335 request_value_reader.get_ref().clone().into(),
4336 ));
4337
4338 client.request(request.unwrap()).await
4339 };
4340
4341 match req_result {
4342 Err(err) => {
4343 if let common::Retry::After(d) = dlg.http_error(&err) {
4344 sleep(d).await;
4345 continue;
4346 }
4347 dlg.finished(false);
4348 return Err(common::Error::HttpError(err));
4349 }
4350 Ok(res) => {
4351 let (mut parts, body) = res.into_parts();
4352 let mut body = common::Body::new(body);
4353 if !parts.status.is_success() {
4354 let bytes = common::to_bytes(body).await.unwrap_or_default();
4355 let error = serde_json::from_str(&common::to_string(&bytes));
4356 let response = common::to_response(parts, bytes.into());
4357
4358 if let common::Retry::After(d) =
4359 dlg.http_failure(&response, error.as_ref().ok())
4360 {
4361 sleep(d).await;
4362 continue;
4363 }
4364
4365 dlg.finished(false);
4366
4367 return Err(match error {
4368 Ok(value) => common::Error::BadRequest(value),
4369 _ => common::Error::Failure(response),
4370 });
4371 }
4372 let response = {
4373 let bytes = common::to_bytes(body).await.unwrap_or_default();
4374 let encoded = common::to_string(&bytes);
4375 match serde_json::from_str(&encoded) {
4376 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4377 Err(error) => {
4378 dlg.response_json_decode_error(&encoded, &error);
4379 return Err(common::Error::JsonDecodeError(
4380 encoded.to_string(),
4381 error,
4382 ));
4383 }
4384 }
4385 };
4386
4387 dlg.finished(true);
4388 return Ok(response);
4389 }
4390 }
4391 }
4392 }
4393
4394 ///
4395 /// Sets the *request* property to the given value.
4396 ///
4397 /// Even though the property as already been set when instantiating this call,
4398 /// we provide this method for API completeness.
4399 pub fn request(
4400 mut self,
4401 new_value: TestIamPermissionsRequest,
4402 ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4403 self._request = new_value;
4404 self
4405 }
4406 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
4407 ///
4408 /// Sets the *resource* path property to the given value.
4409 ///
4410 /// Even though the property as already been set when instantiating this call,
4411 /// we provide this method for API completeness.
4412 pub fn resource(
4413 mut self,
4414 new_value: &str,
4415 ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4416 self._resource = new_value.to_string();
4417 self
4418 }
4419 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4420 /// while executing the actual API request.
4421 ///
4422 /// ````text
4423 /// It should be used to handle progress information, and to implement a certain level of resilience.
4424 /// ````
4425 ///
4426 /// Sets the *delegate* property to the given value.
4427 pub fn delegate(
4428 mut self,
4429 new_value: &'a mut dyn common::Delegate,
4430 ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4431 self._delegate = Some(new_value);
4432 self
4433 }
4434
4435 /// Set any additional parameter of the query string used in the request.
4436 /// It should be used to set parameters which are not yet available through their own
4437 /// setters.
4438 ///
4439 /// Please note that this method must not be used to set any of the known parameters
4440 /// which have their own setter method. If done anyway, the request will fail.
4441 ///
4442 /// # Additional Parameters
4443 ///
4444 /// * *$.xgafv* (query-string) - V1 error format.
4445 /// * *access_token* (query-string) - OAuth access token.
4446 /// * *alt* (query-string) - Data format for response.
4447 /// * *callback* (query-string) - JSONP
4448 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4449 /// * *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.
4450 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4451 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4452 /// * *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.
4453 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4454 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4455 pub fn param<T>(
4456 mut self,
4457 name: T,
4458 value: T,
4459 ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4460 where
4461 T: AsRef<str>,
4462 {
4463 self._additional_params
4464 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4465 self
4466 }
4467
4468 /// Identifies the authorization scope for the method you are building.
4469 ///
4470 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4471 /// [`Scope::CloudPlatform`].
4472 ///
4473 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4474 /// tokens for more than one scope.
4475 ///
4476 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4477 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4478 /// sufficient, a read-write scope will do as well.
4479 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4480 where
4481 St: AsRef<str>,
4482 {
4483 self._scopes.insert(String::from(scope.as_ref()));
4484 self
4485 }
4486 /// Identifies the authorization scope(s) for the method you are building.
4487 ///
4488 /// See [`Self::add_scope()`] for details.
4489 pub fn add_scopes<I, St>(
4490 mut self,
4491 scopes: I,
4492 ) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C>
4493 where
4494 I: IntoIterator<Item = St>,
4495 St: AsRef<str>,
4496 {
4497 self._scopes
4498 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4499 self
4500 }
4501
4502 /// Removes all scopes, and no default scope will be used either.
4503 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4504 /// for details).
4505 pub fn clear_scopes(mut self) -> AccessPolicyAccessLevelTestIamPermissionCall<'a, C> {
4506 self._scopes.clear();
4507 self
4508 }
4509}
4510
4511/// Creates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. The name of this `AuthorizedOrgsDesc` will be assigned during creation.
4512///
4513/// A builder for the *authorizedOrgsDescs.create* method supported by a *accessPolicy* resource.
4514/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4515///
4516/// # Example
4517///
4518/// Instantiate a resource method builder
4519///
4520/// ```test_harness,no_run
4521/// # extern crate hyper;
4522/// # extern crate hyper_rustls;
4523/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
4524/// use accesscontextmanager1::api::AuthorizedOrgsDesc;
4525/// # async fn dox() {
4526/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4527///
4528/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4529/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4530/// # secret,
4531/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4532/// # ).build().await.unwrap();
4533///
4534/// # let client = hyper_util::client::legacy::Client::builder(
4535/// # hyper_util::rt::TokioExecutor::new()
4536/// # )
4537/// # .build(
4538/// # hyper_rustls::HttpsConnectorBuilder::new()
4539/// # .with_native_roots()
4540/// # .unwrap()
4541/// # .https_or_http()
4542/// # .enable_http1()
4543/// # .build()
4544/// # );
4545/// # let mut hub = AccessContextManager::new(client, auth);
4546/// // As the method needs a request, you would usually fill it with the desired information
4547/// // into the respective structure. Some of the parts shown here might not be applicable !
4548/// // Values shown here are possibly random and not representative !
4549/// let mut req = AuthorizedOrgsDesc::default();
4550///
4551/// // You can configure optional parameters by calling the respective setters at will, and
4552/// // execute the final call using `doit()`.
4553/// // Values shown here are possibly random and not representative !
4554/// let result = hub.access_policies().authorized_orgs_descs_create(req, "parent")
4555/// .doit().await;
4556/// # }
4557/// ```
4558pub struct AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
4559where
4560 C: 'a,
4561{
4562 hub: &'a AccessContextManager<C>,
4563 _request: AuthorizedOrgsDesc,
4564 _parent: String,
4565 _delegate: Option<&'a mut dyn common::Delegate>,
4566 _additional_params: HashMap<String, String>,
4567 _scopes: BTreeSet<String>,
4568}
4569
4570impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {}
4571
4572impl<'a, C> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
4573where
4574 C: common::Connector,
4575{
4576 /// Perform the operation you have build so far.
4577 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4578 use std::borrow::Cow;
4579 use std::io::{Read, Seek};
4580
4581 use common::{url::Params, ToParts};
4582 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4583
4584 let mut dd = common::DefaultDelegate;
4585 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4586 dlg.begin(common::MethodInfo {
4587 id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.create",
4588 http_method: hyper::Method::POST,
4589 });
4590
4591 for &field in ["alt", "parent"].iter() {
4592 if self._additional_params.contains_key(field) {
4593 dlg.finished(false);
4594 return Err(common::Error::FieldClash(field));
4595 }
4596 }
4597
4598 let mut params = Params::with_capacity(4 + self._additional_params.len());
4599 params.push("parent", self._parent);
4600
4601 params.extend(self._additional_params.iter());
4602
4603 params.push("alt", "json");
4604 let mut url = self.hub._base_url.clone() + "v1/{+parent}/authorizedOrgsDescs";
4605 if self._scopes.is_empty() {
4606 self._scopes
4607 .insert(Scope::CloudPlatform.as_ref().to_string());
4608 }
4609
4610 #[allow(clippy::single_element_loop)]
4611 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4612 url = params.uri_replacement(url, param_name, find_this, true);
4613 }
4614 {
4615 let to_remove = ["parent"];
4616 params.remove_params(&to_remove);
4617 }
4618
4619 let url = params.parse_with_url(&url);
4620
4621 let mut json_mime_type = mime::APPLICATION_JSON;
4622 let mut request_value_reader = {
4623 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4624 common::remove_json_null_values(&mut value);
4625 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4626 serde_json::to_writer(&mut dst, &value).unwrap();
4627 dst
4628 };
4629 let request_size = request_value_reader
4630 .seek(std::io::SeekFrom::End(0))
4631 .unwrap();
4632 request_value_reader
4633 .seek(std::io::SeekFrom::Start(0))
4634 .unwrap();
4635
4636 loop {
4637 let token = match self
4638 .hub
4639 .auth
4640 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4641 .await
4642 {
4643 Ok(token) => token,
4644 Err(e) => match dlg.token(e) {
4645 Ok(token) => token,
4646 Err(e) => {
4647 dlg.finished(false);
4648 return Err(common::Error::MissingToken(e));
4649 }
4650 },
4651 };
4652 request_value_reader
4653 .seek(std::io::SeekFrom::Start(0))
4654 .unwrap();
4655 let mut req_result = {
4656 let client = &self.hub.client;
4657 dlg.pre_request();
4658 let mut req_builder = hyper::Request::builder()
4659 .method(hyper::Method::POST)
4660 .uri(url.as_str())
4661 .header(USER_AGENT, self.hub._user_agent.clone());
4662
4663 if let Some(token) = token.as_ref() {
4664 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4665 }
4666
4667 let request = req_builder
4668 .header(CONTENT_TYPE, json_mime_type.to_string())
4669 .header(CONTENT_LENGTH, request_size as u64)
4670 .body(common::to_body(
4671 request_value_reader.get_ref().clone().into(),
4672 ));
4673
4674 client.request(request.unwrap()).await
4675 };
4676
4677 match req_result {
4678 Err(err) => {
4679 if let common::Retry::After(d) = dlg.http_error(&err) {
4680 sleep(d).await;
4681 continue;
4682 }
4683 dlg.finished(false);
4684 return Err(common::Error::HttpError(err));
4685 }
4686 Ok(res) => {
4687 let (mut parts, body) = res.into_parts();
4688 let mut body = common::Body::new(body);
4689 if !parts.status.is_success() {
4690 let bytes = common::to_bytes(body).await.unwrap_or_default();
4691 let error = serde_json::from_str(&common::to_string(&bytes));
4692 let response = common::to_response(parts, bytes.into());
4693
4694 if let common::Retry::After(d) =
4695 dlg.http_failure(&response, error.as_ref().ok())
4696 {
4697 sleep(d).await;
4698 continue;
4699 }
4700
4701 dlg.finished(false);
4702
4703 return Err(match error {
4704 Ok(value) => common::Error::BadRequest(value),
4705 _ => common::Error::Failure(response),
4706 });
4707 }
4708 let response = {
4709 let bytes = common::to_bytes(body).await.unwrap_or_default();
4710 let encoded = common::to_string(&bytes);
4711 match serde_json::from_str(&encoded) {
4712 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4713 Err(error) => {
4714 dlg.response_json_decode_error(&encoded, &error);
4715 return Err(common::Error::JsonDecodeError(
4716 encoded.to_string(),
4717 error,
4718 ));
4719 }
4720 }
4721 };
4722
4723 dlg.finished(true);
4724 return Ok(response);
4725 }
4726 }
4727 }
4728 }
4729
4730 ///
4731 /// Sets the *request* property to the given value.
4732 ///
4733 /// Even though the property as already been set when instantiating this call,
4734 /// we provide this method for API completeness.
4735 pub fn request(
4736 mut self,
4737 new_value: AuthorizedOrgsDesc,
4738 ) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
4739 self._request = new_value;
4740 self
4741 }
4742 /// Required. Resource name for the access policy which owns this Authorized Orgs Desc. Format: `accessPolicies/{policy_id}`
4743 ///
4744 /// Sets the *parent* path property to the given value.
4745 ///
4746 /// Even though the property as already been set when instantiating this call,
4747 /// we provide this method for API completeness.
4748 pub fn parent(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
4749 self._parent = new_value.to_string();
4750 self
4751 }
4752 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4753 /// while executing the actual API request.
4754 ///
4755 /// ````text
4756 /// It should be used to handle progress information, and to implement a certain level of resilience.
4757 /// ````
4758 ///
4759 /// Sets the *delegate* property to the given value.
4760 pub fn delegate(
4761 mut self,
4762 new_value: &'a mut dyn common::Delegate,
4763 ) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
4764 self._delegate = Some(new_value);
4765 self
4766 }
4767
4768 /// Set any additional parameter of the query string used in the request.
4769 /// It should be used to set parameters which are not yet available through their own
4770 /// setters.
4771 ///
4772 /// Please note that this method must not be used to set any of the known parameters
4773 /// which have their own setter method. If done anyway, the request will fail.
4774 ///
4775 /// # Additional Parameters
4776 ///
4777 /// * *$.xgafv* (query-string) - V1 error format.
4778 /// * *access_token* (query-string) - OAuth access token.
4779 /// * *alt* (query-string) - Data format for response.
4780 /// * *callback* (query-string) - JSONP
4781 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4782 /// * *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.
4783 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4784 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4785 /// * *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.
4786 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4787 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4788 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
4789 where
4790 T: AsRef<str>,
4791 {
4792 self._additional_params
4793 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4794 self
4795 }
4796
4797 /// Identifies the authorization scope for the method you are building.
4798 ///
4799 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4800 /// [`Scope::CloudPlatform`].
4801 ///
4802 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4803 /// tokens for more than one scope.
4804 ///
4805 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4806 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4807 /// sufficient, a read-write scope will do as well.
4808 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
4809 where
4810 St: AsRef<str>,
4811 {
4812 self._scopes.insert(String::from(scope.as_ref()));
4813 self
4814 }
4815 /// Identifies the authorization scope(s) for the method you are building.
4816 ///
4817 /// See [`Self::add_scope()`] for details.
4818 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C>
4819 where
4820 I: IntoIterator<Item = St>,
4821 St: AsRef<str>,
4822 {
4823 self._scopes
4824 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4825 self
4826 }
4827
4828 /// Removes all scopes, and no default scope will be used either.
4829 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4830 /// for details).
4831 pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescCreateCall<'a, C> {
4832 self._scopes.clear();
4833 self
4834 }
4835}
4836
4837/// Deletes an authorized orgs desc based on the resource name. The long-running operation from this RPC has a successful status after the authorized orgs desc is removed from long-lasting storage.
4838///
4839/// A builder for the *authorizedOrgsDescs.delete* method supported by a *accessPolicy* resource.
4840/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
4841///
4842/// # Example
4843///
4844/// Instantiate a resource method builder
4845///
4846/// ```test_harness,no_run
4847/// # extern crate hyper;
4848/// # extern crate hyper_rustls;
4849/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
4850/// # async fn dox() {
4851/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4852///
4853/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4854/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4855/// # secret,
4856/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4857/// # ).build().await.unwrap();
4858///
4859/// # let client = hyper_util::client::legacy::Client::builder(
4860/// # hyper_util::rt::TokioExecutor::new()
4861/// # )
4862/// # .build(
4863/// # hyper_rustls::HttpsConnectorBuilder::new()
4864/// # .with_native_roots()
4865/// # .unwrap()
4866/// # .https_or_http()
4867/// # .enable_http1()
4868/// # .build()
4869/// # );
4870/// # let mut hub = AccessContextManager::new(client, auth);
4871/// // You can configure optional parameters by calling the respective setters at will, and
4872/// // execute the final call using `doit()`.
4873/// // Values shown here are possibly random and not representative !
4874/// let result = hub.access_policies().authorized_orgs_descs_delete("name")
4875/// .doit().await;
4876/// # }
4877/// ```
4878pub struct AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
4879where
4880 C: 'a,
4881{
4882 hub: &'a AccessContextManager<C>,
4883 _name: String,
4884 _delegate: Option<&'a mut dyn common::Delegate>,
4885 _additional_params: HashMap<String, String>,
4886 _scopes: BTreeSet<String>,
4887}
4888
4889impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {}
4890
4891impl<'a, C> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
4892where
4893 C: common::Connector,
4894{
4895 /// Perform the operation you have build so far.
4896 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4897 use std::borrow::Cow;
4898 use std::io::{Read, Seek};
4899
4900 use common::{url::Params, ToParts};
4901 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4902
4903 let mut dd = common::DefaultDelegate;
4904 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4905 dlg.begin(common::MethodInfo {
4906 id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.delete",
4907 http_method: hyper::Method::DELETE,
4908 });
4909
4910 for &field in ["alt", "name"].iter() {
4911 if self._additional_params.contains_key(field) {
4912 dlg.finished(false);
4913 return Err(common::Error::FieldClash(field));
4914 }
4915 }
4916
4917 let mut params = Params::with_capacity(3 + self._additional_params.len());
4918 params.push("name", self._name);
4919
4920 params.extend(self._additional_params.iter());
4921
4922 params.push("alt", "json");
4923 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4924 if self._scopes.is_empty() {
4925 self._scopes
4926 .insert(Scope::CloudPlatform.as_ref().to_string());
4927 }
4928
4929 #[allow(clippy::single_element_loop)]
4930 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4931 url = params.uri_replacement(url, param_name, find_this, true);
4932 }
4933 {
4934 let to_remove = ["name"];
4935 params.remove_params(&to_remove);
4936 }
4937
4938 let url = params.parse_with_url(&url);
4939
4940 loop {
4941 let token = match self
4942 .hub
4943 .auth
4944 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4945 .await
4946 {
4947 Ok(token) => token,
4948 Err(e) => match dlg.token(e) {
4949 Ok(token) => token,
4950 Err(e) => {
4951 dlg.finished(false);
4952 return Err(common::Error::MissingToken(e));
4953 }
4954 },
4955 };
4956 let mut req_result = {
4957 let client = &self.hub.client;
4958 dlg.pre_request();
4959 let mut req_builder = hyper::Request::builder()
4960 .method(hyper::Method::DELETE)
4961 .uri(url.as_str())
4962 .header(USER_AGENT, self.hub._user_agent.clone());
4963
4964 if let Some(token) = token.as_ref() {
4965 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4966 }
4967
4968 let request = req_builder
4969 .header(CONTENT_LENGTH, 0_u64)
4970 .body(common::to_body::<String>(None));
4971
4972 client.request(request.unwrap()).await
4973 };
4974
4975 match req_result {
4976 Err(err) => {
4977 if let common::Retry::After(d) = dlg.http_error(&err) {
4978 sleep(d).await;
4979 continue;
4980 }
4981 dlg.finished(false);
4982 return Err(common::Error::HttpError(err));
4983 }
4984 Ok(res) => {
4985 let (mut parts, body) = res.into_parts();
4986 let mut body = common::Body::new(body);
4987 if !parts.status.is_success() {
4988 let bytes = common::to_bytes(body).await.unwrap_or_default();
4989 let error = serde_json::from_str(&common::to_string(&bytes));
4990 let response = common::to_response(parts, bytes.into());
4991
4992 if let common::Retry::After(d) =
4993 dlg.http_failure(&response, error.as_ref().ok())
4994 {
4995 sleep(d).await;
4996 continue;
4997 }
4998
4999 dlg.finished(false);
5000
5001 return Err(match error {
5002 Ok(value) => common::Error::BadRequest(value),
5003 _ => common::Error::Failure(response),
5004 });
5005 }
5006 let response = {
5007 let bytes = common::to_bytes(body).await.unwrap_or_default();
5008 let encoded = common::to_string(&bytes);
5009 match serde_json::from_str(&encoded) {
5010 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5011 Err(error) => {
5012 dlg.response_json_decode_error(&encoded, &error);
5013 return Err(common::Error::JsonDecodeError(
5014 encoded.to_string(),
5015 error,
5016 ));
5017 }
5018 }
5019 };
5020
5021 dlg.finished(true);
5022 return Ok(response);
5023 }
5024 }
5025 }
5026 }
5027
5028 /// Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDesc/{authorized_orgs_desc_id}`
5029 ///
5030 /// Sets the *name* path property to the given value.
5031 ///
5032 /// Even though the property as already been set when instantiating this call,
5033 /// we provide this method for API completeness.
5034 pub fn name(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
5035 self._name = new_value.to_string();
5036 self
5037 }
5038 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5039 /// while executing the actual API request.
5040 ///
5041 /// ````text
5042 /// It should be used to handle progress information, and to implement a certain level of resilience.
5043 /// ````
5044 ///
5045 /// Sets the *delegate* property to the given value.
5046 pub fn delegate(
5047 mut self,
5048 new_value: &'a mut dyn common::Delegate,
5049 ) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
5050 self._delegate = Some(new_value);
5051 self
5052 }
5053
5054 /// Set any additional parameter of the query string used in the request.
5055 /// It should be used to set parameters which are not yet available through their own
5056 /// setters.
5057 ///
5058 /// Please note that this method must not be used to set any of the known parameters
5059 /// which have their own setter method. If done anyway, the request will fail.
5060 ///
5061 /// # Additional Parameters
5062 ///
5063 /// * *$.xgafv* (query-string) - V1 error format.
5064 /// * *access_token* (query-string) - OAuth access token.
5065 /// * *alt* (query-string) - Data format for response.
5066 /// * *callback* (query-string) - JSONP
5067 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5068 /// * *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.
5069 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5070 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5071 /// * *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.
5072 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5073 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5074 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5075 where
5076 T: AsRef<str>,
5077 {
5078 self._additional_params
5079 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5080 self
5081 }
5082
5083 /// Identifies the authorization scope for the method you are building.
5084 ///
5085 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5086 /// [`Scope::CloudPlatform`].
5087 ///
5088 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5089 /// tokens for more than one scope.
5090 ///
5091 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5092 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5093 /// sufficient, a read-write scope will do as well.
5094 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5095 where
5096 St: AsRef<str>,
5097 {
5098 self._scopes.insert(String::from(scope.as_ref()));
5099 self
5100 }
5101 /// Identifies the authorization scope(s) for the method you are building.
5102 ///
5103 /// See [`Self::add_scope()`] for details.
5104 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C>
5105 where
5106 I: IntoIterator<Item = St>,
5107 St: AsRef<str>,
5108 {
5109 self._scopes
5110 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5111 self
5112 }
5113
5114 /// Removes all scopes, and no default scope will be used either.
5115 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5116 /// for details).
5117 pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescDeleteCall<'a, C> {
5118 self._scopes.clear();
5119 self
5120 }
5121}
5122
5123/// Gets an authorized orgs desc based on the resource name.
5124///
5125/// A builder for the *authorizedOrgsDescs.get* method supported by a *accessPolicy* resource.
5126/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
5127///
5128/// # Example
5129///
5130/// Instantiate a resource method builder
5131///
5132/// ```test_harness,no_run
5133/// # extern crate hyper;
5134/// # extern crate hyper_rustls;
5135/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
5136/// # async fn dox() {
5137/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5138///
5139/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5140/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5141/// # secret,
5142/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5143/// # ).build().await.unwrap();
5144///
5145/// # let client = hyper_util::client::legacy::Client::builder(
5146/// # hyper_util::rt::TokioExecutor::new()
5147/// # )
5148/// # .build(
5149/// # hyper_rustls::HttpsConnectorBuilder::new()
5150/// # .with_native_roots()
5151/// # .unwrap()
5152/// # .https_or_http()
5153/// # .enable_http1()
5154/// # .build()
5155/// # );
5156/// # let mut hub = AccessContextManager::new(client, auth);
5157/// // You can configure optional parameters by calling the respective setters at will, and
5158/// // execute the final call using `doit()`.
5159/// // Values shown here are possibly random and not representative !
5160/// let result = hub.access_policies().authorized_orgs_descs_get("name")
5161/// .doit().await;
5162/// # }
5163/// ```
5164pub struct AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5165where
5166 C: 'a,
5167{
5168 hub: &'a AccessContextManager<C>,
5169 _name: String,
5170 _delegate: Option<&'a mut dyn common::Delegate>,
5171 _additional_params: HashMap<String, String>,
5172 _scopes: BTreeSet<String>,
5173}
5174
5175impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {}
5176
5177impl<'a, C> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5178where
5179 C: common::Connector,
5180{
5181 /// Perform the operation you have build so far.
5182 pub async fn doit(mut self) -> common::Result<(common::Response, AuthorizedOrgsDesc)> {
5183 use std::borrow::Cow;
5184 use std::io::{Read, Seek};
5185
5186 use common::{url::Params, ToParts};
5187 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5188
5189 let mut dd = common::DefaultDelegate;
5190 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5191 dlg.begin(common::MethodInfo {
5192 id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.get",
5193 http_method: hyper::Method::GET,
5194 });
5195
5196 for &field in ["alt", "name"].iter() {
5197 if self._additional_params.contains_key(field) {
5198 dlg.finished(false);
5199 return Err(common::Error::FieldClash(field));
5200 }
5201 }
5202
5203 let mut params = Params::with_capacity(3 + self._additional_params.len());
5204 params.push("name", self._name);
5205
5206 params.extend(self._additional_params.iter());
5207
5208 params.push("alt", "json");
5209 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5210 if self._scopes.is_empty() {
5211 self._scopes
5212 .insert(Scope::CloudPlatform.as_ref().to_string());
5213 }
5214
5215 #[allow(clippy::single_element_loop)]
5216 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5217 url = params.uri_replacement(url, param_name, find_this, true);
5218 }
5219 {
5220 let to_remove = ["name"];
5221 params.remove_params(&to_remove);
5222 }
5223
5224 let url = params.parse_with_url(&url);
5225
5226 loop {
5227 let token = match self
5228 .hub
5229 .auth
5230 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5231 .await
5232 {
5233 Ok(token) => token,
5234 Err(e) => match dlg.token(e) {
5235 Ok(token) => token,
5236 Err(e) => {
5237 dlg.finished(false);
5238 return Err(common::Error::MissingToken(e));
5239 }
5240 },
5241 };
5242 let mut req_result = {
5243 let client = &self.hub.client;
5244 dlg.pre_request();
5245 let mut req_builder = hyper::Request::builder()
5246 .method(hyper::Method::GET)
5247 .uri(url.as_str())
5248 .header(USER_AGENT, self.hub._user_agent.clone());
5249
5250 if let Some(token) = token.as_ref() {
5251 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5252 }
5253
5254 let request = req_builder
5255 .header(CONTENT_LENGTH, 0_u64)
5256 .body(common::to_body::<String>(None));
5257
5258 client.request(request.unwrap()).await
5259 };
5260
5261 match req_result {
5262 Err(err) => {
5263 if let common::Retry::After(d) = dlg.http_error(&err) {
5264 sleep(d).await;
5265 continue;
5266 }
5267 dlg.finished(false);
5268 return Err(common::Error::HttpError(err));
5269 }
5270 Ok(res) => {
5271 let (mut parts, body) = res.into_parts();
5272 let mut body = common::Body::new(body);
5273 if !parts.status.is_success() {
5274 let bytes = common::to_bytes(body).await.unwrap_or_default();
5275 let error = serde_json::from_str(&common::to_string(&bytes));
5276 let response = common::to_response(parts, bytes.into());
5277
5278 if let common::Retry::After(d) =
5279 dlg.http_failure(&response, error.as_ref().ok())
5280 {
5281 sleep(d).await;
5282 continue;
5283 }
5284
5285 dlg.finished(false);
5286
5287 return Err(match error {
5288 Ok(value) => common::Error::BadRequest(value),
5289 _ => common::Error::Failure(response),
5290 });
5291 }
5292 let response = {
5293 let bytes = common::to_bytes(body).await.unwrap_or_default();
5294 let encoded = common::to_string(&bytes);
5295 match serde_json::from_str(&encoded) {
5296 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5297 Err(error) => {
5298 dlg.response_json_decode_error(&encoded, &error);
5299 return Err(common::Error::JsonDecodeError(
5300 encoded.to_string(),
5301 error,
5302 ));
5303 }
5304 }
5305 };
5306
5307 dlg.finished(true);
5308 return Ok(response);
5309 }
5310 }
5311 }
5312 }
5313
5314 /// Required. Resource name for the Authorized Orgs Desc. Format: `accessPolicies/{policy_id}/authorizedOrgsDescs/{authorized_orgs_descs_id}`
5315 ///
5316 /// Sets the *name* path property to the given value.
5317 ///
5318 /// Even though the property as already been set when instantiating this call,
5319 /// we provide this method for API completeness.
5320 pub fn name(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
5321 self._name = new_value.to_string();
5322 self
5323 }
5324 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5325 /// while executing the actual API request.
5326 ///
5327 /// ````text
5328 /// It should be used to handle progress information, and to implement a certain level of resilience.
5329 /// ````
5330 ///
5331 /// Sets the *delegate* property to the given value.
5332 pub fn delegate(
5333 mut self,
5334 new_value: &'a mut dyn common::Delegate,
5335 ) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
5336 self._delegate = Some(new_value);
5337 self
5338 }
5339
5340 /// Set any additional parameter of the query string used in the request.
5341 /// It should be used to set parameters which are not yet available through their own
5342 /// setters.
5343 ///
5344 /// Please note that this method must not be used to set any of the known parameters
5345 /// which have their own setter method. If done anyway, the request will fail.
5346 ///
5347 /// # Additional Parameters
5348 ///
5349 /// * *$.xgafv* (query-string) - V1 error format.
5350 /// * *access_token* (query-string) - OAuth access token.
5351 /// * *alt* (query-string) - Data format for response.
5352 /// * *callback* (query-string) - JSONP
5353 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5354 /// * *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.
5355 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5356 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5357 /// * *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.
5358 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5359 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5360 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5361 where
5362 T: AsRef<str>,
5363 {
5364 self._additional_params
5365 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5366 self
5367 }
5368
5369 /// Identifies the authorization scope for the method you are building.
5370 ///
5371 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5372 /// [`Scope::CloudPlatform`].
5373 ///
5374 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5375 /// tokens for more than one scope.
5376 ///
5377 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5378 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5379 /// sufficient, a read-write scope will do as well.
5380 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5381 where
5382 St: AsRef<str>,
5383 {
5384 self._scopes.insert(String::from(scope.as_ref()));
5385 self
5386 }
5387 /// Identifies the authorization scope(s) for the method you are building.
5388 ///
5389 /// See [`Self::add_scope()`] for details.
5390 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C>
5391 where
5392 I: IntoIterator<Item = St>,
5393 St: AsRef<str>,
5394 {
5395 self._scopes
5396 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5397 self
5398 }
5399
5400 /// Removes all scopes, and no default scope will be used either.
5401 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5402 /// for details).
5403 pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescGetCall<'a, C> {
5404 self._scopes.clear();
5405 self
5406 }
5407}
5408
5409/// Lists all authorized orgs descs for an access policy.
5410///
5411/// A builder for the *authorizedOrgsDescs.list* method supported by a *accessPolicy* resource.
5412/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
5413///
5414/// # Example
5415///
5416/// Instantiate a resource method builder
5417///
5418/// ```test_harness,no_run
5419/// # extern crate hyper;
5420/// # extern crate hyper_rustls;
5421/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
5422/// # async fn dox() {
5423/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5424///
5425/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5426/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5427/// # secret,
5428/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5429/// # ).build().await.unwrap();
5430///
5431/// # let client = hyper_util::client::legacy::Client::builder(
5432/// # hyper_util::rt::TokioExecutor::new()
5433/// # )
5434/// # .build(
5435/// # hyper_rustls::HttpsConnectorBuilder::new()
5436/// # .with_native_roots()
5437/// # .unwrap()
5438/// # .https_or_http()
5439/// # .enable_http1()
5440/// # .build()
5441/// # );
5442/// # let mut hub = AccessContextManager::new(client, auth);
5443/// // You can configure optional parameters by calling the respective setters at will, and
5444/// // execute the final call using `doit()`.
5445/// // Values shown here are possibly random and not representative !
5446/// let result = hub.access_policies().authorized_orgs_descs_list("parent")
5447/// .page_token("rebum.")
5448/// .page_size(-57)
5449/// .doit().await;
5450/// # }
5451/// ```
5452pub struct AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5453where
5454 C: 'a,
5455{
5456 hub: &'a AccessContextManager<C>,
5457 _parent: String,
5458 _page_token: Option<String>,
5459 _page_size: Option<i32>,
5460 _delegate: Option<&'a mut dyn common::Delegate>,
5461 _additional_params: HashMap<String, String>,
5462 _scopes: BTreeSet<String>,
5463}
5464
5465impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescListCall<'a, C> {}
5466
5467impl<'a, C> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5468where
5469 C: common::Connector,
5470{
5471 /// Perform the operation you have build so far.
5472 pub async fn doit(
5473 mut self,
5474 ) -> common::Result<(common::Response, ListAuthorizedOrgsDescsResponse)> {
5475 use std::borrow::Cow;
5476 use std::io::{Read, Seek};
5477
5478 use common::{url::Params, ToParts};
5479 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5480
5481 let mut dd = common::DefaultDelegate;
5482 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5483 dlg.begin(common::MethodInfo {
5484 id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.list",
5485 http_method: hyper::Method::GET,
5486 });
5487
5488 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5489 if self._additional_params.contains_key(field) {
5490 dlg.finished(false);
5491 return Err(common::Error::FieldClash(field));
5492 }
5493 }
5494
5495 let mut params = Params::with_capacity(5 + self._additional_params.len());
5496 params.push("parent", self._parent);
5497 if let Some(value) = self._page_token.as_ref() {
5498 params.push("pageToken", value);
5499 }
5500 if let Some(value) = self._page_size.as_ref() {
5501 params.push("pageSize", value.to_string());
5502 }
5503
5504 params.extend(self._additional_params.iter());
5505
5506 params.push("alt", "json");
5507 let mut url = self.hub._base_url.clone() + "v1/{+parent}/authorizedOrgsDescs";
5508 if self._scopes.is_empty() {
5509 self._scopes
5510 .insert(Scope::CloudPlatform.as_ref().to_string());
5511 }
5512
5513 #[allow(clippy::single_element_loop)]
5514 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5515 url = params.uri_replacement(url, param_name, find_this, true);
5516 }
5517 {
5518 let to_remove = ["parent"];
5519 params.remove_params(&to_remove);
5520 }
5521
5522 let url = params.parse_with_url(&url);
5523
5524 loop {
5525 let token = match self
5526 .hub
5527 .auth
5528 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5529 .await
5530 {
5531 Ok(token) => token,
5532 Err(e) => match dlg.token(e) {
5533 Ok(token) => token,
5534 Err(e) => {
5535 dlg.finished(false);
5536 return Err(common::Error::MissingToken(e));
5537 }
5538 },
5539 };
5540 let mut req_result = {
5541 let client = &self.hub.client;
5542 dlg.pre_request();
5543 let mut req_builder = hyper::Request::builder()
5544 .method(hyper::Method::GET)
5545 .uri(url.as_str())
5546 .header(USER_AGENT, self.hub._user_agent.clone());
5547
5548 if let Some(token) = token.as_ref() {
5549 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5550 }
5551
5552 let request = req_builder
5553 .header(CONTENT_LENGTH, 0_u64)
5554 .body(common::to_body::<String>(None));
5555
5556 client.request(request.unwrap()).await
5557 };
5558
5559 match req_result {
5560 Err(err) => {
5561 if let common::Retry::After(d) = dlg.http_error(&err) {
5562 sleep(d).await;
5563 continue;
5564 }
5565 dlg.finished(false);
5566 return Err(common::Error::HttpError(err));
5567 }
5568 Ok(res) => {
5569 let (mut parts, body) = res.into_parts();
5570 let mut body = common::Body::new(body);
5571 if !parts.status.is_success() {
5572 let bytes = common::to_bytes(body).await.unwrap_or_default();
5573 let error = serde_json::from_str(&common::to_string(&bytes));
5574 let response = common::to_response(parts, bytes.into());
5575
5576 if let common::Retry::After(d) =
5577 dlg.http_failure(&response, error.as_ref().ok())
5578 {
5579 sleep(d).await;
5580 continue;
5581 }
5582
5583 dlg.finished(false);
5584
5585 return Err(match error {
5586 Ok(value) => common::Error::BadRequest(value),
5587 _ => common::Error::Failure(response),
5588 });
5589 }
5590 let response = {
5591 let bytes = common::to_bytes(body).await.unwrap_or_default();
5592 let encoded = common::to_string(&bytes);
5593 match serde_json::from_str(&encoded) {
5594 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5595 Err(error) => {
5596 dlg.response_json_decode_error(&encoded, &error);
5597 return Err(common::Error::JsonDecodeError(
5598 encoded.to_string(),
5599 error,
5600 ));
5601 }
5602 }
5603 };
5604
5605 dlg.finished(true);
5606 return Ok(response);
5607 }
5608 }
5609 }
5610 }
5611
5612 /// Required. Resource name for the access policy to list Authorized Orgs Desc from. Format: `accessPolicies/{policy_id}`
5613 ///
5614 /// Sets the *parent* path property to the given value.
5615 ///
5616 /// Even though the property as already been set when instantiating this call,
5617 /// we provide this method for API completeness.
5618 pub fn parent(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5619 self._parent = new_value.to_string();
5620 self
5621 }
5622 /// Next page token for the next batch of Authorized Orgs Desc instances. Defaults to the first page of results.
5623 ///
5624 /// Sets the *page token* query property to the given value.
5625 pub fn page_token(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5626 self._page_token = Some(new_value.to_string());
5627 self
5628 }
5629 /// Number of Authorized Orgs Descs to include in the list. Default 100.
5630 ///
5631 /// Sets the *page size* query property to the given value.
5632 pub fn page_size(mut self, new_value: i32) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5633 self._page_size = Some(new_value);
5634 self
5635 }
5636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5637 /// while executing the actual API request.
5638 ///
5639 /// ````text
5640 /// It should be used to handle progress information, and to implement a certain level of resilience.
5641 /// ````
5642 ///
5643 /// Sets the *delegate* property to the given value.
5644 pub fn delegate(
5645 mut self,
5646 new_value: &'a mut dyn common::Delegate,
5647 ) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5648 self._delegate = Some(new_value);
5649 self
5650 }
5651
5652 /// Set any additional parameter of the query string used in the request.
5653 /// It should be used to set parameters which are not yet available through their own
5654 /// setters.
5655 ///
5656 /// Please note that this method must not be used to set any of the known parameters
5657 /// which have their own setter method. If done anyway, the request will fail.
5658 ///
5659 /// # Additional Parameters
5660 ///
5661 /// * *$.xgafv* (query-string) - V1 error format.
5662 /// * *access_token* (query-string) - OAuth access token.
5663 /// * *alt* (query-string) - Data format for response.
5664 /// * *callback* (query-string) - JSONP
5665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5666 /// * *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.
5667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5669 /// * *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.
5670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5672 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5673 where
5674 T: AsRef<str>,
5675 {
5676 self._additional_params
5677 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5678 self
5679 }
5680
5681 /// Identifies the authorization scope for the method you are building.
5682 ///
5683 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5684 /// [`Scope::CloudPlatform`].
5685 ///
5686 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5687 /// tokens for more than one scope.
5688 ///
5689 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5690 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5691 /// sufficient, a read-write scope will do as well.
5692 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5693 where
5694 St: AsRef<str>,
5695 {
5696 self._scopes.insert(String::from(scope.as_ref()));
5697 self
5698 }
5699 /// Identifies the authorization scope(s) for the method you are building.
5700 ///
5701 /// See [`Self::add_scope()`] for details.
5702 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C>
5703 where
5704 I: IntoIterator<Item = St>,
5705 St: AsRef<str>,
5706 {
5707 self._scopes
5708 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5709 self
5710 }
5711
5712 /// Removes all scopes, and no default scope will be used either.
5713 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5714 /// for details).
5715 pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescListCall<'a, C> {
5716 self._scopes.clear();
5717 self
5718 }
5719}
5720
5721/// Updates an authorized orgs desc. The long-running operation from this RPC has a successful status after the authorized orgs desc propagates to long-lasting storage. If a authorized orgs desc contains errors, an error response is returned for the first error encountered. Only the organization list in `AuthorizedOrgsDesc` can be updated. The name, authorization_type, asset_type and authorization_direction cannot be updated.
5722///
5723/// A builder for the *authorizedOrgsDescs.patch* method supported by a *accessPolicy* resource.
5724/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
5725///
5726/// # Example
5727///
5728/// Instantiate a resource method builder
5729///
5730/// ```test_harness,no_run
5731/// # extern crate hyper;
5732/// # extern crate hyper_rustls;
5733/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
5734/// use accesscontextmanager1::api::AuthorizedOrgsDesc;
5735/// # async fn dox() {
5736/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5737///
5738/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5739/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5740/// # secret,
5741/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5742/// # ).build().await.unwrap();
5743///
5744/// # let client = hyper_util::client::legacy::Client::builder(
5745/// # hyper_util::rt::TokioExecutor::new()
5746/// # )
5747/// # .build(
5748/// # hyper_rustls::HttpsConnectorBuilder::new()
5749/// # .with_native_roots()
5750/// # .unwrap()
5751/// # .https_or_http()
5752/// # .enable_http1()
5753/// # .build()
5754/// # );
5755/// # let mut hub = AccessContextManager::new(client, auth);
5756/// // As the method needs a request, you would usually fill it with the desired information
5757/// // into the respective structure. Some of the parts shown here might not be applicable !
5758/// // Values shown here are possibly random and not representative !
5759/// let mut req = AuthorizedOrgsDesc::default();
5760///
5761/// // You can configure optional parameters by calling the respective setters at will, and
5762/// // execute the final call using `doit()`.
5763/// // Values shown here are possibly random and not representative !
5764/// let result = hub.access_policies().authorized_orgs_descs_patch(req, "name")
5765/// .update_mask(FieldMask::new::<&str>(&[]))
5766/// .doit().await;
5767/// # }
5768/// ```
5769pub struct AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
5770where
5771 C: 'a,
5772{
5773 hub: &'a AccessContextManager<C>,
5774 _request: AuthorizedOrgsDesc,
5775 _name: String,
5776 _update_mask: Option<common::FieldMask>,
5777 _delegate: Option<&'a mut dyn common::Delegate>,
5778 _additional_params: HashMap<String, String>,
5779 _scopes: BTreeSet<String>,
5780}
5781
5782impl<'a, C> common::CallBuilder for AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {}
5783
5784impl<'a, C> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
5785where
5786 C: common::Connector,
5787{
5788 /// Perform the operation you have build so far.
5789 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5790 use std::borrow::Cow;
5791 use std::io::{Read, Seek};
5792
5793 use common::{url::Params, ToParts};
5794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5795
5796 let mut dd = common::DefaultDelegate;
5797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5798 dlg.begin(common::MethodInfo {
5799 id: "accesscontextmanager.accessPolicies.authorizedOrgsDescs.patch",
5800 http_method: hyper::Method::PATCH,
5801 });
5802
5803 for &field in ["alt", "name", "updateMask"].iter() {
5804 if self._additional_params.contains_key(field) {
5805 dlg.finished(false);
5806 return Err(common::Error::FieldClash(field));
5807 }
5808 }
5809
5810 let mut params = Params::with_capacity(5 + self._additional_params.len());
5811 params.push("name", self._name);
5812 if let Some(value) = self._update_mask.as_ref() {
5813 params.push("updateMask", value.to_string());
5814 }
5815
5816 params.extend(self._additional_params.iter());
5817
5818 params.push("alt", "json");
5819 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5820 if self._scopes.is_empty() {
5821 self._scopes
5822 .insert(Scope::CloudPlatform.as_ref().to_string());
5823 }
5824
5825 #[allow(clippy::single_element_loop)]
5826 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5827 url = params.uri_replacement(url, param_name, find_this, true);
5828 }
5829 {
5830 let to_remove = ["name"];
5831 params.remove_params(&to_remove);
5832 }
5833
5834 let url = params.parse_with_url(&url);
5835
5836 let mut json_mime_type = mime::APPLICATION_JSON;
5837 let mut request_value_reader = {
5838 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5839 common::remove_json_null_values(&mut value);
5840 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5841 serde_json::to_writer(&mut dst, &value).unwrap();
5842 dst
5843 };
5844 let request_size = request_value_reader
5845 .seek(std::io::SeekFrom::End(0))
5846 .unwrap();
5847 request_value_reader
5848 .seek(std::io::SeekFrom::Start(0))
5849 .unwrap();
5850
5851 loop {
5852 let token = match self
5853 .hub
5854 .auth
5855 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5856 .await
5857 {
5858 Ok(token) => token,
5859 Err(e) => match dlg.token(e) {
5860 Ok(token) => token,
5861 Err(e) => {
5862 dlg.finished(false);
5863 return Err(common::Error::MissingToken(e));
5864 }
5865 },
5866 };
5867 request_value_reader
5868 .seek(std::io::SeekFrom::Start(0))
5869 .unwrap();
5870 let mut req_result = {
5871 let client = &self.hub.client;
5872 dlg.pre_request();
5873 let mut req_builder = hyper::Request::builder()
5874 .method(hyper::Method::PATCH)
5875 .uri(url.as_str())
5876 .header(USER_AGENT, self.hub._user_agent.clone());
5877
5878 if let Some(token) = token.as_ref() {
5879 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5880 }
5881
5882 let request = req_builder
5883 .header(CONTENT_TYPE, json_mime_type.to_string())
5884 .header(CONTENT_LENGTH, request_size as u64)
5885 .body(common::to_body(
5886 request_value_reader.get_ref().clone().into(),
5887 ));
5888
5889 client.request(request.unwrap()).await
5890 };
5891
5892 match req_result {
5893 Err(err) => {
5894 if let common::Retry::After(d) = dlg.http_error(&err) {
5895 sleep(d).await;
5896 continue;
5897 }
5898 dlg.finished(false);
5899 return Err(common::Error::HttpError(err));
5900 }
5901 Ok(res) => {
5902 let (mut parts, body) = res.into_parts();
5903 let mut body = common::Body::new(body);
5904 if !parts.status.is_success() {
5905 let bytes = common::to_bytes(body).await.unwrap_or_default();
5906 let error = serde_json::from_str(&common::to_string(&bytes));
5907 let response = common::to_response(parts, bytes.into());
5908
5909 if let common::Retry::After(d) =
5910 dlg.http_failure(&response, error.as_ref().ok())
5911 {
5912 sleep(d).await;
5913 continue;
5914 }
5915
5916 dlg.finished(false);
5917
5918 return Err(match error {
5919 Ok(value) => common::Error::BadRequest(value),
5920 _ => common::Error::Failure(response),
5921 });
5922 }
5923 let response = {
5924 let bytes = common::to_bytes(body).await.unwrap_or_default();
5925 let encoded = common::to_string(&bytes);
5926 match serde_json::from_str(&encoded) {
5927 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5928 Err(error) => {
5929 dlg.response_json_decode_error(&encoded, &error);
5930 return Err(common::Error::JsonDecodeError(
5931 encoded.to_string(),
5932 error,
5933 ));
5934 }
5935 }
5936 };
5937
5938 dlg.finished(true);
5939 return Ok(response);
5940 }
5941 }
5942 }
5943 }
5944
5945 ///
5946 /// Sets the *request* property to the given value.
5947 ///
5948 /// Even though the property as already been set when instantiating this call,
5949 /// we provide this method for API completeness.
5950 pub fn request(
5951 mut self,
5952 new_value: AuthorizedOrgsDesc,
5953 ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
5954 self._request = new_value;
5955 self
5956 }
5957 /// Identifier. Resource name for the `AuthorizedOrgsDesc`. Format: `accessPolicies/{access_policy}/authorizedOrgsDescs/{authorized_orgs_desc}`. The `authorized_orgs_desc` component must begin with a letter, followed by alphanumeric characters or `_`. After you create an `AuthorizedOrgsDesc`, you cannot change its `name`.
5958 ///
5959 /// Sets the *name* path property to the given value.
5960 ///
5961 /// Even though the property as already been set when instantiating this call,
5962 /// we provide this method for API completeness.
5963 pub fn name(mut self, new_value: &str) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
5964 self._name = new_value.to_string();
5965 self
5966 }
5967 /// Required. Mask to control which fields get updated. Must be non-empty.
5968 ///
5969 /// Sets the *update mask* query property to the given value.
5970 pub fn update_mask(
5971 mut self,
5972 new_value: common::FieldMask,
5973 ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
5974 self._update_mask = Some(new_value);
5975 self
5976 }
5977 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5978 /// while executing the actual API request.
5979 ///
5980 /// ````text
5981 /// It should be used to handle progress information, and to implement a certain level of resilience.
5982 /// ````
5983 ///
5984 /// Sets the *delegate* property to the given value.
5985 pub fn delegate(
5986 mut self,
5987 new_value: &'a mut dyn common::Delegate,
5988 ) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
5989 self._delegate = Some(new_value);
5990 self
5991 }
5992
5993 /// Set any additional parameter of the query string used in the request.
5994 /// It should be used to set parameters which are not yet available through their own
5995 /// setters.
5996 ///
5997 /// Please note that this method must not be used to set any of the known parameters
5998 /// which have their own setter method. If done anyway, the request will fail.
5999 ///
6000 /// # Additional Parameters
6001 ///
6002 /// * *$.xgafv* (query-string) - V1 error format.
6003 /// * *access_token* (query-string) - OAuth access token.
6004 /// * *alt* (query-string) - Data format for response.
6005 /// * *callback* (query-string) - JSONP
6006 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6007 /// * *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.
6008 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6009 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6010 /// * *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.
6011 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6012 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6013 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6014 where
6015 T: AsRef<str>,
6016 {
6017 self._additional_params
6018 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6019 self
6020 }
6021
6022 /// Identifies the authorization scope for the method you are building.
6023 ///
6024 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6025 /// [`Scope::CloudPlatform`].
6026 ///
6027 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6028 /// tokens for more than one scope.
6029 ///
6030 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6031 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6032 /// sufficient, a read-write scope will do as well.
6033 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6034 where
6035 St: AsRef<str>,
6036 {
6037 self._scopes.insert(String::from(scope.as_ref()));
6038 self
6039 }
6040 /// Identifies the authorization scope(s) for the method you are building.
6041 ///
6042 /// See [`Self::add_scope()`] for details.
6043 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C>
6044 where
6045 I: IntoIterator<Item = St>,
6046 St: AsRef<str>,
6047 {
6048 self._scopes
6049 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6050 self
6051 }
6052
6053 /// Removes all scopes, and no default scope will be used either.
6054 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6055 /// for details).
6056 pub fn clear_scopes(mut self) -> AccessPolicyAuthorizedOrgsDescPatchCall<'a, C> {
6057 self._scopes.clear();
6058 self
6059 }
6060}
6061
6062/// Commits the dry-run specification for all the service perimeters in an access policy. A commit operation on a service perimeter involves copying its `spec` field to the `status` field of the service perimeter. Only service perimeters with `use_explicit_dry_run_spec` field set to true are affected by a commit operation. The long-running operation from this RPC has a successful status after the dry-run specifications for all the service perimeters have been committed. If a commit fails, it causes the long-running operation to return an error response and the entire commit operation is cancelled. When successful, the Operation.response field contains CommitServicePerimetersResponse. The `dry_run` and the `spec` fields are cleared after a successful commit operation.
6063///
6064/// A builder for the *servicePerimeters.commit* method supported by a *accessPolicy* resource.
6065/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
6066///
6067/// # Example
6068///
6069/// Instantiate a resource method builder
6070///
6071/// ```test_harness,no_run
6072/// # extern crate hyper;
6073/// # extern crate hyper_rustls;
6074/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
6075/// use accesscontextmanager1::api::CommitServicePerimetersRequest;
6076/// # async fn dox() {
6077/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6078///
6079/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6080/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6081/// # secret,
6082/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6083/// # ).build().await.unwrap();
6084///
6085/// # let client = hyper_util::client::legacy::Client::builder(
6086/// # hyper_util::rt::TokioExecutor::new()
6087/// # )
6088/// # .build(
6089/// # hyper_rustls::HttpsConnectorBuilder::new()
6090/// # .with_native_roots()
6091/// # .unwrap()
6092/// # .https_or_http()
6093/// # .enable_http1()
6094/// # .build()
6095/// # );
6096/// # let mut hub = AccessContextManager::new(client, auth);
6097/// // As the method needs a request, you would usually fill it with the desired information
6098/// // into the respective structure. Some of the parts shown here might not be applicable !
6099/// // Values shown here are possibly random and not representative !
6100/// let mut req = CommitServicePerimetersRequest::default();
6101///
6102/// // You can configure optional parameters by calling the respective setters at will, and
6103/// // execute the final call using `doit()`.
6104/// // Values shown here are possibly random and not representative !
6105/// let result = hub.access_policies().service_perimeters_commit(req, "parent")
6106/// .doit().await;
6107/// # }
6108/// ```
6109pub struct AccessPolicyServicePerimeterCommitCall<'a, C>
6110where
6111 C: 'a,
6112{
6113 hub: &'a AccessContextManager<C>,
6114 _request: CommitServicePerimetersRequest,
6115 _parent: String,
6116 _delegate: Option<&'a mut dyn common::Delegate>,
6117 _additional_params: HashMap<String, String>,
6118 _scopes: BTreeSet<String>,
6119}
6120
6121impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterCommitCall<'a, C> {}
6122
6123impl<'a, C> AccessPolicyServicePerimeterCommitCall<'a, C>
6124where
6125 C: common::Connector,
6126{
6127 /// Perform the operation you have build so far.
6128 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6129 use std::borrow::Cow;
6130 use std::io::{Read, Seek};
6131
6132 use common::{url::Params, ToParts};
6133 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6134
6135 let mut dd = common::DefaultDelegate;
6136 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6137 dlg.begin(common::MethodInfo {
6138 id: "accesscontextmanager.accessPolicies.servicePerimeters.commit",
6139 http_method: hyper::Method::POST,
6140 });
6141
6142 for &field in ["alt", "parent"].iter() {
6143 if self._additional_params.contains_key(field) {
6144 dlg.finished(false);
6145 return Err(common::Error::FieldClash(field));
6146 }
6147 }
6148
6149 let mut params = Params::with_capacity(4 + self._additional_params.len());
6150 params.push("parent", self._parent);
6151
6152 params.extend(self._additional_params.iter());
6153
6154 params.push("alt", "json");
6155 let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters:commit";
6156 if self._scopes.is_empty() {
6157 self._scopes
6158 .insert(Scope::CloudPlatform.as_ref().to_string());
6159 }
6160
6161 #[allow(clippy::single_element_loop)]
6162 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6163 url = params.uri_replacement(url, param_name, find_this, true);
6164 }
6165 {
6166 let to_remove = ["parent"];
6167 params.remove_params(&to_remove);
6168 }
6169
6170 let url = params.parse_with_url(&url);
6171
6172 let mut json_mime_type = mime::APPLICATION_JSON;
6173 let mut request_value_reader = {
6174 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6175 common::remove_json_null_values(&mut value);
6176 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6177 serde_json::to_writer(&mut dst, &value).unwrap();
6178 dst
6179 };
6180 let request_size = request_value_reader
6181 .seek(std::io::SeekFrom::End(0))
6182 .unwrap();
6183 request_value_reader
6184 .seek(std::io::SeekFrom::Start(0))
6185 .unwrap();
6186
6187 loop {
6188 let token = match self
6189 .hub
6190 .auth
6191 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6192 .await
6193 {
6194 Ok(token) => token,
6195 Err(e) => match dlg.token(e) {
6196 Ok(token) => token,
6197 Err(e) => {
6198 dlg.finished(false);
6199 return Err(common::Error::MissingToken(e));
6200 }
6201 },
6202 };
6203 request_value_reader
6204 .seek(std::io::SeekFrom::Start(0))
6205 .unwrap();
6206 let mut req_result = {
6207 let client = &self.hub.client;
6208 dlg.pre_request();
6209 let mut req_builder = hyper::Request::builder()
6210 .method(hyper::Method::POST)
6211 .uri(url.as_str())
6212 .header(USER_AGENT, self.hub._user_agent.clone());
6213
6214 if let Some(token) = token.as_ref() {
6215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6216 }
6217
6218 let request = req_builder
6219 .header(CONTENT_TYPE, json_mime_type.to_string())
6220 .header(CONTENT_LENGTH, request_size as u64)
6221 .body(common::to_body(
6222 request_value_reader.get_ref().clone().into(),
6223 ));
6224
6225 client.request(request.unwrap()).await
6226 };
6227
6228 match req_result {
6229 Err(err) => {
6230 if let common::Retry::After(d) = dlg.http_error(&err) {
6231 sleep(d).await;
6232 continue;
6233 }
6234 dlg.finished(false);
6235 return Err(common::Error::HttpError(err));
6236 }
6237 Ok(res) => {
6238 let (mut parts, body) = res.into_parts();
6239 let mut body = common::Body::new(body);
6240 if !parts.status.is_success() {
6241 let bytes = common::to_bytes(body).await.unwrap_or_default();
6242 let error = serde_json::from_str(&common::to_string(&bytes));
6243 let response = common::to_response(parts, bytes.into());
6244
6245 if let common::Retry::After(d) =
6246 dlg.http_failure(&response, error.as_ref().ok())
6247 {
6248 sleep(d).await;
6249 continue;
6250 }
6251
6252 dlg.finished(false);
6253
6254 return Err(match error {
6255 Ok(value) => common::Error::BadRequest(value),
6256 _ => common::Error::Failure(response),
6257 });
6258 }
6259 let response = {
6260 let bytes = common::to_bytes(body).await.unwrap_or_default();
6261 let encoded = common::to_string(&bytes);
6262 match serde_json::from_str(&encoded) {
6263 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6264 Err(error) => {
6265 dlg.response_json_decode_error(&encoded, &error);
6266 return Err(common::Error::JsonDecodeError(
6267 encoded.to_string(),
6268 error,
6269 ));
6270 }
6271 }
6272 };
6273
6274 dlg.finished(true);
6275 return Ok(response);
6276 }
6277 }
6278 }
6279 }
6280
6281 ///
6282 /// Sets the *request* property to the given value.
6283 ///
6284 /// Even though the property as already been set when instantiating this call,
6285 /// we provide this method for API completeness.
6286 pub fn request(
6287 mut self,
6288 new_value: CommitServicePerimetersRequest,
6289 ) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6290 self._request = new_value;
6291 self
6292 }
6293 /// Required. Resource name for the parent Access Policy which owns all Service Perimeters in scope for the commit operation. Format: `accessPolicies/{policy_id}`
6294 ///
6295 /// Sets the *parent* path property to the given value.
6296 ///
6297 /// Even though the property as already been set when instantiating this call,
6298 /// we provide this method for API completeness.
6299 pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6300 self._parent = new_value.to_string();
6301 self
6302 }
6303 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6304 /// while executing the actual API request.
6305 ///
6306 /// ````text
6307 /// It should be used to handle progress information, and to implement a certain level of resilience.
6308 /// ````
6309 ///
6310 /// Sets the *delegate* property to the given value.
6311 pub fn delegate(
6312 mut self,
6313 new_value: &'a mut dyn common::Delegate,
6314 ) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6315 self._delegate = Some(new_value);
6316 self
6317 }
6318
6319 /// Set any additional parameter of the query string used in the request.
6320 /// It should be used to set parameters which are not yet available through their own
6321 /// setters.
6322 ///
6323 /// Please note that this method must not be used to set any of the known parameters
6324 /// which have their own setter method. If done anyway, the request will fail.
6325 ///
6326 /// # Additional Parameters
6327 ///
6328 /// * *$.xgafv* (query-string) - V1 error format.
6329 /// * *access_token* (query-string) - OAuth access token.
6330 /// * *alt* (query-string) - Data format for response.
6331 /// * *callback* (query-string) - JSONP
6332 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6333 /// * *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.
6334 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6335 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6336 /// * *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.
6337 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6338 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6339 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterCommitCall<'a, C>
6340 where
6341 T: AsRef<str>,
6342 {
6343 self._additional_params
6344 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6345 self
6346 }
6347
6348 /// Identifies the authorization scope for the method you are building.
6349 ///
6350 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6351 /// [`Scope::CloudPlatform`].
6352 ///
6353 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6354 /// tokens for more than one scope.
6355 ///
6356 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6357 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6358 /// sufficient, a read-write scope will do as well.
6359 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterCommitCall<'a, C>
6360 where
6361 St: AsRef<str>,
6362 {
6363 self._scopes.insert(String::from(scope.as_ref()));
6364 self
6365 }
6366 /// Identifies the authorization scope(s) for the method you are building.
6367 ///
6368 /// See [`Self::add_scope()`] for details.
6369 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterCommitCall<'a, C>
6370 where
6371 I: IntoIterator<Item = St>,
6372 St: AsRef<str>,
6373 {
6374 self._scopes
6375 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6376 self
6377 }
6378
6379 /// Removes all scopes, and no default scope will be used either.
6380 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6381 /// for details).
6382 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterCommitCall<'a, C> {
6383 self._scopes.clear();
6384 self
6385 }
6386}
6387
6388/// Creates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
6389///
6390/// A builder for the *servicePerimeters.create* method supported by a *accessPolicy* resource.
6391/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
6392///
6393/// # Example
6394///
6395/// Instantiate a resource method builder
6396///
6397/// ```test_harness,no_run
6398/// # extern crate hyper;
6399/// # extern crate hyper_rustls;
6400/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
6401/// use accesscontextmanager1::api::ServicePerimeter;
6402/// # async fn dox() {
6403/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6404///
6405/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6406/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6407/// # secret,
6408/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6409/// # ).build().await.unwrap();
6410///
6411/// # let client = hyper_util::client::legacy::Client::builder(
6412/// # hyper_util::rt::TokioExecutor::new()
6413/// # )
6414/// # .build(
6415/// # hyper_rustls::HttpsConnectorBuilder::new()
6416/// # .with_native_roots()
6417/// # .unwrap()
6418/// # .https_or_http()
6419/// # .enable_http1()
6420/// # .build()
6421/// # );
6422/// # let mut hub = AccessContextManager::new(client, auth);
6423/// // As the method needs a request, you would usually fill it with the desired information
6424/// // into the respective structure. Some of the parts shown here might not be applicable !
6425/// // Values shown here are possibly random and not representative !
6426/// let mut req = ServicePerimeter::default();
6427///
6428/// // You can configure optional parameters by calling the respective setters at will, and
6429/// // execute the final call using `doit()`.
6430/// // Values shown here are possibly random and not representative !
6431/// let result = hub.access_policies().service_perimeters_create(req, "parent")
6432/// .doit().await;
6433/// # }
6434/// ```
6435pub struct AccessPolicyServicePerimeterCreateCall<'a, C>
6436where
6437 C: 'a,
6438{
6439 hub: &'a AccessContextManager<C>,
6440 _request: ServicePerimeter,
6441 _parent: String,
6442 _delegate: Option<&'a mut dyn common::Delegate>,
6443 _additional_params: HashMap<String, String>,
6444 _scopes: BTreeSet<String>,
6445}
6446
6447impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterCreateCall<'a, C> {}
6448
6449impl<'a, C> AccessPolicyServicePerimeterCreateCall<'a, C>
6450where
6451 C: common::Connector,
6452{
6453 /// Perform the operation you have build so far.
6454 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6455 use std::borrow::Cow;
6456 use std::io::{Read, Seek};
6457
6458 use common::{url::Params, ToParts};
6459 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6460
6461 let mut dd = common::DefaultDelegate;
6462 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6463 dlg.begin(common::MethodInfo {
6464 id: "accesscontextmanager.accessPolicies.servicePerimeters.create",
6465 http_method: hyper::Method::POST,
6466 });
6467
6468 for &field in ["alt", "parent"].iter() {
6469 if self._additional_params.contains_key(field) {
6470 dlg.finished(false);
6471 return Err(common::Error::FieldClash(field));
6472 }
6473 }
6474
6475 let mut params = Params::with_capacity(4 + self._additional_params.len());
6476 params.push("parent", self._parent);
6477
6478 params.extend(self._additional_params.iter());
6479
6480 params.push("alt", "json");
6481 let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters";
6482 if self._scopes.is_empty() {
6483 self._scopes
6484 .insert(Scope::CloudPlatform.as_ref().to_string());
6485 }
6486
6487 #[allow(clippy::single_element_loop)]
6488 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6489 url = params.uri_replacement(url, param_name, find_this, true);
6490 }
6491 {
6492 let to_remove = ["parent"];
6493 params.remove_params(&to_remove);
6494 }
6495
6496 let url = params.parse_with_url(&url);
6497
6498 let mut json_mime_type = mime::APPLICATION_JSON;
6499 let mut request_value_reader = {
6500 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6501 common::remove_json_null_values(&mut value);
6502 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6503 serde_json::to_writer(&mut dst, &value).unwrap();
6504 dst
6505 };
6506 let request_size = request_value_reader
6507 .seek(std::io::SeekFrom::End(0))
6508 .unwrap();
6509 request_value_reader
6510 .seek(std::io::SeekFrom::Start(0))
6511 .unwrap();
6512
6513 loop {
6514 let token = match self
6515 .hub
6516 .auth
6517 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6518 .await
6519 {
6520 Ok(token) => token,
6521 Err(e) => match dlg.token(e) {
6522 Ok(token) => token,
6523 Err(e) => {
6524 dlg.finished(false);
6525 return Err(common::Error::MissingToken(e));
6526 }
6527 },
6528 };
6529 request_value_reader
6530 .seek(std::io::SeekFrom::Start(0))
6531 .unwrap();
6532 let mut req_result = {
6533 let client = &self.hub.client;
6534 dlg.pre_request();
6535 let mut req_builder = hyper::Request::builder()
6536 .method(hyper::Method::POST)
6537 .uri(url.as_str())
6538 .header(USER_AGENT, self.hub._user_agent.clone());
6539
6540 if let Some(token) = token.as_ref() {
6541 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6542 }
6543
6544 let request = req_builder
6545 .header(CONTENT_TYPE, json_mime_type.to_string())
6546 .header(CONTENT_LENGTH, request_size as u64)
6547 .body(common::to_body(
6548 request_value_reader.get_ref().clone().into(),
6549 ));
6550
6551 client.request(request.unwrap()).await
6552 };
6553
6554 match req_result {
6555 Err(err) => {
6556 if let common::Retry::After(d) = dlg.http_error(&err) {
6557 sleep(d).await;
6558 continue;
6559 }
6560 dlg.finished(false);
6561 return Err(common::Error::HttpError(err));
6562 }
6563 Ok(res) => {
6564 let (mut parts, body) = res.into_parts();
6565 let mut body = common::Body::new(body);
6566 if !parts.status.is_success() {
6567 let bytes = common::to_bytes(body).await.unwrap_or_default();
6568 let error = serde_json::from_str(&common::to_string(&bytes));
6569 let response = common::to_response(parts, bytes.into());
6570
6571 if let common::Retry::After(d) =
6572 dlg.http_failure(&response, error.as_ref().ok())
6573 {
6574 sleep(d).await;
6575 continue;
6576 }
6577
6578 dlg.finished(false);
6579
6580 return Err(match error {
6581 Ok(value) => common::Error::BadRequest(value),
6582 _ => common::Error::Failure(response),
6583 });
6584 }
6585 let response = {
6586 let bytes = common::to_bytes(body).await.unwrap_or_default();
6587 let encoded = common::to_string(&bytes);
6588 match serde_json::from_str(&encoded) {
6589 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6590 Err(error) => {
6591 dlg.response_json_decode_error(&encoded, &error);
6592 return Err(common::Error::JsonDecodeError(
6593 encoded.to_string(),
6594 error,
6595 ));
6596 }
6597 }
6598 };
6599
6600 dlg.finished(true);
6601 return Ok(response);
6602 }
6603 }
6604 }
6605 }
6606
6607 ///
6608 /// Sets the *request* property to the given value.
6609 ///
6610 /// Even though the property as already been set when instantiating this call,
6611 /// we provide this method for API completeness.
6612 pub fn request(
6613 mut self,
6614 new_value: ServicePerimeter,
6615 ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
6616 self._request = new_value;
6617 self
6618 }
6619 /// Required. Resource name for the access policy which owns this Service Perimeter. Format: `accessPolicies/{policy_id}`
6620 ///
6621 /// Sets the *parent* path property to the given value.
6622 ///
6623 /// Even though the property as already been set when instantiating this call,
6624 /// we provide this method for API completeness.
6625 pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
6626 self._parent = new_value.to_string();
6627 self
6628 }
6629 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6630 /// while executing the actual API request.
6631 ///
6632 /// ````text
6633 /// It should be used to handle progress information, and to implement a certain level of resilience.
6634 /// ````
6635 ///
6636 /// Sets the *delegate* property to the given value.
6637 pub fn delegate(
6638 mut self,
6639 new_value: &'a mut dyn common::Delegate,
6640 ) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
6641 self._delegate = Some(new_value);
6642 self
6643 }
6644
6645 /// Set any additional parameter of the query string used in the request.
6646 /// It should be used to set parameters which are not yet available through their own
6647 /// setters.
6648 ///
6649 /// Please note that this method must not be used to set any of the known parameters
6650 /// which have their own setter method. If done anyway, the request will fail.
6651 ///
6652 /// # Additional Parameters
6653 ///
6654 /// * *$.xgafv* (query-string) - V1 error format.
6655 /// * *access_token* (query-string) - OAuth access token.
6656 /// * *alt* (query-string) - Data format for response.
6657 /// * *callback* (query-string) - JSONP
6658 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6659 /// * *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.
6660 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6661 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6662 /// * *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.
6663 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6664 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6665 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterCreateCall<'a, C>
6666 where
6667 T: AsRef<str>,
6668 {
6669 self._additional_params
6670 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6671 self
6672 }
6673
6674 /// Identifies the authorization scope for the method you are building.
6675 ///
6676 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6677 /// [`Scope::CloudPlatform`].
6678 ///
6679 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6680 /// tokens for more than one scope.
6681 ///
6682 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6683 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6684 /// sufficient, a read-write scope will do as well.
6685 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterCreateCall<'a, C>
6686 where
6687 St: AsRef<str>,
6688 {
6689 self._scopes.insert(String::from(scope.as_ref()));
6690 self
6691 }
6692 /// Identifies the authorization scope(s) for the method you are building.
6693 ///
6694 /// See [`Self::add_scope()`] for details.
6695 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterCreateCall<'a, C>
6696 where
6697 I: IntoIterator<Item = St>,
6698 St: AsRef<str>,
6699 {
6700 self._scopes
6701 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6702 self
6703 }
6704
6705 /// Removes all scopes, and no default scope will be used either.
6706 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6707 /// for details).
6708 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterCreateCall<'a, C> {
6709 self._scopes.clear();
6710 self
6711 }
6712}
6713
6714/// Deletes a service perimeter based on the resource name. The long-running operation from this RPC has a successful status after the service perimeter is removed from long-lasting storage.
6715///
6716/// A builder for the *servicePerimeters.delete* method supported by a *accessPolicy* resource.
6717/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
6718///
6719/// # Example
6720///
6721/// Instantiate a resource method builder
6722///
6723/// ```test_harness,no_run
6724/// # extern crate hyper;
6725/// # extern crate hyper_rustls;
6726/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
6727/// # async fn dox() {
6728/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6729///
6730/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6732/// # secret,
6733/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6734/// # ).build().await.unwrap();
6735///
6736/// # let client = hyper_util::client::legacy::Client::builder(
6737/// # hyper_util::rt::TokioExecutor::new()
6738/// # )
6739/// # .build(
6740/// # hyper_rustls::HttpsConnectorBuilder::new()
6741/// # .with_native_roots()
6742/// # .unwrap()
6743/// # .https_or_http()
6744/// # .enable_http1()
6745/// # .build()
6746/// # );
6747/// # let mut hub = AccessContextManager::new(client, auth);
6748/// // You can configure optional parameters by calling the respective setters at will, and
6749/// // execute the final call using `doit()`.
6750/// // Values shown here are possibly random and not representative !
6751/// let result = hub.access_policies().service_perimeters_delete("name")
6752/// .doit().await;
6753/// # }
6754/// ```
6755pub struct AccessPolicyServicePerimeterDeleteCall<'a, C>
6756where
6757 C: 'a,
6758{
6759 hub: &'a AccessContextManager<C>,
6760 _name: String,
6761 _delegate: Option<&'a mut dyn common::Delegate>,
6762 _additional_params: HashMap<String, String>,
6763 _scopes: BTreeSet<String>,
6764}
6765
6766impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterDeleteCall<'a, C> {}
6767
6768impl<'a, C> AccessPolicyServicePerimeterDeleteCall<'a, C>
6769where
6770 C: common::Connector,
6771{
6772 /// Perform the operation you have build so far.
6773 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6774 use std::borrow::Cow;
6775 use std::io::{Read, Seek};
6776
6777 use common::{url::Params, ToParts};
6778 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6779
6780 let mut dd = common::DefaultDelegate;
6781 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6782 dlg.begin(common::MethodInfo {
6783 id: "accesscontextmanager.accessPolicies.servicePerimeters.delete",
6784 http_method: hyper::Method::DELETE,
6785 });
6786
6787 for &field in ["alt", "name"].iter() {
6788 if self._additional_params.contains_key(field) {
6789 dlg.finished(false);
6790 return Err(common::Error::FieldClash(field));
6791 }
6792 }
6793
6794 let mut params = Params::with_capacity(3 + self._additional_params.len());
6795 params.push("name", self._name);
6796
6797 params.extend(self._additional_params.iter());
6798
6799 params.push("alt", "json");
6800 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6801 if self._scopes.is_empty() {
6802 self._scopes
6803 .insert(Scope::CloudPlatform.as_ref().to_string());
6804 }
6805
6806 #[allow(clippy::single_element_loop)]
6807 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6808 url = params.uri_replacement(url, param_name, find_this, true);
6809 }
6810 {
6811 let to_remove = ["name"];
6812 params.remove_params(&to_remove);
6813 }
6814
6815 let url = params.parse_with_url(&url);
6816
6817 loop {
6818 let token = match self
6819 .hub
6820 .auth
6821 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6822 .await
6823 {
6824 Ok(token) => token,
6825 Err(e) => match dlg.token(e) {
6826 Ok(token) => token,
6827 Err(e) => {
6828 dlg.finished(false);
6829 return Err(common::Error::MissingToken(e));
6830 }
6831 },
6832 };
6833 let mut req_result = {
6834 let client = &self.hub.client;
6835 dlg.pre_request();
6836 let mut req_builder = hyper::Request::builder()
6837 .method(hyper::Method::DELETE)
6838 .uri(url.as_str())
6839 .header(USER_AGENT, self.hub._user_agent.clone());
6840
6841 if let Some(token) = token.as_ref() {
6842 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6843 }
6844
6845 let request = req_builder
6846 .header(CONTENT_LENGTH, 0_u64)
6847 .body(common::to_body::<String>(None));
6848
6849 client.request(request.unwrap()).await
6850 };
6851
6852 match req_result {
6853 Err(err) => {
6854 if let common::Retry::After(d) = dlg.http_error(&err) {
6855 sleep(d).await;
6856 continue;
6857 }
6858 dlg.finished(false);
6859 return Err(common::Error::HttpError(err));
6860 }
6861 Ok(res) => {
6862 let (mut parts, body) = res.into_parts();
6863 let mut body = common::Body::new(body);
6864 if !parts.status.is_success() {
6865 let bytes = common::to_bytes(body).await.unwrap_or_default();
6866 let error = serde_json::from_str(&common::to_string(&bytes));
6867 let response = common::to_response(parts, bytes.into());
6868
6869 if let common::Retry::After(d) =
6870 dlg.http_failure(&response, error.as_ref().ok())
6871 {
6872 sleep(d).await;
6873 continue;
6874 }
6875
6876 dlg.finished(false);
6877
6878 return Err(match error {
6879 Ok(value) => common::Error::BadRequest(value),
6880 _ => common::Error::Failure(response),
6881 });
6882 }
6883 let response = {
6884 let bytes = common::to_bytes(body).await.unwrap_or_default();
6885 let encoded = common::to_string(&bytes);
6886 match serde_json::from_str(&encoded) {
6887 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6888 Err(error) => {
6889 dlg.response_json_decode_error(&encoded, &error);
6890 return Err(common::Error::JsonDecodeError(
6891 encoded.to_string(),
6892 error,
6893 ));
6894 }
6895 }
6896 };
6897
6898 dlg.finished(true);
6899 return Ok(response);
6900 }
6901 }
6902 }
6903 }
6904
6905 /// Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeter_id}`
6906 ///
6907 /// Sets the *name* path property to the given value.
6908 ///
6909 /// Even though the property as already been set when instantiating this call,
6910 /// we provide this method for API completeness.
6911 pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
6912 self._name = new_value.to_string();
6913 self
6914 }
6915 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6916 /// while executing the actual API request.
6917 ///
6918 /// ````text
6919 /// It should be used to handle progress information, and to implement a certain level of resilience.
6920 /// ````
6921 ///
6922 /// Sets the *delegate* property to the given value.
6923 pub fn delegate(
6924 mut self,
6925 new_value: &'a mut dyn common::Delegate,
6926 ) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
6927 self._delegate = Some(new_value);
6928 self
6929 }
6930
6931 /// Set any additional parameter of the query string used in the request.
6932 /// It should be used to set parameters which are not yet available through their own
6933 /// setters.
6934 ///
6935 /// Please note that this method must not be used to set any of the known parameters
6936 /// which have their own setter method. If done anyway, the request will fail.
6937 ///
6938 /// # Additional Parameters
6939 ///
6940 /// * *$.xgafv* (query-string) - V1 error format.
6941 /// * *access_token* (query-string) - OAuth access token.
6942 /// * *alt* (query-string) - Data format for response.
6943 /// * *callback* (query-string) - JSONP
6944 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6945 /// * *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.
6946 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6947 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6948 /// * *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.
6949 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6950 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6951 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
6952 where
6953 T: AsRef<str>,
6954 {
6955 self._additional_params
6956 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6957 self
6958 }
6959
6960 /// Identifies the authorization scope for the method you are building.
6961 ///
6962 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6963 /// [`Scope::CloudPlatform`].
6964 ///
6965 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6966 /// tokens for more than one scope.
6967 ///
6968 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6969 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6970 /// sufficient, a read-write scope will do as well.
6971 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
6972 where
6973 St: AsRef<str>,
6974 {
6975 self._scopes.insert(String::from(scope.as_ref()));
6976 self
6977 }
6978 /// Identifies the authorization scope(s) for the method you are building.
6979 ///
6980 /// See [`Self::add_scope()`] for details.
6981 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterDeleteCall<'a, C>
6982 where
6983 I: IntoIterator<Item = St>,
6984 St: AsRef<str>,
6985 {
6986 self._scopes
6987 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6988 self
6989 }
6990
6991 /// Removes all scopes, and no default scope will be used either.
6992 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6993 /// for details).
6994 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterDeleteCall<'a, C> {
6995 self._scopes.clear();
6996 self
6997 }
6998}
6999
7000/// Gets a service perimeter based on the resource name.
7001///
7002/// A builder for the *servicePerimeters.get* method supported by a *accessPolicy* resource.
7003/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7004///
7005/// # Example
7006///
7007/// Instantiate a resource method builder
7008///
7009/// ```test_harness,no_run
7010/// # extern crate hyper;
7011/// # extern crate hyper_rustls;
7012/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7013/// # async fn dox() {
7014/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7015///
7016/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7017/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7018/// # secret,
7019/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7020/// # ).build().await.unwrap();
7021///
7022/// # let client = hyper_util::client::legacy::Client::builder(
7023/// # hyper_util::rt::TokioExecutor::new()
7024/// # )
7025/// # .build(
7026/// # hyper_rustls::HttpsConnectorBuilder::new()
7027/// # .with_native_roots()
7028/// # .unwrap()
7029/// # .https_or_http()
7030/// # .enable_http1()
7031/// # .build()
7032/// # );
7033/// # let mut hub = AccessContextManager::new(client, auth);
7034/// // You can configure optional parameters by calling the respective setters at will, and
7035/// // execute the final call using `doit()`.
7036/// // Values shown here are possibly random and not representative !
7037/// let result = hub.access_policies().service_perimeters_get("name")
7038/// .doit().await;
7039/// # }
7040/// ```
7041pub struct AccessPolicyServicePerimeterGetCall<'a, C>
7042where
7043 C: 'a,
7044{
7045 hub: &'a AccessContextManager<C>,
7046 _name: String,
7047 _delegate: Option<&'a mut dyn common::Delegate>,
7048 _additional_params: HashMap<String, String>,
7049 _scopes: BTreeSet<String>,
7050}
7051
7052impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterGetCall<'a, C> {}
7053
7054impl<'a, C> AccessPolicyServicePerimeterGetCall<'a, C>
7055where
7056 C: common::Connector,
7057{
7058 /// Perform the operation you have build so far.
7059 pub async fn doit(mut self) -> common::Result<(common::Response, ServicePerimeter)> {
7060 use std::borrow::Cow;
7061 use std::io::{Read, Seek};
7062
7063 use common::{url::Params, ToParts};
7064 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7065
7066 let mut dd = common::DefaultDelegate;
7067 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7068 dlg.begin(common::MethodInfo {
7069 id: "accesscontextmanager.accessPolicies.servicePerimeters.get",
7070 http_method: hyper::Method::GET,
7071 });
7072
7073 for &field in ["alt", "name"].iter() {
7074 if self._additional_params.contains_key(field) {
7075 dlg.finished(false);
7076 return Err(common::Error::FieldClash(field));
7077 }
7078 }
7079
7080 let mut params = Params::with_capacity(3 + self._additional_params.len());
7081 params.push("name", self._name);
7082
7083 params.extend(self._additional_params.iter());
7084
7085 params.push("alt", "json");
7086 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7087 if self._scopes.is_empty() {
7088 self._scopes
7089 .insert(Scope::CloudPlatform.as_ref().to_string());
7090 }
7091
7092 #[allow(clippy::single_element_loop)]
7093 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7094 url = params.uri_replacement(url, param_name, find_this, true);
7095 }
7096 {
7097 let to_remove = ["name"];
7098 params.remove_params(&to_remove);
7099 }
7100
7101 let url = params.parse_with_url(&url);
7102
7103 loop {
7104 let token = match self
7105 .hub
7106 .auth
7107 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7108 .await
7109 {
7110 Ok(token) => token,
7111 Err(e) => match dlg.token(e) {
7112 Ok(token) => token,
7113 Err(e) => {
7114 dlg.finished(false);
7115 return Err(common::Error::MissingToken(e));
7116 }
7117 },
7118 };
7119 let mut req_result = {
7120 let client = &self.hub.client;
7121 dlg.pre_request();
7122 let mut req_builder = hyper::Request::builder()
7123 .method(hyper::Method::GET)
7124 .uri(url.as_str())
7125 .header(USER_AGENT, self.hub._user_agent.clone());
7126
7127 if let Some(token) = token.as_ref() {
7128 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7129 }
7130
7131 let request = req_builder
7132 .header(CONTENT_LENGTH, 0_u64)
7133 .body(common::to_body::<String>(None));
7134
7135 client.request(request.unwrap()).await
7136 };
7137
7138 match req_result {
7139 Err(err) => {
7140 if let common::Retry::After(d) = dlg.http_error(&err) {
7141 sleep(d).await;
7142 continue;
7143 }
7144 dlg.finished(false);
7145 return Err(common::Error::HttpError(err));
7146 }
7147 Ok(res) => {
7148 let (mut parts, body) = res.into_parts();
7149 let mut body = common::Body::new(body);
7150 if !parts.status.is_success() {
7151 let bytes = common::to_bytes(body).await.unwrap_or_default();
7152 let error = serde_json::from_str(&common::to_string(&bytes));
7153 let response = common::to_response(parts, bytes.into());
7154
7155 if let common::Retry::After(d) =
7156 dlg.http_failure(&response, error.as_ref().ok())
7157 {
7158 sleep(d).await;
7159 continue;
7160 }
7161
7162 dlg.finished(false);
7163
7164 return Err(match error {
7165 Ok(value) => common::Error::BadRequest(value),
7166 _ => common::Error::Failure(response),
7167 });
7168 }
7169 let response = {
7170 let bytes = common::to_bytes(body).await.unwrap_or_default();
7171 let encoded = common::to_string(&bytes);
7172 match serde_json::from_str(&encoded) {
7173 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7174 Err(error) => {
7175 dlg.response_json_decode_error(&encoded, &error);
7176 return Err(common::Error::JsonDecodeError(
7177 encoded.to_string(),
7178 error,
7179 ));
7180 }
7181 }
7182 };
7183
7184 dlg.finished(true);
7185 return Ok(response);
7186 }
7187 }
7188 }
7189 }
7190
7191 /// Required. Resource name for the Service Perimeter. Format: `accessPolicies/{policy_id}/servicePerimeters/{service_perimeters_id}`
7192 ///
7193 /// Sets the *name* path property to the given value.
7194 ///
7195 /// Even though the property as already been set when instantiating this call,
7196 /// we provide this method for API completeness.
7197 pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterGetCall<'a, C> {
7198 self._name = new_value.to_string();
7199 self
7200 }
7201 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7202 /// while executing the actual API request.
7203 ///
7204 /// ````text
7205 /// It should be used to handle progress information, and to implement a certain level of resilience.
7206 /// ````
7207 ///
7208 /// Sets the *delegate* property to the given value.
7209 pub fn delegate(
7210 mut self,
7211 new_value: &'a mut dyn common::Delegate,
7212 ) -> AccessPolicyServicePerimeterGetCall<'a, C> {
7213 self._delegate = Some(new_value);
7214 self
7215 }
7216
7217 /// Set any additional parameter of the query string used in the request.
7218 /// It should be used to set parameters which are not yet available through their own
7219 /// setters.
7220 ///
7221 /// Please note that this method must not be used to set any of the known parameters
7222 /// which have their own setter method. If done anyway, the request will fail.
7223 ///
7224 /// # Additional Parameters
7225 ///
7226 /// * *$.xgafv* (query-string) - V1 error format.
7227 /// * *access_token* (query-string) - OAuth access token.
7228 /// * *alt* (query-string) - Data format for response.
7229 /// * *callback* (query-string) - JSONP
7230 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7231 /// * *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.
7232 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7233 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7234 /// * *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.
7235 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7236 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7237 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterGetCall<'a, C>
7238 where
7239 T: AsRef<str>,
7240 {
7241 self._additional_params
7242 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7243 self
7244 }
7245
7246 /// Identifies the authorization scope for the method you are building.
7247 ///
7248 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7249 /// [`Scope::CloudPlatform`].
7250 ///
7251 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7252 /// tokens for more than one scope.
7253 ///
7254 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7255 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7256 /// sufficient, a read-write scope will do as well.
7257 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterGetCall<'a, C>
7258 where
7259 St: AsRef<str>,
7260 {
7261 self._scopes.insert(String::from(scope.as_ref()));
7262 self
7263 }
7264 /// Identifies the authorization scope(s) for the method you are building.
7265 ///
7266 /// See [`Self::add_scope()`] for details.
7267 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterGetCall<'a, C>
7268 where
7269 I: IntoIterator<Item = St>,
7270 St: AsRef<str>,
7271 {
7272 self._scopes
7273 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7274 self
7275 }
7276
7277 /// Removes all scopes, and no default scope will be used either.
7278 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7279 /// for details).
7280 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterGetCall<'a, C> {
7281 self._scopes.clear();
7282 self
7283 }
7284}
7285
7286/// Lists all service perimeters for an access policy.
7287///
7288/// A builder for the *servicePerimeters.list* method supported by a *accessPolicy* resource.
7289/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7290///
7291/// # Example
7292///
7293/// Instantiate a resource method builder
7294///
7295/// ```test_harness,no_run
7296/// # extern crate hyper;
7297/// # extern crate hyper_rustls;
7298/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7299/// # async fn dox() {
7300/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7301///
7302/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7303/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7304/// # secret,
7305/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7306/// # ).build().await.unwrap();
7307///
7308/// # let client = hyper_util::client::legacy::Client::builder(
7309/// # hyper_util::rt::TokioExecutor::new()
7310/// # )
7311/// # .build(
7312/// # hyper_rustls::HttpsConnectorBuilder::new()
7313/// # .with_native_roots()
7314/// # .unwrap()
7315/// # .https_or_http()
7316/// # .enable_http1()
7317/// # .build()
7318/// # );
7319/// # let mut hub = AccessContextManager::new(client, auth);
7320/// // You can configure optional parameters by calling the respective setters at will, and
7321/// // execute the final call using `doit()`.
7322/// // Values shown here are possibly random and not representative !
7323/// let result = hub.access_policies().service_perimeters_list("parent")
7324/// .page_token("Lorem")
7325/// .page_size(-25)
7326/// .doit().await;
7327/// # }
7328/// ```
7329pub struct AccessPolicyServicePerimeterListCall<'a, C>
7330where
7331 C: 'a,
7332{
7333 hub: &'a AccessContextManager<C>,
7334 _parent: String,
7335 _page_token: Option<String>,
7336 _page_size: Option<i32>,
7337 _delegate: Option<&'a mut dyn common::Delegate>,
7338 _additional_params: HashMap<String, String>,
7339 _scopes: BTreeSet<String>,
7340}
7341
7342impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterListCall<'a, C> {}
7343
7344impl<'a, C> AccessPolicyServicePerimeterListCall<'a, C>
7345where
7346 C: common::Connector,
7347{
7348 /// Perform the operation you have build so far.
7349 pub async fn doit(
7350 mut self,
7351 ) -> common::Result<(common::Response, ListServicePerimetersResponse)> {
7352 use std::borrow::Cow;
7353 use std::io::{Read, Seek};
7354
7355 use common::{url::Params, ToParts};
7356 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7357
7358 let mut dd = common::DefaultDelegate;
7359 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7360 dlg.begin(common::MethodInfo {
7361 id: "accesscontextmanager.accessPolicies.servicePerimeters.list",
7362 http_method: hyper::Method::GET,
7363 });
7364
7365 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
7366 if self._additional_params.contains_key(field) {
7367 dlg.finished(false);
7368 return Err(common::Error::FieldClash(field));
7369 }
7370 }
7371
7372 let mut params = Params::with_capacity(5 + self._additional_params.len());
7373 params.push("parent", self._parent);
7374 if let Some(value) = self._page_token.as_ref() {
7375 params.push("pageToken", value);
7376 }
7377 if let Some(value) = self._page_size.as_ref() {
7378 params.push("pageSize", value.to_string());
7379 }
7380
7381 params.extend(self._additional_params.iter());
7382
7383 params.push("alt", "json");
7384 let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters";
7385 if self._scopes.is_empty() {
7386 self._scopes
7387 .insert(Scope::CloudPlatform.as_ref().to_string());
7388 }
7389
7390 #[allow(clippy::single_element_loop)]
7391 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7392 url = params.uri_replacement(url, param_name, find_this, true);
7393 }
7394 {
7395 let to_remove = ["parent"];
7396 params.remove_params(&to_remove);
7397 }
7398
7399 let url = params.parse_with_url(&url);
7400
7401 loop {
7402 let token = match self
7403 .hub
7404 .auth
7405 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7406 .await
7407 {
7408 Ok(token) => token,
7409 Err(e) => match dlg.token(e) {
7410 Ok(token) => token,
7411 Err(e) => {
7412 dlg.finished(false);
7413 return Err(common::Error::MissingToken(e));
7414 }
7415 },
7416 };
7417 let mut req_result = {
7418 let client = &self.hub.client;
7419 dlg.pre_request();
7420 let mut req_builder = hyper::Request::builder()
7421 .method(hyper::Method::GET)
7422 .uri(url.as_str())
7423 .header(USER_AGENT, self.hub._user_agent.clone());
7424
7425 if let Some(token) = token.as_ref() {
7426 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7427 }
7428
7429 let request = req_builder
7430 .header(CONTENT_LENGTH, 0_u64)
7431 .body(common::to_body::<String>(None));
7432
7433 client.request(request.unwrap()).await
7434 };
7435
7436 match req_result {
7437 Err(err) => {
7438 if let common::Retry::After(d) = dlg.http_error(&err) {
7439 sleep(d).await;
7440 continue;
7441 }
7442 dlg.finished(false);
7443 return Err(common::Error::HttpError(err));
7444 }
7445 Ok(res) => {
7446 let (mut parts, body) = res.into_parts();
7447 let mut body = common::Body::new(body);
7448 if !parts.status.is_success() {
7449 let bytes = common::to_bytes(body).await.unwrap_or_default();
7450 let error = serde_json::from_str(&common::to_string(&bytes));
7451 let response = common::to_response(parts, bytes.into());
7452
7453 if let common::Retry::After(d) =
7454 dlg.http_failure(&response, error.as_ref().ok())
7455 {
7456 sleep(d).await;
7457 continue;
7458 }
7459
7460 dlg.finished(false);
7461
7462 return Err(match error {
7463 Ok(value) => common::Error::BadRequest(value),
7464 _ => common::Error::Failure(response),
7465 });
7466 }
7467 let response = {
7468 let bytes = common::to_bytes(body).await.unwrap_or_default();
7469 let encoded = common::to_string(&bytes);
7470 match serde_json::from_str(&encoded) {
7471 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7472 Err(error) => {
7473 dlg.response_json_decode_error(&encoded, &error);
7474 return Err(common::Error::JsonDecodeError(
7475 encoded.to_string(),
7476 error,
7477 ));
7478 }
7479 }
7480 };
7481
7482 dlg.finished(true);
7483 return Ok(response);
7484 }
7485 }
7486 }
7487 }
7488
7489 /// Required. Resource name for the access policy to list Service Perimeters from. Format: `accessPolicies/{policy_id}`
7490 ///
7491 /// Sets the *parent* path property to the given value.
7492 ///
7493 /// Even though the property as already been set when instantiating this call,
7494 /// we provide this method for API completeness.
7495 pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterListCall<'a, C> {
7496 self._parent = new_value.to_string();
7497 self
7498 }
7499 /// Next page token for the next batch of Service Perimeter instances. Defaults to the first page of results.
7500 ///
7501 /// Sets the *page token* query property to the given value.
7502 pub fn page_token(mut self, new_value: &str) -> AccessPolicyServicePerimeterListCall<'a, C> {
7503 self._page_token = Some(new_value.to_string());
7504 self
7505 }
7506 /// Number of Service Perimeters to include in the list. Default 100.
7507 ///
7508 /// Sets the *page size* query property to the given value.
7509 pub fn page_size(mut self, new_value: i32) -> AccessPolicyServicePerimeterListCall<'a, C> {
7510 self._page_size = Some(new_value);
7511 self
7512 }
7513 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7514 /// while executing the actual API request.
7515 ///
7516 /// ````text
7517 /// It should be used to handle progress information, and to implement a certain level of resilience.
7518 /// ````
7519 ///
7520 /// Sets the *delegate* property to the given value.
7521 pub fn delegate(
7522 mut self,
7523 new_value: &'a mut dyn common::Delegate,
7524 ) -> AccessPolicyServicePerimeterListCall<'a, C> {
7525 self._delegate = Some(new_value);
7526 self
7527 }
7528
7529 /// Set any additional parameter of the query string used in the request.
7530 /// It should be used to set parameters which are not yet available through their own
7531 /// setters.
7532 ///
7533 /// Please note that this method must not be used to set any of the known parameters
7534 /// which have their own setter method. If done anyway, the request will fail.
7535 ///
7536 /// # Additional Parameters
7537 ///
7538 /// * *$.xgafv* (query-string) - V1 error format.
7539 /// * *access_token* (query-string) - OAuth access token.
7540 /// * *alt* (query-string) - Data format for response.
7541 /// * *callback* (query-string) - JSONP
7542 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7543 /// * *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.
7544 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7545 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7546 /// * *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.
7547 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7548 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7549 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterListCall<'a, C>
7550 where
7551 T: AsRef<str>,
7552 {
7553 self._additional_params
7554 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7555 self
7556 }
7557
7558 /// Identifies the authorization scope for the method you are building.
7559 ///
7560 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7561 /// [`Scope::CloudPlatform`].
7562 ///
7563 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7564 /// tokens for more than one scope.
7565 ///
7566 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7567 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7568 /// sufficient, a read-write scope will do as well.
7569 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterListCall<'a, C>
7570 where
7571 St: AsRef<str>,
7572 {
7573 self._scopes.insert(String::from(scope.as_ref()));
7574 self
7575 }
7576 /// Identifies the authorization scope(s) for the method you are building.
7577 ///
7578 /// See [`Self::add_scope()`] for details.
7579 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterListCall<'a, C>
7580 where
7581 I: IntoIterator<Item = St>,
7582 St: AsRef<str>,
7583 {
7584 self._scopes
7585 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7586 self
7587 }
7588
7589 /// Removes all scopes, and no default scope will be used either.
7590 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7591 /// for details).
7592 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterListCall<'a, C> {
7593 self._scopes.clear();
7594 self
7595 }
7596}
7597
7598/// Updates a service perimeter. The long-running operation from this RPC has a successful status after the service perimeter propagates to long-lasting storage. If a service perimeter contains errors, an error response is returned for the first error encountered.
7599///
7600/// A builder for the *servicePerimeters.patch* method supported by a *accessPolicy* resource.
7601/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7602///
7603/// # Example
7604///
7605/// Instantiate a resource method builder
7606///
7607/// ```test_harness,no_run
7608/// # extern crate hyper;
7609/// # extern crate hyper_rustls;
7610/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7611/// use accesscontextmanager1::api::ServicePerimeter;
7612/// # async fn dox() {
7613/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7614///
7615/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7616/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7617/// # secret,
7618/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7619/// # ).build().await.unwrap();
7620///
7621/// # let client = hyper_util::client::legacy::Client::builder(
7622/// # hyper_util::rt::TokioExecutor::new()
7623/// # )
7624/// # .build(
7625/// # hyper_rustls::HttpsConnectorBuilder::new()
7626/// # .with_native_roots()
7627/// # .unwrap()
7628/// # .https_or_http()
7629/// # .enable_http1()
7630/// # .build()
7631/// # );
7632/// # let mut hub = AccessContextManager::new(client, auth);
7633/// // As the method needs a request, you would usually fill it with the desired information
7634/// // into the respective structure. Some of the parts shown here might not be applicable !
7635/// // Values shown here are possibly random and not representative !
7636/// let mut req = ServicePerimeter::default();
7637///
7638/// // You can configure optional parameters by calling the respective setters at will, and
7639/// // execute the final call using `doit()`.
7640/// // Values shown here are possibly random and not representative !
7641/// let result = hub.access_policies().service_perimeters_patch(req, "name")
7642/// .update_mask(FieldMask::new::<&str>(&[]))
7643/// .doit().await;
7644/// # }
7645/// ```
7646pub struct AccessPolicyServicePerimeterPatchCall<'a, C>
7647where
7648 C: 'a,
7649{
7650 hub: &'a AccessContextManager<C>,
7651 _request: ServicePerimeter,
7652 _name: String,
7653 _update_mask: Option<common::FieldMask>,
7654 _delegate: Option<&'a mut dyn common::Delegate>,
7655 _additional_params: HashMap<String, String>,
7656 _scopes: BTreeSet<String>,
7657}
7658
7659impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterPatchCall<'a, C> {}
7660
7661impl<'a, C> AccessPolicyServicePerimeterPatchCall<'a, C>
7662where
7663 C: common::Connector,
7664{
7665 /// Perform the operation you have build so far.
7666 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7667 use std::borrow::Cow;
7668 use std::io::{Read, Seek};
7669
7670 use common::{url::Params, ToParts};
7671 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7672
7673 let mut dd = common::DefaultDelegate;
7674 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7675 dlg.begin(common::MethodInfo {
7676 id: "accesscontextmanager.accessPolicies.servicePerimeters.patch",
7677 http_method: hyper::Method::PATCH,
7678 });
7679
7680 for &field in ["alt", "name", "updateMask"].iter() {
7681 if self._additional_params.contains_key(field) {
7682 dlg.finished(false);
7683 return Err(common::Error::FieldClash(field));
7684 }
7685 }
7686
7687 let mut params = Params::with_capacity(5 + self._additional_params.len());
7688 params.push("name", self._name);
7689 if let Some(value) = self._update_mask.as_ref() {
7690 params.push("updateMask", value.to_string());
7691 }
7692
7693 params.extend(self._additional_params.iter());
7694
7695 params.push("alt", "json");
7696 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7697 if self._scopes.is_empty() {
7698 self._scopes
7699 .insert(Scope::CloudPlatform.as_ref().to_string());
7700 }
7701
7702 #[allow(clippy::single_element_loop)]
7703 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7704 url = params.uri_replacement(url, param_name, find_this, true);
7705 }
7706 {
7707 let to_remove = ["name"];
7708 params.remove_params(&to_remove);
7709 }
7710
7711 let url = params.parse_with_url(&url);
7712
7713 let mut json_mime_type = mime::APPLICATION_JSON;
7714 let mut request_value_reader = {
7715 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7716 common::remove_json_null_values(&mut value);
7717 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7718 serde_json::to_writer(&mut dst, &value).unwrap();
7719 dst
7720 };
7721 let request_size = request_value_reader
7722 .seek(std::io::SeekFrom::End(0))
7723 .unwrap();
7724 request_value_reader
7725 .seek(std::io::SeekFrom::Start(0))
7726 .unwrap();
7727
7728 loop {
7729 let token = match self
7730 .hub
7731 .auth
7732 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7733 .await
7734 {
7735 Ok(token) => token,
7736 Err(e) => match dlg.token(e) {
7737 Ok(token) => token,
7738 Err(e) => {
7739 dlg.finished(false);
7740 return Err(common::Error::MissingToken(e));
7741 }
7742 },
7743 };
7744 request_value_reader
7745 .seek(std::io::SeekFrom::Start(0))
7746 .unwrap();
7747 let mut req_result = {
7748 let client = &self.hub.client;
7749 dlg.pre_request();
7750 let mut req_builder = hyper::Request::builder()
7751 .method(hyper::Method::PATCH)
7752 .uri(url.as_str())
7753 .header(USER_AGENT, self.hub._user_agent.clone());
7754
7755 if let Some(token) = token.as_ref() {
7756 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7757 }
7758
7759 let request = req_builder
7760 .header(CONTENT_TYPE, json_mime_type.to_string())
7761 .header(CONTENT_LENGTH, request_size as u64)
7762 .body(common::to_body(
7763 request_value_reader.get_ref().clone().into(),
7764 ));
7765
7766 client.request(request.unwrap()).await
7767 };
7768
7769 match req_result {
7770 Err(err) => {
7771 if let common::Retry::After(d) = dlg.http_error(&err) {
7772 sleep(d).await;
7773 continue;
7774 }
7775 dlg.finished(false);
7776 return Err(common::Error::HttpError(err));
7777 }
7778 Ok(res) => {
7779 let (mut parts, body) = res.into_parts();
7780 let mut body = common::Body::new(body);
7781 if !parts.status.is_success() {
7782 let bytes = common::to_bytes(body).await.unwrap_or_default();
7783 let error = serde_json::from_str(&common::to_string(&bytes));
7784 let response = common::to_response(parts, bytes.into());
7785
7786 if let common::Retry::After(d) =
7787 dlg.http_failure(&response, error.as_ref().ok())
7788 {
7789 sleep(d).await;
7790 continue;
7791 }
7792
7793 dlg.finished(false);
7794
7795 return Err(match error {
7796 Ok(value) => common::Error::BadRequest(value),
7797 _ => common::Error::Failure(response),
7798 });
7799 }
7800 let response = {
7801 let bytes = common::to_bytes(body).await.unwrap_or_default();
7802 let encoded = common::to_string(&bytes);
7803 match serde_json::from_str(&encoded) {
7804 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7805 Err(error) => {
7806 dlg.response_json_decode_error(&encoded, &error);
7807 return Err(common::Error::JsonDecodeError(
7808 encoded.to_string(),
7809 error,
7810 ));
7811 }
7812 }
7813 };
7814
7815 dlg.finished(true);
7816 return Ok(response);
7817 }
7818 }
7819 }
7820 }
7821
7822 ///
7823 /// Sets the *request* property to the given value.
7824 ///
7825 /// Even though the property as already been set when instantiating this call,
7826 /// we provide this method for API completeness.
7827 pub fn request(
7828 mut self,
7829 new_value: ServicePerimeter,
7830 ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
7831 self._request = new_value;
7832 self
7833 }
7834 /// Identifier. Resource name for the `ServicePerimeter`. Format: `accessPolicies/{access_policy}/servicePerimeters/{service_perimeter}`. The `service_perimeter` component must begin with a letter, followed by alphanumeric characters or `_`. After you create a `ServicePerimeter`, you cannot change its `name`.
7835 ///
7836 /// Sets the *name* path property to the given value.
7837 ///
7838 /// Even though the property as already been set when instantiating this call,
7839 /// we provide this method for API completeness.
7840 pub fn name(mut self, new_value: &str) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
7841 self._name = new_value.to_string();
7842 self
7843 }
7844 /// Required. Mask to control which fields get updated. Must be non-empty.
7845 ///
7846 /// Sets the *update mask* query property to the given value.
7847 pub fn update_mask(
7848 mut self,
7849 new_value: common::FieldMask,
7850 ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
7851 self._update_mask = Some(new_value);
7852 self
7853 }
7854 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7855 /// while executing the actual API request.
7856 ///
7857 /// ````text
7858 /// It should be used to handle progress information, and to implement a certain level of resilience.
7859 /// ````
7860 ///
7861 /// Sets the *delegate* property to the given value.
7862 pub fn delegate(
7863 mut self,
7864 new_value: &'a mut dyn common::Delegate,
7865 ) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
7866 self._delegate = Some(new_value);
7867 self
7868 }
7869
7870 /// Set any additional parameter of the query string used in the request.
7871 /// It should be used to set parameters which are not yet available through their own
7872 /// setters.
7873 ///
7874 /// Please note that this method must not be used to set any of the known parameters
7875 /// which have their own setter method. If done anyway, the request will fail.
7876 ///
7877 /// # Additional Parameters
7878 ///
7879 /// * *$.xgafv* (query-string) - V1 error format.
7880 /// * *access_token* (query-string) - OAuth access token.
7881 /// * *alt* (query-string) - Data format for response.
7882 /// * *callback* (query-string) - JSONP
7883 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7884 /// * *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.
7885 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7886 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7887 /// * *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.
7888 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7889 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7890 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyServicePerimeterPatchCall<'a, C>
7891 where
7892 T: AsRef<str>,
7893 {
7894 self._additional_params
7895 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7896 self
7897 }
7898
7899 /// Identifies the authorization scope for the method you are building.
7900 ///
7901 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7902 /// [`Scope::CloudPlatform`].
7903 ///
7904 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7905 /// tokens for more than one scope.
7906 ///
7907 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7908 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7909 /// sufficient, a read-write scope will do as well.
7910 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterPatchCall<'a, C>
7911 where
7912 St: AsRef<str>,
7913 {
7914 self._scopes.insert(String::from(scope.as_ref()));
7915 self
7916 }
7917 /// Identifies the authorization scope(s) for the method you are building.
7918 ///
7919 /// See [`Self::add_scope()`] for details.
7920 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyServicePerimeterPatchCall<'a, C>
7921 where
7922 I: IntoIterator<Item = St>,
7923 St: AsRef<str>,
7924 {
7925 self._scopes
7926 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7927 self
7928 }
7929
7930 /// Removes all scopes, and no default scope will be used either.
7931 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7932 /// for details).
7933 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterPatchCall<'a, C> {
7934 self._scopes.clear();
7935 self
7936 }
7937}
7938
7939/// Replace all existing service perimeters in an access policy with the service perimeters provided. This is done atomically. The long-running operation from this RPC has a successful status after all replacements propagate to long-lasting storage. Replacements containing errors result in an error response for the first error encountered. Upon an error, replacement are cancelled and existing service perimeters are not affected. The Operation.response field contains ReplaceServicePerimetersResponse.
7940///
7941/// A builder for the *servicePerimeters.replaceAll* method supported by a *accessPolicy* resource.
7942/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
7943///
7944/// # Example
7945///
7946/// Instantiate a resource method builder
7947///
7948/// ```test_harness,no_run
7949/// # extern crate hyper;
7950/// # extern crate hyper_rustls;
7951/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
7952/// use accesscontextmanager1::api::ReplaceServicePerimetersRequest;
7953/// # async fn dox() {
7954/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7955///
7956/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7957/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7958/// # secret,
7959/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7960/// # ).build().await.unwrap();
7961///
7962/// # let client = hyper_util::client::legacy::Client::builder(
7963/// # hyper_util::rt::TokioExecutor::new()
7964/// # )
7965/// # .build(
7966/// # hyper_rustls::HttpsConnectorBuilder::new()
7967/// # .with_native_roots()
7968/// # .unwrap()
7969/// # .https_or_http()
7970/// # .enable_http1()
7971/// # .build()
7972/// # );
7973/// # let mut hub = AccessContextManager::new(client, auth);
7974/// // As the method needs a request, you would usually fill it with the desired information
7975/// // into the respective structure. Some of the parts shown here might not be applicable !
7976/// // Values shown here are possibly random and not representative !
7977/// let mut req = ReplaceServicePerimetersRequest::default();
7978///
7979/// // You can configure optional parameters by calling the respective setters at will, and
7980/// // execute the final call using `doit()`.
7981/// // Values shown here are possibly random and not representative !
7982/// let result = hub.access_policies().service_perimeters_replace_all(req, "parent")
7983/// .doit().await;
7984/// # }
7985/// ```
7986pub struct AccessPolicyServicePerimeterReplaceAllCall<'a, C>
7987where
7988 C: 'a,
7989{
7990 hub: &'a AccessContextManager<C>,
7991 _request: ReplaceServicePerimetersRequest,
7992 _parent: String,
7993 _delegate: Option<&'a mut dyn common::Delegate>,
7994 _additional_params: HashMap<String, String>,
7995 _scopes: BTreeSet<String>,
7996}
7997
7998impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterReplaceAllCall<'a, C> {}
7999
8000impl<'a, C> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8001where
8002 C: common::Connector,
8003{
8004 /// Perform the operation you have build so far.
8005 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8006 use std::borrow::Cow;
8007 use std::io::{Read, Seek};
8008
8009 use common::{url::Params, ToParts};
8010 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8011
8012 let mut dd = common::DefaultDelegate;
8013 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8014 dlg.begin(common::MethodInfo {
8015 id: "accesscontextmanager.accessPolicies.servicePerimeters.replaceAll",
8016 http_method: hyper::Method::POST,
8017 });
8018
8019 for &field in ["alt", "parent"].iter() {
8020 if self._additional_params.contains_key(field) {
8021 dlg.finished(false);
8022 return Err(common::Error::FieldClash(field));
8023 }
8024 }
8025
8026 let mut params = Params::with_capacity(4 + self._additional_params.len());
8027 params.push("parent", self._parent);
8028
8029 params.extend(self._additional_params.iter());
8030
8031 params.push("alt", "json");
8032 let mut url = self.hub._base_url.clone() + "v1/{+parent}/servicePerimeters:replaceAll";
8033 if self._scopes.is_empty() {
8034 self._scopes
8035 .insert(Scope::CloudPlatform.as_ref().to_string());
8036 }
8037
8038 #[allow(clippy::single_element_loop)]
8039 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8040 url = params.uri_replacement(url, param_name, find_this, true);
8041 }
8042 {
8043 let to_remove = ["parent"];
8044 params.remove_params(&to_remove);
8045 }
8046
8047 let url = params.parse_with_url(&url);
8048
8049 let mut json_mime_type = mime::APPLICATION_JSON;
8050 let mut request_value_reader = {
8051 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8052 common::remove_json_null_values(&mut value);
8053 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8054 serde_json::to_writer(&mut dst, &value).unwrap();
8055 dst
8056 };
8057 let request_size = request_value_reader
8058 .seek(std::io::SeekFrom::End(0))
8059 .unwrap();
8060 request_value_reader
8061 .seek(std::io::SeekFrom::Start(0))
8062 .unwrap();
8063
8064 loop {
8065 let token = match self
8066 .hub
8067 .auth
8068 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8069 .await
8070 {
8071 Ok(token) => token,
8072 Err(e) => match dlg.token(e) {
8073 Ok(token) => token,
8074 Err(e) => {
8075 dlg.finished(false);
8076 return Err(common::Error::MissingToken(e));
8077 }
8078 },
8079 };
8080 request_value_reader
8081 .seek(std::io::SeekFrom::Start(0))
8082 .unwrap();
8083 let mut req_result = {
8084 let client = &self.hub.client;
8085 dlg.pre_request();
8086 let mut req_builder = hyper::Request::builder()
8087 .method(hyper::Method::POST)
8088 .uri(url.as_str())
8089 .header(USER_AGENT, self.hub._user_agent.clone());
8090
8091 if let Some(token) = token.as_ref() {
8092 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8093 }
8094
8095 let request = req_builder
8096 .header(CONTENT_TYPE, json_mime_type.to_string())
8097 .header(CONTENT_LENGTH, request_size as u64)
8098 .body(common::to_body(
8099 request_value_reader.get_ref().clone().into(),
8100 ));
8101
8102 client.request(request.unwrap()).await
8103 };
8104
8105 match req_result {
8106 Err(err) => {
8107 if let common::Retry::After(d) = dlg.http_error(&err) {
8108 sleep(d).await;
8109 continue;
8110 }
8111 dlg.finished(false);
8112 return Err(common::Error::HttpError(err));
8113 }
8114 Ok(res) => {
8115 let (mut parts, body) = res.into_parts();
8116 let mut body = common::Body::new(body);
8117 if !parts.status.is_success() {
8118 let bytes = common::to_bytes(body).await.unwrap_or_default();
8119 let error = serde_json::from_str(&common::to_string(&bytes));
8120 let response = common::to_response(parts, bytes.into());
8121
8122 if let common::Retry::After(d) =
8123 dlg.http_failure(&response, error.as_ref().ok())
8124 {
8125 sleep(d).await;
8126 continue;
8127 }
8128
8129 dlg.finished(false);
8130
8131 return Err(match error {
8132 Ok(value) => common::Error::BadRequest(value),
8133 _ => common::Error::Failure(response),
8134 });
8135 }
8136 let response = {
8137 let bytes = common::to_bytes(body).await.unwrap_or_default();
8138 let encoded = common::to_string(&bytes);
8139 match serde_json::from_str(&encoded) {
8140 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8141 Err(error) => {
8142 dlg.response_json_decode_error(&encoded, &error);
8143 return Err(common::Error::JsonDecodeError(
8144 encoded.to_string(),
8145 error,
8146 ));
8147 }
8148 }
8149 };
8150
8151 dlg.finished(true);
8152 return Ok(response);
8153 }
8154 }
8155 }
8156 }
8157
8158 ///
8159 /// Sets the *request* property to the given value.
8160 ///
8161 /// Even though the property as already been set when instantiating this call,
8162 /// we provide this method for API completeness.
8163 pub fn request(
8164 mut self,
8165 new_value: ReplaceServicePerimetersRequest,
8166 ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8167 self._request = new_value;
8168 self
8169 }
8170 /// Required. Resource name for the access policy which owns these Service Perimeters. Format: `accessPolicies/{policy_id}`
8171 ///
8172 /// Sets the *parent* path property to the given value.
8173 ///
8174 /// Even though the property as already been set when instantiating this call,
8175 /// we provide this method for API completeness.
8176 pub fn parent(mut self, new_value: &str) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8177 self._parent = new_value.to_string();
8178 self
8179 }
8180 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8181 /// while executing the actual API request.
8182 ///
8183 /// ````text
8184 /// It should be used to handle progress information, and to implement a certain level of resilience.
8185 /// ````
8186 ///
8187 /// Sets the *delegate* property to the given value.
8188 pub fn delegate(
8189 mut self,
8190 new_value: &'a mut dyn common::Delegate,
8191 ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8192 self._delegate = Some(new_value);
8193 self
8194 }
8195
8196 /// Set any additional parameter of the query string used in the request.
8197 /// It should be used to set parameters which are not yet available through their own
8198 /// setters.
8199 ///
8200 /// Please note that this method must not be used to set any of the known parameters
8201 /// which have their own setter method. If done anyway, the request will fail.
8202 ///
8203 /// # Additional Parameters
8204 ///
8205 /// * *$.xgafv* (query-string) - V1 error format.
8206 /// * *access_token* (query-string) - OAuth access token.
8207 /// * *alt* (query-string) - Data format for response.
8208 /// * *callback* (query-string) - JSONP
8209 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8210 /// * *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.
8211 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8212 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8213 /// * *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.
8214 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8215 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8216 pub fn param<T>(
8217 mut self,
8218 name: T,
8219 value: T,
8220 ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8221 where
8222 T: AsRef<str>,
8223 {
8224 self._additional_params
8225 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8226 self
8227 }
8228
8229 /// Identifies the authorization scope for the method you are building.
8230 ///
8231 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8232 /// [`Scope::CloudPlatform`].
8233 ///
8234 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8235 /// tokens for more than one scope.
8236 ///
8237 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8238 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8239 /// sufficient, a read-write scope will do as well.
8240 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8241 where
8242 St: AsRef<str>,
8243 {
8244 self._scopes.insert(String::from(scope.as_ref()));
8245 self
8246 }
8247 /// Identifies the authorization scope(s) for the method you are building.
8248 ///
8249 /// See [`Self::add_scope()`] for details.
8250 pub fn add_scopes<I, St>(
8251 mut self,
8252 scopes: I,
8253 ) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C>
8254 where
8255 I: IntoIterator<Item = St>,
8256 St: AsRef<str>,
8257 {
8258 self._scopes
8259 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8260 self
8261 }
8262
8263 /// Removes all scopes, and no default scope will be used either.
8264 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8265 /// for details).
8266 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterReplaceAllCall<'a, C> {
8267 self._scopes.clear();
8268 self
8269 }
8270}
8271
8272/// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
8273///
8274/// A builder for the *servicePerimeters.testIamPermissions* method supported by a *accessPolicy* resource.
8275/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
8276///
8277/// # Example
8278///
8279/// Instantiate a resource method builder
8280///
8281/// ```test_harness,no_run
8282/// # extern crate hyper;
8283/// # extern crate hyper_rustls;
8284/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
8285/// use accesscontextmanager1::api::TestIamPermissionsRequest;
8286/// # async fn dox() {
8287/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8288///
8289/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8290/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8291/// # secret,
8292/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8293/// # ).build().await.unwrap();
8294///
8295/// # let client = hyper_util::client::legacy::Client::builder(
8296/// # hyper_util::rt::TokioExecutor::new()
8297/// # )
8298/// # .build(
8299/// # hyper_rustls::HttpsConnectorBuilder::new()
8300/// # .with_native_roots()
8301/// # .unwrap()
8302/// # .https_or_http()
8303/// # .enable_http1()
8304/// # .build()
8305/// # );
8306/// # let mut hub = AccessContextManager::new(client, auth);
8307/// // As the method needs a request, you would usually fill it with the desired information
8308/// // into the respective structure. Some of the parts shown here might not be applicable !
8309/// // Values shown here are possibly random and not representative !
8310/// let mut req = TestIamPermissionsRequest::default();
8311///
8312/// // You can configure optional parameters by calling the respective setters at will, and
8313/// // execute the final call using `doit()`.
8314/// // Values shown here are possibly random and not representative !
8315/// let result = hub.access_policies().service_perimeters_test_iam_permissions(req, "resource")
8316/// .doit().await;
8317/// # }
8318/// ```
8319pub struct AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8320where
8321 C: 'a,
8322{
8323 hub: &'a AccessContextManager<C>,
8324 _request: TestIamPermissionsRequest,
8325 _resource: String,
8326 _delegate: Option<&'a mut dyn common::Delegate>,
8327 _additional_params: HashMap<String, String>,
8328 _scopes: BTreeSet<String>,
8329}
8330
8331impl<'a, C> common::CallBuilder for AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {}
8332
8333impl<'a, C> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8334where
8335 C: common::Connector,
8336{
8337 /// Perform the operation you have build so far.
8338 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8339 use std::borrow::Cow;
8340 use std::io::{Read, Seek};
8341
8342 use common::{url::Params, ToParts};
8343 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8344
8345 let mut dd = common::DefaultDelegate;
8346 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8347 dlg.begin(common::MethodInfo {
8348 id: "accesscontextmanager.accessPolicies.servicePerimeters.testIamPermissions",
8349 http_method: hyper::Method::POST,
8350 });
8351
8352 for &field in ["alt", "resource"].iter() {
8353 if self._additional_params.contains_key(field) {
8354 dlg.finished(false);
8355 return Err(common::Error::FieldClash(field));
8356 }
8357 }
8358
8359 let mut params = Params::with_capacity(4 + self._additional_params.len());
8360 params.push("resource", self._resource);
8361
8362 params.extend(self._additional_params.iter());
8363
8364 params.push("alt", "json");
8365 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
8366 if self._scopes.is_empty() {
8367 self._scopes
8368 .insert(Scope::CloudPlatform.as_ref().to_string());
8369 }
8370
8371 #[allow(clippy::single_element_loop)]
8372 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8373 url = params.uri_replacement(url, param_name, find_this, true);
8374 }
8375 {
8376 let to_remove = ["resource"];
8377 params.remove_params(&to_remove);
8378 }
8379
8380 let url = params.parse_with_url(&url);
8381
8382 let mut json_mime_type = mime::APPLICATION_JSON;
8383 let mut request_value_reader = {
8384 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8385 common::remove_json_null_values(&mut value);
8386 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8387 serde_json::to_writer(&mut dst, &value).unwrap();
8388 dst
8389 };
8390 let request_size = request_value_reader
8391 .seek(std::io::SeekFrom::End(0))
8392 .unwrap();
8393 request_value_reader
8394 .seek(std::io::SeekFrom::Start(0))
8395 .unwrap();
8396
8397 loop {
8398 let token = match self
8399 .hub
8400 .auth
8401 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8402 .await
8403 {
8404 Ok(token) => token,
8405 Err(e) => match dlg.token(e) {
8406 Ok(token) => token,
8407 Err(e) => {
8408 dlg.finished(false);
8409 return Err(common::Error::MissingToken(e));
8410 }
8411 },
8412 };
8413 request_value_reader
8414 .seek(std::io::SeekFrom::Start(0))
8415 .unwrap();
8416 let mut req_result = {
8417 let client = &self.hub.client;
8418 dlg.pre_request();
8419 let mut req_builder = hyper::Request::builder()
8420 .method(hyper::Method::POST)
8421 .uri(url.as_str())
8422 .header(USER_AGENT, self.hub._user_agent.clone());
8423
8424 if let Some(token) = token.as_ref() {
8425 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8426 }
8427
8428 let request = req_builder
8429 .header(CONTENT_TYPE, json_mime_type.to_string())
8430 .header(CONTENT_LENGTH, request_size as u64)
8431 .body(common::to_body(
8432 request_value_reader.get_ref().clone().into(),
8433 ));
8434
8435 client.request(request.unwrap()).await
8436 };
8437
8438 match req_result {
8439 Err(err) => {
8440 if let common::Retry::After(d) = dlg.http_error(&err) {
8441 sleep(d).await;
8442 continue;
8443 }
8444 dlg.finished(false);
8445 return Err(common::Error::HttpError(err));
8446 }
8447 Ok(res) => {
8448 let (mut parts, body) = res.into_parts();
8449 let mut body = common::Body::new(body);
8450 if !parts.status.is_success() {
8451 let bytes = common::to_bytes(body).await.unwrap_or_default();
8452 let error = serde_json::from_str(&common::to_string(&bytes));
8453 let response = common::to_response(parts, bytes.into());
8454
8455 if let common::Retry::After(d) =
8456 dlg.http_failure(&response, error.as_ref().ok())
8457 {
8458 sleep(d).await;
8459 continue;
8460 }
8461
8462 dlg.finished(false);
8463
8464 return Err(match error {
8465 Ok(value) => common::Error::BadRequest(value),
8466 _ => common::Error::Failure(response),
8467 });
8468 }
8469 let response = {
8470 let bytes = common::to_bytes(body).await.unwrap_or_default();
8471 let encoded = common::to_string(&bytes);
8472 match serde_json::from_str(&encoded) {
8473 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8474 Err(error) => {
8475 dlg.response_json_decode_error(&encoded, &error);
8476 return Err(common::Error::JsonDecodeError(
8477 encoded.to_string(),
8478 error,
8479 ));
8480 }
8481 }
8482 };
8483
8484 dlg.finished(true);
8485 return Ok(response);
8486 }
8487 }
8488 }
8489 }
8490
8491 ///
8492 /// Sets the *request* property to the given value.
8493 ///
8494 /// Even though the property as already been set when instantiating this call,
8495 /// we provide this method for API completeness.
8496 pub fn request(
8497 mut self,
8498 new_value: TestIamPermissionsRequest,
8499 ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
8500 self._request = new_value;
8501 self
8502 }
8503 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8504 ///
8505 /// Sets the *resource* path property to the given value.
8506 ///
8507 /// Even though the property as already been set when instantiating this call,
8508 /// we provide this method for API completeness.
8509 pub fn resource(
8510 mut self,
8511 new_value: &str,
8512 ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
8513 self._resource = new_value.to_string();
8514 self
8515 }
8516 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8517 /// while executing the actual API request.
8518 ///
8519 /// ````text
8520 /// It should be used to handle progress information, and to implement a certain level of resilience.
8521 /// ````
8522 ///
8523 /// Sets the *delegate* property to the given value.
8524 pub fn delegate(
8525 mut self,
8526 new_value: &'a mut dyn common::Delegate,
8527 ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
8528 self._delegate = Some(new_value);
8529 self
8530 }
8531
8532 /// Set any additional parameter of the query string used in the request.
8533 /// It should be used to set parameters which are not yet available through their own
8534 /// setters.
8535 ///
8536 /// Please note that this method must not be used to set any of the known parameters
8537 /// which have their own setter method. If done anyway, the request will fail.
8538 ///
8539 /// # Additional Parameters
8540 ///
8541 /// * *$.xgafv* (query-string) - V1 error format.
8542 /// * *access_token* (query-string) - OAuth access token.
8543 /// * *alt* (query-string) - Data format for response.
8544 /// * *callback* (query-string) - JSONP
8545 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8546 /// * *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.
8547 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8548 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8549 /// * *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.
8550 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8551 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8552 pub fn param<T>(
8553 mut self,
8554 name: T,
8555 value: T,
8556 ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8557 where
8558 T: AsRef<str>,
8559 {
8560 self._additional_params
8561 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8562 self
8563 }
8564
8565 /// Identifies the authorization scope for the method you are building.
8566 ///
8567 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8568 /// [`Scope::CloudPlatform`].
8569 ///
8570 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8571 /// tokens for more than one scope.
8572 ///
8573 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8574 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8575 /// sufficient, a read-write scope will do as well.
8576 pub fn add_scope<St>(
8577 mut self,
8578 scope: St,
8579 ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8580 where
8581 St: AsRef<str>,
8582 {
8583 self._scopes.insert(String::from(scope.as_ref()));
8584 self
8585 }
8586 /// Identifies the authorization scope(s) for the method you are building.
8587 ///
8588 /// See [`Self::add_scope()`] for details.
8589 pub fn add_scopes<I, St>(
8590 mut self,
8591 scopes: I,
8592 ) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C>
8593 where
8594 I: IntoIterator<Item = St>,
8595 St: AsRef<str>,
8596 {
8597 self._scopes
8598 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8599 self
8600 }
8601
8602 /// Removes all scopes, and no default scope will be used either.
8603 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8604 /// for details).
8605 pub fn clear_scopes(mut self) -> AccessPolicyServicePerimeterTestIamPermissionCall<'a, C> {
8606 self._scopes.clear();
8607 self
8608 }
8609}
8610
8611/// Creates an access policy. This method fails if the organization already has an access policy. The long-running operation has a successful status after the access policy propagates to long-lasting storage. Syntactic and basic semantic errors are returned in `metadata` as a BadRequest proto.
8612///
8613/// A builder for the *create* method supported by a *accessPolicy* resource.
8614/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
8615///
8616/// # Example
8617///
8618/// Instantiate a resource method builder
8619///
8620/// ```test_harness,no_run
8621/// # extern crate hyper;
8622/// # extern crate hyper_rustls;
8623/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
8624/// use accesscontextmanager1::api::AccessPolicy;
8625/// # async fn dox() {
8626/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8627///
8628/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8629/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8630/// # secret,
8631/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8632/// # ).build().await.unwrap();
8633///
8634/// # let client = hyper_util::client::legacy::Client::builder(
8635/// # hyper_util::rt::TokioExecutor::new()
8636/// # )
8637/// # .build(
8638/// # hyper_rustls::HttpsConnectorBuilder::new()
8639/// # .with_native_roots()
8640/// # .unwrap()
8641/// # .https_or_http()
8642/// # .enable_http1()
8643/// # .build()
8644/// # );
8645/// # let mut hub = AccessContextManager::new(client, auth);
8646/// // As the method needs a request, you would usually fill it with the desired information
8647/// // into the respective structure. Some of the parts shown here might not be applicable !
8648/// // Values shown here are possibly random and not representative !
8649/// let mut req = AccessPolicy::default();
8650///
8651/// // You can configure optional parameters by calling the respective setters at will, and
8652/// // execute the final call using `doit()`.
8653/// // Values shown here are possibly random and not representative !
8654/// let result = hub.access_policies().create(req)
8655/// .doit().await;
8656/// # }
8657/// ```
8658pub struct AccessPolicyCreateCall<'a, C>
8659where
8660 C: 'a,
8661{
8662 hub: &'a AccessContextManager<C>,
8663 _request: AccessPolicy,
8664 _delegate: Option<&'a mut dyn common::Delegate>,
8665 _additional_params: HashMap<String, String>,
8666 _scopes: BTreeSet<String>,
8667}
8668
8669impl<'a, C> common::CallBuilder for AccessPolicyCreateCall<'a, C> {}
8670
8671impl<'a, C> AccessPolicyCreateCall<'a, C>
8672where
8673 C: common::Connector,
8674{
8675 /// Perform the operation you have build so far.
8676 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8677 use std::borrow::Cow;
8678 use std::io::{Read, Seek};
8679
8680 use common::{url::Params, ToParts};
8681 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8682
8683 let mut dd = common::DefaultDelegate;
8684 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8685 dlg.begin(common::MethodInfo {
8686 id: "accesscontextmanager.accessPolicies.create",
8687 http_method: hyper::Method::POST,
8688 });
8689
8690 for &field in ["alt"].iter() {
8691 if self._additional_params.contains_key(field) {
8692 dlg.finished(false);
8693 return Err(common::Error::FieldClash(field));
8694 }
8695 }
8696
8697 let mut params = Params::with_capacity(3 + self._additional_params.len());
8698
8699 params.extend(self._additional_params.iter());
8700
8701 params.push("alt", "json");
8702 let mut url = self.hub._base_url.clone() + "v1/accessPolicies";
8703 if self._scopes.is_empty() {
8704 self._scopes
8705 .insert(Scope::CloudPlatform.as_ref().to_string());
8706 }
8707
8708 let url = params.parse_with_url(&url);
8709
8710 let mut json_mime_type = mime::APPLICATION_JSON;
8711 let mut request_value_reader = {
8712 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8713 common::remove_json_null_values(&mut value);
8714 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8715 serde_json::to_writer(&mut dst, &value).unwrap();
8716 dst
8717 };
8718 let request_size = request_value_reader
8719 .seek(std::io::SeekFrom::End(0))
8720 .unwrap();
8721 request_value_reader
8722 .seek(std::io::SeekFrom::Start(0))
8723 .unwrap();
8724
8725 loop {
8726 let token = match self
8727 .hub
8728 .auth
8729 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8730 .await
8731 {
8732 Ok(token) => token,
8733 Err(e) => match dlg.token(e) {
8734 Ok(token) => token,
8735 Err(e) => {
8736 dlg.finished(false);
8737 return Err(common::Error::MissingToken(e));
8738 }
8739 },
8740 };
8741 request_value_reader
8742 .seek(std::io::SeekFrom::Start(0))
8743 .unwrap();
8744 let mut req_result = {
8745 let client = &self.hub.client;
8746 dlg.pre_request();
8747 let mut req_builder = hyper::Request::builder()
8748 .method(hyper::Method::POST)
8749 .uri(url.as_str())
8750 .header(USER_AGENT, self.hub._user_agent.clone());
8751
8752 if let Some(token) = token.as_ref() {
8753 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8754 }
8755
8756 let request = req_builder
8757 .header(CONTENT_TYPE, json_mime_type.to_string())
8758 .header(CONTENT_LENGTH, request_size as u64)
8759 .body(common::to_body(
8760 request_value_reader.get_ref().clone().into(),
8761 ));
8762
8763 client.request(request.unwrap()).await
8764 };
8765
8766 match req_result {
8767 Err(err) => {
8768 if let common::Retry::After(d) = dlg.http_error(&err) {
8769 sleep(d).await;
8770 continue;
8771 }
8772 dlg.finished(false);
8773 return Err(common::Error::HttpError(err));
8774 }
8775 Ok(res) => {
8776 let (mut parts, body) = res.into_parts();
8777 let mut body = common::Body::new(body);
8778 if !parts.status.is_success() {
8779 let bytes = common::to_bytes(body).await.unwrap_or_default();
8780 let error = serde_json::from_str(&common::to_string(&bytes));
8781 let response = common::to_response(parts, bytes.into());
8782
8783 if let common::Retry::After(d) =
8784 dlg.http_failure(&response, error.as_ref().ok())
8785 {
8786 sleep(d).await;
8787 continue;
8788 }
8789
8790 dlg.finished(false);
8791
8792 return Err(match error {
8793 Ok(value) => common::Error::BadRequest(value),
8794 _ => common::Error::Failure(response),
8795 });
8796 }
8797 let response = {
8798 let bytes = common::to_bytes(body).await.unwrap_or_default();
8799 let encoded = common::to_string(&bytes);
8800 match serde_json::from_str(&encoded) {
8801 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8802 Err(error) => {
8803 dlg.response_json_decode_error(&encoded, &error);
8804 return Err(common::Error::JsonDecodeError(
8805 encoded.to_string(),
8806 error,
8807 ));
8808 }
8809 }
8810 };
8811
8812 dlg.finished(true);
8813 return Ok(response);
8814 }
8815 }
8816 }
8817 }
8818
8819 ///
8820 /// Sets the *request* property to the given value.
8821 ///
8822 /// Even though the property as already been set when instantiating this call,
8823 /// we provide this method for API completeness.
8824 pub fn request(mut self, new_value: AccessPolicy) -> AccessPolicyCreateCall<'a, C> {
8825 self._request = new_value;
8826 self
8827 }
8828 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8829 /// while executing the actual API request.
8830 ///
8831 /// ````text
8832 /// It should be used to handle progress information, and to implement a certain level of resilience.
8833 /// ````
8834 ///
8835 /// Sets the *delegate* property to the given value.
8836 pub fn delegate(
8837 mut self,
8838 new_value: &'a mut dyn common::Delegate,
8839 ) -> AccessPolicyCreateCall<'a, C> {
8840 self._delegate = Some(new_value);
8841 self
8842 }
8843
8844 /// Set any additional parameter of the query string used in the request.
8845 /// It should be used to set parameters which are not yet available through their own
8846 /// setters.
8847 ///
8848 /// Please note that this method must not be used to set any of the known parameters
8849 /// which have their own setter method. If done anyway, the request will fail.
8850 ///
8851 /// # Additional Parameters
8852 ///
8853 /// * *$.xgafv* (query-string) - V1 error format.
8854 /// * *access_token* (query-string) - OAuth access token.
8855 /// * *alt* (query-string) - Data format for response.
8856 /// * *callback* (query-string) - JSONP
8857 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8858 /// * *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.
8859 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8860 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8861 /// * *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.
8862 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8863 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8864 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyCreateCall<'a, C>
8865 where
8866 T: AsRef<str>,
8867 {
8868 self._additional_params
8869 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8870 self
8871 }
8872
8873 /// Identifies the authorization scope for the method you are building.
8874 ///
8875 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8876 /// [`Scope::CloudPlatform`].
8877 ///
8878 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8879 /// tokens for more than one scope.
8880 ///
8881 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8882 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8883 /// sufficient, a read-write scope will do as well.
8884 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyCreateCall<'a, C>
8885 where
8886 St: AsRef<str>,
8887 {
8888 self._scopes.insert(String::from(scope.as_ref()));
8889 self
8890 }
8891 /// Identifies the authorization scope(s) for the method you are building.
8892 ///
8893 /// See [`Self::add_scope()`] for details.
8894 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyCreateCall<'a, C>
8895 where
8896 I: IntoIterator<Item = St>,
8897 St: AsRef<str>,
8898 {
8899 self._scopes
8900 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8901 self
8902 }
8903
8904 /// Removes all scopes, and no default scope will be used either.
8905 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8906 /// for details).
8907 pub fn clear_scopes(mut self) -> AccessPolicyCreateCall<'a, C> {
8908 self._scopes.clear();
8909 self
8910 }
8911}
8912
8913/// Deletes an access policy based on the resource name. The long-running operation has a successful status after the access policy is removed from long-lasting storage.
8914///
8915/// A builder for the *delete* method supported by a *accessPolicy* resource.
8916/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
8917///
8918/// # Example
8919///
8920/// Instantiate a resource method builder
8921///
8922/// ```test_harness,no_run
8923/// # extern crate hyper;
8924/// # extern crate hyper_rustls;
8925/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
8926/// # async fn dox() {
8927/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8928///
8929/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8930/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8931/// # secret,
8932/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8933/// # ).build().await.unwrap();
8934///
8935/// # let client = hyper_util::client::legacy::Client::builder(
8936/// # hyper_util::rt::TokioExecutor::new()
8937/// # )
8938/// # .build(
8939/// # hyper_rustls::HttpsConnectorBuilder::new()
8940/// # .with_native_roots()
8941/// # .unwrap()
8942/// # .https_or_http()
8943/// # .enable_http1()
8944/// # .build()
8945/// # );
8946/// # let mut hub = AccessContextManager::new(client, auth);
8947/// // You can configure optional parameters by calling the respective setters at will, and
8948/// // execute the final call using `doit()`.
8949/// // Values shown here are possibly random and not representative !
8950/// let result = hub.access_policies().delete("name")
8951/// .doit().await;
8952/// # }
8953/// ```
8954pub struct AccessPolicyDeleteCall<'a, C>
8955where
8956 C: 'a,
8957{
8958 hub: &'a AccessContextManager<C>,
8959 _name: String,
8960 _delegate: Option<&'a mut dyn common::Delegate>,
8961 _additional_params: HashMap<String, String>,
8962 _scopes: BTreeSet<String>,
8963}
8964
8965impl<'a, C> common::CallBuilder for AccessPolicyDeleteCall<'a, C> {}
8966
8967impl<'a, C> AccessPolicyDeleteCall<'a, C>
8968where
8969 C: common::Connector,
8970{
8971 /// Perform the operation you have build so far.
8972 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8973 use std::borrow::Cow;
8974 use std::io::{Read, Seek};
8975
8976 use common::{url::Params, ToParts};
8977 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8978
8979 let mut dd = common::DefaultDelegate;
8980 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8981 dlg.begin(common::MethodInfo {
8982 id: "accesscontextmanager.accessPolicies.delete",
8983 http_method: hyper::Method::DELETE,
8984 });
8985
8986 for &field in ["alt", "name"].iter() {
8987 if self._additional_params.contains_key(field) {
8988 dlg.finished(false);
8989 return Err(common::Error::FieldClash(field));
8990 }
8991 }
8992
8993 let mut params = Params::with_capacity(3 + self._additional_params.len());
8994 params.push("name", self._name);
8995
8996 params.extend(self._additional_params.iter());
8997
8998 params.push("alt", "json");
8999 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9000 if self._scopes.is_empty() {
9001 self._scopes
9002 .insert(Scope::CloudPlatform.as_ref().to_string());
9003 }
9004
9005 #[allow(clippy::single_element_loop)]
9006 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9007 url = params.uri_replacement(url, param_name, find_this, true);
9008 }
9009 {
9010 let to_remove = ["name"];
9011 params.remove_params(&to_remove);
9012 }
9013
9014 let url = params.parse_with_url(&url);
9015
9016 loop {
9017 let token = match self
9018 .hub
9019 .auth
9020 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9021 .await
9022 {
9023 Ok(token) => token,
9024 Err(e) => match dlg.token(e) {
9025 Ok(token) => token,
9026 Err(e) => {
9027 dlg.finished(false);
9028 return Err(common::Error::MissingToken(e));
9029 }
9030 },
9031 };
9032 let mut req_result = {
9033 let client = &self.hub.client;
9034 dlg.pre_request();
9035 let mut req_builder = hyper::Request::builder()
9036 .method(hyper::Method::DELETE)
9037 .uri(url.as_str())
9038 .header(USER_AGENT, self.hub._user_agent.clone());
9039
9040 if let Some(token) = token.as_ref() {
9041 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9042 }
9043
9044 let request = req_builder
9045 .header(CONTENT_LENGTH, 0_u64)
9046 .body(common::to_body::<String>(None));
9047
9048 client.request(request.unwrap()).await
9049 };
9050
9051 match req_result {
9052 Err(err) => {
9053 if let common::Retry::After(d) = dlg.http_error(&err) {
9054 sleep(d).await;
9055 continue;
9056 }
9057 dlg.finished(false);
9058 return Err(common::Error::HttpError(err));
9059 }
9060 Ok(res) => {
9061 let (mut parts, body) = res.into_parts();
9062 let mut body = common::Body::new(body);
9063 if !parts.status.is_success() {
9064 let bytes = common::to_bytes(body).await.unwrap_or_default();
9065 let error = serde_json::from_str(&common::to_string(&bytes));
9066 let response = common::to_response(parts, bytes.into());
9067
9068 if let common::Retry::After(d) =
9069 dlg.http_failure(&response, error.as_ref().ok())
9070 {
9071 sleep(d).await;
9072 continue;
9073 }
9074
9075 dlg.finished(false);
9076
9077 return Err(match error {
9078 Ok(value) => common::Error::BadRequest(value),
9079 _ => common::Error::Failure(response),
9080 });
9081 }
9082 let response = {
9083 let bytes = common::to_bytes(body).await.unwrap_or_default();
9084 let encoded = common::to_string(&bytes);
9085 match serde_json::from_str(&encoded) {
9086 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9087 Err(error) => {
9088 dlg.response_json_decode_error(&encoded, &error);
9089 return Err(common::Error::JsonDecodeError(
9090 encoded.to_string(),
9091 error,
9092 ));
9093 }
9094 }
9095 };
9096
9097 dlg.finished(true);
9098 return Ok(response);
9099 }
9100 }
9101 }
9102 }
9103
9104 /// Required. Resource name for the access policy to delete. Format `accessPolicies/{policy_id}`
9105 ///
9106 /// Sets the *name* path property to the given value.
9107 ///
9108 /// Even though the property as already been set when instantiating this call,
9109 /// we provide this method for API completeness.
9110 pub fn name(mut self, new_value: &str) -> AccessPolicyDeleteCall<'a, C> {
9111 self._name = new_value.to_string();
9112 self
9113 }
9114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9115 /// while executing the actual API request.
9116 ///
9117 /// ````text
9118 /// It should be used to handle progress information, and to implement a certain level of resilience.
9119 /// ````
9120 ///
9121 /// Sets the *delegate* property to the given value.
9122 pub fn delegate(
9123 mut self,
9124 new_value: &'a mut dyn common::Delegate,
9125 ) -> AccessPolicyDeleteCall<'a, C> {
9126 self._delegate = Some(new_value);
9127 self
9128 }
9129
9130 /// Set any additional parameter of the query string used in the request.
9131 /// It should be used to set parameters which are not yet available through their own
9132 /// setters.
9133 ///
9134 /// Please note that this method must not be used to set any of the known parameters
9135 /// which have their own setter method. If done anyway, the request will fail.
9136 ///
9137 /// # Additional Parameters
9138 ///
9139 /// * *$.xgafv* (query-string) - V1 error format.
9140 /// * *access_token* (query-string) - OAuth access token.
9141 /// * *alt* (query-string) - Data format for response.
9142 /// * *callback* (query-string) - JSONP
9143 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9144 /// * *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.
9145 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9146 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9147 /// * *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.
9148 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9149 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9150 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyDeleteCall<'a, C>
9151 where
9152 T: AsRef<str>,
9153 {
9154 self._additional_params
9155 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9156 self
9157 }
9158
9159 /// Identifies the authorization scope for the method you are building.
9160 ///
9161 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9162 /// [`Scope::CloudPlatform`].
9163 ///
9164 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9165 /// tokens for more than one scope.
9166 ///
9167 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9168 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9169 /// sufficient, a read-write scope will do as well.
9170 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyDeleteCall<'a, C>
9171 where
9172 St: AsRef<str>,
9173 {
9174 self._scopes.insert(String::from(scope.as_ref()));
9175 self
9176 }
9177 /// Identifies the authorization scope(s) for the method you are building.
9178 ///
9179 /// See [`Self::add_scope()`] for details.
9180 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyDeleteCall<'a, C>
9181 where
9182 I: IntoIterator<Item = St>,
9183 St: AsRef<str>,
9184 {
9185 self._scopes
9186 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9187 self
9188 }
9189
9190 /// Removes all scopes, and no default scope will be used either.
9191 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9192 /// for details).
9193 pub fn clear_scopes(mut self) -> AccessPolicyDeleteCall<'a, C> {
9194 self._scopes.clear();
9195 self
9196 }
9197}
9198
9199/// Returns an access policy based on the name.
9200///
9201/// A builder for the *get* method supported by a *accessPolicy* resource.
9202/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
9203///
9204/// # Example
9205///
9206/// Instantiate a resource method builder
9207///
9208/// ```test_harness,no_run
9209/// # extern crate hyper;
9210/// # extern crate hyper_rustls;
9211/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
9212/// # async fn dox() {
9213/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9214///
9215/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9216/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9217/// # secret,
9218/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9219/// # ).build().await.unwrap();
9220///
9221/// # let client = hyper_util::client::legacy::Client::builder(
9222/// # hyper_util::rt::TokioExecutor::new()
9223/// # )
9224/// # .build(
9225/// # hyper_rustls::HttpsConnectorBuilder::new()
9226/// # .with_native_roots()
9227/// # .unwrap()
9228/// # .https_or_http()
9229/// # .enable_http1()
9230/// # .build()
9231/// # );
9232/// # let mut hub = AccessContextManager::new(client, auth);
9233/// // You can configure optional parameters by calling the respective setters at will, and
9234/// // execute the final call using `doit()`.
9235/// // Values shown here are possibly random and not representative !
9236/// let result = hub.access_policies().get("name")
9237/// .doit().await;
9238/// # }
9239/// ```
9240pub struct AccessPolicyGetCall<'a, C>
9241where
9242 C: 'a,
9243{
9244 hub: &'a AccessContextManager<C>,
9245 _name: String,
9246 _delegate: Option<&'a mut dyn common::Delegate>,
9247 _additional_params: HashMap<String, String>,
9248 _scopes: BTreeSet<String>,
9249}
9250
9251impl<'a, C> common::CallBuilder for AccessPolicyGetCall<'a, C> {}
9252
9253impl<'a, C> AccessPolicyGetCall<'a, C>
9254where
9255 C: common::Connector,
9256{
9257 /// Perform the operation you have build so far.
9258 pub async fn doit(mut self) -> common::Result<(common::Response, AccessPolicy)> {
9259 use std::borrow::Cow;
9260 use std::io::{Read, Seek};
9261
9262 use common::{url::Params, ToParts};
9263 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9264
9265 let mut dd = common::DefaultDelegate;
9266 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9267 dlg.begin(common::MethodInfo {
9268 id: "accesscontextmanager.accessPolicies.get",
9269 http_method: hyper::Method::GET,
9270 });
9271
9272 for &field in ["alt", "name"].iter() {
9273 if self._additional_params.contains_key(field) {
9274 dlg.finished(false);
9275 return Err(common::Error::FieldClash(field));
9276 }
9277 }
9278
9279 let mut params = Params::with_capacity(3 + self._additional_params.len());
9280 params.push("name", self._name);
9281
9282 params.extend(self._additional_params.iter());
9283
9284 params.push("alt", "json");
9285 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9286 if self._scopes.is_empty() {
9287 self._scopes
9288 .insert(Scope::CloudPlatform.as_ref().to_string());
9289 }
9290
9291 #[allow(clippy::single_element_loop)]
9292 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9293 url = params.uri_replacement(url, param_name, find_this, true);
9294 }
9295 {
9296 let to_remove = ["name"];
9297 params.remove_params(&to_remove);
9298 }
9299
9300 let url = params.parse_with_url(&url);
9301
9302 loop {
9303 let token = match self
9304 .hub
9305 .auth
9306 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9307 .await
9308 {
9309 Ok(token) => token,
9310 Err(e) => match dlg.token(e) {
9311 Ok(token) => token,
9312 Err(e) => {
9313 dlg.finished(false);
9314 return Err(common::Error::MissingToken(e));
9315 }
9316 },
9317 };
9318 let mut req_result = {
9319 let client = &self.hub.client;
9320 dlg.pre_request();
9321 let mut req_builder = hyper::Request::builder()
9322 .method(hyper::Method::GET)
9323 .uri(url.as_str())
9324 .header(USER_AGENT, self.hub._user_agent.clone());
9325
9326 if let Some(token) = token.as_ref() {
9327 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9328 }
9329
9330 let request = req_builder
9331 .header(CONTENT_LENGTH, 0_u64)
9332 .body(common::to_body::<String>(None));
9333
9334 client.request(request.unwrap()).await
9335 };
9336
9337 match req_result {
9338 Err(err) => {
9339 if let common::Retry::After(d) = dlg.http_error(&err) {
9340 sleep(d).await;
9341 continue;
9342 }
9343 dlg.finished(false);
9344 return Err(common::Error::HttpError(err));
9345 }
9346 Ok(res) => {
9347 let (mut parts, body) = res.into_parts();
9348 let mut body = common::Body::new(body);
9349 if !parts.status.is_success() {
9350 let bytes = common::to_bytes(body).await.unwrap_or_default();
9351 let error = serde_json::from_str(&common::to_string(&bytes));
9352 let response = common::to_response(parts, bytes.into());
9353
9354 if let common::Retry::After(d) =
9355 dlg.http_failure(&response, error.as_ref().ok())
9356 {
9357 sleep(d).await;
9358 continue;
9359 }
9360
9361 dlg.finished(false);
9362
9363 return Err(match error {
9364 Ok(value) => common::Error::BadRequest(value),
9365 _ => common::Error::Failure(response),
9366 });
9367 }
9368 let response = {
9369 let bytes = common::to_bytes(body).await.unwrap_or_default();
9370 let encoded = common::to_string(&bytes);
9371 match serde_json::from_str(&encoded) {
9372 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9373 Err(error) => {
9374 dlg.response_json_decode_error(&encoded, &error);
9375 return Err(common::Error::JsonDecodeError(
9376 encoded.to_string(),
9377 error,
9378 ));
9379 }
9380 }
9381 };
9382
9383 dlg.finished(true);
9384 return Ok(response);
9385 }
9386 }
9387 }
9388 }
9389
9390 /// Required. Resource name for the access policy to get. Format `accessPolicies/{policy_id}`
9391 ///
9392 /// Sets the *name* path property to the given value.
9393 ///
9394 /// Even though the property as already been set when instantiating this call,
9395 /// we provide this method for API completeness.
9396 pub fn name(mut self, new_value: &str) -> AccessPolicyGetCall<'a, C> {
9397 self._name = new_value.to_string();
9398 self
9399 }
9400 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9401 /// while executing the actual API request.
9402 ///
9403 /// ````text
9404 /// It should be used to handle progress information, and to implement a certain level of resilience.
9405 /// ````
9406 ///
9407 /// Sets the *delegate* property to the given value.
9408 pub fn delegate(
9409 mut self,
9410 new_value: &'a mut dyn common::Delegate,
9411 ) -> AccessPolicyGetCall<'a, C> {
9412 self._delegate = Some(new_value);
9413 self
9414 }
9415
9416 /// Set any additional parameter of the query string used in the request.
9417 /// It should be used to set parameters which are not yet available through their own
9418 /// setters.
9419 ///
9420 /// Please note that this method must not be used to set any of the known parameters
9421 /// which have their own setter method. If done anyway, the request will fail.
9422 ///
9423 /// # Additional Parameters
9424 ///
9425 /// * *$.xgafv* (query-string) - V1 error format.
9426 /// * *access_token* (query-string) - OAuth access token.
9427 /// * *alt* (query-string) - Data format for response.
9428 /// * *callback* (query-string) - JSONP
9429 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9430 /// * *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.
9431 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9432 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9433 /// * *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.
9434 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9435 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9436 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyGetCall<'a, C>
9437 where
9438 T: AsRef<str>,
9439 {
9440 self._additional_params
9441 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9442 self
9443 }
9444
9445 /// Identifies the authorization scope for the method you are building.
9446 ///
9447 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9448 /// [`Scope::CloudPlatform`].
9449 ///
9450 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9451 /// tokens for more than one scope.
9452 ///
9453 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9454 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9455 /// sufficient, a read-write scope will do as well.
9456 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyGetCall<'a, C>
9457 where
9458 St: AsRef<str>,
9459 {
9460 self._scopes.insert(String::from(scope.as_ref()));
9461 self
9462 }
9463 /// Identifies the authorization scope(s) for the method you are building.
9464 ///
9465 /// See [`Self::add_scope()`] for details.
9466 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyGetCall<'a, C>
9467 where
9468 I: IntoIterator<Item = St>,
9469 St: AsRef<str>,
9470 {
9471 self._scopes
9472 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9473 self
9474 }
9475
9476 /// Removes all scopes, and no default scope will be used either.
9477 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9478 /// for details).
9479 pub fn clear_scopes(mut self) -> AccessPolicyGetCall<'a, C> {
9480 self._scopes.clear();
9481 self
9482 }
9483}
9484
9485/// Gets the IAM policy for the specified Access Context Manager access policy.
9486///
9487/// A builder for the *getIamPolicy* method supported by a *accessPolicy* resource.
9488/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
9489///
9490/// # Example
9491///
9492/// Instantiate a resource method builder
9493///
9494/// ```test_harness,no_run
9495/// # extern crate hyper;
9496/// # extern crate hyper_rustls;
9497/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
9498/// use accesscontextmanager1::api::GetIamPolicyRequest;
9499/// # async fn dox() {
9500/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9501///
9502/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9503/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9504/// # secret,
9505/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9506/// # ).build().await.unwrap();
9507///
9508/// # let client = hyper_util::client::legacy::Client::builder(
9509/// # hyper_util::rt::TokioExecutor::new()
9510/// # )
9511/// # .build(
9512/// # hyper_rustls::HttpsConnectorBuilder::new()
9513/// # .with_native_roots()
9514/// # .unwrap()
9515/// # .https_or_http()
9516/// # .enable_http1()
9517/// # .build()
9518/// # );
9519/// # let mut hub = AccessContextManager::new(client, auth);
9520/// // As the method needs a request, you would usually fill it with the desired information
9521/// // into the respective structure. Some of the parts shown here might not be applicable !
9522/// // Values shown here are possibly random and not representative !
9523/// let mut req = GetIamPolicyRequest::default();
9524///
9525/// // You can configure optional parameters by calling the respective setters at will, and
9526/// // execute the final call using `doit()`.
9527/// // Values shown here are possibly random and not representative !
9528/// let result = hub.access_policies().get_iam_policy(req, "resource")
9529/// .doit().await;
9530/// # }
9531/// ```
9532pub struct AccessPolicyGetIamPolicyCall<'a, C>
9533where
9534 C: 'a,
9535{
9536 hub: &'a AccessContextManager<C>,
9537 _request: GetIamPolicyRequest,
9538 _resource: String,
9539 _delegate: Option<&'a mut dyn common::Delegate>,
9540 _additional_params: HashMap<String, String>,
9541 _scopes: BTreeSet<String>,
9542}
9543
9544impl<'a, C> common::CallBuilder for AccessPolicyGetIamPolicyCall<'a, C> {}
9545
9546impl<'a, C> AccessPolicyGetIamPolicyCall<'a, C>
9547where
9548 C: common::Connector,
9549{
9550 /// Perform the operation you have build so far.
9551 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9552 use std::borrow::Cow;
9553 use std::io::{Read, Seek};
9554
9555 use common::{url::Params, ToParts};
9556 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9557
9558 let mut dd = common::DefaultDelegate;
9559 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9560 dlg.begin(common::MethodInfo {
9561 id: "accesscontextmanager.accessPolicies.getIamPolicy",
9562 http_method: hyper::Method::POST,
9563 });
9564
9565 for &field in ["alt", "resource"].iter() {
9566 if self._additional_params.contains_key(field) {
9567 dlg.finished(false);
9568 return Err(common::Error::FieldClash(field));
9569 }
9570 }
9571
9572 let mut params = Params::with_capacity(4 + self._additional_params.len());
9573 params.push("resource", self._resource);
9574
9575 params.extend(self._additional_params.iter());
9576
9577 params.push("alt", "json");
9578 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
9579 if self._scopes.is_empty() {
9580 self._scopes
9581 .insert(Scope::CloudPlatform.as_ref().to_string());
9582 }
9583
9584 #[allow(clippy::single_element_loop)]
9585 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9586 url = params.uri_replacement(url, param_name, find_this, true);
9587 }
9588 {
9589 let to_remove = ["resource"];
9590 params.remove_params(&to_remove);
9591 }
9592
9593 let url = params.parse_with_url(&url);
9594
9595 let mut json_mime_type = mime::APPLICATION_JSON;
9596 let mut request_value_reader = {
9597 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9598 common::remove_json_null_values(&mut value);
9599 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9600 serde_json::to_writer(&mut dst, &value).unwrap();
9601 dst
9602 };
9603 let request_size = request_value_reader
9604 .seek(std::io::SeekFrom::End(0))
9605 .unwrap();
9606 request_value_reader
9607 .seek(std::io::SeekFrom::Start(0))
9608 .unwrap();
9609
9610 loop {
9611 let token = match self
9612 .hub
9613 .auth
9614 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9615 .await
9616 {
9617 Ok(token) => token,
9618 Err(e) => match dlg.token(e) {
9619 Ok(token) => token,
9620 Err(e) => {
9621 dlg.finished(false);
9622 return Err(common::Error::MissingToken(e));
9623 }
9624 },
9625 };
9626 request_value_reader
9627 .seek(std::io::SeekFrom::Start(0))
9628 .unwrap();
9629 let mut req_result = {
9630 let client = &self.hub.client;
9631 dlg.pre_request();
9632 let mut req_builder = hyper::Request::builder()
9633 .method(hyper::Method::POST)
9634 .uri(url.as_str())
9635 .header(USER_AGENT, self.hub._user_agent.clone());
9636
9637 if let Some(token) = token.as_ref() {
9638 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9639 }
9640
9641 let request = req_builder
9642 .header(CONTENT_TYPE, json_mime_type.to_string())
9643 .header(CONTENT_LENGTH, request_size as u64)
9644 .body(common::to_body(
9645 request_value_reader.get_ref().clone().into(),
9646 ));
9647
9648 client.request(request.unwrap()).await
9649 };
9650
9651 match req_result {
9652 Err(err) => {
9653 if let common::Retry::After(d) = dlg.http_error(&err) {
9654 sleep(d).await;
9655 continue;
9656 }
9657 dlg.finished(false);
9658 return Err(common::Error::HttpError(err));
9659 }
9660 Ok(res) => {
9661 let (mut parts, body) = res.into_parts();
9662 let mut body = common::Body::new(body);
9663 if !parts.status.is_success() {
9664 let bytes = common::to_bytes(body).await.unwrap_or_default();
9665 let error = serde_json::from_str(&common::to_string(&bytes));
9666 let response = common::to_response(parts, bytes.into());
9667
9668 if let common::Retry::After(d) =
9669 dlg.http_failure(&response, error.as_ref().ok())
9670 {
9671 sleep(d).await;
9672 continue;
9673 }
9674
9675 dlg.finished(false);
9676
9677 return Err(match error {
9678 Ok(value) => common::Error::BadRequest(value),
9679 _ => common::Error::Failure(response),
9680 });
9681 }
9682 let response = {
9683 let bytes = common::to_bytes(body).await.unwrap_or_default();
9684 let encoded = common::to_string(&bytes);
9685 match serde_json::from_str(&encoded) {
9686 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9687 Err(error) => {
9688 dlg.response_json_decode_error(&encoded, &error);
9689 return Err(common::Error::JsonDecodeError(
9690 encoded.to_string(),
9691 error,
9692 ));
9693 }
9694 }
9695 };
9696
9697 dlg.finished(true);
9698 return Ok(response);
9699 }
9700 }
9701 }
9702 }
9703
9704 ///
9705 /// Sets the *request* property to the given value.
9706 ///
9707 /// Even though the property as already been set when instantiating this call,
9708 /// we provide this method for API completeness.
9709 pub fn request(
9710 mut self,
9711 new_value: GetIamPolicyRequest,
9712 ) -> AccessPolicyGetIamPolicyCall<'a, C> {
9713 self._request = new_value;
9714 self
9715 }
9716 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
9717 ///
9718 /// Sets the *resource* path property to the given value.
9719 ///
9720 /// Even though the property as already been set when instantiating this call,
9721 /// we provide this method for API completeness.
9722 pub fn resource(mut self, new_value: &str) -> AccessPolicyGetIamPolicyCall<'a, C> {
9723 self._resource = new_value.to_string();
9724 self
9725 }
9726 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9727 /// while executing the actual API request.
9728 ///
9729 /// ````text
9730 /// It should be used to handle progress information, and to implement a certain level of resilience.
9731 /// ````
9732 ///
9733 /// Sets the *delegate* property to the given value.
9734 pub fn delegate(
9735 mut self,
9736 new_value: &'a mut dyn common::Delegate,
9737 ) -> AccessPolicyGetIamPolicyCall<'a, C> {
9738 self._delegate = Some(new_value);
9739 self
9740 }
9741
9742 /// Set any additional parameter of the query string used in the request.
9743 /// It should be used to set parameters which are not yet available through their own
9744 /// setters.
9745 ///
9746 /// Please note that this method must not be used to set any of the known parameters
9747 /// which have their own setter method. If done anyway, the request will fail.
9748 ///
9749 /// # Additional Parameters
9750 ///
9751 /// * *$.xgafv* (query-string) - V1 error format.
9752 /// * *access_token* (query-string) - OAuth access token.
9753 /// * *alt* (query-string) - Data format for response.
9754 /// * *callback* (query-string) - JSONP
9755 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9756 /// * *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.
9757 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9758 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9759 /// * *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.
9760 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9761 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9762 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyGetIamPolicyCall<'a, C>
9763 where
9764 T: AsRef<str>,
9765 {
9766 self._additional_params
9767 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9768 self
9769 }
9770
9771 /// Identifies the authorization scope for the method you are building.
9772 ///
9773 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9774 /// [`Scope::CloudPlatform`].
9775 ///
9776 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9777 /// tokens for more than one scope.
9778 ///
9779 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9780 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9781 /// sufficient, a read-write scope will do as well.
9782 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyGetIamPolicyCall<'a, C>
9783 where
9784 St: AsRef<str>,
9785 {
9786 self._scopes.insert(String::from(scope.as_ref()));
9787 self
9788 }
9789 /// Identifies the authorization scope(s) for the method you are building.
9790 ///
9791 /// See [`Self::add_scope()`] for details.
9792 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyGetIamPolicyCall<'a, C>
9793 where
9794 I: IntoIterator<Item = St>,
9795 St: AsRef<str>,
9796 {
9797 self._scopes
9798 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9799 self
9800 }
9801
9802 /// Removes all scopes, and no default scope will be used either.
9803 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9804 /// for details).
9805 pub fn clear_scopes(mut self) -> AccessPolicyGetIamPolicyCall<'a, C> {
9806 self._scopes.clear();
9807 self
9808 }
9809}
9810
9811/// Lists all access policies in an organization.
9812///
9813/// A builder for the *list* method supported by a *accessPolicy* resource.
9814/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
9815///
9816/// # Example
9817///
9818/// Instantiate a resource method builder
9819///
9820/// ```test_harness,no_run
9821/// # extern crate hyper;
9822/// # extern crate hyper_rustls;
9823/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
9824/// # async fn dox() {
9825/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9826///
9827/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9829/// # secret,
9830/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9831/// # ).build().await.unwrap();
9832///
9833/// # let client = hyper_util::client::legacy::Client::builder(
9834/// # hyper_util::rt::TokioExecutor::new()
9835/// # )
9836/// # .build(
9837/// # hyper_rustls::HttpsConnectorBuilder::new()
9838/// # .with_native_roots()
9839/// # .unwrap()
9840/// # .https_or_http()
9841/// # .enable_http1()
9842/// # .build()
9843/// # );
9844/// # let mut hub = AccessContextManager::new(client, auth);
9845/// // You can configure optional parameters by calling the respective setters at will, and
9846/// // execute the final call using `doit()`.
9847/// // Values shown here are possibly random and not representative !
9848/// let result = hub.access_policies().list()
9849/// .parent("kasd")
9850/// .page_token("et")
9851/// .page_size(-43)
9852/// .doit().await;
9853/// # }
9854/// ```
9855pub struct AccessPolicyListCall<'a, C>
9856where
9857 C: 'a,
9858{
9859 hub: &'a AccessContextManager<C>,
9860 _parent: Option<String>,
9861 _page_token: Option<String>,
9862 _page_size: Option<i32>,
9863 _delegate: Option<&'a mut dyn common::Delegate>,
9864 _additional_params: HashMap<String, String>,
9865 _scopes: BTreeSet<String>,
9866}
9867
9868impl<'a, C> common::CallBuilder for AccessPolicyListCall<'a, C> {}
9869
9870impl<'a, C> AccessPolicyListCall<'a, C>
9871where
9872 C: common::Connector,
9873{
9874 /// Perform the operation you have build so far.
9875 pub async fn doit(mut self) -> common::Result<(common::Response, ListAccessPoliciesResponse)> {
9876 use std::borrow::Cow;
9877 use std::io::{Read, Seek};
9878
9879 use common::{url::Params, ToParts};
9880 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9881
9882 let mut dd = common::DefaultDelegate;
9883 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9884 dlg.begin(common::MethodInfo {
9885 id: "accesscontextmanager.accessPolicies.list",
9886 http_method: hyper::Method::GET,
9887 });
9888
9889 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9890 if self._additional_params.contains_key(field) {
9891 dlg.finished(false);
9892 return Err(common::Error::FieldClash(field));
9893 }
9894 }
9895
9896 let mut params = Params::with_capacity(5 + self._additional_params.len());
9897 if let Some(value) = self._parent.as_ref() {
9898 params.push("parent", value);
9899 }
9900 if let Some(value) = self._page_token.as_ref() {
9901 params.push("pageToken", value);
9902 }
9903 if let Some(value) = self._page_size.as_ref() {
9904 params.push("pageSize", value.to_string());
9905 }
9906
9907 params.extend(self._additional_params.iter());
9908
9909 params.push("alt", "json");
9910 let mut url = self.hub._base_url.clone() + "v1/accessPolicies";
9911 if self._scopes.is_empty() {
9912 self._scopes
9913 .insert(Scope::CloudPlatform.as_ref().to_string());
9914 }
9915
9916 let url = params.parse_with_url(&url);
9917
9918 loop {
9919 let token = match self
9920 .hub
9921 .auth
9922 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9923 .await
9924 {
9925 Ok(token) => token,
9926 Err(e) => match dlg.token(e) {
9927 Ok(token) => token,
9928 Err(e) => {
9929 dlg.finished(false);
9930 return Err(common::Error::MissingToken(e));
9931 }
9932 },
9933 };
9934 let mut req_result = {
9935 let client = &self.hub.client;
9936 dlg.pre_request();
9937 let mut req_builder = hyper::Request::builder()
9938 .method(hyper::Method::GET)
9939 .uri(url.as_str())
9940 .header(USER_AGENT, self.hub._user_agent.clone());
9941
9942 if let Some(token) = token.as_ref() {
9943 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9944 }
9945
9946 let request = req_builder
9947 .header(CONTENT_LENGTH, 0_u64)
9948 .body(common::to_body::<String>(None));
9949
9950 client.request(request.unwrap()).await
9951 };
9952
9953 match req_result {
9954 Err(err) => {
9955 if let common::Retry::After(d) = dlg.http_error(&err) {
9956 sleep(d).await;
9957 continue;
9958 }
9959 dlg.finished(false);
9960 return Err(common::Error::HttpError(err));
9961 }
9962 Ok(res) => {
9963 let (mut parts, body) = res.into_parts();
9964 let mut body = common::Body::new(body);
9965 if !parts.status.is_success() {
9966 let bytes = common::to_bytes(body).await.unwrap_or_default();
9967 let error = serde_json::from_str(&common::to_string(&bytes));
9968 let response = common::to_response(parts, bytes.into());
9969
9970 if let common::Retry::After(d) =
9971 dlg.http_failure(&response, error.as_ref().ok())
9972 {
9973 sleep(d).await;
9974 continue;
9975 }
9976
9977 dlg.finished(false);
9978
9979 return Err(match error {
9980 Ok(value) => common::Error::BadRequest(value),
9981 _ => common::Error::Failure(response),
9982 });
9983 }
9984 let response = {
9985 let bytes = common::to_bytes(body).await.unwrap_or_default();
9986 let encoded = common::to_string(&bytes);
9987 match serde_json::from_str(&encoded) {
9988 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9989 Err(error) => {
9990 dlg.response_json_decode_error(&encoded, &error);
9991 return Err(common::Error::JsonDecodeError(
9992 encoded.to_string(),
9993 error,
9994 ));
9995 }
9996 }
9997 };
9998
9999 dlg.finished(true);
10000 return Ok(response);
10001 }
10002 }
10003 }
10004 }
10005
10006 /// Required. Resource name for the container to list AccessPolicy instances from. Format: `organizations/{org_id}`
10007 ///
10008 /// Sets the *parent* query property to the given value.
10009 pub fn parent(mut self, new_value: &str) -> AccessPolicyListCall<'a, C> {
10010 self._parent = Some(new_value.to_string());
10011 self
10012 }
10013 /// Next page token for the next batch of AccessPolicy instances. Defaults to the first page of results.
10014 ///
10015 /// Sets the *page token* query property to the given value.
10016 pub fn page_token(mut self, new_value: &str) -> AccessPolicyListCall<'a, C> {
10017 self._page_token = Some(new_value.to_string());
10018 self
10019 }
10020 /// Number of AccessPolicy instances to include in the list. Default 100.
10021 ///
10022 /// Sets the *page size* query property to the given value.
10023 pub fn page_size(mut self, new_value: i32) -> AccessPolicyListCall<'a, C> {
10024 self._page_size = Some(new_value);
10025 self
10026 }
10027 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10028 /// while executing the actual API request.
10029 ///
10030 /// ````text
10031 /// It should be used to handle progress information, and to implement a certain level of resilience.
10032 /// ````
10033 ///
10034 /// Sets the *delegate* property to the given value.
10035 pub fn delegate(
10036 mut self,
10037 new_value: &'a mut dyn common::Delegate,
10038 ) -> AccessPolicyListCall<'a, C> {
10039 self._delegate = Some(new_value);
10040 self
10041 }
10042
10043 /// Set any additional parameter of the query string used in the request.
10044 /// It should be used to set parameters which are not yet available through their own
10045 /// setters.
10046 ///
10047 /// Please note that this method must not be used to set any of the known parameters
10048 /// which have their own setter method. If done anyway, the request will fail.
10049 ///
10050 /// # Additional Parameters
10051 ///
10052 /// * *$.xgafv* (query-string) - V1 error format.
10053 /// * *access_token* (query-string) - OAuth access token.
10054 /// * *alt* (query-string) - Data format for response.
10055 /// * *callback* (query-string) - JSONP
10056 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10057 /// * *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.
10058 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10059 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10060 /// * *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.
10061 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10062 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10063 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyListCall<'a, C>
10064 where
10065 T: AsRef<str>,
10066 {
10067 self._additional_params
10068 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10069 self
10070 }
10071
10072 /// Identifies the authorization scope for the method you are building.
10073 ///
10074 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10075 /// [`Scope::CloudPlatform`].
10076 ///
10077 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10078 /// tokens for more than one scope.
10079 ///
10080 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10081 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10082 /// sufficient, a read-write scope will do as well.
10083 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyListCall<'a, C>
10084 where
10085 St: AsRef<str>,
10086 {
10087 self._scopes.insert(String::from(scope.as_ref()));
10088 self
10089 }
10090 /// Identifies the authorization scope(s) for the method you are building.
10091 ///
10092 /// See [`Self::add_scope()`] for details.
10093 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyListCall<'a, C>
10094 where
10095 I: IntoIterator<Item = St>,
10096 St: AsRef<str>,
10097 {
10098 self._scopes
10099 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10100 self
10101 }
10102
10103 /// Removes all scopes, and no default scope will be used either.
10104 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10105 /// for details).
10106 pub fn clear_scopes(mut self) -> AccessPolicyListCall<'a, C> {
10107 self._scopes.clear();
10108 self
10109 }
10110}
10111
10112/// Updates an access policy. The long-running operation from this RPC has a successful status after the changes to the access policy propagate to long-lasting storage.
10113///
10114/// A builder for the *patch* method supported by a *accessPolicy* resource.
10115/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
10116///
10117/// # Example
10118///
10119/// Instantiate a resource method builder
10120///
10121/// ```test_harness,no_run
10122/// # extern crate hyper;
10123/// # extern crate hyper_rustls;
10124/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
10125/// use accesscontextmanager1::api::AccessPolicy;
10126/// # async fn dox() {
10127/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10128///
10129/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10130/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10131/// # secret,
10132/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10133/// # ).build().await.unwrap();
10134///
10135/// # let client = hyper_util::client::legacy::Client::builder(
10136/// # hyper_util::rt::TokioExecutor::new()
10137/// # )
10138/// # .build(
10139/// # hyper_rustls::HttpsConnectorBuilder::new()
10140/// # .with_native_roots()
10141/// # .unwrap()
10142/// # .https_or_http()
10143/// # .enable_http1()
10144/// # .build()
10145/// # );
10146/// # let mut hub = AccessContextManager::new(client, auth);
10147/// // As the method needs a request, you would usually fill it with the desired information
10148/// // into the respective structure. Some of the parts shown here might not be applicable !
10149/// // Values shown here are possibly random and not representative !
10150/// let mut req = AccessPolicy::default();
10151///
10152/// // You can configure optional parameters by calling the respective setters at will, and
10153/// // execute the final call using `doit()`.
10154/// // Values shown here are possibly random and not representative !
10155/// let result = hub.access_policies().patch(req, "name")
10156/// .update_mask(FieldMask::new::<&str>(&[]))
10157/// .doit().await;
10158/// # }
10159/// ```
10160pub struct AccessPolicyPatchCall<'a, C>
10161where
10162 C: 'a,
10163{
10164 hub: &'a AccessContextManager<C>,
10165 _request: AccessPolicy,
10166 _name: String,
10167 _update_mask: Option<common::FieldMask>,
10168 _delegate: Option<&'a mut dyn common::Delegate>,
10169 _additional_params: HashMap<String, String>,
10170 _scopes: BTreeSet<String>,
10171}
10172
10173impl<'a, C> common::CallBuilder for AccessPolicyPatchCall<'a, C> {}
10174
10175impl<'a, C> AccessPolicyPatchCall<'a, C>
10176where
10177 C: common::Connector,
10178{
10179 /// Perform the operation you have build so far.
10180 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10181 use std::borrow::Cow;
10182 use std::io::{Read, Seek};
10183
10184 use common::{url::Params, ToParts};
10185 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10186
10187 let mut dd = common::DefaultDelegate;
10188 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10189 dlg.begin(common::MethodInfo {
10190 id: "accesscontextmanager.accessPolicies.patch",
10191 http_method: hyper::Method::PATCH,
10192 });
10193
10194 for &field in ["alt", "name", "updateMask"].iter() {
10195 if self._additional_params.contains_key(field) {
10196 dlg.finished(false);
10197 return Err(common::Error::FieldClash(field));
10198 }
10199 }
10200
10201 let mut params = Params::with_capacity(5 + self._additional_params.len());
10202 params.push("name", self._name);
10203 if let Some(value) = self._update_mask.as_ref() {
10204 params.push("updateMask", value.to_string());
10205 }
10206
10207 params.extend(self._additional_params.iter());
10208
10209 params.push("alt", "json");
10210 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10211 if self._scopes.is_empty() {
10212 self._scopes
10213 .insert(Scope::CloudPlatform.as_ref().to_string());
10214 }
10215
10216 #[allow(clippy::single_element_loop)]
10217 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10218 url = params.uri_replacement(url, param_name, find_this, true);
10219 }
10220 {
10221 let to_remove = ["name"];
10222 params.remove_params(&to_remove);
10223 }
10224
10225 let url = params.parse_with_url(&url);
10226
10227 let mut json_mime_type = mime::APPLICATION_JSON;
10228 let mut request_value_reader = {
10229 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10230 common::remove_json_null_values(&mut value);
10231 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10232 serde_json::to_writer(&mut dst, &value).unwrap();
10233 dst
10234 };
10235 let request_size = request_value_reader
10236 .seek(std::io::SeekFrom::End(0))
10237 .unwrap();
10238 request_value_reader
10239 .seek(std::io::SeekFrom::Start(0))
10240 .unwrap();
10241
10242 loop {
10243 let token = match self
10244 .hub
10245 .auth
10246 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10247 .await
10248 {
10249 Ok(token) => token,
10250 Err(e) => match dlg.token(e) {
10251 Ok(token) => token,
10252 Err(e) => {
10253 dlg.finished(false);
10254 return Err(common::Error::MissingToken(e));
10255 }
10256 },
10257 };
10258 request_value_reader
10259 .seek(std::io::SeekFrom::Start(0))
10260 .unwrap();
10261 let mut req_result = {
10262 let client = &self.hub.client;
10263 dlg.pre_request();
10264 let mut req_builder = hyper::Request::builder()
10265 .method(hyper::Method::PATCH)
10266 .uri(url.as_str())
10267 .header(USER_AGENT, self.hub._user_agent.clone());
10268
10269 if let Some(token) = token.as_ref() {
10270 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10271 }
10272
10273 let request = req_builder
10274 .header(CONTENT_TYPE, json_mime_type.to_string())
10275 .header(CONTENT_LENGTH, request_size as u64)
10276 .body(common::to_body(
10277 request_value_reader.get_ref().clone().into(),
10278 ));
10279
10280 client.request(request.unwrap()).await
10281 };
10282
10283 match req_result {
10284 Err(err) => {
10285 if let common::Retry::After(d) = dlg.http_error(&err) {
10286 sleep(d).await;
10287 continue;
10288 }
10289 dlg.finished(false);
10290 return Err(common::Error::HttpError(err));
10291 }
10292 Ok(res) => {
10293 let (mut parts, body) = res.into_parts();
10294 let mut body = common::Body::new(body);
10295 if !parts.status.is_success() {
10296 let bytes = common::to_bytes(body).await.unwrap_or_default();
10297 let error = serde_json::from_str(&common::to_string(&bytes));
10298 let response = common::to_response(parts, bytes.into());
10299
10300 if let common::Retry::After(d) =
10301 dlg.http_failure(&response, error.as_ref().ok())
10302 {
10303 sleep(d).await;
10304 continue;
10305 }
10306
10307 dlg.finished(false);
10308
10309 return Err(match error {
10310 Ok(value) => common::Error::BadRequest(value),
10311 _ => common::Error::Failure(response),
10312 });
10313 }
10314 let response = {
10315 let bytes = common::to_bytes(body).await.unwrap_or_default();
10316 let encoded = common::to_string(&bytes);
10317 match serde_json::from_str(&encoded) {
10318 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10319 Err(error) => {
10320 dlg.response_json_decode_error(&encoded, &error);
10321 return Err(common::Error::JsonDecodeError(
10322 encoded.to_string(),
10323 error,
10324 ));
10325 }
10326 }
10327 };
10328
10329 dlg.finished(true);
10330 return Ok(response);
10331 }
10332 }
10333 }
10334 }
10335
10336 ///
10337 /// Sets the *request* property to the given value.
10338 ///
10339 /// Even though the property as already been set when instantiating this call,
10340 /// we provide this method for API completeness.
10341 pub fn request(mut self, new_value: AccessPolicy) -> AccessPolicyPatchCall<'a, C> {
10342 self._request = new_value;
10343 self
10344 }
10345 /// Output only. Identifier. Resource name of the `AccessPolicy`. Format: `accessPolicies/{access_policy}`
10346 ///
10347 /// Sets the *name* path property to the given value.
10348 ///
10349 /// Even though the property as already been set when instantiating this call,
10350 /// we provide this method for API completeness.
10351 pub fn name(mut self, new_value: &str) -> AccessPolicyPatchCall<'a, C> {
10352 self._name = new_value.to_string();
10353 self
10354 }
10355 /// Required. Mask to control which fields get updated. Must be non-empty.
10356 ///
10357 /// Sets the *update mask* query property to the given value.
10358 pub fn update_mask(mut self, new_value: common::FieldMask) -> AccessPolicyPatchCall<'a, C> {
10359 self._update_mask = Some(new_value);
10360 self
10361 }
10362 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10363 /// while executing the actual API request.
10364 ///
10365 /// ````text
10366 /// It should be used to handle progress information, and to implement a certain level of resilience.
10367 /// ````
10368 ///
10369 /// Sets the *delegate* property to the given value.
10370 pub fn delegate(
10371 mut self,
10372 new_value: &'a mut dyn common::Delegate,
10373 ) -> AccessPolicyPatchCall<'a, C> {
10374 self._delegate = Some(new_value);
10375 self
10376 }
10377
10378 /// Set any additional parameter of the query string used in the request.
10379 /// It should be used to set parameters which are not yet available through their own
10380 /// setters.
10381 ///
10382 /// Please note that this method must not be used to set any of the known parameters
10383 /// which have their own setter method. If done anyway, the request will fail.
10384 ///
10385 /// # Additional Parameters
10386 ///
10387 /// * *$.xgafv* (query-string) - V1 error format.
10388 /// * *access_token* (query-string) - OAuth access token.
10389 /// * *alt* (query-string) - Data format for response.
10390 /// * *callback* (query-string) - JSONP
10391 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10392 /// * *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.
10393 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10394 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10395 /// * *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.
10396 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10397 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10398 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyPatchCall<'a, C>
10399 where
10400 T: AsRef<str>,
10401 {
10402 self._additional_params
10403 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10404 self
10405 }
10406
10407 /// Identifies the authorization scope for the method you are building.
10408 ///
10409 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10410 /// [`Scope::CloudPlatform`].
10411 ///
10412 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10413 /// tokens for more than one scope.
10414 ///
10415 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10416 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10417 /// sufficient, a read-write scope will do as well.
10418 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyPatchCall<'a, C>
10419 where
10420 St: AsRef<str>,
10421 {
10422 self._scopes.insert(String::from(scope.as_ref()));
10423 self
10424 }
10425 /// Identifies the authorization scope(s) for the method you are building.
10426 ///
10427 /// See [`Self::add_scope()`] for details.
10428 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyPatchCall<'a, C>
10429 where
10430 I: IntoIterator<Item = St>,
10431 St: AsRef<str>,
10432 {
10433 self._scopes
10434 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10435 self
10436 }
10437
10438 /// Removes all scopes, and no default scope will be used either.
10439 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10440 /// for details).
10441 pub fn clear_scopes(mut self) -> AccessPolicyPatchCall<'a, C> {
10442 self._scopes.clear();
10443 self
10444 }
10445}
10446
10447/// Sets the IAM policy for the specified Access Context Manager access policy. This method replaces the existing IAM policy on the access policy. The IAM policy controls the set of users who can perform specific operations on the Access Context Manager access policy.
10448///
10449/// A builder for the *setIamPolicy* method supported by a *accessPolicy* resource.
10450/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
10451///
10452/// # Example
10453///
10454/// Instantiate a resource method builder
10455///
10456/// ```test_harness,no_run
10457/// # extern crate hyper;
10458/// # extern crate hyper_rustls;
10459/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
10460/// use accesscontextmanager1::api::SetIamPolicyRequest;
10461/// # async fn dox() {
10462/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10463///
10464/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10465/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10466/// # secret,
10467/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10468/// # ).build().await.unwrap();
10469///
10470/// # let client = hyper_util::client::legacy::Client::builder(
10471/// # hyper_util::rt::TokioExecutor::new()
10472/// # )
10473/// # .build(
10474/// # hyper_rustls::HttpsConnectorBuilder::new()
10475/// # .with_native_roots()
10476/// # .unwrap()
10477/// # .https_or_http()
10478/// # .enable_http1()
10479/// # .build()
10480/// # );
10481/// # let mut hub = AccessContextManager::new(client, auth);
10482/// // As the method needs a request, you would usually fill it with the desired information
10483/// // into the respective structure. Some of the parts shown here might not be applicable !
10484/// // Values shown here are possibly random and not representative !
10485/// let mut req = SetIamPolicyRequest::default();
10486///
10487/// // You can configure optional parameters by calling the respective setters at will, and
10488/// // execute the final call using `doit()`.
10489/// // Values shown here are possibly random and not representative !
10490/// let result = hub.access_policies().set_iam_policy(req, "resource")
10491/// .doit().await;
10492/// # }
10493/// ```
10494pub struct AccessPolicySetIamPolicyCall<'a, C>
10495where
10496 C: 'a,
10497{
10498 hub: &'a AccessContextManager<C>,
10499 _request: SetIamPolicyRequest,
10500 _resource: String,
10501 _delegate: Option<&'a mut dyn common::Delegate>,
10502 _additional_params: HashMap<String, String>,
10503 _scopes: BTreeSet<String>,
10504}
10505
10506impl<'a, C> common::CallBuilder for AccessPolicySetIamPolicyCall<'a, C> {}
10507
10508impl<'a, C> AccessPolicySetIamPolicyCall<'a, C>
10509where
10510 C: common::Connector,
10511{
10512 /// Perform the operation you have build so far.
10513 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10514 use std::borrow::Cow;
10515 use std::io::{Read, Seek};
10516
10517 use common::{url::Params, ToParts};
10518 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10519
10520 let mut dd = common::DefaultDelegate;
10521 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10522 dlg.begin(common::MethodInfo {
10523 id: "accesscontextmanager.accessPolicies.setIamPolicy",
10524 http_method: hyper::Method::POST,
10525 });
10526
10527 for &field in ["alt", "resource"].iter() {
10528 if self._additional_params.contains_key(field) {
10529 dlg.finished(false);
10530 return Err(common::Error::FieldClash(field));
10531 }
10532 }
10533
10534 let mut params = Params::with_capacity(4 + self._additional_params.len());
10535 params.push("resource", self._resource);
10536
10537 params.extend(self._additional_params.iter());
10538
10539 params.push("alt", "json");
10540 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
10541 if self._scopes.is_empty() {
10542 self._scopes
10543 .insert(Scope::CloudPlatform.as_ref().to_string());
10544 }
10545
10546 #[allow(clippy::single_element_loop)]
10547 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10548 url = params.uri_replacement(url, param_name, find_this, true);
10549 }
10550 {
10551 let to_remove = ["resource"];
10552 params.remove_params(&to_remove);
10553 }
10554
10555 let url = params.parse_with_url(&url);
10556
10557 let mut json_mime_type = mime::APPLICATION_JSON;
10558 let mut request_value_reader = {
10559 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10560 common::remove_json_null_values(&mut value);
10561 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10562 serde_json::to_writer(&mut dst, &value).unwrap();
10563 dst
10564 };
10565 let request_size = request_value_reader
10566 .seek(std::io::SeekFrom::End(0))
10567 .unwrap();
10568 request_value_reader
10569 .seek(std::io::SeekFrom::Start(0))
10570 .unwrap();
10571
10572 loop {
10573 let token = match self
10574 .hub
10575 .auth
10576 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10577 .await
10578 {
10579 Ok(token) => token,
10580 Err(e) => match dlg.token(e) {
10581 Ok(token) => token,
10582 Err(e) => {
10583 dlg.finished(false);
10584 return Err(common::Error::MissingToken(e));
10585 }
10586 },
10587 };
10588 request_value_reader
10589 .seek(std::io::SeekFrom::Start(0))
10590 .unwrap();
10591 let mut req_result = {
10592 let client = &self.hub.client;
10593 dlg.pre_request();
10594 let mut req_builder = hyper::Request::builder()
10595 .method(hyper::Method::POST)
10596 .uri(url.as_str())
10597 .header(USER_AGENT, self.hub._user_agent.clone());
10598
10599 if let Some(token) = token.as_ref() {
10600 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10601 }
10602
10603 let request = req_builder
10604 .header(CONTENT_TYPE, json_mime_type.to_string())
10605 .header(CONTENT_LENGTH, request_size as u64)
10606 .body(common::to_body(
10607 request_value_reader.get_ref().clone().into(),
10608 ));
10609
10610 client.request(request.unwrap()).await
10611 };
10612
10613 match req_result {
10614 Err(err) => {
10615 if let common::Retry::After(d) = dlg.http_error(&err) {
10616 sleep(d).await;
10617 continue;
10618 }
10619 dlg.finished(false);
10620 return Err(common::Error::HttpError(err));
10621 }
10622 Ok(res) => {
10623 let (mut parts, body) = res.into_parts();
10624 let mut body = common::Body::new(body);
10625 if !parts.status.is_success() {
10626 let bytes = common::to_bytes(body).await.unwrap_or_default();
10627 let error = serde_json::from_str(&common::to_string(&bytes));
10628 let response = common::to_response(parts, bytes.into());
10629
10630 if let common::Retry::After(d) =
10631 dlg.http_failure(&response, error.as_ref().ok())
10632 {
10633 sleep(d).await;
10634 continue;
10635 }
10636
10637 dlg.finished(false);
10638
10639 return Err(match error {
10640 Ok(value) => common::Error::BadRequest(value),
10641 _ => common::Error::Failure(response),
10642 });
10643 }
10644 let response = {
10645 let bytes = common::to_bytes(body).await.unwrap_or_default();
10646 let encoded = common::to_string(&bytes);
10647 match serde_json::from_str(&encoded) {
10648 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10649 Err(error) => {
10650 dlg.response_json_decode_error(&encoded, &error);
10651 return Err(common::Error::JsonDecodeError(
10652 encoded.to_string(),
10653 error,
10654 ));
10655 }
10656 }
10657 };
10658
10659 dlg.finished(true);
10660 return Ok(response);
10661 }
10662 }
10663 }
10664 }
10665
10666 ///
10667 /// Sets the *request* property to the given value.
10668 ///
10669 /// Even though the property as already been set when instantiating this call,
10670 /// we provide this method for API completeness.
10671 pub fn request(
10672 mut self,
10673 new_value: SetIamPolicyRequest,
10674 ) -> AccessPolicySetIamPolicyCall<'a, C> {
10675 self._request = new_value;
10676 self
10677 }
10678 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
10679 ///
10680 /// Sets the *resource* path property to the given value.
10681 ///
10682 /// Even though the property as already been set when instantiating this call,
10683 /// we provide this method for API completeness.
10684 pub fn resource(mut self, new_value: &str) -> AccessPolicySetIamPolicyCall<'a, C> {
10685 self._resource = new_value.to_string();
10686 self
10687 }
10688 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10689 /// while executing the actual API request.
10690 ///
10691 /// ````text
10692 /// It should be used to handle progress information, and to implement a certain level of resilience.
10693 /// ````
10694 ///
10695 /// Sets the *delegate* property to the given value.
10696 pub fn delegate(
10697 mut self,
10698 new_value: &'a mut dyn common::Delegate,
10699 ) -> AccessPolicySetIamPolicyCall<'a, C> {
10700 self._delegate = Some(new_value);
10701 self
10702 }
10703
10704 /// Set any additional parameter of the query string used in the request.
10705 /// It should be used to set parameters which are not yet available through their own
10706 /// setters.
10707 ///
10708 /// Please note that this method must not be used to set any of the known parameters
10709 /// which have their own setter method. If done anyway, the request will fail.
10710 ///
10711 /// # Additional Parameters
10712 ///
10713 /// * *$.xgafv* (query-string) - V1 error format.
10714 /// * *access_token* (query-string) - OAuth access token.
10715 /// * *alt* (query-string) - Data format for response.
10716 /// * *callback* (query-string) - JSONP
10717 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10718 /// * *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.
10719 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10720 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10721 /// * *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.
10722 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10723 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10724 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicySetIamPolicyCall<'a, C>
10725 where
10726 T: AsRef<str>,
10727 {
10728 self._additional_params
10729 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10730 self
10731 }
10732
10733 /// Identifies the authorization scope for the method you are building.
10734 ///
10735 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10736 /// [`Scope::CloudPlatform`].
10737 ///
10738 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10739 /// tokens for more than one scope.
10740 ///
10741 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10742 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10743 /// sufficient, a read-write scope will do as well.
10744 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicySetIamPolicyCall<'a, C>
10745 where
10746 St: AsRef<str>,
10747 {
10748 self._scopes.insert(String::from(scope.as_ref()));
10749 self
10750 }
10751 /// Identifies the authorization scope(s) for the method you are building.
10752 ///
10753 /// See [`Self::add_scope()`] for details.
10754 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicySetIamPolicyCall<'a, C>
10755 where
10756 I: IntoIterator<Item = St>,
10757 St: AsRef<str>,
10758 {
10759 self._scopes
10760 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10761 self
10762 }
10763
10764 /// Removes all scopes, and no default scope will be used either.
10765 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10766 /// for details).
10767 pub fn clear_scopes(mut self) -> AccessPolicySetIamPolicyCall<'a, C> {
10768 self._scopes.clear();
10769 self
10770 }
10771}
10772
10773/// Returns the IAM permissions that the caller has on the specified Access Context Manager resource. The resource can be an AccessPolicy, AccessLevel, or ServicePerimeter. This method does not support other resources.
10774///
10775/// A builder for the *testIamPermissions* method supported by a *accessPolicy* resource.
10776/// It is not used directly, but through a [`AccessPolicyMethods`] instance.
10777///
10778/// # Example
10779///
10780/// Instantiate a resource method builder
10781///
10782/// ```test_harness,no_run
10783/// # extern crate hyper;
10784/// # extern crate hyper_rustls;
10785/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
10786/// use accesscontextmanager1::api::TestIamPermissionsRequest;
10787/// # async fn dox() {
10788/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10789///
10790/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10791/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10792/// # secret,
10793/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10794/// # ).build().await.unwrap();
10795///
10796/// # let client = hyper_util::client::legacy::Client::builder(
10797/// # hyper_util::rt::TokioExecutor::new()
10798/// # )
10799/// # .build(
10800/// # hyper_rustls::HttpsConnectorBuilder::new()
10801/// # .with_native_roots()
10802/// # .unwrap()
10803/// # .https_or_http()
10804/// # .enable_http1()
10805/// # .build()
10806/// # );
10807/// # let mut hub = AccessContextManager::new(client, auth);
10808/// // As the method needs a request, you would usually fill it with the desired information
10809/// // into the respective structure. Some of the parts shown here might not be applicable !
10810/// // Values shown here are possibly random and not representative !
10811/// let mut req = TestIamPermissionsRequest::default();
10812///
10813/// // You can configure optional parameters by calling the respective setters at will, and
10814/// // execute the final call using `doit()`.
10815/// // Values shown here are possibly random and not representative !
10816/// let result = hub.access_policies().test_iam_permissions(req, "resource")
10817/// .doit().await;
10818/// # }
10819/// ```
10820pub struct AccessPolicyTestIamPermissionCall<'a, C>
10821where
10822 C: 'a,
10823{
10824 hub: &'a AccessContextManager<C>,
10825 _request: TestIamPermissionsRequest,
10826 _resource: String,
10827 _delegate: Option<&'a mut dyn common::Delegate>,
10828 _additional_params: HashMap<String, String>,
10829 _scopes: BTreeSet<String>,
10830}
10831
10832impl<'a, C> common::CallBuilder for AccessPolicyTestIamPermissionCall<'a, C> {}
10833
10834impl<'a, C> AccessPolicyTestIamPermissionCall<'a, C>
10835where
10836 C: common::Connector,
10837{
10838 /// Perform the operation you have build so far.
10839 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
10840 use std::borrow::Cow;
10841 use std::io::{Read, Seek};
10842
10843 use common::{url::Params, ToParts};
10844 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10845
10846 let mut dd = common::DefaultDelegate;
10847 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10848 dlg.begin(common::MethodInfo {
10849 id: "accesscontextmanager.accessPolicies.testIamPermissions",
10850 http_method: hyper::Method::POST,
10851 });
10852
10853 for &field in ["alt", "resource"].iter() {
10854 if self._additional_params.contains_key(field) {
10855 dlg.finished(false);
10856 return Err(common::Error::FieldClash(field));
10857 }
10858 }
10859
10860 let mut params = Params::with_capacity(4 + self._additional_params.len());
10861 params.push("resource", self._resource);
10862
10863 params.extend(self._additional_params.iter());
10864
10865 params.push("alt", "json");
10866 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
10867 if self._scopes.is_empty() {
10868 self._scopes
10869 .insert(Scope::CloudPlatform.as_ref().to_string());
10870 }
10871
10872 #[allow(clippy::single_element_loop)]
10873 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10874 url = params.uri_replacement(url, param_name, find_this, true);
10875 }
10876 {
10877 let to_remove = ["resource"];
10878 params.remove_params(&to_remove);
10879 }
10880
10881 let url = params.parse_with_url(&url);
10882
10883 let mut json_mime_type = mime::APPLICATION_JSON;
10884 let mut request_value_reader = {
10885 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10886 common::remove_json_null_values(&mut value);
10887 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10888 serde_json::to_writer(&mut dst, &value).unwrap();
10889 dst
10890 };
10891 let request_size = request_value_reader
10892 .seek(std::io::SeekFrom::End(0))
10893 .unwrap();
10894 request_value_reader
10895 .seek(std::io::SeekFrom::Start(0))
10896 .unwrap();
10897
10898 loop {
10899 let token = match self
10900 .hub
10901 .auth
10902 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10903 .await
10904 {
10905 Ok(token) => token,
10906 Err(e) => match dlg.token(e) {
10907 Ok(token) => token,
10908 Err(e) => {
10909 dlg.finished(false);
10910 return Err(common::Error::MissingToken(e));
10911 }
10912 },
10913 };
10914 request_value_reader
10915 .seek(std::io::SeekFrom::Start(0))
10916 .unwrap();
10917 let mut req_result = {
10918 let client = &self.hub.client;
10919 dlg.pre_request();
10920 let mut req_builder = hyper::Request::builder()
10921 .method(hyper::Method::POST)
10922 .uri(url.as_str())
10923 .header(USER_AGENT, self.hub._user_agent.clone());
10924
10925 if let Some(token) = token.as_ref() {
10926 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10927 }
10928
10929 let request = req_builder
10930 .header(CONTENT_TYPE, json_mime_type.to_string())
10931 .header(CONTENT_LENGTH, request_size as u64)
10932 .body(common::to_body(
10933 request_value_reader.get_ref().clone().into(),
10934 ));
10935
10936 client.request(request.unwrap()).await
10937 };
10938
10939 match req_result {
10940 Err(err) => {
10941 if let common::Retry::After(d) = dlg.http_error(&err) {
10942 sleep(d).await;
10943 continue;
10944 }
10945 dlg.finished(false);
10946 return Err(common::Error::HttpError(err));
10947 }
10948 Ok(res) => {
10949 let (mut parts, body) = res.into_parts();
10950 let mut body = common::Body::new(body);
10951 if !parts.status.is_success() {
10952 let bytes = common::to_bytes(body).await.unwrap_or_default();
10953 let error = serde_json::from_str(&common::to_string(&bytes));
10954 let response = common::to_response(parts, bytes.into());
10955
10956 if let common::Retry::After(d) =
10957 dlg.http_failure(&response, error.as_ref().ok())
10958 {
10959 sleep(d).await;
10960 continue;
10961 }
10962
10963 dlg.finished(false);
10964
10965 return Err(match error {
10966 Ok(value) => common::Error::BadRequest(value),
10967 _ => common::Error::Failure(response),
10968 });
10969 }
10970 let response = {
10971 let bytes = common::to_bytes(body).await.unwrap_or_default();
10972 let encoded = common::to_string(&bytes);
10973 match serde_json::from_str(&encoded) {
10974 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10975 Err(error) => {
10976 dlg.response_json_decode_error(&encoded, &error);
10977 return Err(common::Error::JsonDecodeError(
10978 encoded.to_string(),
10979 error,
10980 ));
10981 }
10982 }
10983 };
10984
10985 dlg.finished(true);
10986 return Ok(response);
10987 }
10988 }
10989 }
10990 }
10991
10992 ///
10993 /// Sets the *request* property to the given value.
10994 ///
10995 /// Even though the property as already been set when instantiating this call,
10996 /// we provide this method for API completeness.
10997 pub fn request(
10998 mut self,
10999 new_value: TestIamPermissionsRequest,
11000 ) -> AccessPolicyTestIamPermissionCall<'a, C> {
11001 self._request = new_value;
11002 self
11003 }
11004 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
11005 ///
11006 /// Sets the *resource* path property to the given value.
11007 ///
11008 /// Even though the property as already been set when instantiating this call,
11009 /// we provide this method for API completeness.
11010 pub fn resource(mut self, new_value: &str) -> AccessPolicyTestIamPermissionCall<'a, C> {
11011 self._resource = new_value.to_string();
11012 self
11013 }
11014 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11015 /// while executing the actual API request.
11016 ///
11017 /// ````text
11018 /// It should be used to handle progress information, and to implement a certain level of resilience.
11019 /// ````
11020 ///
11021 /// Sets the *delegate* property to the given value.
11022 pub fn delegate(
11023 mut self,
11024 new_value: &'a mut dyn common::Delegate,
11025 ) -> AccessPolicyTestIamPermissionCall<'a, C> {
11026 self._delegate = Some(new_value);
11027 self
11028 }
11029
11030 /// Set any additional parameter of the query string used in the request.
11031 /// It should be used to set parameters which are not yet available through their own
11032 /// setters.
11033 ///
11034 /// Please note that this method must not be used to set any of the known parameters
11035 /// which have their own setter method. If done anyway, the request will fail.
11036 ///
11037 /// # Additional Parameters
11038 ///
11039 /// * *$.xgafv* (query-string) - V1 error format.
11040 /// * *access_token* (query-string) - OAuth access token.
11041 /// * *alt* (query-string) - Data format for response.
11042 /// * *callback* (query-string) - JSONP
11043 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11044 /// * *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.
11045 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11046 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11047 /// * *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.
11048 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11049 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11050 pub fn param<T>(mut self, name: T, value: T) -> AccessPolicyTestIamPermissionCall<'a, C>
11051 where
11052 T: AsRef<str>,
11053 {
11054 self._additional_params
11055 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11056 self
11057 }
11058
11059 /// Identifies the authorization scope for the method you are building.
11060 ///
11061 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11062 /// [`Scope::CloudPlatform`].
11063 ///
11064 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11065 /// tokens for more than one scope.
11066 ///
11067 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11068 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11069 /// sufficient, a read-write scope will do as well.
11070 pub fn add_scope<St>(mut self, scope: St) -> AccessPolicyTestIamPermissionCall<'a, C>
11071 where
11072 St: AsRef<str>,
11073 {
11074 self._scopes.insert(String::from(scope.as_ref()));
11075 self
11076 }
11077 /// Identifies the authorization scope(s) for the method you are building.
11078 ///
11079 /// See [`Self::add_scope()`] for details.
11080 pub fn add_scopes<I, St>(mut self, scopes: I) -> AccessPolicyTestIamPermissionCall<'a, C>
11081 where
11082 I: IntoIterator<Item = St>,
11083 St: AsRef<str>,
11084 {
11085 self._scopes
11086 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11087 self
11088 }
11089
11090 /// Removes all scopes, and no default scope will be used either.
11091 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11092 /// for details).
11093 pub fn clear_scopes(mut self) -> AccessPolicyTestIamPermissionCall<'a, C> {
11094 self._scopes.clear();
11095 self
11096 }
11097}
11098
11099/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
11100///
11101/// A builder for the *cancel* method supported by a *operation* resource.
11102/// It is not used directly, but through a [`OperationMethods`] instance.
11103///
11104/// # Example
11105///
11106/// Instantiate a resource method builder
11107///
11108/// ```test_harness,no_run
11109/// # extern crate hyper;
11110/// # extern crate hyper_rustls;
11111/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
11112/// use accesscontextmanager1::api::CancelOperationRequest;
11113/// # async fn dox() {
11114/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11115///
11116/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11117/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11118/// # secret,
11119/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11120/// # ).build().await.unwrap();
11121///
11122/// # let client = hyper_util::client::legacy::Client::builder(
11123/// # hyper_util::rt::TokioExecutor::new()
11124/// # )
11125/// # .build(
11126/// # hyper_rustls::HttpsConnectorBuilder::new()
11127/// # .with_native_roots()
11128/// # .unwrap()
11129/// # .https_or_http()
11130/// # .enable_http1()
11131/// # .build()
11132/// # );
11133/// # let mut hub = AccessContextManager::new(client, auth);
11134/// // As the method needs a request, you would usually fill it with the desired information
11135/// // into the respective structure. Some of the parts shown here might not be applicable !
11136/// // Values shown here are possibly random and not representative !
11137/// let mut req = CancelOperationRequest::default();
11138///
11139/// // You can configure optional parameters by calling the respective setters at will, and
11140/// // execute the final call using `doit()`.
11141/// // Values shown here are possibly random and not representative !
11142/// let result = hub.operations().cancel(req, "name")
11143/// .doit().await;
11144/// # }
11145/// ```
11146pub struct OperationCancelCall<'a, C>
11147where
11148 C: 'a,
11149{
11150 hub: &'a AccessContextManager<C>,
11151 _request: CancelOperationRequest,
11152 _name: String,
11153 _delegate: Option<&'a mut dyn common::Delegate>,
11154 _additional_params: HashMap<String, String>,
11155 _scopes: BTreeSet<String>,
11156}
11157
11158impl<'a, C> common::CallBuilder for OperationCancelCall<'a, C> {}
11159
11160impl<'a, C> OperationCancelCall<'a, C>
11161where
11162 C: common::Connector,
11163{
11164 /// Perform the operation you have build so far.
11165 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11166 use std::borrow::Cow;
11167 use std::io::{Read, Seek};
11168
11169 use common::{url::Params, ToParts};
11170 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11171
11172 let mut dd = common::DefaultDelegate;
11173 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11174 dlg.begin(common::MethodInfo {
11175 id: "accesscontextmanager.operations.cancel",
11176 http_method: hyper::Method::POST,
11177 });
11178
11179 for &field in ["alt", "name"].iter() {
11180 if self._additional_params.contains_key(field) {
11181 dlg.finished(false);
11182 return Err(common::Error::FieldClash(field));
11183 }
11184 }
11185
11186 let mut params = Params::with_capacity(4 + self._additional_params.len());
11187 params.push("name", self._name);
11188
11189 params.extend(self._additional_params.iter());
11190
11191 params.push("alt", "json");
11192 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
11193 if self._scopes.is_empty() {
11194 self._scopes
11195 .insert(Scope::CloudPlatform.as_ref().to_string());
11196 }
11197
11198 #[allow(clippy::single_element_loop)]
11199 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11200 url = params.uri_replacement(url, param_name, find_this, true);
11201 }
11202 {
11203 let to_remove = ["name"];
11204 params.remove_params(&to_remove);
11205 }
11206
11207 let url = params.parse_with_url(&url);
11208
11209 let mut json_mime_type = mime::APPLICATION_JSON;
11210 let mut request_value_reader = {
11211 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11212 common::remove_json_null_values(&mut value);
11213 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11214 serde_json::to_writer(&mut dst, &value).unwrap();
11215 dst
11216 };
11217 let request_size = request_value_reader
11218 .seek(std::io::SeekFrom::End(0))
11219 .unwrap();
11220 request_value_reader
11221 .seek(std::io::SeekFrom::Start(0))
11222 .unwrap();
11223
11224 loop {
11225 let token = match self
11226 .hub
11227 .auth
11228 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11229 .await
11230 {
11231 Ok(token) => token,
11232 Err(e) => match dlg.token(e) {
11233 Ok(token) => token,
11234 Err(e) => {
11235 dlg.finished(false);
11236 return Err(common::Error::MissingToken(e));
11237 }
11238 },
11239 };
11240 request_value_reader
11241 .seek(std::io::SeekFrom::Start(0))
11242 .unwrap();
11243 let mut req_result = {
11244 let client = &self.hub.client;
11245 dlg.pre_request();
11246 let mut req_builder = hyper::Request::builder()
11247 .method(hyper::Method::POST)
11248 .uri(url.as_str())
11249 .header(USER_AGENT, self.hub._user_agent.clone());
11250
11251 if let Some(token) = token.as_ref() {
11252 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11253 }
11254
11255 let request = req_builder
11256 .header(CONTENT_TYPE, json_mime_type.to_string())
11257 .header(CONTENT_LENGTH, request_size as u64)
11258 .body(common::to_body(
11259 request_value_reader.get_ref().clone().into(),
11260 ));
11261
11262 client.request(request.unwrap()).await
11263 };
11264
11265 match req_result {
11266 Err(err) => {
11267 if let common::Retry::After(d) = dlg.http_error(&err) {
11268 sleep(d).await;
11269 continue;
11270 }
11271 dlg.finished(false);
11272 return Err(common::Error::HttpError(err));
11273 }
11274 Ok(res) => {
11275 let (mut parts, body) = res.into_parts();
11276 let mut body = common::Body::new(body);
11277 if !parts.status.is_success() {
11278 let bytes = common::to_bytes(body).await.unwrap_or_default();
11279 let error = serde_json::from_str(&common::to_string(&bytes));
11280 let response = common::to_response(parts, bytes.into());
11281
11282 if let common::Retry::After(d) =
11283 dlg.http_failure(&response, error.as_ref().ok())
11284 {
11285 sleep(d).await;
11286 continue;
11287 }
11288
11289 dlg.finished(false);
11290
11291 return Err(match error {
11292 Ok(value) => common::Error::BadRequest(value),
11293 _ => common::Error::Failure(response),
11294 });
11295 }
11296 let response = {
11297 let bytes = common::to_bytes(body).await.unwrap_or_default();
11298 let encoded = common::to_string(&bytes);
11299 match serde_json::from_str(&encoded) {
11300 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11301 Err(error) => {
11302 dlg.response_json_decode_error(&encoded, &error);
11303 return Err(common::Error::JsonDecodeError(
11304 encoded.to_string(),
11305 error,
11306 ));
11307 }
11308 }
11309 };
11310
11311 dlg.finished(true);
11312 return Ok(response);
11313 }
11314 }
11315 }
11316 }
11317
11318 ///
11319 /// Sets the *request* property to the given value.
11320 ///
11321 /// Even though the property as already been set when instantiating this call,
11322 /// we provide this method for API completeness.
11323 pub fn request(mut self, new_value: CancelOperationRequest) -> OperationCancelCall<'a, C> {
11324 self._request = new_value;
11325 self
11326 }
11327 /// The name of the operation resource to be cancelled.
11328 ///
11329 /// Sets the *name* path property to the given value.
11330 ///
11331 /// Even though the property as already been set when instantiating this call,
11332 /// we provide this method for API completeness.
11333 pub fn name(mut self, new_value: &str) -> OperationCancelCall<'a, C> {
11334 self._name = new_value.to_string();
11335 self
11336 }
11337 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11338 /// while executing the actual API request.
11339 ///
11340 /// ````text
11341 /// It should be used to handle progress information, and to implement a certain level of resilience.
11342 /// ````
11343 ///
11344 /// Sets the *delegate* property to the given value.
11345 pub fn delegate(
11346 mut self,
11347 new_value: &'a mut dyn common::Delegate,
11348 ) -> OperationCancelCall<'a, C> {
11349 self._delegate = Some(new_value);
11350 self
11351 }
11352
11353 /// Set any additional parameter of the query string used in the request.
11354 /// It should be used to set parameters which are not yet available through their own
11355 /// setters.
11356 ///
11357 /// Please note that this method must not be used to set any of the known parameters
11358 /// which have their own setter method. If done anyway, the request will fail.
11359 ///
11360 /// # Additional Parameters
11361 ///
11362 /// * *$.xgafv* (query-string) - V1 error format.
11363 /// * *access_token* (query-string) - OAuth access token.
11364 /// * *alt* (query-string) - Data format for response.
11365 /// * *callback* (query-string) - JSONP
11366 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11367 /// * *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.
11368 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11369 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11370 /// * *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.
11371 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11372 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11373 pub fn param<T>(mut self, name: T, value: T) -> OperationCancelCall<'a, C>
11374 where
11375 T: AsRef<str>,
11376 {
11377 self._additional_params
11378 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11379 self
11380 }
11381
11382 /// Identifies the authorization scope for the method you are building.
11383 ///
11384 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11385 /// [`Scope::CloudPlatform`].
11386 ///
11387 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11388 /// tokens for more than one scope.
11389 ///
11390 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11391 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11392 /// sufficient, a read-write scope will do as well.
11393 pub fn add_scope<St>(mut self, scope: St) -> OperationCancelCall<'a, C>
11394 where
11395 St: AsRef<str>,
11396 {
11397 self._scopes.insert(String::from(scope.as_ref()));
11398 self
11399 }
11400 /// Identifies the authorization scope(s) for the method you are building.
11401 ///
11402 /// See [`Self::add_scope()`] for details.
11403 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationCancelCall<'a, C>
11404 where
11405 I: IntoIterator<Item = St>,
11406 St: AsRef<str>,
11407 {
11408 self._scopes
11409 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11410 self
11411 }
11412
11413 /// Removes all scopes, and no default scope will be used either.
11414 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11415 /// for details).
11416 pub fn clear_scopes(mut self) -> OperationCancelCall<'a, C> {
11417 self._scopes.clear();
11418 self
11419 }
11420}
11421
11422/// Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
11423///
11424/// A builder for the *delete* method supported by a *operation* resource.
11425/// It is not used directly, but through a [`OperationMethods`] instance.
11426///
11427/// # Example
11428///
11429/// Instantiate a resource method builder
11430///
11431/// ```test_harness,no_run
11432/// # extern crate hyper;
11433/// # extern crate hyper_rustls;
11434/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
11435/// # async fn dox() {
11436/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11437///
11438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11439/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11440/// # secret,
11441/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11442/// # ).build().await.unwrap();
11443///
11444/// # let client = hyper_util::client::legacy::Client::builder(
11445/// # hyper_util::rt::TokioExecutor::new()
11446/// # )
11447/// # .build(
11448/// # hyper_rustls::HttpsConnectorBuilder::new()
11449/// # .with_native_roots()
11450/// # .unwrap()
11451/// # .https_or_http()
11452/// # .enable_http1()
11453/// # .build()
11454/// # );
11455/// # let mut hub = AccessContextManager::new(client, auth);
11456/// // You can configure optional parameters by calling the respective setters at will, and
11457/// // execute the final call using `doit()`.
11458/// // Values shown here are possibly random and not representative !
11459/// let result = hub.operations().delete("name")
11460/// .doit().await;
11461/// # }
11462/// ```
11463pub struct OperationDeleteCall<'a, C>
11464where
11465 C: 'a,
11466{
11467 hub: &'a AccessContextManager<C>,
11468 _name: String,
11469 _delegate: Option<&'a mut dyn common::Delegate>,
11470 _additional_params: HashMap<String, String>,
11471 _scopes: BTreeSet<String>,
11472}
11473
11474impl<'a, C> common::CallBuilder for OperationDeleteCall<'a, C> {}
11475
11476impl<'a, C> OperationDeleteCall<'a, C>
11477where
11478 C: common::Connector,
11479{
11480 /// Perform the operation you have build so far.
11481 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11482 use std::borrow::Cow;
11483 use std::io::{Read, Seek};
11484
11485 use common::{url::Params, ToParts};
11486 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11487
11488 let mut dd = common::DefaultDelegate;
11489 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11490 dlg.begin(common::MethodInfo {
11491 id: "accesscontextmanager.operations.delete",
11492 http_method: hyper::Method::DELETE,
11493 });
11494
11495 for &field in ["alt", "name"].iter() {
11496 if self._additional_params.contains_key(field) {
11497 dlg.finished(false);
11498 return Err(common::Error::FieldClash(field));
11499 }
11500 }
11501
11502 let mut params = Params::with_capacity(3 + self._additional_params.len());
11503 params.push("name", self._name);
11504
11505 params.extend(self._additional_params.iter());
11506
11507 params.push("alt", "json");
11508 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11509 if self._scopes.is_empty() {
11510 self._scopes
11511 .insert(Scope::CloudPlatform.as_ref().to_string());
11512 }
11513
11514 #[allow(clippy::single_element_loop)]
11515 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11516 url = params.uri_replacement(url, param_name, find_this, true);
11517 }
11518 {
11519 let to_remove = ["name"];
11520 params.remove_params(&to_remove);
11521 }
11522
11523 let url = params.parse_with_url(&url);
11524
11525 loop {
11526 let token = match self
11527 .hub
11528 .auth
11529 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11530 .await
11531 {
11532 Ok(token) => token,
11533 Err(e) => match dlg.token(e) {
11534 Ok(token) => token,
11535 Err(e) => {
11536 dlg.finished(false);
11537 return Err(common::Error::MissingToken(e));
11538 }
11539 },
11540 };
11541 let mut req_result = {
11542 let client = &self.hub.client;
11543 dlg.pre_request();
11544 let mut req_builder = hyper::Request::builder()
11545 .method(hyper::Method::DELETE)
11546 .uri(url.as_str())
11547 .header(USER_AGENT, self.hub._user_agent.clone());
11548
11549 if let Some(token) = token.as_ref() {
11550 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11551 }
11552
11553 let request = req_builder
11554 .header(CONTENT_LENGTH, 0_u64)
11555 .body(common::to_body::<String>(None));
11556
11557 client.request(request.unwrap()).await
11558 };
11559
11560 match req_result {
11561 Err(err) => {
11562 if let common::Retry::After(d) = dlg.http_error(&err) {
11563 sleep(d).await;
11564 continue;
11565 }
11566 dlg.finished(false);
11567 return Err(common::Error::HttpError(err));
11568 }
11569 Ok(res) => {
11570 let (mut parts, body) = res.into_parts();
11571 let mut body = common::Body::new(body);
11572 if !parts.status.is_success() {
11573 let bytes = common::to_bytes(body).await.unwrap_or_default();
11574 let error = serde_json::from_str(&common::to_string(&bytes));
11575 let response = common::to_response(parts, bytes.into());
11576
11577 if let common::Retry::After(d) =
11578 dlg.http_failure(&response, error.as_ref().ok())
11579 {
11580 sleep(d).await;
11581 continue;
11582 }
11583
11584 dlg.finished(false);
11585
11586 return Err(match error {
11587 Ok(value) => common::Error::BadRequest(value),
11588 _ => common::Error::Failure(response),
11589 });
11590 }
11591 let response = {
11592 let bytes = common::to_bytes(body).await.unwrap_or_default();
11593 let encoded = common::to_string(&bytes);
11594 match serde_json::from_str(&encoded) {
11595 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11596 Err(error) => {
11597 dlg.response_json_decode_error(&encoded, &error);
11598 return Err(common::Error::JsonDecodeError(
11599 encoded.to_string(),
11600 error,
11601 ));
11602 }
11603 }
11604 };
11605
11606 dlg.finished(true);
11607 return Ok(response);
11608 }
11609 }
11610 }
11611 }
11612
11613 /// The name of the operation resource to be deleted.
11614 ///
11615 /// Sets the *name* path property to the given value.
11616 ///
11617 /// Even though the property as already been set when instantiating this call,
11618 /// we provide this method for API completeness.
11619 pub fn name(mut self, new_value: &str) -> OperationDeleteCall<'a, C> {
11620 self._name = new_value.to_string();
11621 self
11622 }
11623 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11624 /// while executing the actual API request.
11625 ///
11626 /// ````text
11627 /// It should be used to handle progress information, and to implement a certain level of resilience.
11628 /// ````
11629 ///
11630 /// Sets the *delegate* property to the given value.
11631 pub fn delegate(
11632 mut self,
11633 new_value: &'a mut dyn common::Delegate,
11634 ) -> OperationDeleteCall<'a, C> {
11635 self._delegate = Some(new_value);
11636 self
11637 }
11638
11639 /// Set any additional parameter of the query string used in the request.
11640 /// It should be used to set parameters which are not yet available through their own
11641 /// setters.
11642 ///
11643 /// Please note that this method must not be used to set any of the known parameters
11644 /// which have their own setter method. If done anyway, the request will fail.
11645 ///
11646 /// # Additional Parameters
11647 ///
11648 /// * *$.xgafv* (query-string) - V1 error format.
11649 /// * *access_token* (query-string) - OAuth access token.
11650 /// * *alt* (query-string) - Data format for response.
11651 /// * *callback* (query-string) - JSONP
11652 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11653 /// * *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.
11654 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11655 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11656 /// * *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.
11657 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11658 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11659 pub fn param<T>(mut self, name: T, value: T) -> OperationDeleteCall<'a, C>
11660 where
11661 T: AsRef<str>,
11662 {
11663 self._additional_params
11664 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11665 self
11666 }
11667
11668 /// Identifies the authorization scope for the method you are building.
11669 ///
11670 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11671 /// [`Scope::CloudPlatform`].
11672 ///
11673 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11674 /// tokens for more than one scope.
11675 ///
11676 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11677 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11678 /// sufficient, a read-write scope will do as well.
11679 pub fn add_scope<St>(mut self, scope: St) -> OperationDeleteCall<'a, C>
11680 where
11681 St: AsRef<str>,
11682 {
11683 self._scopes.insert(String::from(scope.as_ref()));
11684 self
11685 }
11686 /// Identifies the authorization scope(s) for the method you are building.
11687 ///
11688 /// See [`Self::add_scope()`] for details.
11689 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationDeleteCall<'a, C>
11690 where
11691 I: IntoIterator<Item = St>,
11692 St: AsRef<str>,
11693 {
11694 self._scopes
11695 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11696 self
11697 }
11698
11699 /// Removes all scopes, and no default scope will be used either.
11700 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11701 /// for details).
11702 pub fn clear_scopes(mut self) -> OperationDeleteCall<'a, C> {
11703 self._scopes.clear();
11704 self
11705 }
11706}
11707
11708/// 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.
11709///
11710/// A builder for the *get* method supported by a *operation* resource.
11711/// It is not used directly, but through a [`OperationMethods`] instance.
11712///
11713/// # Example
11714///
11715/// Instantiate a resource method builder
11716///
11717/// ```test_harness,no_run
11718/// # extern crate hyper;
11719/// # extern crate hyper_rustls;
11720/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
11721/// # async fn dox() {
11722/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11723///
11724/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11725/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11726/// # secret,
11727/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11728/// # ).build().await.unwrap();
11729///
11730/// # let client = hyper_util::client::legacy::Client::builder(
11731/// # hyper_util::rt::TokioExecutor::new()
11732/// # )
11733/// # .build(
11734/// # hyper_rustls::HttpsConnectorBuilder::new()
11735/// # .with_native_roots()
11736/// # .unwrap()
11737/// # .https_or_http()
11738/// # .enable_http1()
11739/// # .build()
11740/// # );
11741/// # let mut hub = AccessContextManager::new(client, auth);
11742/// // You can configure optional parameters by calling the respective setters at will, and
11743/// // execute the final call using `doit()`.
11744/// // Values shown here are possibly random and not representative !
11745/// let result = hub.operations().get("name")
11746/// .doit().await;
11747/// # }
11748/// ```
11749pub struct OperationGetCall<'a, C>
11750where
11751 C: 'a,
11752{
11753 hub: &'a AccessContextManager<C>,
11754 _name: String,
11755 _delegate: Option<&'a mut dyn common::Delegate>,
11756 _additional_params: HashMap<String, String>,
11757 _scopes: BTreeSet<String>,
11758}
11759
11760impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
11761
11762impl<'a, C> OperationGetCall<'a, C>
11763where
11764 C: common::Connector,
11765{
11766 /// Perform the operation you have build so far.
11767 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11768 use std::borrow::Cow;
11769 use std::io::{Read, Seek};
11770
11771 use common::{url::Params, ToParts};
11772 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11773
11774 let mut dd = common::DefaultDelegate;
11775 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11776 dlg.begin(common::MethodInfo {
11777 id: "accesscontextmanager.operations.get",
11778 http_method: hyper::Method::GET,
11779 });
11780
11781 for &field in ["alt", "name"].iter() {
11782 if self._additional_params.contains_key(field) {
11783 dlg.finished(false);
11784 return Err(common::Error::FieldClash(field));
11785 }
11786 }
11787
11788 let mut params = Params::with_capacity(3 + self._additional_params.len());
11789 params.push("name", self._name);
11790
11791 params.extend(self._additional_params.iter());
11792
11793 params.push("alt", "json");
11794 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11795 if self._scopes.is_empty() {
11796 self._scopes
11797 .insert(Scope::CloudPlatform.as_ref().to_string());
11798 }
11799
11800 #[allow(clippy::single_element_loop)]
11801 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11802 url = params.uri_replacement(url, param_name, find_this, true);
11803 }
11804 {
11805 let to_remove = ["name"];
11806 params.remove_params(&to_remove);
11807 }
11808
11809 let url = params.parse_with_url(&url);
11810
11811 loop {
11812 let token = match self
11813 .hub
11814 .auth
11815 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11816 .await
11817 {
11818 Ok(token) => token,
11819 Err(e) => match dlg.token(e) {
11820 Ok(token) => token,
11821 Err(e) => {
11822 dlg.finished(false);
11823 return Err(common::Error::MissingToken(e));
11824 }
11825 },
11826 };
11827 let mut req_result = {
11828 let client = &self.hub.client;
11829 dlg.pre_request();
11830 let mut req_builder = hyper::Request::builder()
11831 .method(hyper::Method::GET)
11832 .uri(url.as_str())
11833 .header(USER_AGENT, self.hub._user_agent.clone());
11834
11835 if let Some(token) = token.as_ref() {
11836 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11837 }
11838
11839 let request = req_builder
11840 .header(CONTENT_LENGTH, 0_u64)
11841 .body(common::to_body::<String>(None));
11842
11843 client.request(request.unwrap()).await
11844 };
11845
11846 match req_result {
11847 Err(err) => {
11848 if let common::Retry::After(d) = dlg.http_error(&err) {
11849 sleep(d).await;
11850 continue;
11851 }
11852 dlg.finished(false);
11853 return Err(common::Error::HttpError(err));
11854 }
11855 Ok(res) => {
11856 let (mut parts, body) = res.into_parts();
11857 let mut body = common::Body::new(body);
11858 if !parts.status.is_success() {
11859 let bytes = common::to_bytes(body).await.unwrap_or_default();
11860 let error = serde_json::from_str(&common::to_string(&bytes));
11861 let response = common::to_response(parts, bytes.into());
11862
11863 if let common::Retry::After(d) =
11864 dlg.http_failure(&response, error.as_ref().ok())
11865 {
11866 sleep(d).await;
11867 continue;
11868 }
11869
11870 dlg.finished(false);
11871
11872 return Err(match error {
11873 Ok(value) => common::Error::BadRequest(value),
11874 _ => common::Error::Failure(response),
11875 });
11876 }
11877 let response = {
11878 let bytes = common::to_bytes(body).await.unwrap_or_default();
11879 let encoded = common::to_string(&bytes);
11880 match serde_json::from_str(&encoded) {
11881 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11882 Err(error) => {
11883 dlg.response_json_decode_error(&encoded, &error);
11884 return Err(common::Error::JsonDecodeError(
11885 encoded.to_string(),
11886 error,
11887 ));
11888 }
11889 }
11890 };
11891
11892 dlg.finished(true);
11893 return Ok(response);
11894 }
11895 }
11896 }
11897 }
11898
11899 /// The name of the operation resource.
11900 ///
11901 /// Sets the *name* path property to the given value.
11902 ///
11903 /// Even though the property as already been set when instantiating this call,
11904 /// we provide this method for API completeness.
11905 pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
11906 self._name = new_value.to_string();
11907 self
11908 }
11909 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11910 /// while executing the actual API request.
11911 ///
11912 /// ````text
11913 /// It should be used to handle progress information, and to implement a certain level of resilience.
11914 /// ````
11915 ///
11916 /// Sets the *delegate* property to the given value.
11917 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
11918 self._delegate = Some(new_value);
11919 self
11920 }
11921
11922 /// Set any additional parameter of the query string used in the request.
11923 /// It should be used to set parameters which are not yet available through their own
11924 /// setters.
11925 ///
11926 /// Please note that this method must not be used to set any of the known parameters
11927 /// which have their own setter method. If done anyway, the request will fail.
11928 ///
11929 /// # Additional Parameters
11930 ///
11931 /// * *$.xgafv* (query-string) - V1 error format.
11932 /// * *access_token* (query-string) - OAuth access token.
11933 /// * *alt* (query-string) - Data format for response.
11934 /// * *callback* (query-string) - JSONP
11935 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11936 /// * *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.
11937 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11938 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11939 /// * *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.
11940 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11941 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11942 pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
11943 where
11944 T: AsRef<str>,
11945 {
11946 self._additional_params
11947 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11948 self
11949 }
11950
11951 /// Identifies the authorization scope for the method you are building.
11952 ///
11953 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11954 /// [`Scope::CloudPlatform`].
11955 ///
11956 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11957 /// tokens for more than one scope.
11958 ///
11959 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11960 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11961 /// sufficient, a read-write scope will do as well.
11962 pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
11963 where
11964 St: AsRef<str>,
11965 {
11966 self._scopes.insert(String::from(scope.as_ref()));
11967 self
11968 }
11969 /// Identifies the authorization scope(s) for the method you are building.
11970 ///
11971 /// See [`Self::add_scope()`] for details.
11972 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
11973 where
11974 I: IntoIterator<Item = St>,
11975 St: AsRef<str>,
11976 {
11977 self._scopes
11978 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11979 self
11980 }
11981
11982 /// Removes all scopes, and no default scope will be used either.
11983 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11984 /// for details).
11985 pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
11986 self._scopes.clear();
11987 self
11988 }
11989}
11990
11991/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
11992///
11993/// A builder for the *list* method supported by a *operation* resource.
11994/// It is not used directly, but through a [`OperationMethods`] instance.
11995///
11996/// # Example
11997///
11998/// Instantiate a resource method builder
11999///
12000/// ```test_harness,no_run
12001/// # extern crate hyper;
12002/// # extern crate hyper_rustls;
12003/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
12004/// # async fn dox() {
12005/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12006///
12007/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12008/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12009/// # secret,
12010/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12011/// # ).build().await.unwrap();
12012///
12013/// # let client = hyper_util::client::legacy::Client::builder(
12014/// # hyper_util::rt::TokioExecutor::new()
12015/// # )
12016/// # .build(
12017/// # hyper_rustls::HttpsConnectorBuilder::new()
12018/// # .with_native_roots()
12019/// # .unwrap()
12020/// # .https_or_http()
12021/// # .enable_http1()
12022/// # .build()
12023/// # );
12024/// # let mut hub = AccessContextManager::new(client, auth);
12025/// // You can configure optional parameters by calling the respective setters at will, and
12026/// // execute the final call using `doit()`.
12027/// // Values shown here are possibly random and not representative !
12028/// let result = hub.operations().list("name")
12029/// .page_token("et")
12030/// .page_size(-28)
12031/// .filter("amet.")
12032/// .doit().await;
12033/// # }
12034/// ```
12035pub struct OperationListCall<'a, C>
12036where
12037 C: 'a,
12038{
12039 hub: &'a AccessContextManager<C>,
12040 _name: String,
12041 _page_token: Option<String>,
12042 _page_size: Option<i32>,
12043 _filter: Option<String>,
12044 _delegate: Option<&'a mut dyn common::Delegate>,
12045 _additional_params: HashMap<String, String>,
12046 _scopes: BTreeSet<String>,
12047}
12048
12049impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
12050
12051impl<'a, C> OperationListCall<'a, C>
12052where
12053 C: common::Connector,
12054{
12055 /// Perform the operation you have build so far.
12056 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
12057 use std::borrow::Cow;
12058 use std::io::{Read, Seek};
12059
12060 use common::{url::Params, ToParts};
12061 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12062
12063 let mut dd = common::DefaultDelegate;
12064 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12065 dlg.begin(common::MethodInfo {
12066 id: "accesscontextmanager.operations.list",
12067 http_method: hyper::Method::GET,
12068 });
12069
12070 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
12071 if self._additional_params.contains_key(field) {
12072 dlg.finished(false);
12073 return Err(common::Error::FieldClash(field));
12074 }
12075 }
12076
12077 let mut params = Params::with_capacity(6 + self._additional_params.len());
12078 params.push("name", self._name);
12079 if let Some(value) = self._page_token.as_ref() {
12080 params.push("pageToken", value);
12081 }
12082 if let Some(value) = self._page_size.as_ref() {
12083 params.push("pageSize", value.to_string());
12084 }
12085 if let Some(value) = self._filter.as_ref() {
12086 params.push("filter", value);
12087 }
12088
12089 params.extend(self._additional_params.iter());
12090
12091 params.push("alt", "json");
12092 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12093 if self._scopes.is_empty() {
12094 self._scopes
12095 .insert(Scope::CloudPlatform.as_ref().to_string());
12096 }
12097
12098 #[allow(clippy::single_element_loop)]
12099 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12100 url = params.uri_replacement(url, param_name, find_this, true);
12101 }
12102 {
12103 let to_remove = ["name"];
12104 params.remove_params(&to_remove);
12105 }
12106
12107 let url = params.parse_with_url(&url);
12108
12109 loop {
12110 let token = match self
12111 .hub
12112 .auth
12113 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12114 .await
12115 {
12116 Ok(token) => token,
12117 Err(e) => match dlg.token(e) {
12118 Ok(token) => token,
12119 Err(e) => {
12120 dlg.finished(false);
12121 return Err(common::Error::MissingToken(e));
12122 }
12123 },
12124 };
12125 let mut req_result = {
12126 let client = &self.hub.client;
12127 dlg.pre_request();
12128 let mut req_builder = hyper::Request::builder()
12129 .method(hyper::Method::GET)
12130 .uri(url.as_str())
12131 .header(USER_AGENT, self.hub._user_agent.clone());
12132
12133 if let Some(token) = token.as_ref() {
12134 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12135 }
12136
12137 let request = req_builder
12138 .header(CONTENT_LENGTH, 0_u64)
12139 .body(common::to_body::<String>(None));
12140
12141 client.request(request.unwrap()).await
12142 };
12143
12144 match req_result {
12145 Err(err) => {
12146 if let common::Retry::After(d) = dlg.http_error(&err) {
12147 sleep(d).await;
12148 continue;
12149 }
12150 dlg.finished(false);
12151 return Err(common::Error::HttpError(err));
12152 }
12153 Ok(res) => {
12154 let (mut parts, body) = res.into_parts();
12155 let mut body = common::Body::new(body);
12156 if !parts.status.is_success() {
12157 let bytes = common::to_bytes(body).await.unwrap_or_default();
12158 let error = serde_json::from_str(&common::to_string(&bytes));
12159 let response = common::to_response(parts, bytes.into());
12160
12161 if let common::Retry::After(d) =
12162 dlg.http_failure(&response, error.as_ref().ok())
12163 {
12164 sleep(d).await;
12165 continue;
12166 }
12167
12168 dlg.finished(false);
12169
12170 return Err(match error {
12171 Ok(value) => common::Error::BadRequest(value),
12172 _ => common::Error::Failure(response),
12173 });
12174 }
12175 let response = {
12176 let bytes = common::to_bytes(body).await.unwrap_or_default();
12177 let encoded = common::to_string(&bytes);
12178 match serde_json::from_str(&encoded) {
12179 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12180 Err(error) => {
12181 dlg.response_json_decode_error(&encoded, &error);
12182 return Err(common::Error::JsonDecodeError(
12183 encoded.to_string(),
12184 error,
12185 ));
12186 }
12187 }
12188 };
12189
12190 dlg.finished(true);
12191 return Ok(response);
12192 }
12193 }
12194 }
12195 }
12196
12197 /// The name of the operation's parent resource.
12198 ///
12199 /// Sets the *name* path property to the given value.
12200 ///
12201 /// Even though the property as already been set when instantiating this call,
12202 /// we provide this method for API completeness.
12203 pub fn name(mut self, new_value: &str) -> OperationListCall<'a, C> {
12204 self._name = new_value.to_string();
12205 self
12206 }
12207 /// The standard list page token.
12208 ///
12209 /// Sets the *page token* query property to the given value.
12210 pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
12211 self._page_token = Some(new_value.to_string());
12212 self
12213 }
12214 /// The standard list page size.
12215 ///
12216 /// Sets the *page size* query property to the given value.
12217 pub fn page_size(mut self, new_value: i32) -> OperationListCall<'a, C> {
12218 self._page_size = Some(new_value);
12219 self
12220 }
12221 /// The standard list filter.
12222 ///
12223 /// Sets the *filter* query property to the given value.
12224 pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C> {
12225 self._filter = Some(new_value.to_string());
12226 self
12227 }
12228 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12229 /// while executing the actual API request.
12230 ///
12231 /// ````text
12232 /// It should be used to handle progress information, and to implement a certain level of resilience.
12233 /// ````
12234 ///
12235 /// Sets the *delegate* property to the given value.
12236 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
12237 self._delegate = Some(new_value);
12238 self
12239 }
12240
12241 /// Set any additional parameter of the query string used in the request.
12242 /// It should be used to set parameters which are not yet available through their own
12243 /// setters.
12244 ///
12245 /// Please note that this method must not be used to set any of the known parameters
12246 /// which have their own setter method. If done anyway, the request will fail.
12247 ///
12248 /// # Additional Parameters
12249 ///
12250 /// * *$.xgafv* (query-string) - V1 error format.
12251 /// * *access_token* (query-string) - OAuth access token.
12252 /// * *alt* (query-string) - Data format for response.
12253 /// * *callback* (query-string) - JSONP
12254 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12255 /// * *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.
12256 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12257 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12258 /// * *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.
12259 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12260 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12261 pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
12262 where
12263 T: AsRef<str>,
12264 {
12265 self._additional_params
12266 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12267 self
12268 }
12269
12270 /// Identifies the authorization scope for the method you are building.
12271 ///
12272 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12273 /// [`Scope::CloudPlatform`].
12274 ///
12275 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12276 /// tokens for more than one scope.
12277 ///
12278 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12279 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12280 /// sufficient, a read-write scope will do as well.
12281 pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
12282 where
12283 St: AsRef<str>,
12284 {
12285 self._scopes.insert(String::from(scope.as_ref()));
12286 self
12287 }
12288 /// Identifies the authorization scope(s) for the method you are building.
12289 ///
12290 /// See [`Self::add_scope()`] for details.
12291 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
12292 where
12293 I: IntoIterator<Item = St>,
12294 St: AsRef<str>,
12295 {
12296 self._scopes
12297 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12298 self
12299 }
12300
12301 /// Removes all scopes, and no default scope will be used either.
12302 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12303 /// for details).
12304 pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
12305 self._scopes.clear();
12306 self
12307 }
12308}
12309
12310/// Creates a GcpUserAccessBinding. If the client specifies a name, the server ignores it. Fails if a resource already exists with the same group_key. Completion of this long-running operation does not necessarily signify that the new binding is deployed onto all affected users, which may take more time.
12311///
12312/// A builder for the *gcpUserAccessBindings.create* method supported by a *organization* resource.
12313/// It is not used directly, but through a [`OrganizationMethods`] instance.
12314///
12315/// # Example
12316///
12317/// Instantiate a resource method builder
12318///
12319/// ```test_harness,no_run
12320/// # extern crate hyper;
12321/// # extern crate hyper_rustls;
12322/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
12323/// use accesscontextmanager1::api::GcpUserAccessBinding;
12324/// # async fn dox() {
12325/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12326///
12327/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12328/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12329/// # secret,
12330/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12331/// # ).build().await.unwrap();
12332///
12333/// # let client = hyper_util::client::legacy::Client::builder(
12334/// # hyper_util::rt::TokioExecutor::new()
12335/// # )
12336/// # .build(
12337/// # hyper_rustls::HttpsConnectorBuilder::new()
12338/// # .with_native_roots()
12339/// # .unwrap()
12340/// # .https_or_http()
12341/// # .enable_http1()
12342/// # .build()
12343/// # );
12344/// # let mut hub = AccessContextManager::new(client, auth);
12345/// // As the method needs a request, you would usually fill it with the desired information
12346/// // into the respective structure. Some of the parts shown here might not be applicable !
12347/// // Values shown here are possibly random and not representative !
12348/// let mut req = GcpUserAccessBinding::default();
12349///
12350/// // You can configure optional parameters by calling the respective setters at will, and
12351/// // execute the final call using `doit()`.
12352/// // Values shown here are possibly random and not representative !
12353/// let result = hub.organizations().gcp_user_access_bindings_create(req, "parent")
12354/// .doit().await;
12355/// # }
12356/// ```
12357pub struct OrganizationGcpUserAccessBindingCreateCall<'a, C>
12358where
12359 C: 'a,
12360{
12361 hub: &'a AccessContextManager<C>,
12362 _request: GcpUserAccessBinding,
12363 _parent: String,
12364 _delegate: Option<&'a mut dyn common::Delegate>,
12365 _additional_params: HashMap<String, String>,
12366 _scopes: BTreeSet<String>,
12367}
12368
12369impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingCreateCall<'a, C> {}
12370
12371impl<'a, C> OrganizationGcpUserAccessBindingCreateCall<'a, C>
12372where
12373 C: common::Connector,
12374{
12375 /// Perform the operation you have build so far.
12376 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12377 use std::borrow::Cow;
12378 use std::io::{Read, Seek};
12379
12380 use common::{url::Params, ToParts};
12381 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12382
12383 let mut dd = common::DefaultDelegate;
12384 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12385 dlg.begin(common::MethodInfo {
12386 id: "accesscontextmanager.organizations.gcpUserAccessBindings.create",
12387 http_method: hyper::Method::POST,
12388 });
12389
12390 for &field in ["alt", "parent"].iter() {
12391 if self._additional_params.contains_key(field) {
12392 dlg.finished(false);
12393 return Err(common::Error::FieldClash(field));
12394 }
12395 }
12396
12397 let mut params = Params::with_capacity(4 + self._additional_params.len());
12398 params.push("parent", self._parent);
12399
12400 params.extend(self._additional_params.iter());
12401
12402 params.push("alt", "json");
12403 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gcpUserAccessBindings";
12404 if self._scopes.is_empty() {
12405 self._scopes
12406 .insert(Scope::CloudPlatform.as_ref().to_string());
12407 }
12408
12409 #[allow(clippy::single_element_loop)]
12410 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12411 url = params.uri_replacement(url, param_name, find_this, true);
12412 }
12413 {
12414 let to_remove = ["parent"];
12415 params.remove_params(&to_remove);
12416 }
12417
12418 let url = params.parse_with_url(&url);
12419
12420 let mut json_mime_type = mime::APPLICATION_JSON;
12421 let mut request_value_reader = {
12422 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12423 common::remove_json_null_values(&mut value);
12424 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12425 serde_json::to_writer(&mut dst, &value).unwrap();
12426 dst
12427 };
12428 let request_size = request_value_reader
12429 .seek(std::io::SeekFrom::End(0))
12430 .unwrap();
12431 request_value_reader
12432 .seek(std::io::SeekFrom::Start(0))
12433 .unwrap();
12434
12435 loop {
12436 let token = match self
12437 .hub
12438 .auth
12439 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12440 .await
12441 {
12442 Ok(token) => token,
12443 Err(e) => match dlg.token(e) {
12444 Ok(token) => token,
12445 Err(e) => {
12446 dlg.finished(false);
12447 return Err(common::Error::MissingToken(e));
12448 }
12449 },
12450 };
12451 request_value_reader
12452 .seek(std::io::SeekFrom::Start(0))
12453 .unwrap();
12454 let mut req_result = {
12455 let client = &self.hub.client;
12456 dlg.pre_request();
12457 let mut req_builder = hyper::Request::builder()
12458 .method(hyper::Method::POST)
12459 .uri(url.as_str())
12460 .header(USER_AGENT, self.hub._user_agent.clone());
12461
12462 if let Some(token) = token.as_ref() {
12463 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12464 }
12465
12466 let request = req_builder
12467 .header(CONTENT_TYPE, json_mime_type.to_string())
12468 .header(CONTENT_LENGTH, request_size as u64)
12469 .body(common::to_body(
12470 request_value_reader.get_ref().clone().into(),
12471 ));
12472
12473 client.request(request.unwrap()).await
12474 };
12475
12476 match req_result {
12477 Err(err) => {
12478 if let common::Retry::After(d) = dlg.http_error(&err) {
12479 sleep(d).await;
12480 continue;
12481 }
12482 dlg.finished(false);
12483 return Err(common::Error::HttpError(err));
12484 }
12485 Ok(res) => {
12486 let (mut parts, body) = res.into_parts();
12487 let mut body = common::Body::new(body);
12488 if !parts.status.is_success() {
12489 let bytes = common::to_bytes(body).await.unwrap_or_default();
12490 let error = serde_json::from_str(&common::to_string(&bytes));
12491 let response = common::to_response(parts, bytes.into());
12492
12493 if let common::Retry::After(d) =
12494 dlg.http_failure(&response, error.as_ref().ok())
12495 {
12496 sleep(d).await;
12497 continue;
12498 }
12499
12500 dlg.finished(false);
12501
12502 return Err(match error {
12503 Ok(value) => common::Error::BadRequest(value),
12504 _ => common::Error::Failure(response),
12505 });
12506 }
12507 let response = {
12508 let bytes = common::to_bytes(body).await.unwrap_or_default();
12509 let encoded = common::to_string(&bytes);
12510 match serde_json::from_str(&encoded) {
12511 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12512 Err(error) => {
12513 dlg.response_json_decode_error(&encoded, &error);
12514 return Err(common::Error::JsonDecodeError(
12515 encoded.to_string(),
12516 error,
12517 ));
12518 }
12519 }
12520 };
12521
12522 dlg.finished(true);
12523 return Ok(response);
12524 }
12525 }
12526 }
12527 }
12528
12529 ///
12530 /// Sets the *request* property to the given value.
12531 ///
12532 /// Even though the property as already been set when instantiating this call,
12533 /// we provide this method for API completeness.
12534 pub fn request(
12535 mut self,
12536 new_value: GcpUserAccessBinding,
12537 ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
12538 self._request = new_value;
12539 self
12540 }
12541 /// Required. Example: "organizations/256"
12542 ///
12543 /// Sets the *parent* path property to the given value.
12544 ///
12545 /// Even though the property as already been set when instantiating this call,
12546 /// we provide this method for API completeness.
12547 pub fn parent(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
12548 self._parent = new_value.to_string();
12549 self
12550 }
12551 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12552 /// while executing the actual API request.
12553 ///
12554 /// ````text
12555 /// It should be used to handle progress information, and to implement a certain level of resilience.
12556 /// ````
12557 ///
12558 /// Sets the *delegate* property to the given value.
12559 pub fn delegate(
12560 mut self,
12561 new_value: &'a mut dyn common::Delegate,
12562 ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
12563 self._delegate = Some(new_value);
12564 self
12565 }
12566
12567 /// Set any additional parameter of the query string used in the request.
12568 /// It should be used to set parameters which are not yet available through their own
12569 /// setters.
12570 ///
12571 /// Please note that this method must not be used to set any of the known parameters
12572 /// which have their own setter method. If done anyway, the request will fail.
12573 ///
12574 /// # Additional Parameters
12575 ///
12576 /// * *$.xgafv* (query-string) - V1 error format.
12577 /// * *access_token* (query-string) - OAuth access token.
12578 /// * *alt* (query-string) - Data format for response.
12579 /// * *callback* (query-string) - JSONP
12580 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12581 /// * *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.
12582 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12583 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12584 /// * *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.
12585 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12586 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12587 pub fn param<T>(
12588 mut self,
12589 name: T,
12590 value: T,
12591 ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C>
12592 where
12593 T: AsRef<str>,
12594 {
12595 self._additional_params
12596 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12597 self
12598 }
12599
12600 /// Identifies the authorization scope for the method you are building.
12601 ///
12602 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12603 /// [`Scope::CloudPlatform`].
12604 ///
12605 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12606 /// tokens for more than one scope.
12607 ///
12608 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12609 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12610 /// sufficient, a read-write scope will do as well.
12611 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingCreateCall<'a, C>
12612 where
12613 St: AsRef<str>,
12614 {
12615 self._scopes.insert(String::from(scope.as_ref()));
12616 self
12617 }
12618 /// Identifies the authorization scope(s) for the method you are building.
12619 ///
12620 /// See [`Self::add_scope()`] for details.
12621 pub fn add_scopes<I, St>(
12622 mut self,
12623 scopes: I,
12624 ) -> OrganizationGcpUserAccessBindingCreateCall<'a, C>
12625 where
12626 I: IntoIterator<Item = St>,
12627 St: AsRef<str>,
12628 {
12629 self._scopes
12630 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12631 self
12632 }
12633
12634 /// Removes all scopes, and no default scope will be used either.
12635 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12636 /// for details).
12637 pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingCreateCall<'a, C> {
12638 self._scopes.clear();
12639 self
12640 }
12641}
12642
12643/// Deletes a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the binding deletion is deployed onto all affected users, which may take more time.
12644///
12645/// A builder for the *gcpUserAccessBindings.delete* method supported by a *organization* resource.
12646/// It is not used directly, but through a [`OrganizationMethods`] instance.
12647///
12648/// # Example
12649///
12650/// Instantiate a resource method builder
12651///
12652/// ```test_harness,no_run
12653/// # extern crate hyper;
12654/// # extern crate hyper_rustls;
12655/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
12656/// # async fn dox() {
12657/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12658///
12659/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12660/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12661/// # secret,
12662/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12663/// # ).build().await.unwrap();
12664///
12665/// # let client = hyper_util::client::legacy::Client::builder(
12666/// # hyper_util::rt::TokioExecutor::new()
12667/// # )
12668/// # .build(
12669/// # hyper_rustls::HttpsConnectorBuilder::new()
12670/// # .with_native_roots()
12671/// # .unwrap()
12672/// # .https_or_http()
12673/// # .enable_http1()
12674/// # .build()
12675/// # );
12676/// # let mut hub = AccessContextManager::new(client, auth);
12677/// // You can configure optional parameters by calling the respective setters at will, and
12678/// // execute the final call using `doit()`.
12679/// // Values shown here are possibly random and not representative !
12680/// let result = hub.organizations().gcp_user_access_bindings_delete("name")
12681/// .doit().await;
12682/// # }
12683/// ```
12684pub struct OrganizationGcpUserAccessBindingDeleteCall<'a, C>
12685where
12686 C: 'a,
12687{
12688 hub: &'a AccessContextManager<C>,
12689 _name: String,
12690 _delegate: Option<&'a mut dyn common::Delegate>,
12691 _additional_params: HashMap<String, String>,
12692 _scopes: BTreeSet<String>,
12693}
12694
12695impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingDeleteCall<'a, C> {}
12696
12697impl<'a, C> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
12698where
12699 C: common::Connector,
12700{
12701 /// Perform the operation you have build so far.
12702 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12703 use std::borrow::Cow;
12704 use std::io::{Read, Seek};
12705
12706 use common::{url::Params, ToParts};
12707 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12708
12709 let mut dd = common::DefaultDelegate;
12710 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12711 dlg.begin(common::MethodInfo {
12712 id: "accesscontextmanager.organizations.gcpUserAccessBindings.delete",
12713 http_method: hyper::Method::DELETE,
12714 });
12715
12716 for &field in ["alt", "name"].iter() {
12717 if self._additional_params.contains_key(field) {
12718 dlg.finished(false);
12719 return Err(common::Error::FieldClash(field));
12720 }
12721 }
12722
12723 let mut params = Params::with_capacity(3 + self._additional_params.len());
12724 params.push("name", self._name);
12725
12726 params.extend(self._additional_params.iter());
12727
12728 params.push("alt", "json");
12729 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12730 if self._scopes.is_empty() {
12731 self._scopes
12732 .insert(Scope::CloudPlatform.as_ref().to_string());
12733 }
12734
12735 #[allow(clippy::single_element_loop)]
12736 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12737 url = params.uri_replacement(url, param_name, find_this, true);
12738 }
12739 {
12740 let to_remove = ["name"];
12741 params.remove_params(&to_remove);
12742 }
12743
12744 let url = params.parse_with_url(&url);
12745
12746 loop {
12747 let token = match self
12748 .hub
12749 .auth
12750 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12751 .await
12752 {
12753 Ok(token) => token,
12754 Err(e) => match dlg.token(e) {
12755 Ok(token) => token,
12756 Err(e) => {
12757 dlg.finished(false);
12758 return Err(common::Error::MissingToken(e));
12759 }
12760 },
12761 };
12762 let mut req_result = {
12763 let client = &self.hub.client;
12764 dlg.pre_request();
12765 let mut req_builder = hyper::Request::builder()
12766 .method(hyper::Method::DELETE)
12767 .uri(url.as_str())
12768 .header(USER_AGENT, self.hub._user_agent.clone());
12769
12770 if let Some(token) = token.as_ref() {
12771 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12772 }
12773
12774 let request = req_builder
12775 .header(CONTENT_LENGTH, 0_u64)
12776 .body(common::to_body::<String>(None));
12777
12778 client.request(request.unwrap()).await
12779 };
12780
12781 match req_result {
12782 Err(err) => {
12783 if let common::Retry::After(d) = dlg.http_error(&err) {
12784 sleep(d).await;
12785 continue;
12786 }
12787 dlg.finished(false);
12788 return Err(common::Error::HttpError(err));
12789 }
12790 Ok(res) => {
12791 let (mut parts, body) = res.into_parts();
12792 let mut body = common::Body::new(body);
12793 if !parts.status.is_success() {
12794 let bytes = common::to_bytes(body).await.unwrap_or_default();
12795 let error = serde_json::from_str(&common::to_string(&bytes));
12796 let response = common::to_response(parts, bytes.into());
12797
12798 if let common::Retry::After(d) =
12799 dlg.http_failure(&response, error.as_ref().ok())
12800 {
12801 sleep(d).await;
12802 continue;
12803 }
12804
12805 dlg.finished(false);
12806
12807 return Err(match error {
12808 Ok(value) => common::Error::BadRequest(value),
12809 _ => common::Error::Failure(response),
12810 });
12811 }
12812 let response = {
12813 let bytes = common::to_bytes(body).await.unwrap_or_default();
12814 let encoded = common::to_string(&bytes);
12815 match serde_json::from_str(&encoded) {
12816 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12817 Err(error) => {
12818 dlg.response_json_decode_error(&encoded, &error);
12819 return Err(common::Error::JsonDecodeError(
12820 encoded.to_string(),
12821 error,
12822 ));
12823 }
12824 }
12825 };
12826
12827 dlg.finished(true);
12828 return Ok(response);
12829 }
12830 }
12831 }
12832 }
12833
12834 /// Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
12835 ///
12836 /// Sets the *name* path property to the given value.
12837 ///
12838 /// Even though the property as already been set when instantiating this call,
12839 /// we provide this method for API completeness.
12840 pub fn name(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
12841 self._name = new_value.to_string();
12842 self
12843 }
12844 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12845 /// while executing the actual API request.
12846 ///
12847 /// ````text
12848 /// It should be used to handle progress information, and to implement a certain level of resilience.
12849 /// ````
12850 ///
12851 /// Sets the *delegate* property to the given value.
12852 pub fn delegate(
12853 mut self,
12854 new_value: &'a mut dyn common::Delegate,
12855 ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
12856 self._delegate = Some(new_value);
12857 self
12858 }
12859
12860 /// Set any additional parameter of the query string used in the request.
12861 /// It should be used to set parameters which are not yet available through their own
12862 /// setters.
12863 ///
12864 /// Please note that this method must not be used to set any of the known parameters
12865 /// which have their own setter method. If done anyway, the request will fail.
12866 ///
12867 /// # Additional Parameters
12868 ///
12869 /// * *$.xgafv* (query-string) - V1 error format.
12870 /// * *access_token* (query-string) - OAuth access token.
12871 /// * *alt* (query-string) - Data format for response.
12872 /// * *callback* (query-string) - JSONP
12873 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12874 /// * *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.
12875 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12876 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12877 /// * *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.
12878 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12879 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12880 pub fn param<T>(
12881 mut self,
12882 name: T,
12883 value: T,
12884 ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
12885 where
12886 T: AsRef<str>,
12887 {
12888 self._additional_params
12889 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12890 self
12891 }
12892
12893 /// Identifies the authorization scope for the method you are building.
12894 ///
12895 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12896 /// [`Scope::CloudPlatform`].
12897 ///
12898 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12899 /// tokens for more than one scope.
12900 ///
12901 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12902 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12903 /// sufficient, a read-write scope will do as well.
12904 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
12905 where
12906 St: AsRef<str>,
12907 {
12908 self._scopes.insert(String::from(scope.as_ref()));
12909 self
12910 }
12911 /// Identifies the authorization scope(s) for the method you are building.
12912 ///
12913 /// See [`Self::add_scope()`] for details.
12914 pub fn add_scopes<I, St>(
12915 mut self,
12916 scopes: I,
12917 ) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C>
12918 where
12919 I: IntoIterator<Item = St>,
12920 St: AsRef<str>,
12921 {
12922 self._scopes
12923 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12924 self
12925 }
12926
12927 /// Removes all scopes, and no default scope will be used either.
12928 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12929 /// for details).
12930 pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingDeleteCall<'a, C> {
12931 self._scopes.clear();
12932 self
12933 }
12934}
12935
12936/// Gets the GcpUserAccessBinding with the given name.
12937///
12938/// A builder for the *gcpUserAccessBindings.get* method supported by a *organization* resource.
12939/// It is not used directly, but through a [`OrganizationMethods`] instance.
12940///
12941/// # Example
12942///
12943/// Instantiate a resource method builder
12944///
12945/// ```test_harness,no_run
12946/// # extern crate hyper;
12947/// # extern crate hyper_rustls;
12948/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
12949/// # async fn dox() {
12950/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12951///
12952/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12953/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12954/// # secret,
12955/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12956/// # ).build().await.unwrap();
12957///
12958/// # let client = hyper_util::client::legacy::Client::builder(
12959/// # hyper_util::rt::TokioExecutor::new()
12960/// # )
12961/// # .build(
12962/// # hyper_rustls::HttpsConnectorBuilder::new()
12963/// # .with_native_roots()
12964/// # .unwrap()
12965/// # .https_or_http()
12966/// # .enable_http1()
12967/// # .build()
12968/// # );
12969/// # let mut hub = AccessContextManager::new(client, auth);
12970/// // You can configure optional parameters by calling the respective setters at will, and
12971/// // execute the final call using `doit()`.
12972/// // Values shown here are possibly random and not representative !
12973/// let result = hub.organizations().gcp_user_access_bindings_get("name")
12974/// .doit().await;
12975/// # }
12976/// ```
12977pub struct OrganizationGcpUserAccessBindingGetCall<'a, C>
12978where
12979 C: 'a,
12980{
12981 hub: &'a AccessContextManager<C>,
12982 _name: String,
12983 _delegate: Option<&'a mut dyn common::Delegate>,
12984 _additional_params: HashMap<String, String>,
12985 _scopes: BTreeSet<String>,
12986}
12987
12988impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingGetCall<'a, C> {}
12989
12990impl<'a, C> OrganizationGcpUserAccessBindingGetCall<'a, C>
12991where
12992 C: common::Connector,
12993{
12994 /// Perform the operation you have build so far.
12995 pub async fn doit(mut self) -> common::Result<(common::Response, GcpUserAccessBinding)> {
12996 use std::borrow::Cow;
12997 use std::io::{Read, Seek};
12998
12999 use common::{url::Params, ToParts};
13000 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13001
13002 let mut dd = common::DefaultDelegate;
13003 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13004 dlg.begin(common::MethodInfo {
13005 id: "accesscontextmanager.organizations.gcpUserAccessBindings.get",
13006 http_method: hyper::Method::GET,
13007 });
13008
13009 for &field in ["alt", "name"].iter() {
13010 if self._additional_params.contains_key(field) {
13011 dlg.finished(false);
13012 return Err(common::Error::FieldClash(field));
13013 }
13014 }
13015
13016 let mut params = Params::with_capacity(3 + self._additional_params.len());
13017 params.push("name", self._name);
13018
13019 params.extend(self._additional_params.iter());
13020
13021 params.push("alt", "json");
13022 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13023 if self._scopes.is_empty() {
13024 self._scopes
13025 .insert(Scope::CloudPlatform.as_ref().to_string());
13026 }
13027
13028 #[allow(clippy::single_element_loop)]
13029 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13030 url = params.uri_replacement(url, param_name, find_this, true);
13031 }
13032 {
13033 let to_remove = ["name"];
13034 params.remove_params(&to_remove);
13035 }
13036
13037 let url = params.parse_with_url(&url);
13038
13039 loop {
13040 let token = match self
13041 .hub
13042 .auth
13043 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13044 .await
13045 {
13046 Ok(token) => token,
13047 Err(e) => match dlg.token(e) {
13048 Ok(token) => token,
13049 Err(e) => {
13050 dlg.finished(false);
13051 return Err(common::Error::MissingToken(e));
13052 }
13053 },
13054 };
13055 let mut req_result = {
13056 let client = &self.hub.client;
13057 dlg.pre_request();
13058 let mut req_builder = hyper::Request::builder()
13059 .method(hyper::Method::GET)
13060 .uri(url.as_str())
13061 .header(USER_AGENT, self.hub._user_agent.clone());
13062
13063 if let Some(token) = token.as_ref() {
13064 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13065 }
13066
13067 let request = req_builder
13068 .header(CONTENT_LENGTH, 0_u64)
13069 .body(common::to_body::<String>(None));
13070
13071 client.request(request.unwrap()).await
13072 };
13073
13074 match req_result {
13075 Err(err) => {
13076 if let common::Retry::After(d) = dlg.http_error(&err) {
13077 sleep(d).await;
13078 continue;
13079 }
13080 dlg.finished(false);
13081 return Err(common::Error::HttpError(err));
13082 }
13083 Ok(res) => {
13084 let (mut parts, body) = res.into_parts();
13085 let mut body = common::Body::new(body);
13086 if !parts.status.is_success() {
13087 let bytes = common::to_bytes(body).await.unwrap_or_default();
13088 let error = serde_json::from_str(&common::to_string(&bytes));
13089 let response = common::to_response(parts, bytes.into());
13090
13091 if let common::Retry::After(d) =
13092 dlg.http_failure(&response, error.as_ref().ok())
13093 {
13094 sleep(d).await;
13095 continue;
13096 }
13097
13098 dlg.finished(false);
13099
13100 return Err(match error {
13101 Ok(value) => common::Error::BadRequest(value),
13102 _ => common::Error::Failure(response),
13103 });
13104 }
13105 let response = {
13106 let bytes = common::to_bytes(body).await.unwrap_or_default();
13107 let encoded = common::to_string(&bytes);
13108 match serde_json::from_str(&encoded) {
13109 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13110 Err(error) => {
13111 dlg.response_json_decode_error(&encoded, &error);
13112 return Err(common::Error::JsonDecodeError(
13113 encoded.to_string(),
13114 error,
13115 ));
13116 }
13117 }
13118 };
13119
13120 dlg.finished(true);
13121 return Ok(response);
13122 }
13123 }
13124 }
13125 }
13126
13127 /// Required. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
13128 ///
13129 /// Sets the *name* path property to the given value.
13130 ///
13131 /// Even though the property as already been set when instantiating this call,
13132 /// we provide this method for API completeness.
13133 pub fn name(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
13134 self._name = new_value.to_string();
13135 self
13136 }
13137 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13138 /// while executing the actual API request.
13139 ///
13140 /// ````text
13141 /// It should be used to handle progress information, and to implement a certain level of resilience.
13142 /// ````
13143 ///
13144 /// Sets the *delegate* property to the given value.
13145 pub fn delegate(
13146 mut self,
13147 new_value: &'a mut dyn common::Delegate,
13148 ) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
13149 self._delegate = Some(new_value);
13150 self
13151 }
13152
13153 /// Set any additional parameter of the query string used in the request.
13154 /// It should be used to set parameters which are not yet available through their own
13155 /// setters.
13156 ///
13157 /// Please note that this method must not be used to set any of the known parameters
13158 /// which have their own setter method. If done anyway, the request will fail.
13159 ///
13160 /// # Additional Parameters
13161 ///
13162 /// * *$.xgafv* (query-string) - V1 error format.
13163 /// * *access_token* (query-string) - OAuth access token.
13164 /// * *alt* (query-string) - Data format for response.
13165 /// * *callback* (query-string) - JSONP
13166 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13167 /// * *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.
13168 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13169 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13170 /// * *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.
13171 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13172 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13173 pub fn param<T>(mut self, name: T, value: T) -> OrganizationGcpUserAccessBindingGetCall<'a, C>
13174 where
13175 T: AsRef<str>,
13176 {
13177 self._additional_params
13178 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13179 self
13180 }
13181
13182 /// Identifies the authorization scope for the method you are building.
13183 ///
13184 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13185 /// [`Scope::CloudPlatform`].
13186 ///
13187 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13188 /// tokens for more than one scope.
13189 ///
13190 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13191 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13192 /// sufficient, a read-write scope will do as well.
13193 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingGetCall<'a, C>
13194 where
13195 St: AsRef<str>,
13196 {
13197 self._scopes.insert(String::from(scope.as_ref()));
13198 self
13199 }
13200 /// Identifies the authorization scope(s) for the method you are building.
13201 ///
13202 /// See [`Self::add_scope()`] for details.
13203 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGcpUserAccessBindingGetCall<'a, C>
13204 where
13205 I: IntoIterator<Item = St>,
13206 St: AsRef<str>,
13207 {
13208 self._scopes
13209 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13210 self
13211 }
13212
13213 /// Removes all scopes, and no default scope will be used either.
13214 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13215 /// for details).
13216 pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingGetCall<'a, C> {
13217 self._scopes.clear();
13218 self
13219 }
13220}
13221
13222/// Lists all GcpUserAccessBindings for a Google Cloud organization.
13223///
13224/// A builder for the *gcpUserAccessBindings.list* method supported by a *organization* resource.
13225/// It is not used directly, but through a [`OrganizationMethods`] instance.
13226///
13227/// # Example
13228///
13229/// Instantiate a resource method builder
13230///
13231/// ```test_harness,no_run
13232/// # extern crate hyper;
13233/// # extern crate hyper_rustls;
13234/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
13235/// # async fn dox() {
13236/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13237///
13238/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13239/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13240/// # secret,
13241/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13242/// # ).build().await.unwrap();
13243///
13244/// # let client = hyper_util::client::legacy::Client::builder(
13245/// # hyper_util::rt::TokioExecutor::new()
13246/// # )
13247/// # .build(
13248/// # hyper_rustls::HttpsConnectorBuilder::new()
13249/// # .with_native_roots()
13250/// # .unwrap()
13251/// # .https_or_http()
13252/// # .enable_http1()
13253/// # .build()
13254/// # );
13255/// # let mut hub = AccessContextManager::new(client, auth);
13256/// // You can configure optional parameters by calling the respective setters at will, and
13257/// // execute the final call using `doit()`.
13258/// // Values shown here are possibly random and not representative !
13259/// let result = hub.organizations().gcp_user_access_bindings_list("parent")
13260/// .page_token("et")
13261/// .page_size(-95)
13262/// .doit().await;
13263/// # }
13264/// ```
13265pub struct OrganizationGcpUserAccessBindingListCall<'a, C>
13266where
13267 C: 'a,
13268{
13269 hub: &'a AccessContextManager<C>,
13270 _parent: String,
13271 _page_token: Option<String>,
13272 _page_size: Option<i32>,
13273 _delegate: Option<&'a mut dyn common::Delegate>,
13274 _additional_params: HashMap<String, String>,
13275 _scopes: BTreeSet<String>,
13276}
13277
13278impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingListCall<'a, C> {}
13279
13280impl<'a, C> OrganizationGcpUserAccessBindingListCall<'a, C>
13281where
13282 C: common::Connector,
13283{
13284 /// Perform the operation you have build so far.
13285 pub async fn doit(
13286 mut self,
13287 ) -> common::Result<(common::Response, ListGcpUserAccessBindingsResponse)> {
13288 use std::borrow::Cow;
13289 use std::io::{Read, Seek};
13290
13291 use common::{url::Params, ToParts};
13292 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13293
13294 let mut dd = common::DefaultDelegate;
13295 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13296 dlg.begin(common::MethodInfo {
13297 id: "accesscontextmanager.organizations.gcpUserAccessBindings.list",
13298 http_method: hyper::Method::GET,
13299 });
13300
13301 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
13302 if self._additional_params.contains_key(field) {
13303 dlg.finished(false);
13304 return Err(common::Error::FieldClash(field));
13305 }
13306 }
13307
13308 let mut params = Params::with_capacity(5 + self._additional_params.len());
13309 params.push("parent", self._parent);
13310 if let Some(value) = self._page_token.as_ref() {
13311 params.push("pageToken", value);
13312 }
13313 if let Some(value) = self._page_size.as_ref() {
13314 params.push("pageSize", value.to_string());
13315 }
13316
13317 params.extend(self._additional_params.iter());
13318
13319 params.push("alt", "json");
13320 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gcpUserAccessBindings";
13321 if self._scopes.is_empty() {
13322 self._scopes
13323 .insert(Scope::CloudPlatform.as_ref().to_string());
13324 }
13325
13326 #[allow(clippy::single_element_loop)]
13327 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13328 url = params.uri_replacement(url, param_name, find_this, true);
13329 }
13330 {
13331 let to_remove = ["parent"];
13332 params.remove_params(&to_remove);
13333 }
13334
13335 let url = params.parse_with_url(&url);
13336
13337 loop {
13338 let token = match self
13339 .hub
13340 .auth
13341 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13342 .await
13343 {
13344 Ok(token) => token,
13345 Err(e) => match dlg.token(e) {
13346 Ok(token) => token,
13347 Err(e) => {
13348 dlg.finished(false);
13349 return Err(common::Error::MissingToken(e));
13350 }
13351 },
13352 };
13353 let mut req_result = {
13354 let client = &self.hub.client;
13355 dlg.pre_request();
13356 let mut req_builder = hyper::Request::builder()
13357 .method(hyper::Method::GET)
13358 .uri(url.as_str())
13359 .header(USER_AGENT, self.hub._user_agent.clone());
13360
13361 if let Some(token) = token.as_ref() {
13362 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13363 }
13364
13365 let request = req_builder
13366 .header(CONTENT_LENGTH, 0_u64)
13367 .body(common::to_body::<String>(None));
13368
13369 client.request(request.unwrap()).await
13370 };
13371
13372 match req_result {
13373 Err(err) => {
13374 if let common::Retry::After(d) = dlg.http_error(&err) {
13375 sleep(d).await;
13376 continue;
13377 }
13378 dlg.finished(false);
13379 return Err(common::Error::HttpError(err));
13380 }
13381 Ok(res) => {
13382 let (mut parts, body) = res.into_parts();
13383 let mut body = common::Body::new(body);
13384 if !parts.status.is_success() {
13385 let bytes = common::to_bytes(body).await.unwrap_or_default();
13386 let error = serde_json::from_str(&common::to_string(&bytes));
13387 let response = common::to_response(parts, bytes.into());
13388
13389 if let common::Retry::After(d) =
13390 dlg.http_failure(&response, error.as_ref().ok())
13391 {
13392 sleep(d).await;
13393 continue;
13394 }
13395
13396 dlg.finished(false);
13397
13398 return Err(match error {
13399 Ok(value) => common::Error::BadRequest(value),
13400 _ => common::Error::Failure(response),
13401 });
13402 }
13403 let response = {
13404 let bytes = common::to_bytes(body).await.unwrap_or_default();
13405 let encoded = common::to_string(&bytes);
13406 match serde_json::from_str(&encoded) {
13407 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13408 Err(error) => {
13409 dlg.response_json_decode_error(&encoded, &error);
13410 return Err(common::Error::JsonDecodeError(
13411 encoded.to_string(),
13412 error,
13413 ));
13414 }
13415 }
13416 };
13417
13418 dlg.finished(true);
13419 return Ok(response);
13420 }
13421 }
13422 }
13423 }
13424
13425 /// Required. Example: "organizations/256"
13426 ///
13427 /// Sets the *parent* path property to the given value.
13428 ///
13429 /// Even though the property as already been set when instantiating this call,
13430 /// we provide this method for API completeness.
13431 pub fn parent(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
13432 self._parent = new_value.to_string();
13433 self
13434 }
13435 /// Optional. If left blank, returns the first page. To enumerate all items, use the next_page_token from your previous list operation.
13436 ///
13437 /// Sets the *page token* query property to the given value.
13438 pub fn page_token(
13439 mut self,
13440 new_value: &str,
13441 ) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
13442 self._page_token = Some(new_value.to_string());
13443 self
13444 }
13445 /// Optional. Maximum number of items to return. The server may return fewer items. If left blank, the server may return any number of items.
13446 ///
13447 /// Sets the *page size* query property to the given value.
13448 pub fn page_size(mut self, new_value: i32) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
13449 self._page_size = Some(new_value);
13450 self
13451 }
13452 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13453 /// while executing the actual API request.
13454 ///
13455 /// ````text
13456 /// It should be used to handle progress information, and to implement a certain level of resilience.
13457 /// ````
13458 ///
13459 /// Sets the *delegate* property to the given value.
13460 pub fn delegate(
13461 mut self,
13462 new_value: &'a mut dyn common::Delegate,
13463 ) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
13464 self._delegate = Some(new_value);
13465 self
13466 }
13467
13468 /// Set any additional parameter of the query string used in the request.
13469 /// It should be used to set parameters which are not yet available through their own
13470 /// setters.
13471 ///
13472 /// Please note that this method must not be used to set any of the known parameters
13473 /// which have their own setter method. If done anyway, the request will fail.
13474 ///
13475 /// # Additional Parameters
13476 ///
13477 /// * *$.xgafv* (query-string) - V1 error format.
13478 /// * *access_token* (query-string) - OAuth access token.
13479 /// * *alt* (query-string) - Data format for response.
13480 /// * *callback* (query-string) - JSONP
13481 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13482 /// * *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.
13483 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13484 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13485 /// * *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.
13486 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13487 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13488 pub fn param<T>(mut self, name: T, value: T) -> OrganizationGcpUserAccessBindingListCall<'a, C>
13489 where
13490 T: AsRef<str>,
13491 {
13492 self._additional_params
13493 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13494 self
13495 }
13496
13497 /// Identifies the authorization scope for the method you are building.
13498 ///
13499 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13500 /// [`Scope::CloudPlatform`].
13501 ///
13502 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13503 /// tokens for more than one scope.
13504 ///
13505 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13506 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13507 /// sufficient, a read-write scope will do as well.
13508 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingListCall<'a, C>
13509 where
13510 St: AsRef<str>,
13511 {
13512 self._scopes.insert(String::from(scope.as_ref()));
13513 self
13514 }
13515 /// Identifies the authorization scope(s) for the method you are building.
13516 ///
13517 /// See [`Self::add_scope()`] for details.
13518 pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationGcpUserAccessBindingListCall<'a, C>
13519 where
13520 I: IntoIterator<Item = St>,
13521 St: AsRef<str>,
13522 {
13523 self._scopes
13524 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13525 self
13526 }
13527
13528 /// Removes all scopes, and no default scope will be used either.
13529 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13530 /// for details).
13531 pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingListCall<'a, C> {
13532 self._scopes.clear();
13533 self
13534 }
13535}
13536
13537/// Updates a GcpUserAccessBinding. Completion of this long-running operation does not necessarily signify that the changed binding is deployed onto all affected users, which may take more time.
13538///
13539/// A builder for the *gcpUserAccessBindings.patch* method supported by a *organization* resource.
13540/// It is not used directly, but through a [`OrganizationMethods`] instance.
13541///
13542/// # Example
13543///
13544/// Instantiate a resource method builder
13545///
13546/// ```test_harness,no_run
13547/// # extern crate hyper;
13548/// # extern crate hyper_rustls;
13549/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
13550/// use accesscontextmanager1::api::GcpUserAccessBinding;
13551/// # async fn dox() {
13552/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13553///
13554/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13555/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13556/// # secret,
13557/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13558/// # ).build().await.unwrap();
13559///
13560/// # let client = hyper_util::client::legacy::Client::builder(
13561/// # hyper_util::rt::TokioExecutor::new()
13562/// # )
13563/// # .build(
13564/// # hyper_rustls::HttpsConnectorBuilder::new()
13565/// # .with_native_roots()
13566/// # .unwrap()
13567/// # .https_or_http()
13568/// # .enable_http1()
13569/// # .build()
13570/// # );
13571/// # let mut hub = AccessContextManager::new(client, auth);
13572/// // As the method needs a request, you would usually fill it with the desired information
13573/// // into the respective structure. Some of the parts shown here might not be applicable !
13574/// // Values shown here are possibly random and not representative !
13575/// let mut req = GcpUserAccessBinding::default();
13576///
13577/// // You can configure optional parameters by calling the respective setters at will, and
13578/// // execute the final call using `doit()`.
13579/// // Values shown here are possibly random and not representative !
13580/// let result = hub.organizations().gcp_user_access_bindings_patch(req, "name")
13581/// .update_mask(FieldMask::new::<&str>(&[]))
13582/// .doit().await;
13583/// # }
13584/// ```
13585pub struct OrganizationGcpUserAccessBindingPatchCall<'a, C>
13586where
13587 C: 'a,
13588{
13589 hub: &'a AccessContextManager<C>,
13590 _request: GcpUserAccessBinding,
13591 _name: String,
13592 _update_mask: Option<common::FieldMask>,
13593 _delegate: Option<&'a mut dyn common::Delegate>,
13594 _additional_params: HashMap<String, String>,
13595 _scopes: BTreeSet<String>,
13596}
13597
13598impl<'a, C> common::CallBuilder for OrganizationGcpUserAccessBindingPatchCall<'a, C> {}
13599
13600impl<'a, C> OrganizationGcpUserAccessBindingPatchCall<'a, C>
13601where
13602 C: common::Connector,
13603{
13604 /// Perform the operation you have build so far.
13605 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13606 use std::borrow::Cow;
13607 use std::io::{Read, Seek};
13608
13609 use common::{url::Params, ToParts};
13610 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13611
13612 let mut dd = common::DefaultDelegate;
13613 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13614 dlg.begin(common::MethodInfo {
13615 id: "accesscontextmanager.organizations.gcpUserAccessBindings.patch",
13616 http_method: hyper::Method::PATCH,
13617 });
13618
13619 for &field in ["alt", "name", "updateMask"].iter() {
13620 if self._additional_params.contains_key(field) {
13621 dlg.finished(false);
13622 return Err(common::Error::FieldClash(field));
13623 }
13624 }
13625
13626 let mut params = Params::with_capacity(5 + self._additional_params.len());
13627 params.push("name", self._name);
13628 if let Some(value) = self._update_mask.as_ref() {
13629 params.push("updateMask", value.to_string());
13630 }
13631
13632 params.extend(self._additional_params.iter());
13633
13634 params.push("alt", "json");
13635 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13636 if self._scopes.is_empty() {
13637 self._scopes
13638 .insert(Scope::CloudPlatform.as_ref().to_string());
13639 }
13640
13641 #[allow(clippy::single_element_loop)]
13642 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13643 url = params.uri_replacement(url, param_name, find_this, true);
13644 }
13645 {
13646 let to_remove = ["name"];
13647 params.remove_params(&to_remove);
13648 }
13649
13650 let url = params.parse_with_url(&url);
13651
13652 let mut json_mime_type = mime::APPLICATION_JSON;
13653 let mut request_value_reader = {
13654 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13655 common::remove_json_null_values(&mut value);
13656 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13657 serde_json::to_writer(&mut dst, &value).unwrap();
13658 dst
13659 };
13660 let request_size = request_value_reader
13661 .seek(std::io::SeekFrom::End(0))
13662 .unwrap();
13663 request_value_reader
13664 .seek(std::io::SeekFrom::Start(0))
13665 .unwrap();
13666
13667 loop {
13668 let token = match self
13669 .hub
13670 .auth
13671 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13672 .await
13673 {
13674 Ok(token) => token,
13675 Err(e) => match dlg.token(e) {
13676 Ok(token) => token,
13677 Err(e) => {
13678 dlg.finished(false);
13679 return Err(common::Error::MissingToken(e));
13680 }
13681 },
13682 };
13683 request_value_reader
13684 .seek(std::io::SeekFrom::Start(0))
13685 .unwrap();
13686 let mut req_result = {
13687 let client = &self.hub.client;
13688 dlg.pre_request();
13689 let mut req_builder = hyper::Request::builder()
13690 .method(hyper::Method::PATCH)
13691 .uri(url.as_str())
13692 .header(USER_AGENT, self.hub._user_agent.clone());
13693
13694 if let Some(token) = token.as_ref() {
13695 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13696 }
13697
13698 let request = req_builder
13699 .header(CONTENT_TYPE, json_mime_type.to_string())
13700 .header(CONTENT_LENGTH, request_size as u64)
13701 .body(common::to_body(
13702 request_value_reader.get_ref().clone().into(),
13703 ));
13704
13705 client.request(request.unwrap()).await
13706 };
13707
13708 match req_result {
13709 Err(err) => {
13710 if let common::Retry::After(d) = dlg.http_error(&err) {
13711 sleep(d).await;
13712 continue;
13713 }
13714 dlg.finished(false);
13715 return Err(common::Error::HttpError(err));
13716 }
13717 Ok(res) => {
13718 let (mut parts, body) = res.into_parts();
13719 let mut body = common::Body::new(body);
13720 if !parts.status.is_success() {
13721 let bytes = common::to_bytes(body).await.unwrap_or_default();
13722 let error = serde_json::from_str(&common::to_string(&bytes));
13723 let response = common::to_response(parts, bytes.into());
13724
13725 if let common::Retry::After(d) =
13726 dlg.http_failure(&response, error.as_ref().ok())
13727 {
13728 sleep(d).await;
13729 continue;
13730 }
13731
13732 dlg.finished(false);
13733
13734 return Err(match error {
13735 Ok(value) => common::Error::BadRequest(value),
13736 _ => common::Error::Failure(response),
13737 });
13738 }
13739 let response = {
13740 let bytes = common::to_bytes(body).await.unwrap_or_default();
13741 let encoded = common::to_string(&bytes);
13742 match serde_json::from_str(&encoded) {
13743 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13744 Err(error) => {
13745 dlg.response_json_decode_error(&encoded, &error);
13746 return Err(common::Error::JsonDecodeError(
13747 encoded.to_string(),
13748 error,
13749 ));
13750 }
13751 }
13752 };
13753
13754 dlg.finished(true);
13755 return Ok(response);
13756 }
13757 }
13758 }
13759 }
13760
13761 ///
13762 /// Sets the *request* property to the given value.
13763 ///
13764 /// Even though the property as already been set when instantiating this call,
13765 /// we provide this method for API completeness.
13766 pub fn request(
13767 mut self,
13768 new_value: GcpUserAccessBinding,
13769 ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
13770 self._request = new_value;
13771 self
13772 }
13773 /// Immutable. Assigned by the server during creation. The last segment has an arbitrary length and has only URI unreserved characters (as defined by [RFC 3986 Section 2.3](https://tools.ietf.org/html/rfc3986#section-2.3)). Should not be specified by the client during creation. Example: "organizations/256/gcpUserAccessBindings/b3-BhcX_Ud5N"
13774 ///
13775 /// Sets the *name* path property to the given value.
13776 ///
13777 /// Even though the property as already been set when instantiating this call,
13778 /// we provide this method for API completeness.
13779 pub fn name(mut self, new_value: &str) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
13780 self._name = new_value.to_string();
13781 self
13782 }
13783 /// Required. Only the fields specified in this mask are updated. Because name and group_key cannot be changed, update_mask is required and may only contain the following fields: `access_levels`, `dry_run_access_levels`. update_mask { paths: "access_levels" }
13784 ///
13785 /// Sets the *update mask* query property to the given value.
13786 pub fn update_mask(
13787 mut self,
13788 new_value: common::FieldMask,
13789 ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
13790 self._update_mask = Some(new_value);
13791 self
13792 }
13793 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13794 /// while executing the actual API request.
13795 ///
13796 /// ````text
13797 /// It should be used to handle progress information, and to implement a certain level of resilience.
13798 /// ````
13799 ///
13800 /// Sets the *delegate* property to the given value.
13801 pub fn delegate(
13802 mut self,
13803 new_value: &'a mut dyn common::Delegate,
13804 ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
13805 self._delegate = Some(new_value);
13806 self
13807 }
13808
13809 /// Set any additional parameter of the query string used in the request.
13810 /// It should be used to set parameters which are not yet available through their own
13811 /// setters.
13812 ///
13813 /// Please note that this method must not be used to set any of the known parameters
13814 /// which have their own setter method. If done anyway, the request will fail.
13815 ///
13816 /// # Additional Parameters
13817 ///
13818 /// * *$.xgafv* (query-string) - V1 error format.
13819 /// * *access_token* (query-string) - OAuth access token.
13820 /// * *alt* (query-string) - Data format for response.
13821 /// * *callback* (query-string) - JSONP
13822 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13823 /// * *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.
13824 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13825 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13826 /// * *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.
13827 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13828 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13829 pub fn param<T>(mut self, name: T, value: T) -> OrganizationGcpUserAccessBindingPatchCall<'a, C>
13830 where
13831 T: AsRef<str>,
13832 {
13833 self._additional_params
13834 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13835 self
13836 }
13837
13838 /// Identifies the authorization scope for the method you are building.
13839 ///
13840 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13841 /// [`Scope::CloudPlatform`].
13842 ///
13843 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13844 /// tokens for more than one scope.
13845 ///
13846 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13847 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13848 /// sufficient, a read-write scope will do as well.
13849 pub fn add_scope<St>(mut self, scope: St) -> OrganizationGcpUserAccessBindingPatchCall<'a, C>
13850 where
13851 St: AsRef<str>,
13852 {
13853 self._scopes.insert(String::from(scope.as_ref()));
13854 self
13855 }
13856 /// Identifies the authorization scope(s) for the method you are building.
13857 ///
13858 /// See [`Self::add_scope()`] for details.
13859 pub fn add_scopes<I, St>(
13860 mut self,
13861 scopes: I,
13862 ) -> OrganizationGcpUserAccessBindingPatchCall<'a, C>
13863 where
13864 I: IntoIterator<Item = St>,
13865 St: AsRef<str>,
13866 {
13867 self._scopes
13868 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13869 self
13870 }
13871
13872 /// Removes all scopes, and no default scope will be used either.
13873 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13874 /// for details).
13875 pub fn clear_scopes(mut self) -> OrganizationGcpUserAccessBindingPatchCall<'a, C> {
13876 self._scopes.clear();
13877 self
13878 }
13879}
13880
13881/// Returns a VPC-SC supported service based on the service name.
13882///
13883/// A builder for the *get* method supported by a *service* resource.
13884/// It is not used directly, but through a [`ServiceMethods`] instance.
13885///
13886/// # Example
13887///
13888/// Instantiate a resource method builder
13889///
13890/// ```test_harness,no_run
13891/// # extern crate hyper;
13892/// # extern crate hyper_rustls;
13893/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
13894/// # async fn dox() {
13895/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13896///
13897/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13898/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13899/// # secret,
13900/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13901/// # ).build().await.unwrap();
13902///
13903/// # let client = hyper_util::client::legacy::Client::builder(
13904/// # hyper_util::rt::TokioExecutor::new()
13905/// # )
13906/// # .build(
13907/// # hyper_rustls::HttpsConnectorBuilder::new()
13908/// # .with_native_roots()
13909/// # .unwrap()
13910/// # .https_or_http()
13911/// # .enable_http1()
13912/// # .build()
13913/// # );
13914/// # let mut hub = AccessContextManager::new(client, auth);
13915/// // You can configure optional parameters by calling the respective setters at will, and
13916/// // execute the final call using `doit()`.
13917/// // Values shown here are possibly random and not representative !
13918/// let result = hub.services().get("name")
13919/// .doit().await;
13920/// # }
13921/// ```
13922pub struct ServiceGetCall<'a, C>
13923where
13924 C: 'a,
13925{
13926 hub: &'a AccessContextManager<C>,
13927 _name: String,
13928 _delegate: Option<&'a mut dyn common::Delegate>,
13929 _additional_params: HashMap<String, String>,
13930 _scopes: BTreeSet<String>,
13931}
13932
13933impl<'a, C> common::CallBuilder for ServiceGetCall<'a, C> {}
13934
13935impl<'a, C> ServiceGetCall<'a, C>
13936where
13937 C: common::Connector,
13938{
13939 /// Perform the operation you have build so far.
13940 pub async fn doit(mut self) -> common::Result<(common::Response, SupportedService)> {
13941 use std::borrow::Cow;
13942 use std::io::{Read, Seek};
13943
13944 use common::{url::Params, ToParts};
13945 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13946
13947 let mut dd = common::DefaultDelegate;
13948 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13949 dlg.begin(common::MethodInfo {
13950 id: "accesscontextmanager.services.get",
13951 http_method: hyper::Method::GET,
13952 });
13953
13954 for &field in ["alt", "name"].iter() {
13955 if self._additional_params.contains_key(field) {
13956 dlg.finished(false);
13957 return Err(common::Error::FieldClash(field));
13958 }
13959 }
13960
13961 let mut params = Params::with_capacity(3 + self._additional_params.len());
13962 params.push("name", self._name);
13963
13964 params.extend(self._additional_params.iter());
13965
13966 params.push("alt", "json");
13967 let mut url = self.hub._base_url.clone() + "v1/services/{name}";
13968 if self._scopes.is_empty() {
13969 self._scopes
13970 .insert(Scope::CloudPlatform.as_ref().to_string());
13971 }
13972
13973 #[allow(clippy::single_element_loop)]
13974 for &(find_this, param_name) in [("{name}", "name")].iter() {
13975 url = params.uri_replacement(url, param_name, find_this, false);
13976 }
13977 {
13978 let to_remove = ["name"];
13979 params.remove_params(&to_remove);
13980 }
13981
13982 let url = params.parse_with_url(&url);
13983
13984 loop {
13985 let token = match self
13986 .hub
13987 .auth
13988 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13989 .await
13990 {
13991 Ok(token) => token,
13992 Err(e) => match dlg.token(e) {
13993 Ok(token) => token,
13994 Err(e) => {
13995 dlg.finished(false);
13996 return Err(common::Error::MissingToken(e));
13997 }
13998 },
13999 };
14000 let mut req_result = {
14001 let client = &self.hub.client;
14002 dlg.pre_request();
14003 let mut req_builder = hyper::Request::builder()
14004 .method(hyper::Method::GET)
14005 .uri(url.as_str())
14006 .header(USER_AGENT, self.hub._user_agent.clone());
14007
14008 if let Some(token) = token.as_ref() {
14009 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14010 }
14011
14012 let request = req_builder
14013 .header(CONTENT_LENGTH, 0_u64)
14014 .body(common::to_body::<String>(None));
14015
14016 client.request(request.unwrap()).await
14017 };
14018
14019 match req_result {
14020 Err(err) => {
14021 if let common::Retry::After(d) = dlg.http_error(&err) {
14022 sleep(d).await;
14023 continue;
14024 }
14025 dlg.finished(false);
14026 return Err(common::Error::HttpError(err));
14027 }
14028 Ok(res) => {
14029 let (mut parts, body) = res.into_parts();
14030 let mut body = common::Body::new(body);
14031 if !parts.status.is_success() {
14032 let bytes = common::to_bytes(body).await.unwrap_or_default();
14033 let error = serde_json::from_str(&common::to_string(&bytes));
14034 let response = common::to_response(parts, bytes.into());
14035
14036 if let common::Retry::After(d) =
14037 dlg.http_failure(&response, error.as_ref().ok())
14038 {
14039 sleep(d).await;
14040 continue;
14041 }
14042
14043 dlg.finished(false);
14044
14045 return Err(match error {
14046 Ok(value) => common::Error::BadRequest(value),
14047 _ => common::Error::Failure(response),
14048 });
14049 }
14050 let response = {
14051 let bytes = common::to_bytes(body).await.unwrap_or_default();
14052 let encoded = common::to_string(&bytes);
14053 match serde_json::from_str(&encoded) {
14054 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14055 Err(error) => {
14056 dlg.response_json_decode_error(&encoded, &error);
14057 return Err(common::Error::JsonDecodeError(
14058 encoded.to_string(),
14059 error,
14060 ));
14061 }
14062 }
14063 };
14064
14065 dlg.finished(true);
14066 return Ok(response);
14067 }
14068 }
14069 }
14070 }
14071
14072 /// The name of the service to get information about. The names must be in the same format as used in defining a service perimeter, for example, `storage.googleapis.com`.
14073 ///
14074 /// Sets the *name* path property to the given value.
14075 ///
14076 /// Even though the property as already been set when instantiating this call,
14077 /// we provide this method for API completeness.
14078 pub fn name(mut self, new_value: &str) -> ServiceGetCall<'a, C> {
14079 self._name = new_value.to_string();
14080 self
14081 }
14082 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14083 /// while executing the actual API request.
14084 ///
14085 /// ````text
14086 /// It should be used to handle progress information, and to implement a certain level of resilience.
14087 /// ````
14088 ///
14089 /// Sets the *delegate* property to the given value.
14090 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceGetCall<'a, C> {
14091 self._delegate = Some(new_value);
14092 self
14093 }
14094
14095 /// Set any additional parameter of the query string used in the request.
14096 /// It should be used to set parameters which are not yet available through their own
14097 /// setters.
14098 ///
14099 /// Please note that this method must not be used to set any of the known parameters
14100 /// which have their own setter method. If done anyway, the request will fail.
14101 ///
14102 /// # Additional Parameters
14103 ///
14104 /// * *$.xgafv* (query-string) - V1 error format.
14105 /// * *access_token* (query-string) - OAuth access token.
14106 /// * *alt* (query-string) - Data format for response.
14107 /// * *callback* (query-string) - JSONP
14108 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14109 /// * *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.
14110 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14111 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14112 /// * *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.
14113 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14114 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14115 pub fn param<T>(mut self, name: T, value: T) -> ServiceGetCall<'a, C>
14116 where
14117 T: AsRef<str>,
14118 {
14119 self._additional_params
14120 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14121 self
14122 }
14123
14124 /// Identifies the authorization scope for the method you are building.
14125 ///
14126 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14127 /// [`Scope::CloudPlatform`].
14128 ///
14129 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14130 /// tokens for more than one scope.
14131 ///
14132 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14133 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14134 /// sufficient, a read-write scope will do as well.
14135 pub fn add_scope<St>(mut self, scope: St) -> ServiceGetCall<'a, C>
14136 where
14137 St: AsRef<str>,
14138 {
14139 self._scopes.insert(String::from(scope.as_ref()));
14140 self
14141 }
14142 /// Identifies the authorization scope(s) for the method you are building.
14143 ///
14144 /// See [`Self::add_scope()`] for details.
14145 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceGetCall<'a, C>
14146 where
14147 I: IntoIterator<Item = St>,
14148 St: AsRef<str>,
14149 {
14150 self._scopes
14151 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14152 self
14153 }
14154
14155 /// Removes all scopes, and no default scope will be used either.
14156 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14157 /// for details).
14158 pub fn clear_scopes(mut self) -> ServiceGetCall<'a, C> {
14159 self._scopes.clear();
14160 self
14161 }
14162}
14163
14164/// Lists all VPC-SC supported services.
14165///
14166/// A builder for the *list* method supported by a *service* resource.
14167/// It is not used directly, but through a [`ServiceMethods`] instance.
14168///
14169/// # Example
14170///
14171/// Instantiate a resource method builder
14172///
14173/// ```test_harness,no_run
14174/// # extern crate hyper;
14175/// # extern crate hyper_rustls;
14176/// # extern crate google_accesscontextmanager1 as accesscontextmanager1;
14177/// # async fn dox() {
14178/// # use accesscontextmanager1::{AccessContextManager, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14179///
14180/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14181/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14182/// # secret,
14183/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14184/// # ).build().await.unwrap();
14185///
14186/// # let client = hyper_util::client::legacy::Client::builder(
14187/// # hyper_util::rt::TokioExecutor::new()
14188/// # )
14189/// # .build(
14190/// # hyper_rustls::HttpsConnectorBuilder::new()
14191/// # .with_native_roots()
14192/// # .unwrap()
14193/// # .https_or_http()
14194/// # .enable_http1()
14195/// # .build()
14196/// # );
14197/// # let mut hub = AccessContextManager::new(client, auth);
14198/// // You can configure optional parameters by calling the respective setters at will, and
14199/// // execute the final call using `doit()`.
14200/// // Values shown here are possibly random and not representative !
14201/// let result = hub.services().list()
14202/// .page_token("duo")
14203/// .page_size(-76)
14204/// .doit().await;
14205/// # }
14206/// ```
14207pub struct ServiceListCall<'a, C>
14208where
14209 C: 'a,
14210{
14211 hub: &'a AccessContextManager<C>,
14212 _page_token: Option<String>,
14213 _page_size: Option<i32>,
14214 _delegate: Option<&'a mut dyn common::Delegate>,
14215 _additional_params: HashMap<String, String>,
14216 _scopes: BTreeSet<String>,
14217}
14218
14219impl<'a, C> common::CallBuilder for ServiceListCall<'a, C> {}
14220
14221impl<'a, C> ServiceListCall<'a, C>
14222where
14223 C: common::Connector,
14224{
14225 /// Perform the operation you have build so far.
14226 pub async fn doit(
14227 mut self,
14228 ) -> common::Result<(common::Response, ListSupportedServicesResponse)> {
14229 use std::borrow::Cow;
14230 use std::io::{Read, Seek};
14231
14232 use common::{url::Params, ToParts};
14233 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14234
14235 let mut dd = common::DefaultDelegate;
14236 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14237 dlg.begin(common::MethodInfo {
14238 id: "accesscontextmanager.services.list",
14239 http_method: hyper::Method::GET,
14240 });
14241
14242 for &field in ["alt", "pageToken", "pageSize"].iter() {
14243 if self._additional_params.contains_key(field) {
14244 dlg.finished(false);
14245 return Err(common::Error::FieldClash(field));
14246 }
14247 }
14248
14249 let mut params = Params::with_capacity(4 + self._additional_params.len());
14250 if let Some(value) = self._page_token.as_ref() {
14251 params.push("pageToken", value);
14252 }
14253 if let Some(value) = self._page_size.as_ref() {
14254 params.push("pageSize", value.to_string());
14255 }
14256
14257 params.extend(self._additional_params.iter());
14258
14259 params.push("alt", "json");
14260 let mut url = self.hub._base_url.clone() + "v1/services";
14261 if self._scopes.is_empty() {
14262 self._scopes
14263 .insert(Scope::CloudPlatform.as_ref().to_string());
14264 }
14265
14266 let url = params.parse_with_url(&url);
14267
14268 loop {
14269 let token = match self
14270 .hub
14271 .auth
14272 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14273 .await
14274 {
14275 Ok(token) => token,
14276 Err(e) => match dlg.token(e) {
14277 Ok(token) => token,
14278 Err(e) => {
14279 dlg.finished(false);
14280 return Err(common::Error::MissingToken(e));
14281 }
14282 },
14283 };
14284 let mut req_result = {
14285 let client = &self.hub.client;
14286 dlg.pre_request();
14287 let mut req_builder = hyper::Request::builder()
14288 .method(hyper::Method::GET)
14289 .uri(url.as_str())
14290 .header(USER_AGENT, self.hub._user_agent.clone());
14291
14292 if let Some(token) = token.as_ref() {
14293 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14294 }
14295
14296 let request = req_builder
14297 .header(CONTENT_LENGTH, 0_u64)
14298 .body(common::to_body::<String>(None));
14299
14300 client.request(request.unwrap()).await
14301 };
14302
14303 match req_result {
14304 Err(err) => {
14305 if let common::Retry::After(d) = dlg.http_error(&err) {
14306 sleep(d).await;
14307 continue;
14308 }
14309 dlg.finished(false);
14310 return Err(common::Error::HttpError(err));
14311 }
14312 Ok(res) => {
14313 let (mut parts, body) = res.into_parts();
14314 let mut body = common::Body::new(body);
14315 if !parts.status.is_success() {
14316 let bytes = common::to_bytes(body).await.unwrap_or_default();
14317 let error = serde_json::from_str(&common::to_string(&bytes));
14318 let response = common::to_response(parts, bytes.into());
14319
14320 if let common::Retry::After(d) =
14321 dlg.http_failure(&response, error.as_ref().ok())
14322 {
14323 sleep(d).await;
14324 continue;
14325 }
14326
14327 dlg.finished(false);
14328
14329 return Err(match error {
14330 Ok(value) => common::Error::BadRequest(value),
14331 _ => common::Error::Failure(response),
14332 });
14333 }
14334 let response = {
14335 let bytes = common::to_bytes(body).await.unwrap_or_default();
14336 let encoded = common::to_string(&bytes);
14337 match serde_json::from_str(&encoded) {
14338 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14339 Err(error) => {
14340 dlg.response_json_decode_error(&encoded, &error);
14341 return Err(common::Error::JsonDecodeError(
14342 encoded.to_string(),
14343 error,
14344 ));
14345 }
14346 }
14347 };
14348
14349 dlg.finished(true);
14350 return Ok(response);
14351 }
14352 }
14353 }
14354 }
14355
14356 /// Token to start on a later page. Default is the first page.
14357 ///
14358 /// Sets the *page token* query property to the given value.
14359 pub fn page_token(mut self, new_value: &str) -> ServiceListCall<'a, C> {
14360 self._page_token = Some(new_value.to_string());
14361 self
14362 }
14363 /// This flag specifies the maximum number of services to return per page. Default is 100.
14364 ///
14365 /// Sets the *page size* query property to the given value.
14366 pub fn page_size(mut self, new_value: i32) -> ServiceListCall<'a, C> {
14367 self._page_size = Some(new_value);
14368 self
14369 }
14370 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14371 /// while executing the actual API request.
14372 ///
14373 /// ````text
14374 /// It should be used to handle progress information, and to implement a certain level of resilience.
14375 /// ````
14376 ///
14377 /// Sets the *delegate* property to the given value.
14378 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ServiceListCall<'a, C> {
14379 self._delegate = Some(new_value);
14380 self
14381 }
14382
14383 /// Set any additional parameter of the query string used in the request.
14384 /// It should be used to set parameters which are not yet available through their own
14385 /// setters.
14386 ///
14387 /// Please note that this method must not be used to set any of the known parameters
14388 /// which have their own setter method. If done anyway, the request will fail.
14389 ///
14390 /// # Additional Parameters
14391 ///
14392 /// * *$.xgafv* (query-string) - V1 error format.
14393 /// * *access_token* (query-string) - OAuth access token.
14394 /// * *alt* (query-string) - Data format for response.
14395 /// * *callback* (query-string) - JSONP
14396 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14397 /// * *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.
14398 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14399 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14400 /// * *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.
14401 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14402 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14403 pub fn param<T>(mut self, name: T, value: T) -> ServiceListCall<'a, C>
14404 where
14405 T: AsRef<str>,
14406 {
14407 self._additional_params
14408 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14409 self
14410 }
14411
14412 /// Identifies the authorization scope for the method you are building.
14413 ///
14414 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14415 /// [`Scope::CloudPlatform`].
14416 ///
14417 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14418 /// tokens for more than one scope.
14419 ///
14420 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14421 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14422 /// sufficient, a read-write scope will do as well.
14423 pub fn add_scope<St>(mut self, scope: St) -> ServiceListCall<'a, C>
14424 where
14425 St: AsRef<str>,
14426 {
14427 self._scopes.insert(String::from(scope.as_ref()));
14428 self
14429 }
14430 /// Identifies the authorization scope(s) for the method you are building.
14431 ///
14432 /// See [`Self::add_scope()`] for details.
14433 pub fn add_scopes<I, St>(mut self, scopes: I) -> ServiceListCall<'a, C>
14434 where
14435 I: IntoIterator<Item = St>,
14436 St: AsRef<str>,
14437 {
14438 self._scopes
14439 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14440 self
14441 }
14442
14443 /// Removes all scopes, and no default scope will be used either.
14444 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14445 /// for details).
14446 pub fn clear_scopes(mut self) -> ServiceListCall<'a, C> {
14447 self._scopes.clear();
14448 self
14449 }
14450}