google_assuredworkloads1/
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 Assuredworkloads 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_assuredworkloads1 as assuredworkloads1;
49/// use assuredworkloads1::api::GoogleCloudAssuredworkloadsV1Workload;
50/// use assuredworkloads1::{Result, Error};
51/// # async fn dox() {
52/// use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace  `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63///     .with_native_roots()
64///     .unwrap()
65///     .https_only()
66///     .enable_http2()
67///     .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71///     secret,
72///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73///     yup_oauth2::client::CustomHyperClientBuilder::from(
74///         hyper_util::client::legacy::Client::builder(executor).build(connector),
75///     ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79///     hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82///     hyper_rustls::HttpsConnectorBuilder::new()
83///         .with_native_roots()
84///         .unwrap()
85///         .https_or_http()
86///         .enable_http2()
87///         .build()
88/// );
89/// let mut hub = Assuredworkloads::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GoogleCloudAssuredworkloadsV1Workload::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.organizations().locations_workloads_create(req, "parent")
99///              .external_id("At")
100///              .doit().await;
101///
102/// match result {
103///     Err(e) => match e {
104///         // The Error enum provides details about what exactly happened.
105///         // You can also just use its `Debug`, `Display` or `Error` traits
106///          Error::HttpError(_)
107///         |Error::Io(_)
108///         |Error::MissingAPIKey
109///         |Error::MissingToken(_)
110///         |Error::Cancelled
111///         |Error::UploadSizeLimitExceeded(_, _)
112///         |Error::Failure(_)
113///         |Error::BadRequest(_)
114///         |Error::FieldClash(_)
115///         |Error::JsonDecodeError(_, _) => println!("{}", e),
116///     },
117///     Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct Assuredworkloads<C> {
123    pub client: common::Client<C>,
124    pub auth: Box<dyn common::GetToken>,
125    _user_agent: String,
126    _base_url: String,
127    _root_url: String,
128}
129
130impl<C> common::Hub for Assuredworkloads<C> {}
131
132impl<'a, C> Assuredworkloads<C> {
133    pub fn new<A: 'static + common::GetToken>(
134        client: common::Client<C>,
135        auth: A,
136    ) -> Assuredworkloads<C> {
137        Assuredworkloads {
138            client,
139            auth: Box::new(auth),
140            _user_agent: "google-api-rust-client/7.0.0".to_string(),
141            _base_url: "https://assuredworkloads.googleapis.com/".to_string(),
142            _root_url: "https://assuredworkloads.googleapis.com/".to_string(),
143        }
144    }
145
146    pub fn organizations(&'a self) -> OrganizationMethods<'a, C> {
147        OrganizationMethods { hub: self }
148    }
149
150    /// Set the user-agent header field to use in all requests to the server.
151    /// It defaults to `google-api-rust-client/7.0.0`.
152    ///
153    /// Returns the previously set user-agent.
154    pub fn user_agent(&mut self, agent_name: String) -> String {
155        std::mem::replace(&mut self._user_agent, agent_name)
156    }
157
158    /// Set the base url to use in all requests to the server.
159    /// It defaults to `https://assuredworkloads.googleapis.com/`.
160    ///
161    /// Returns the previously set base url.
162    pub fn base_url(&mut self, new_base_url: String) -> String {
163        std::mem::replace(&mut self._base_url, new_base_url)
164    }
165
166    /// Set the root url to use in all requests to the server.
167    /// It defaults to `https://assuredworkloads.googleapis.com/`.
168    ///
169    /// Returns the previously set root url.
170    pub fn root_url(&mut self, new_root_url: String) -> String {
171        std::mem::replace(&mut self._root_url, new_root_url)
172    }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// Request for acknowledging the violation
179///
180/// # Activities
181///
182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
184///
185/// * [locations workloads violations acknowledge organizations](OrganizationLocationWorkloadViolationAcknowledgeCall) (request)
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct GoogleCloudAssuredworkloadsV1AcknowledgeViolationRequest {
190    /// Optional. Acknowledge type of specified violation.
191    #[serde(rename = "acknowledgeType")]
192    pub acknowledge_type: Option<String>,
193    /// Required. Business justification explaining the need for violation acknowledgement
194    pub comment: Option<String>,
195    /// Optional. This field is deprecated and will be removed in future version of the API. Name of the OrgPolicy which was modified with non-compliant change and resulted in this violation. Format: projects/{project_number}/policies/{constraint_name} folders/{folder_id}/policies/{constraint_name} organizations/{organization_id}/policies/{constraint_name}
196    #[serde(rename = "nonCompliantOrgPolicy")]
197    pub non_compliant_org_policy: Option<String>,
198}
199
200impl common::RequestValue for GoogleCloudAssuredworkloadsV1AcknowledgeViolationRequest {}
201
202/// Response for violation acknowledgement
203///
204/// # Activities
205///
206/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
207/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
208///
209/// * [locations workloads violations acknowledge organizations](OrganizationLocationWorkloadViolationAcknowledgeCall) (response)
210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
211#[serde_with::serde_as]
212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
213pub struct GoogleCloudAssuredworkloadsV1AcknowledgeViolationResponse {
214    _never_set: Option<bool>,
215}
216
217impl common::ResponseResult for GoogleCloudAssuredworkloadsV1AcknowledgeViolationResponse {}
218
219/// Response containing the analysis results for the hypothetical resource move.
220///
221/// # Activities
222///
223/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
224/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
225///
226/// * [locations workloads analyze workload move organizations](OrganizationLocationWorkloadAnalyzeWorkloadMoveCall) (response)
227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
228#[serde_with::serde_as]
229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
230pub struct GoogleCloudAssuredworkloadsV1AnalyzeWorkloadMoveResponse {
231    /// List of analysis results for each asset in scope.
232    #[serde(rename = "assetMoveAnalyses")]
233    pub asset_move_analyses: Option<Vec<GoogleCloudAssuredworkloadsV1AssetMoveAnalysis>>,
234    /// The next page token. Is empty if the last page is reached.
235    #[serde(rename = "nextPageToken")]
236    pub next_page_token: Option<String>,
237}
238
239impl common::ResponseResult for GoogleCloudAssuredworkloadsV1AnalyzeWorkloadMoveResponse {}
240
241/// Request to apply update to a workload.
242///
243/// # Activities
244///
245/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
246/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
247///
248/// * [locations workloads updates apply organizations](OrganizationLocationWorkloadUpdateApplyCall) (request)
249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
250#[serde_with::serde_as]
251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
252pub struct GoogleCloudAssuredworkloadsV1ApplyWorkloadUpdateRequest {
253    /// The action to be performed on the update.
254    pub action: Option<String>,
255}
256
257impl common::RequestValue for GoogleCloudAssuredworkloadsV1ApplyWorkloadUpdateRequest {}
258
259/// Represents move analysis results for an asset.
260///
261/// This type is not used in any activity, and only used as *part* of another schema.
262///
263#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
264#[serde_with::serde_as]
265#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
266pub struct GoogleCloudAssuredworkloadsV1AssetMoveAnalysis {
267    /// List of eligible analyses performed for the asset.
268    #[serde(rename = "analysisGroups")]
269    pub analysis_groups: Option<Vec<GoogleCloudAssuredworkloadsV1MoveAnalysisGroup>>,
270    /// The full resource name of the asset being analyzed. Example: //compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1
271    pub asset: Option<String>,
272    /// Type of the asset being analyzed. Possible values will be among the ones listed [here](https://cloud.google.com/asset-inventory/docs/supported-asset-types).
273    #[serde(rename = "assetType")]
274    pub asset_type: Option<String>,
275}
276
277impl common::Part for GoogleCloudAssuredworkloadsV1AssetMoveAnalysis {}
278
279/// Response for EnableComplianceUpdates endpoint.
280///
281/// # Activities
282///
283/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
284/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
285///
286/// * [locations workloads enable compliance updates organizations](OrganizationLocationWorkloadEnableComplianceUpdateCall) (response)
287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
288#[serde_with::serde_as]
289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
290pub struct GoogleCloudAssuredworkloadsV1EnableComplianceUpdatesResponse {
291    _never_set: Option<bool>,
292}
293
294impl common::ResponseResult for GoogleCloudAssuredworkloadsV1EnableComplianceUpdatesResponse {}
295
296/// Response for EnableResourceMonitoring endpoint.
297///
298/// # Activities
299///
300/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
301/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
302///
303/// * [locations workloads enable resource monitoring organizations](OrganizationLocationWorkloadEnableResourceMonitoringCall) (response)
304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
305#[serde_with::serde_as]
306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
307pub struct GoogleCloudAssuredworkloadsV1EnableResourceMonitoringResponse {
308    _never_set: Option<bool>,
309}
310
311impl common::ResponseResult for GoogleCloudAssuredworkloadsV1EnableResourceMonitoringResponse {}
312
313/// Response of ListViolations endpoint.
314///
315/// # Activities
316///
317/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
318/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
319///
320/// * [locations workloads violations list organizations](OrganizationLocationWorkloadViolationListCall) (response)
321#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
322#[serde_with::serde_as]
323#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
324pub struct GoogleCloudAssuredworkloadsV1ListViolationsResponse {
325    /// The next page token. Returns empty if reached the last page.
326    #[serde(rename = "nextPageToken")]
327    pub next_page_token: Option<String>,
328    /// List of Violations under a Workload.
329    pub violations: Option<Vec<GoogleCloudAssuredworkloadsV1Violation>>,
330}
331
332impl common::ResponseResult for GoogleCloudAssuredworkloadsV1ListViolationsResponse {}
333
334/// Response of listing the compliance updates per workload with pagination.
335///
336/// # Activities
337///
338/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
339/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
340///
341/// * [locations workloads updates list organizations](OrganizationLocationWorkloadUpdateListCall) (response)
342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
343#[serde_with::serde_as]
344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
345pub struct GoogleCloudAssuredworkloadsV1ListWorkloadUpdatesResponse {
346    /// The next page token. Return empty if reached the last page.
347    #[serde(rename = "nextPageToken")]
348    pub next_page_token: Option<String>,
349    /// The list of workload updates for a given workload.
350    #[serde(rename = "workloadUpdates")]
351    pub workload_updates: Option<Vec<GoogleCloudAssuredworkloadsV1WorkloadUpdate>>,
352}
353
354impl common::ResponseResult for GoogleCloudAssuredworkloadsV1ListWorkloadUpdatesResponse {}
355
356/// Response of ListWorkloads endpoint.
357///
358/// # Activities
359///
360/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
361/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
362///
363/// * [locations workloads list organizations](OrganizationLocationWorkloadListCall) (response)
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct GoogleCloudAssuredworkloadsV1ListWorkloadsResponse {
368    /// The next page token. Return empty if reached the last page.
369    #[serde(rename = "nextPageToken")]
370    pub next_page_token: Option<String>,
371    /// List of Workloads under a given parent.
372    pub workloads: Option<Vec<GoogleCloudAssuredworkloadsV1Workload>>,
373}
374
375impl common::ResponseResult for GoogleCloudAssuredworkloadsV1ListWorkloadsResponse {}
376
377/// Represents a logical group of checks performed for an asset. If successful, the group contains the analysis result, otherwise it contains an error with the failure reason.
378///
379/// This type is not used in any activity, and only used as *part* of another schema.
380///
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct GoogleCloudAssuredworkloadsV1MoveAnalysisGroup {
385    /// Result of a successful analysis.
386    #[serde(rename = "analysisResult")]
387    pub analysis_result: Option<GoogleCloudAssuredworkloadsV1MoveAnalysisResult>,
388    /// Name of the analysis group.
389    #[serde(rename = "displayName")]
390    pub display_name: Option<String>,
391    /// Error details for a failed analysis.
392    pub error: Option<GoogleRpcStatus>,
393}
394
395impl common::Part for GoogleCloudAssuredworkloadsV1MoveAnalysisGroup {}
396
397/// Represents the successful move analysis results for a group.
398///
399/// This type is not used in any activity, and only used as *part* of another schema.
400///
401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
402#[serde_with::serde_as]
403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
404pub struct GoogleCloudAssuredworkloadsV1MoveAnalysisResult {
405    /// List of blockers. If not resolved, these will result in compliance violations in the target.
406    pub blockers: Option<Vec<GoogleCloudAssuredworkloadsV1MoveImpact>>,
407    /// List of warnings. These are risks that may or may not result in compliance violations.
408    pub warnings: Option<Vec<GoogleCloudAssuredworkloadsV1MoveImpact>>,
409}
410
411impl common::Part for GoogleCloudAssuredworkloadsV1MoveAnalysisResult {}
412
413/// Represents the impact of moving the asset to the target.
414///
415/// This type is not used in any activity, and only used as *part* of another schema.
416///
417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
418#[serde_with::serde_as]
419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
420pub struct GoogleCloudAssuredworkloadsV1MoveImpact {
421    /// Explanation of the impact.
422    pub detail: Option<String>,
423}
424
425impl common::Part for GoogleCloudAssuredworkloadsV1MoveImpact {}
426
427/// Request for updating permission settings for a partner workload.
428///
429/// # Activities
430///
431/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
432/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
433///
434/// * [locations workloads mutate partner permissions organizations](OrganizationLocationWorkloadMutatePartnerPermissionCall) (request)
435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
436#[serde_with::serde_as]
437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
438pub struct GoogleCloudAssuredworkloadsV1MutatePartnerPermissionsRequest {
439    /// Optional. The etag of the workload. If this is provided, it must match the server's etag.
440    pub etag: Option<String>,
441    /// Required. The partner permissions to be updated.
442    #[serde(rename = "partnerPermissions")]
443    pub partner_permissions: Option<GoogleCloudAssuredworkloadsV1WorkloadPartnerPermissions>,
444    /// Required. The list of fields to be updated. E.g. update_mask { paths: "partner_permissions.data_logs_viewer"}
445    #[serde(rename = "updateMask")]
446    pub update_mask: Option<common::FieldMask>,
447}
448
449impl common::RequestValue for GoogleCloudAssuredworkloadsV1MutatePartnerPermissionsRequest {}
450
451/// This assured workload service object is used to represent the org policy attached to a resource. It servces the same purpose as the orgpolicy.v2.Policy object but with functionality that is limited to what is supported by Assured Workloads(e.g. only one rule under one OrgPolicy object, no conditions, etc).
452///
453/// This type is not used in any activity, and only used as *part* of another schema.
454///
455#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
456#[serde_with::serde_as]
457#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
458pub struct GoogleCloudAssuredworkloadsV1OrgPolicy {
459    /// The constraint name of the OrgPolicy. e.g. "constraints/gcp.resourceLocations".
460    pub constraint: Option<String>,
461    /// If `inherit` is true, policy rules of the lowest ancestor in the resource hierarchy chain are inherited. If it is false, policy rules are not inherited.
462    pub inherit: Option<bool>,
463    /// Ignores policies set above this resource and restores to the `constraint_default` value. `reset` can only be true when `rules` is empty and `inherit` is false.
464    pub reset: Option<bool>,
465    /// Resource that the OrgPolicy attaches to. Format: folders/123" projects/123".
466    pub resource: Option<String>,
467    /// The rule of the OrgPolicy.
468    pub rule: Option<GoogleCloudAssuredworkloadsV1OrgPolicyPolicyRule>,
469}
470
471impl common::Part for GoogleCloudAssuredworkloadsV1OrgPolicy {}
472
473/// A rule used to express this policy.
474///
475/// This type is not used in any activity, and only used as *part* of another schema.
476///
477#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
478#[serde_with::serde_as]
479#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
480pub struct GoogleCloudAssuredworkloadsV1OrgPolicyPolicyRule {
481    /// ListPolicy only when all values are allowed.
482    #[serde(rename = "allowAll")]
483    pub allow_all: Option<bool>,
484    /// ListPolicy only when all values are denied.
485    #[serde(rename = "denyAll")]
486    pub deny_all: Option<bool>,
487    /// BooleanPolicy only.
488    pub enforce: Option<bool>,
489    /// ListPolicy only when custom values are specified.
490    pub values: Option<GoogleCloudAssuredworkloadsV1OrgPolicyPolicyRuleStringValues>,
491}
492
493impl common::Part for GoogleCloudAssuredworkloadsV1OrgPolicyPolicyRule {}
494
495/// The values allowed for a ListPolicy.
496///
497/// This type is not used in any activity, and only used as *part* of another schema.
498///
499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
500#[serde_with::serde_as]
501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
502pub struct GoogleCloudAssuredworkloadsV1OrgPolicyPolicyRuleStringValues {
503    /// List of values allowed at this resource.
504    #[serde(rename = "allowedValues")]
505    pub allowed_values: Option<Vec<String>>,
506    /// List of values denied at this resource.
507    #[serde(rename = "deniedValues")]
508    pub denied_values: Option<Vec<String>>,
509}
510
511impl common::Part for GoogleCloudAssuredworkloadsV1OrgPolicyPolicyRuleStringValues {}
512
513/// Represents an update for an org policy control applied on an Assured Workload resource. The inherited org policy is not considered.
514///
515/// This type is not used in any activity, and only used as *part* of another schema.
516///
517#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
518#[serde_with::serde_as]
519#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
520pub struct GoogleCloudAssuredworkloadsV1OrgPolicyUpdate {
521    /// The org policy currently applied on the assured workload resource.
522    #[serde(rename = "appliedPolicy")]
523    pub applied_policy: Option<GoogleCloudAssuredworkloadsV1OrgPolicy>,
524    /// The suggested org policy that replaces the applied policy.
525    #[serde(rename = "suggestedPolicy")]
526    pub suggested_policy: Option<GoogleCloudAssuredworkloadsV1OrgPolicy>,
527}
528
529impl common::Part for GoogleCloudAssuredworkloadsV1OrgPolicyUpdate {}
530
531/// Request for restricting list of available resources in Workload environment.
532///
533/// # Activities
534///
535/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
536/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
537///
538/// * [locations workloads restrict allowed resources organizations](OrganizationLocationWorkloadRestrictAllowedResourceCall) (request)
539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
540#[serde_with::serde_as]
541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
542pub struct GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesRequest {
543    /// Required. The type of restriction for using gcp products in the Workload environment.
544    #[serde(rename = "restrictionType")]
545    pub restriction_type: Option<String>,
546}
547
548impl common::RequestValue for GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesRequest {}
549
550/// Response for restricting the list of allowed resources.
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/// * [locations workloads restrict allowed resources organizations](OrganizationLocationWorkloadRestrictAllowedResourceCall) (response)
558#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
559#[serde_with::serde_as]
560#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
561pub struct GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesResponse {
562    _never_set: Option<bool>,
563}
564
565impl common::ResponseResult for GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesResponse {}
566
567/// The details of the update.
568///
569/// This type is not used in any activity, and only used as *part* of another schema.
570///
571#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
572#[serde_with::serde_as]
573#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
574pub struct GoogleCloudAssuredworkloadsV1UpdateDetails {
575    /// Update to one org policy, e.g. gcp.resourceLocation.
576    #[serde(rename = "orgPolicyUpdate")]
577    pub org_policy_update: Option<GoogleCloudAssuredworkloadsV1OrgPolicyUpdate>,
578}
579
580impl common::Part for GoogleCloudAssuredworkloadsV1UpdateDetails {}
581
582/// Workload monitoring Violation.
583///
584/// # Activities
585///
586/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
587/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
588///
589/// * [locations workloads violations get organizations](OrganizationLocationWorkloadViolationGetCall) (response)
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct GoogleCloudAssuredworkloadsV1Violation {
594    /// A boolean that indicates if the violation is acknowledged
595    pub acknowledged: Option<bool>,
596    /// Optional. Timestamp when this violation was acknowledged first. Check exception_contexts to find the last time the violation was acknowledged when there are more than one violations. This field will be absent when acknowledged field is marked as false.
597    #[serde(rename = "acknowledgementTime")]
598    pub acknowledgement_time: Option<chrono::DateTime<chrono::offset::Utc>>,
599    /// Optional. Output only. Violation Id of the org-policy violation due to which the resource violation is caused. Empty for org-policy violations.
600    #[serde(rename = "associatedOrgPolicyViolationId")]
601    pub associated_org_policy_violation_id: Option<String>,
602    /// Output only. Immutable. Audit Log Link for violated resource Format: https://console.cloud.google.com/logs/query;query={logName}{protoPayload.resourceName}{timeRange}{folder}
603    #[serde(rename = "auditLogLink")]
604    pub audit_log_link: Option<String>,
605    /// Output only. Time of the event which triggered the Violation.
606    #[serde(rename = "beginTime")]
607    pub begin_time: Option<chrono::DateTime<chrono::offset::Utc>>,
608    /// Output only. Category under which this violation is mapped. e.g. Location, Service Usage, Access, Encryption, etc.
609    pub category: Option<String>,
610    /// Output only. Description for the Violation. e.g. OrgPolicy gcp.resourceLocations has non compliant value.
611    pub description: Option<String>,
612    /// Output only. Immutable. Audit Log link to find business justification provided for violation exception. Format: https://console.cloud.google.com/logs/query;query={logName}{protoPayload.resourceName}{protoPayload.methodName}{timeRange}{organization}
613    #[serde(rename = "exceptionAuditLogLink")]
614    pub exception_audit_log_link: Option<String>,
615    /// Output only. List of all the exception detail added for the violation.
616    #[serde(rename = "exceptionContexts")]
617    pub exception_contexts: Option<Vec<GoogleCloudAssuredworkloadsV1ViolationExceptionContext>>,
618    /// Output only. Immutable. Name of the Violation. Format: organizations/{organization}/locations/{location}/workloads/{workload_id}/violations/{violations_id}
619    pub name: Option<String>,
620    /// Output only. Immutable. Name of the OrgPolicy which was modified with non-compliant change and resulted this violation. Format: projects/{project_number}/policies/{constraint_name} folders/{folder_id}/policies/{constraint_name} organizations/{organization_id}/policies/{constraint_name}
621    #[serde(rename = "nonCompliantOrgPolicy")]
622    pub non_compliant_org_policy: Option<String>,
623    /// Output only. Immutable. The org-policy-constraint that was incorrectly changed, which resulted in this violation.
624    #[serde(rename = "orgPolicyConstraint")]
625    pub org_policy_constraint: Option<String>,
626    /// Optional. Output only. Parent project number where resource is present. Empty for org-policy violations.
627    #[serde(rename = "parentProjectNumber")]
628    pub parent_project_number: Option<String>,
629    /// Output only. Compliance violation remediation
630    pub remediation: Option<GoogleCloudAssuredworkloadsV1ViolationRemediation>,
631    /// Output only. Time of the event which fixed the Violation. If the violation is ACTIVE this will be empty.
632    #[serde(rename = "resolveTime")]
633    pub resolve_time: Option<chrono::DateTime<chrono::offset::Utc>>,
634    /// Optional. Output only. Name of the resource like //storage.googleapis.com/myprojectxyz-testbucket. Empty for org-policy violations.
635    #[serde(rename = "resourceName")]
636    pub resource_name: Option<String>,
637    /// Optional. Output only. Type of the resource like compute.googleapis.com/Disk, etc. Empty for org-policy violations.
638    #[serde(rename = "resourceType")]
639    pub resource_type: Option<String>,
640    /// Output only. State of the violation
641    pub state: Option<String>,
642    /// Output only. The last time when the Violation record was updated.
643    #[serde(rename = "updateTime")]
644    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
645    /// Output only. Type of the violation
646    #[serde(rename = "violationType")]
647    pub violation_type: Option<String>,
648}
649
650impl common::ResponseResult for GoogleCloudAssuredworkloadsV1Violation {}
651
652/// Violation exception detail.
653///
654/// This type is not used in any activity, and only used as *part* of another schema.
655///
656#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
657#[serde_with::serde_as]
658#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
659pub struct GoogleCloudAssuredworkloadsV1ViolationExceptionContext {
660    /// Timestamp when the violation was acknowledged.
661    #[serde(rename = "acknowledgementTime")]
662    pub acknowledgement_time: Option<chrono::DateTime<chrono::offset::Utc>>,
663    /// Business justification provided towards the acknowledgement of the violation.
664    pub comment: Option<String>,
665    /// Name of the user (or service account) who acknowledged the violation.
666    #[serde(rename = "userName")]
667    pub user_name: Option<String>,
668}
669
670impl common::Part for GoogleCloudAssuredworkloadsV1ViolationExceptionContext {}
671
672/// Represents remediation guidance to resolve compliance violation for AssuredWorkload
673///
674/// This type is not used in any activity, and only used as *part* of another schema.
675///
676#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
677#[serde_with::serde_as]
678#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
679pub struct GoogleCloudAssuredworkloadsV1ViolationRemediation {
680    /// Values that can resolve the violation For example: for list org policy violations, this will either be the list of allowed or denied values
681    #[serde(rename = "compliantValues")]
682    pub compliant_values: Option<Vec<String>>,
683    /// Required. Remediation instructions to resolve violations
684    pub instructions: Option<GoogleCloudAssuredworkloadsV1ViolationRemediationInstructions>,
685    /// Output only. Reemediation type based on the type of org policy values violated
686    #[serde(rename = "remediationType")]
687    pub remediation_type: Option<String>,
688}
689
690impl common::Part for GoogleCloudAssuredworkloadsV1ViolationRemediation {}
691
692/// Instructions to remediate violation
693///
694/// This type is not used in any activity, and only used as *part* of another schema.
695///
696#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
697#[serde_with::serde_as]
698#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
699pub struct GoogleCloudAssuredworkloadsV1ViolationRemediationInstructions {
700    /// Remediation instructions to resolve violation via cloud console
701    #[serde(rename = "consoleInstructions")]
702    pub console_instructions:
703        Option<GoogleCloudAssuredworkloadsV1ViolationRemediationInstructionsConsole>,
704    /// Remediation instructions to resolve violation via gcloud cli
705    #[serde(rename = "gcloudInstructions")]
706    pub gcloud_instructions:
707        Option<GoogleCloudAssuredworkloadsV1ViolationRemediationInstructionsGcloud>,
708}
709
710impl common::Part for GoogleCloudAssuredworkloadsV1ViolationRemediationInstructions {}
711
712/// Remediation instructions to resolve violation via cloud console
713///
714/// This type is not used in any activity, and only used as *part* of another schema.
715///
716#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
717#[serde_with::serde_as]
718#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
719pub struct GoogleCloudAssuredworkloadsV1ViolationRemediationInstructionsConsole {
720    /// Additional urls for more information about steps
721    #[serde(rename = "additionalLinks")]
722    pub additional_links: Option<Vec<String>>,
723    /// Link to console page where violations can be resolved
724    #[serde(rename = "consoleUris")]
725    pub console_uris: Option<Vec<String>>,
726    /// Steps to resolve violation via cloud console
727    pub steps: Option<Vec<String>>,
728}
729
730impl common::Part for GoogleCloudAssuredworkloadsV1ViolationRemediationInstructionsConsole {}
731
732/// Remediation instructions to resolve violation via gcloud cli
733///
734/// This type is not used in any activity, and only used as *part* of another schema.
735///
736#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
737#[serde_with::serde_as]
738#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
739pub struct GoogleCloudAssuredworkloadsV1ViolationRemediationInstructionsGcloud {
740    /// Additional urls for more information about steps
741    #[serde(rename = "additionalLinks")]
742    pub additional_links: Option<Vec<String>>,
743    /// Gcloud command to resolve violation
744    #[serde(rename = "gcloudCommands")]
745    pub gcloud_commands: Option<Vec<String>>,
746    /// Steps to resolve violation via gcloud cli
747    pub steps: Option<Vec<String>>,
748}
749
750impl common::Part for GoogleCloudAssuredworkloadsV1ViolationRemediationInstructionsGcloud {}
751
752/// A Workload object for managing highly regulated workloads of cloud customers.
753///
754/// # Activities
755///
756/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
757/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
758///
759/// * [locations workloads create organizations](OrganizationLocationWorkloadCreateCall) (request)
760/// * [locations workloads get organizations](OrganizationLocationWorkloadGetCall) (response)
761/// * [locations workloads mutate partner permissions organizations](OrganizationLocationWorkloadMutatePartnerPermissionCall) (response)
762/// * [locations workloads patch organizations](OrganizationLocationWorkloadPatchCall) (request|response)
763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
764#[serde_with::serde_as]
765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
766pub struct GoogleCloudAssuredworkloadsV1Workload {
767    /// Optional. The billing account used for the resources which are direct children of workload. This billing account is initially associated with the resources created as part of Workload creation. After the initial creation of these resources, the customer can change the assigned billing account. The resource name has the form `billingAccounts/{billing_account_id}`. For example, `billingAccounts/012345-567890-ABCDEF`.
768    #[serde(rename = "billingAccount")]
769    pub billing_account: Option<String>,
770    /// Required. Immutable. Compliance Regime associated with this workload.
771    #[serde(rename = "complianceRegime")]
772    pub compliance_regime: Option<String>,
773    /// Output only. Count of active Violations in the Workload.
774    #[serde(rename = "complianceStatus")]
775    pub compliance_status: Option<GoogleCloudAssuredworkloadsV1WorkloadComplianceStatus>,
776    /// Output only. Urls for services which are compliant for this Assured Workload, but which are currently disallowed by the ResourceUsageRestriction org policy. Invoke RestrictAllowedResources endpoint to allow your project developers to use these services in their environment.
777    #[serde(rename = "compliantButDisallowedServices")]
778    pub compliant_but_disallowed_services: Option<Vec<String>>,
779    /// Output only. Immutable. The Workload creation timestamp.
780    #[serde(rename = "createTime")]
781    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
782    /// Required. The user-assigned display name of the Workload. When present it must be between 4 to 30 characters. Allowed characters are: lowercase and uppercase letters, numbers, hyphen, and spaces. Example: My Workload
783    #[serde(rename = "displayName")]
784    pub display_name: Option<String>,
785    /// Output only. Represents the Ekm Provisioning State of the given workload.
786    #[serde(rename = "ekmProvisioningResponse")]
787    pub ekm_provisioning_response:
788        Option<GoogleCloudAssuredworkloadsV1WorkloadEkmProvisioningResponse>,
789    /// Optional. Indicates the sovereignty status of the given workload. Currently meant to be used by Europe/Canada customers.
790    #[serde(rename = "enableSovereignControls")]
791    pub enable_sovereign_controls: Option<bool>,
792    /// Optional. ETag of the workload, it is calculated on the basis of the Workload contents. It will be used in Update & Delete operations.
793    pub etag: Option<String>,
794    /// Output only. Represents the KAJ enrollment state of the given workload.
795    #[serde(rename = "kajEnrollmentState")]
796    pub kaj_enrollment_state: Option<String>,
797    /// Input only. Settings used to create a CMEK crypto key. When set, a project with a KMS CMEK key is provisioned. This field is deprecated as of Feb 28, 2022. In order to create a Keyring, callers should specify, ENCRYPTION_KEYS_PROJECT or KEYRING in ResourceSettings.resource_type field.
798    #[serde(rename = "kmsSettings")]
799    pub kms_settings: Option<GoogleCloudAssuredworkloadsV1WorkloadKMSSettings>,
800    /// Optional. Labels applied to the workload.
801    pub labels: Option<HashMap<String, String>>,
802    /// Optional. The resource name of the workload. Format: organizations/{organization}/locations/{location}/workloads/{workload} Read-only.
803    pub name: Option<String>,
804    /// Optional. Partner regime associated with this workload.
805    pub partner: Option<String>,
806    /// Optional. Permissions granted to the AW Partner SA account for the customer workload
807    #[serde(rename = "partnerPermissions")]
808    pub partner_permissions: Option<GoogleCloudAssuredworkloadsV1WorkloadPartnerPermissions>,
809    /// Optional. Billing account necessary for purchasing services from Sovereign Partners. This field is required for creating SIA/PSN/CNTXT partner workloads. The caller should have 'billing.resourceAssociations.create' IAM permission on this billing-account. The format of this string is billingAccounts/AAAAAA-BBBBBB-CCCCCC
810    #[serde(rename = "partnerServicesBillingAccount")]
811    pub partner_services_billing_account: Option<String>,
812    /// Input only. The parent resource for the resources managed by this Assured Workload. May be either empty or a folder resource which is a child of the Workload parent. If not specified all resources are created under the parent organization. Format: folders/{folder_id}
813    #[serde(rename = "provisionedResourcesParent")]
814    pub provisioned_resources_parent: Option<String>,
815    /// Output only. Indicates whether resource monitoring is enabled for workload or not. It is true when Resource feed is subscribed to AWM topic and AWM Service Agent Role is binded to AW Service Account for resource Assured workload.
816    #[serde(rename = "resourceMonitoringEnabled")]
817    pub resource_monitoring_enabled: Option<bool>,
818    /// Input only. Resource properties that are used to customize workload resources. These properties (such as custom project id) will be used to create workload resources if possible. This field is optional.
819    #[serde(rename = "resourceSettings")]
820    pub resource_settings: Option<Vec<GoogleCloudAssuredworkloadsV1WorkloadResourceSettings>>,
821    /// Output only. The resources associated with this workload. These resources will be created when creating the workload. If any of the projects already exist, the workload creation will fail. Always read only.
822    pub resources: Option<Vec<GoogleCloudAssuredworkloadsV1WorkloadResourceInfo>>,
823    /// Output only. Represents the SAA enrollment response of the given workload. SAA enrollment response is queried during GetWorkload call. In failure cases, user friendly error message is shown in SAA details page.
824    #[serde(rename = "saaEnrollmentResponse")]
825    pub saa_enrollment_response: Option<GoogleCloudAssuredworkloadsV1WorkloadSaaEnrollmentResponse>,
826    /// Optional. Indicates whether the e-mail notification for a violation is enabled for a workload. This value will be by default True, and if not present will be considered as true. This should only be updated via updateWorkload call. Any Changes to this field during the createWorkload call will not be honored. This will always be true while creating the workload.
827    #[serde(rename = "violationNotificationsEnabled")]
828    pub violation_notifications_enabled: Option<bool>,
829    /// Optional. Options to be set for the given created workload.
830    #[serde(rename = "workloadOptions")]
831    pub workload_options: Option<GoogleCloudAssuredworkloadsV1WorkloadWorkloadOptions>,
832}
833
834impl common::RequestValue for GoogleCloudAssuredworkloadsV1Workload {}
835impl common::ResponseResult for GoogleCloudAssuredworkloadsV1Workload {}
836
837/// Represents the Compliance Status of this workload
838///
839/// This type is not used in any activity, and only used as *part* of another schema.
840///
841#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
842#[serde_with::serde_as]
843#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
844pub struct GoogleCloudAssuredworkloadsV1WorkloadComplianceStatus {
845    /// Number of current resource violations which are not acknowledged.
846    #[serde(rename = "acknowledgedResourceViolationCount")]
847    pub acknowledged_resource_violation_count: Option<i32>,
848    /// Number of current orgPolicy violations which are acknowledged.
849    #[serde(rename = "acknowledgedViolationCount")]
850    pub acknowledged_violation_count: Option<i32>,
851    /// Number of current resource violations which are acknowledged.
852    #[serde(rename = "activeResourceViolationCount")]
853    pub active_resource_violation_count: Option<i32>,
854    /// Number of current orgPolicy violations which are not acknowledged.
855    #[serde(rename = "activeViolationCount")]
856    pub active_violation_count: Option<i32>,
857}
858
859impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadComplianceStatus {}
860
861/// External key management systems(EKM) Provisioning response
862///
863/// This type is not used in any activity, and only used as *part* of another schema.
864///
865#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
866#[serde_with::serde_as]
867#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
868pub struct GoogleCloudAssuredworkloadsV1WorkloadEkmProvisioningResponse {
869    /// Indicates Ekm provisioning error if any.
870    #[serde(rename = "ekmProvisioningErrorDomain")]
871    pub ekm_provisioning_error_domain: Option<String>,
872    /// Detailed error message if Ekm provisioning fails
873    #[serde(rename = "ekmProvisioningErrorMapping")]
874    pub ekm_provisioning_error_mapping: Option<String>,
875    /// Output only. Indicates Ekm enrollment Provisioning of a given workload.
876    #[serde(rename = "ekmProvisioningState")]
877    pub ekm_provisioning_state: Option<String>,
878}
879
880impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadEkmProvisioningResponse {}
881
882/// Settings specific to the Key Management Service.
883///
884/// This type is not used in any activity, and only used as *part* of another schema.
885///
886#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
887#[serde_with::serde_as]
888#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
889pub struct GoogleCloudAssuredworkloadsV1WorkloadKMSSettings {
890    /// Required. Input only. Immutable. The time at which the Key Management Service will automatically create a new version of the crypto key and mark it as the primary.
891    #[serde(rename = "nextRotationTime")]
892    pub next_rotation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
893    /// Required. Input only. Immutable. [next_rotation_time] will be advanced by this period when the Key Management Service automatically rotates a key. Must be at least 24 hours and at most 876,000 hours.
894    #[serde(rename = "rotationPeriod")]
895    #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
896    pub rotation_period: Option<chrono::Duration>,
897}
898
899impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadKMSSettings {}
900
901/// Permissions granted to the AW Partner SA account for the customer workload
902///
903/// This type is not used in any activity, and only used as *part* of another schema.
904///
905#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
906#[serde_with::serde_as]
907#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
908pub struct GoogleCloudAssuredworkloadsV1WorkloadPartnerPermissions {
909    /// Optional. Allow partner to view support case details for an AXT log
910    #[serde(rename = "accessTransparencyLogsSupportCaseViewer")]
911    pub access_transparency_logs_support_case_viewer: Option<bool>,
912    /// Optional. Allow partner to view violation alerts.
913    #[serde(rename = "assuredWorkloadsMonitoring")]
914    pub assured_workloads_monitoring: Option<bool>,
915    /// Optional. Allow the partner to view inspectability logs and monitoring violations.
916    #[serde(rename = "dataLogsViewer")]
917    pub data_logs_viewer: Option<bool>,
918    /// Optional. Allow partner to view access approval logs.
919    #[serde(rename = "serviceAccessApprover")]
920    pub service_access_approver: Option<bool>,
921}
922
923impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadPartnerPermissions {}
924
925/// Represent the resources that are children of this Workload.
926///
927/// This type is not used in any activity, and only used as *part* of another schema.
928///
929#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
930#[serde_with::serde_as]
931#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
932pub struct GoogleCloudAssuredworkloadsV1WorkloadResourceInfo {
933    /// Output only. Resource identifier. For a project this represents project_number.
934    #[serde(rename = "resourceId")]
935    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
936    pub resource_id: Option<i64>,
937    /// Indicates the type of resource.
938    #[serde(rename = "resourceType")]
939    pub resource_type: Option<String>,
940}
941
942impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadResourceInfo {}
943
944/// Represent the custom settings for the resources to be created.
945///
946/// This type is not used in any activity, and only used as *part* of another schema.
947///
948#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
949#[serde_with::serde_as]
950#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
951pub struct GoogleCloudAssuredworkloadsV1WorkloadResourceSettings {
952    /// User-assigned resource display name. If not empty it will be used to create a resource with the specified name.
953    #[serde(rename = "displayName")]
954    pub display_name: Option<String>,
955    /// Resource identifier. For a project this represents project_id. If the project is already taken, the workload creation will fail. For KeyRing, this represents the keyring_id. For a folder, don't set this value as folder_id is assigned by Google.
956    #[serde(rename = "resourceId")]
957    pub resource_id: Option<String>,
958    /// Indicates the type of resource. This field should be specified to correspond the id to the right project type (CONSUMER_PROJECT or ENCRYPTION_KEYS_PROJECT)
959    #[serde(rename = "resourceType")]
960    pub resource_type: Option<String>,
961}
962
963impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadResourceSettings {}
964
965/// Signed Access Approvals (SAA) enrollment response.
966///
967/// This type is not used in any activity, and only used as *part* of another schema.
968///
969#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
970#[serde_with::serde_as]
971#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
972pub struct GoogleCloudAssuredworkloadsV1WorkloadSaaEnrollmentResponse {
973    /// Indicates SAA enrollment setup error if any.
974    #[serde(rename = "setupErrors")]
975    pub setup_errors: Option<Vec<String>>,
976    /// Output only. Indicates SAA enrollment status of a given workload.
977    #[serde(rename = "setupStatus")]
978    pub setup_status: Option<String>,
979}
980
981impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadSaaEnrollmentResponse {}
982
983/// A workload update is a change to the workload's compliance configuration.
984///
985/// This type is not used in any activity, and only used as *part* of another schema.
986///
987#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
988#[serde_with::serde_as]
989#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
990pub struct GoogleCloudAssuredworkloadsV1WorkloadUpdate {
991    /// The time the update was created.
992    #[serde(rename = "createTime")]
993    pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
994    /// The details of the update.
995    pub details: Option<GoogleCloudAssuredworkloadsV1UpdateDetails>,
996    /// Output only. Immutable. Identifier. Resource name of the WorkloadUpdate. Format: organizations/{organization}/locations/{location}/workloads/{workload}/updates/{update}
997    pub name: Option<String>,
998    /// Output only. The state of the update.
999    pub state: Option<String>,
1000    /// The time the update was last updated.
1001    #[serde(rename = "updateTime")]
1002    pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1003}
1004
1005impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadUpdate {}
1006
1007/// Options to be set for the given created workload.
1008///
1009/// This type is not used in any activity, and only used as *part* of another schema.
1010///
1011#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1012#[serde_with::serde_as]
1013#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1014pub struct GoogleCloudAssuredworkloadsV1WorkloadWorkloadOptions {
1015    /// Optional. Specifies type of KAJ Enrollment if provided.
1016    #[serde(rename = "kajEnrollmentType")]
1017    pub kaj_enrollment_type: Option<String>,
1018}
1019
1020impl common::Part for GoogleCloudAssuredworkloadsV1WorkloadWorkloadOptions {}
1021
1022/// The response message for Operations.ListOperations.
1023///
1024/// # Activities
1025///
1026/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1027/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1028///
1029/// * [locations operations list organizations](OrganizationLocationOperationListCall) (response)
1030#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1031#[serde_with::serde_as]
1032#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1033pub struct GoogleLongrunningListOperationsResponse {
1034    /// The standard List next-page token.
1035    #[serde(rename = "nextPageToken")]
1036    pub next_page_token: Option<String>,
1037    /// A list of operations that matches the specified filter in the request.
1038    pub operations: Option<Vec<GoogleLongrunningOperation>>,
1039    /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
1040    pub unreachable: Option<Vec<String>>,
1041}
1042
1043impl common::ResponseResult for GoogleLongrunningListOperationsResponse {}
1044
1045/// This resource represents a long-running operation that is the result of a network API call.
1046///
1047/// # Activities
1048///
1049/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1050/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1051///
1052/// * [locations operations get organizations](OrganizationLocationOperationGetCall) (response)
1053/// * [locations workloads updates apply organizations](OrganizationLocationWorkloadUpdateApplyCall) (response)
1054/// * [locations workloads create organizations](OrganizationLocationWorkloadCreateCall) (response)
1055#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1056#[serde_with::serde_as]
1057#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1058pub struct GoogleLongrunningOperation {
1059    /// 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.
1060    pub done: Option<bool>,
1061    /// The error result of the operation in case of failure or cancellation.
1062    pub error: Option<GoogleRpcStatus>,
1063    /// 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.
1064    pub metadata: Option<HashMap<String, serde_json::Value>>,
1065    /// 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}`.
1066    pub name: Option<String>,
1067    /// 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`.
1068    pub response: Option<HashMap<String, serde_json::Value>>,
1069}
1070
1071impl common::ResponseResult for GoogleLongrunningOperation {}
1072
1073/// 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); }
1074///
1075/// # Activities
1076///
1077/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1078/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1079///
1080/// * [locations workloads delete organizations](OrganizationLocationWorkloadDeleteCall) (response)
1081#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1082#[serde_with::serde_as]
1083#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1084pub struct GoogleProtobufEmpty {
1085    _never_set: Option<bool>,
1086}
1087
1088impl common::ResponseResult for GoogleProtobufEmpty {}
1089
1090/// 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).
1091///
1092/// This type is not used in any activity, and only used as *part* of another schema.
1093///
1094#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1095#[serde_with::serde_as]
1096#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1097pub struct GoogleRpcStatus {
1098    /// The status code, which should be an enum value of google.rpc.Code.
1099    pub code: Option<i32>,
1100    /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
1101    pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
1102    /// 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.
1103    pub message: Option<String>,
1104}
1105
1106impl common::Part for GoogleRpcStatus {}
1107
1108// ###################
1109// MethodBuilders ###
1110// #################
1111
1112/// A builder providing access to all methods supported on *organization* resources.
1113/// It is not used directly, but through the [`Assuredworkloads`] hub.
1114///
1115/// # Example
1116///
1117/// Instantiate a resource builder
1118///
1119/// ```test_harness,no_run
1120/// extern crate hyper;
1121/// extern crate hyper_rustls;
1122/// extern crate google_assuredworkloads1 as assuredworkloads1;
1123///
1124/// # async fn dox() {
1125/// use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1126///
1127/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1128/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1129///     .with_native_roots()
1130///     .unwrap()
1131///     .https_only()
1132///     .enable_http2()
1133///     .build();
1134///
1135/// let executor = hyper_util::rt::TokioExecutor::new();
1136/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1137///     secret,
1138///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1139///     yup_oauth2::client::CustomHyperClientBuilder::from(
1140///         hyper_util::client::legacy::Client::builder(executor).build(connector),
1141///     ),
1142/// ).build().await.unwrap();
1143///
1144/// let client = hyper_util::client::legacy::Client::builder(
1145///     hyper_util::rt::TokioExecutor::new()
1146/// )
1147/// .build(
1148///     hyper_rustls::HttpsConnectorBuilder::new()
1149///         .with_native_roots()
1150///         .unwrap()
1151///         .https_or_http()
1152///         .enable_http2()
1153///         .build()
1154/// );
1155/// let mut hub = Assuredworkloads::new(client, auth);
1156/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1157/// // like `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_workloads_analyze_workload_move(...)`, `locations_workloads_create(...)`, `locations_workloads_delete(...)`, `locations_workloads_enable_compliance_updates(...)`, `locations_workloads_enable_resource_monitoring(...)`, `locations_workloads_get(...)`, `locations_workloads_list(...)`, `locations_workloads_mutate_partner_permissions(...)`, `locations_workloads_patch(...)`, `locations_workloads_restrict_allowed_resources(...)`, `locations_workloads_updates_apply(...)`, `locations_workloads_updates_list(...)`, `locations_workloads_violations_acknowledge(...)`, `locations_workloads_violations_get(...)` and `locations_workloads_violations_list(...)`
1158/// // to build up your call.
1159/// let rb = hub.organizations();
1160/// # }
1161/// ```
1162pub struct OrganizationMethods<'a, C>
1163where
1164    C: 'a,
1165{
1166    hub: &'a Assuredworkloads<C>,
1167}
1168
1169impl<'a, C> common::MethodsBuilder for OrganizationMethods<'a, C> {}
1170
1171impl<'a, C> OrganizationMethods<'a, C> {
1172    /// Create a builder to help you perform the following task:
1173    ///
1174    /// 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.
1175    ///
1176    /// # Arguments
1177    ///
1178    /// * `name` - The name of the operation resource.
1179    pub fn locations_operations_get(
1180        &self,
1181        name: &str,
1182    ) -> OrganizationLocationOperationGetCall<'a, C> {
1183        OrganizationLocationOperationGetCall {
1184            hub: self.hub,
1185            _name: name.to_string(),
1186            _delegate: Default::default(),
1187            _additional_params: Default::default(),
1188            _scopes: Default::default(),
1189        }
1190    }
1191
1192    /// Create a builder to help you perform the following task:
1193    ///
1194    /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1195    ///
1196    /// # Arguments
1197    ///
1198    /// * `name` - The name of the operation's parent resource.
1199    pub fn locations_operations_list(
1200        &self,
1201        name: &str,
1202    ) -> OrganizationLocationOperationListCall<'a, C> {
1203        OrganizationLocationOperationListCall {
1204            hub: self.hub,
1205            _name: name.to_string(),
1206            _return_partial_success: Default::default(),
1207            _page_token: Default::default(),
1208            _page_size: Default::default(),
1209            _filter: Default::default(),
1210            _delegate: Default::default(),
1211            _additional_params: Default::default(),
1212            _scopes: Default::default(),
1213        }
1214    }
1215
1216    /// Create a builder to help you perform the following task:
1217    ///
1218    /// This endpoint creates a new operation to apply the given update.
1219    ///
1220    /// # Arguments
1221    ///
1222    /// * `request` - No description provided.
1223    /// * `name` - Required. The resource name of the update. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}/updates/{update_id}
1224    pub fn locations_workloads_updates_apply(
1225        &self,
1226        request: GoogleCloudAssuredworkloadsV1ApplyWorkloadUpdateRequest,
1227        name: &str,
1228    ) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C> {
1229        OrganizationLocationWorkloadUpdateApplyCall {
1230            hub: self.hub,
1231            _request: request,
1232            _name: name.to_string(),
1233            _delegate: Default::default(),
1234            _additional_params: Default::default(),
1235            _scopes: Default::default(),
1236        }
1237    }
1238
1239    /// Create a builder to help you perform the following task:
1240    ///
1241    /// This endpoint lists all updates for the given workload.
1242    ///
1243    /// # Arguments
1244    ///
1245    /// * `parent` - Required. organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
1246    pub fn locations_workloads_updates_list(
1247        &self,
1248        parent: &str,
1249    ) -> OrganizationLocationWorkloadUpdateListCall<'a, C> {
1250        OrganizationLocationWorkloadUpdateListCall {
1251            hub: self.hub,
1252            _parent: parent.to_string(),
1253            _page_token: Default::default(),
1254            _page_size: Default::default(),
1255            _delegate: Default::default(),
1256            _additional_params: Default::default(),
1257            _scopes: Default::default(),
1258        }
1259    }
1260
1261    /// Create a builder to help you perform the following task:
1262    ///
1263    /// Acknowledges an existing violation. By acknowledging a violation, users acknowledge the existence of a compliance violation in their workload and decide to ignore it due to a valid business justification. Acknowledgement is a permanent operation and it cannot be reverted.
1264    ///
1265    /// # Arguments
1266    ///
1267    /// * `request` - No description provided.
1268    /// * `name` - Required. The resource name of the Violation to acknowledge. Format: organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
1269    pub fn locations_workloads_violations_acknowledge(
1270        &self,
1271        request: GoogleCloudAssuredworkloadsV1AcknowledgeViolationRequest,
1272        name: &str,
1273    ) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C> {
1274        OrganizationLocationWorkloadViolationAcknowledgeCall {
1275            hub: self.hub,
1276            _request: request,
1277            _name: name.to_string(),
1278            _delegate: Default::default(),
1279            _additional_params: Default::default(),
1280            _scopes: Default::default(),
1281        }
1282    }
1283
1284    /// Create a builder to help you perform the following task:
1285    ///
1286    /// Retrieves Assured Workload Violation based on ID.
1287    ///
1288    /// # Arguments
1289    ///
1290    /// * `name` - Required. The resource name of the Violation to fetch (ie. Violation.name). Format: organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
1291    pub fn locations_workloads_violations_get(
1292        &self,
1293        name: &str,
1294    ) -> OrganizationLocationWorkloadViolationGetCall<'a, C> {
1295        OrganizationLocationWorkloadViolationGetCall {
1296            hub: self.hub,
1297            _name: name.to_string(),
1298            _delegate: Default::default(),
1299            _additional_params: Default::default(),
1300            _scopes: Default::default(),
1301        }
1302    }
1303
1304    /// Create a builder to help you perform the following task:
1305    ///
1306    /// Lists the Violations in the AssuredWorkload Environment. Callers may also choose to read across multiple Workloads as per [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash character) as a wildcard character instead of workload-id in the parent. Format `organizations/{org_id}/locations/{location}/workloads/-`
1307    ///
1308    /// # Arguments
1309    ///
1310    /// * `parent` - Required. The Workload name. Format `organizations/{org_id}/locations/{location}/workloads/{workload}`.
1311    pub fn locations_workloads_violations_list(
1312        &self,
1313        parent: &str,
1314    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
1315        OrganizationLocationWorkloadViolationListCall {
1316            hub: self.hub,
1317            _parent: parent.to_string(),
1318            _page_token: Default::default(),
1319            _page_size: Default::default(),
1320            _interval_start_time: Default::default(),
1321            _interval_end_time: Default::default(),
1322            _filter: Default::default(),
1323            _delegate: Default::default(),
1324            _additional_params: Default::default(),
1325            _scopes: Default::default(),
1326        }
1327    }
1328
1329    /// Create a builder to help you perform the following task:
1330    ///
1331    /// Analyzes a hypothetical move of a source resource to a target workload to surface compliance risks. The analysis is best effort and is not guaranteed to be exhaustive.
1332    ///
1333    /// # Arguments
1334    ///
1335    /// * `target` - Required. The resource ID of the folder-based destination workload. This workload is where the source resource will hypothetically be moved to. Specify the workload's relative resource name, formatted as: "organizations/{ORGANIZATION_ID}/locations/{LOCATION_ID}/workloads/{WORKLOAD_ID}" For example: "organizations/123/locations/us-east1/workloads/assured-workload-2"
1336    pub fn locations_workloads_analyze_workload_move(
1337        &self,
1338        target: &str,
1339    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
1340        OrganizationLocationWorkloadAnalyzeWorkloadMoveCall {
1341            hub: self.hub,
1342            _target: target.to_string(),
1343            _project: Default::default(),
1344            _page_token: Default::default(),
1345            _page_size: Default::default(),
1346            _asset_types: Default::default(),
1347            _delegate: Default::default(),
1348            _additional_params: Default::default(),
1349            _scopes: Default::default(),
1350        }
1351    }
1352
1353    /// Create a builder to help you perform the following task:
1354    ///
1355    /// Creates Assured Workload.
1356    ///
1357    /// # Arguments
1358    ///
1359    /// * `request` - No description provided.
1360    /// * `parent` - Required. The resource name of the new Workload's parent. Must be of the form `organizations/{org_id}/locations/{location_id}`.
1361    pub fn locations_workloads_create(
1362        &self,
1363        request: GoogleCloudAssuredworkloadsV1Workload,
1364        parent: &str,
1365    ) -> OrganizationLocationWorkloadCreateCall<'a, C> {
1366        OrganizationLocationWorkloadCreateCall {
1367            hub: self.hub,
1368            _request: request,
1369            _parent: parent.to_string(),
1370            _external_id: Default::default(),
1371            _delegate: Default::default(),
1372            _additional_params: Default::default(),
1373            _scopes: Default::default(),
1374        }
1375    }
1376
1377    /// Create a builder to help you perform the following task:
1378    ///
1379    /// Deletes the workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail with a FAILED_PRECONDITION error. In addition to assuredworkloads.workload.delete permission, the user should also have orgpolicy.policy.set permission on the deleted folder to remove Assured Workloads OrgPolicies.
1380    ///
1381    /// # Arguments
1382    ///
1383    /// * `name` - Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
1384    pub fn locations_workloads_delete(
1385        &self,
1386        name: &str,
1387    ) -> OrganizationLocationWorkloadDeleteCall<'a, C> {
1388        OrganizationLocationWorkloadDeleteCall {
1389            hub: self.hub,
1390            _name: name.to_string(),
1391            _etag: Default::default(),
1392            _delegate: Default::default(),
1393            _additional_params: Default::default(),
1394            _scopes: Default::default(),
1395        }
1396    }
1397
1398    /// Create a builder to help you perform the following task:
1399    ///
1400    /// This endpoint enables Assured Workloads service to offer compliance updates for the folder based assured workload. It sets up an Assured Workloads Service Agent, having permissions to read compliance controls (for example: Org Policies) applied on the workload. The caller must have `resourcemanager.folders.getIamPolicy` and `resourcemanager.folders.setIamPolicy` permissions on the assured workload folder.
1401    ///
1402    /// # Arguments
1403    ///
1404    /// * `name` - Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
1405    pub fn locations_workloads_enable_compliance_updates(
1406        &self,
1407        name: &str,
1408    ) -> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C> {
1409        OrganizationLocationWorkloadEnableComplianceUpdateCall {
1410            hub: self.hub,
1411            _name: name.to_string(),
1412            _delegate: Default::default(),
1413            _additional_params: Default::default(),
1414            _scopes: Default::default(),
1415        }
1416    }
1417
1418    /// Create a builder to help you perform the following task:
1419    ///
1420    /// Enable resource violation monitoring for a workload.
1421    ///
1422    /// # Arguments
1423    ///
1424    /// * `name` - Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
1425    pub fn locations_workloads_enable_resource_monitoring(
1426        &self,
1427        name: &str,
1428    ) -> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C> {
1429        OrganizationLocationWorkloadEnableResourceMonitoringCall {
1430            hub: self.hub,
1431            _name: name.to_string(),
1432            _delegate: Default::default(),
1433            _additional_params: Default::default(),
1434            _scopes: Default::default(),
1435        }
1436    }
1437
1438    /// Create a builder to help you perform the following task:
1439    ///
1440    /// Gets Assured Workload associated with a CRM Node
1441    ///
1442    /// # Arguments
1443    ///
1444    /// * `name` - Required. The resource name of the Workload to fetch. This is the workloads's relative path in the API, formatted as "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}". For example, "organizations/123/locations/us-east1/workloads/assured-workload-1".
1445    pub fn locations_workloads_get(
1446        &self,
1447        name: &str,
1448    ) -> OrganizationLocationWorkloadGetCall<'a, C> {
1449        OrganizationLocationWorkloadGetCall {
1450            hub: self.hub,
1451            _name: name.to_string(),
1452            _delegate: Default::default(),
1453            _additional_params: Default::default(),
1454            _scopes: Default::default(),
1455        }
1456    }
1457
1458    /// Create a builder to help you perform the following task:
1459    ///
1460    /// Lists Assured Workloads under a CRM Node.
1461    ///
1462    /// # Arguments
1463    ///
1464    /// * `parent` - Required. Parent Resource to list workloads from. Must be of the form `organizations/{org_id}/locations/{location}`.
1465    pub fn locations_workloads_list(
1466        &self,
1467        parent: &str,
1468    ) -> OrganizationLocationWorkloadListCall<'a, C> {
1469        OrganizationLocationWorkloadListCall {
1470            hub: self.hub,
1471            _parent: parent.to_string(),
1472            _page_token: Default::default(),
1473            _page_size: Default::default(),
1474            _filter: Default::default(),
1475            _delegate: Default::default(),
1476            _additional_params: Default::default(),
1477            _scopes: Default::default(),
1478        }
1479    }
1480
1481    /// Create a builder to help you perform the following task:
1482    ///
1483    /// Update the permissions settings for an existing partner workload. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.
1484    ///
1485    /// # Arguments
1486    ///
1487    /// * `request` - No description provided.
1488    /// * `name` - Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
1489    pub fn locations_workloads_mutate_partner_permissions(
1490        &self,
1491        request: GoogleCloudAssuredworkloadsV1MutatePartnerPermissionsRequest,
1492        name: &str,
1493    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C> {
1494        OrganizationLocationWorkloadMutatePartnerPermissionCall {
1495            hub: self.hub,
1496            _request: request,
1497            _name: name.to_string(),
1498            _delegate: Default::default(),
1499            _additional_params: Default::default(),
1500            _scopes: Default::default(),
1501        }
1502    }
1503
1504    /// Create a builder to help you perform the following task:
1505    ///
1506    /// Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.
1507    ///
1508    /// # Arguments
1509    ///
1510    /// * `request` - No description provided.
1511    /// * `name` - Optional. The resource name of the workload. Format: organizations/{organization}/locations/{location}/workloads/{workload} Read-only.
1512    pub fn locations_workloads_patch(
1513        &self,
1514        request: GoogleCloudAssuredworkloadsV1Workload,
1515        name: &str,
1516    ) -> OrganizationLocationWorkloadPatchCall<'a, C> {
1517        OrganizationLocationWorkloadPatchCall {
1518            hub: self.hub,
1519            _request: request,
1520            _name: name.to_string(),
1521            _update_mask: Default::default(),
1522            _delegate: Default::default(),
1523            _additional_params: Default::default(),
1524            _scopes: Default::default(),
1525        }
1526    }
1527
1528    /// Create a builder to help you perform the following task:
1529    ///
1530    /// Restrict the list of resources allowed in the Workload environment. The current list of allowed products can be found at https://cloud.google.com/assured-workloads/docs/supported-products In addition to assuredworkloads.workload.update permission, the user should also have orgpolicy.policy.set permission on the folder resource to use this functionality.
1531    ///
1532    /// # Arguments
1533    ///
1534    /// * `request` - No description provided.
1535    /// * `name` - Required. The resource name of the Workload. This is the workloads's relative path in the API, formatted as "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}". For example, "organizations/123/locations/us-east1/workloads/assured-workload-1".
1536    pub fn locations_workloads_restrict_allowed_resources(
1537        &self,
1538        request: GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesRequest,
1539        name: &str,
1540    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C> {
1541        OrganizationLocationWorkloadRestrictAllowedResourceCall {
1542            hub: self.hub,
1543            _request: request,
1544            _name: name.to_string(),
1545            _delegate: Default::default(),
1546            _additional_params: Default::default(),
1547            _scopes: Default::default(),
1548        }
1549    }
1550}
1551
1552// ###################
1553// CallBuilders   ###
1554// #################
1555
1556/// 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.
1557///
1558/// A builder for the *locations.operations.get* method supported by a *organization* resource.
1559/// It is not used directly, but through a [`OrganizationMethods`] instance.
1560///
1561/// # Example
1562///
1563/// Instantiate a resource method builder
1564///
1565/// ```test_harness,no_run
1566/// # extern crate hyper;
1567/// # extern crate hyper_rustls;
1568/// # extern crate google_assuredworkloads1 as assuredworkloads1;
1569/// # async fn dox() {
1570/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1571///
1572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1574/// #     .with_native_roots()
1575/// #     .unwrap()
1576/// #     .https_only()
1577/// #     .enable_http2()
1578/// #     .build();
1579///
1580/// # let executor = hyper_util::rt::TokioExecutor::new();
1581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1582/// #     secret,
1583/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1584/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1585/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1586/// #     ),
1587/// # ).build().await.unwrap();
1588///
1589/// # let client = hyper_util::client::legacy::Client::builder(
1590/// #     hyper_util::rt::TokioExecutor::new()
1591/// # )
1592/// # .build(
1593/// #     hyper_rustls::HttpsConnectorBuilder::new()
1594/// #         .with_native_roots()
1595/// #         .unwrap()
1596/// #         .https_or_http()
1597/// #         .enable_http2()
1598/// #         .build()
1599/// # );
1600/// # let mut hub = Assuredworkloads::new(client, auth);
1601/// // You can configure optional parameters by calling the respective setters at will, and
1602/// // execute the final call using `doit()`.
1603/// // Values shown here are possibly random and not representative !
1604/// let result = hub.organizations().locations_operations_get("name")
1605///              .doit().await;
1606/// # }
1607/// ```
1608pub struct OrganizationLocationOperationGetCall<'a, C>
1609where
1610    C: 'a,
1611{
1612    hub: &'a Assuredworkloads<C>,
1613    _name: String,
1614    _delegate: Option<&'a mut dyn common::Delegate>,
1615    _additional_params: HashMap<String, String>,
1616    _scopes: BTreeSet<String>,
1617}
1618
1619impl<'a, C> common::CallBuilder for OrganizationLocationOperationGetCall<'a, C> {}
1620
1621impl<'a, C> OrganizationLocationOperationGetCall<'a, C>
1622where
1623    C: common::Connector,
1624{
1625    /// Perform the operation you have build so far.
1626    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
1627        use std::borrow::Cow;
1628        use std::io::{Read, Seek};
1629
1630        use common::{url::Params, ToParts};
1631        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1632
1633        let mut dd = common::DefaultDelegate;
1634        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1635        dlg.begin(common::MethodInfo {
1636            id: "assuredworkloads.organizations.locations.operations.get",
1637            http_method: hyper::Method::GET,
1638        });
1639
1640        for &field in ["alt", "name"].iter() {
1641            if self._additional_params.contains_key(field) {
1642                dlg.finished(false);
1643                return Err(common::Error::FieldClash(field));
1644            }
1645        }
1646
1647        let mut params = Params::with_capacity(3 + self._additional_params.len());
1648        params.push("name", self._name);
1649
1650        params.extend(self._additional_params.iter());
1651
1652        params.push("alt", "json");
1653        let mut url = self.hub._base_url.clone() + "v1/{+name}";
1654        if self._scopes.is_empty() {
1655            self._scopes
1656                .insert(Scope::CloudPlatform.as_ref().to_string());
1657        }
1658
1659        #[allow(clippy::single_element_loop)]
1660        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1661            url = params.uri_replacement(url, param_name, find_this, true);
1662        }
1663        {
1664            let to_remove = ["name"];
1665            params.remove_params(&to_remove);
1666        }
1667
1668        let url = params.parse_with_url(&url);
1669
1670        loop {
1671            let token = match self
1672                .hub
1673                .auth
1674                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1675                .await
1676            {
1677                Ok(token) => token,
1678                Err(e) => match dlg.token(e) {
1679                    Ok(token) => token,
1680                    Err(e) => {
1681                        dlg.finished(false);
1682                        return Err(common::Error::MissingToken(e));
1683                    }
1684                },
1685            };
1686            let mut req_result = {
1687                let client = &self.hub.client;
1688                dlg.pre_request();
1689                let mut req_builder = hyper::Request::builder()
1690                    .method(hyper::Method::GET)
1691                    .uri(url.as_str())
1692                    .header(USER_AGENT, self.hub._user_agent.clone());
1693
1694                if let Some(token) = token.as_ref() {
1695                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1696                }
1697
1698                let request = req_builder
1699                    .header(CONTENT_LENGTH, 0_u64)
1700                    .body(common::to_body::<String>(None));
1701
1702                client.request(request.unwrap()).await
1703            };
1704
1705            match req_result {
1706                Err(err) => {
1707                    if let common::Retry::After(d) = dlg.http_error(&err) {
1708                        sleep(d).await;
1709                        continue;
1710                    }
1711                    dlg.finished(false);
1712                    return Err(common::Error::HttpError(err));
1713                }
1714                Ok(res) => {
1715                    let (mut parts, body) = res.into_parts();
1716                    let mut body = common::Body::new(body);
1717                    if !parts.status.is_success() {
1718                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1719                        let error = serde_json::from_str(&common::to_string(&bytes));
1720                        let response = common::to_response(parts, bytes.into());
1721
1722                        if let common::Retry::After(d) =
1723                            dlg.http_failure(&response, error.as_ref().ok())
1724                        {
1725                            sleep(d).await;
1726                            continue;
1727                        }
1728
1729                        dlg.finished(false);
1730
1731                        return Err(match error {
1732                            Ok(value) => common::Error::BadRequest(value),
1733                            _ => common::Error::Failure(response),
1734                        });
1735                    }
1736                    let response = {
1737                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1738                        let encoded = common::to_string(&bytes);
1739                        match serde_json::from_str(&encoded) {
1740                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1741                            Err(error) => {
1742                                dlg.response_json_decode_error(&encoded, &error);
1743                                return Err(common::Error::JsonDecodeError(
1744                                    encoded.to_string(),
1745                                    error,
1746                                ));
1747                            }
1748                        }
1749                    };
1750
1751                    dlg.finished(true);
1752                    return Ok(response);
1753                }
1754            }
1755        }
1756    }
1757
1758    /// The name of the operation resource.
1759    ///
1760    /// Sets the *name* path property to the given value.
1761    ///
1762    /// Even though the property as already been set when instantiating this call,
1763    /// we provide this method for API completeness.
1764    pub fn name(mut self, new_value: &str) -> OrganizationLocationOperationGetCall<'a, C> {
1765        self._name = new_value.to_string();
1766        self
1767    }
1768    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1769    /// while executing the actual API request.
1770    ///
1771    /// ````text
1772    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1773    /// ````
1774    ///
1775    /// Sets the *delegate* property to the given value.
1776    pub fn delegate(
1777        mut self,
1778        new_value: &'a mut dyn common::Delegate,
1779    ) -> OrganizationLocationOperationGetCall<'a, C> {
1780        self._delegate = Some(new_value);
1781        self
1782    }
1783
1784    /// Set any additional parameter of the query string used in the request.
1785    /// It should be used to set parameters which are not yet available through their own
1786    /// setters.
1787    ///
1788    /// Please note that this method must not be used to set any of the known parameters
1789    /// which have their own setter method. If done anyway, the request will fail.
1790    ///
1791    /// # Additional Parameters
1792    ///
1793    /// * *$.xgafv* (query-string) - V1 error format.
1794    /// * *access_token* (query-string) - OAuth access token.
1795    /// * *alt* (query-string) - Data format for response.
1796    /// * *callback* (query-string) - JSONP
1797    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1798    /// * *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.
1799    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1800    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1801    /// * *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.
1802    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1803    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1804    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationOperationGetCall<'a, C>
1805    where
1806        T: AsRef<str>,
1807    {
1808        self._additional_params
1809            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1810        self
1811    }
1812
1813    /// Identifies the authorization scope for the method you are building.
1814    ///
1815    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1816    /// [`Scope::CloudPlatform`].
1817    ///
1818    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1819    /// tokens for more than one scope.
1820    ///
1821    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1822    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1823    /// sufficient, a read-write scope will do as well.
1824    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationOperationGetCall<'a, C>
1825    where
1826        St: AsRef<str>,
1827    {
1828        self._scopes.insert(String::from(scope.as_ref()));
1829        self
1830    }
1831    /// Identifies the authorization scope(s) for the method you are building.
1832    ///
1833    /// See [`Self::add_scope()`] for details.
1834    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationOperationGetCall<'a, C>
1835    where
1836        I: IntoIterator<Item = St>,
1837        St: AsRef<str>,
1838    {
1839        self._scopes
1840            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1841        self
1842    }
1843
1844    /// Removes all scopes, and no default scope will be used either.
1845    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1846    /// for details).
1847    pub fn clear_scopes(mut self) -> OrganizationLocationOperationGetCall<'a, C> {
1848        self._scopes.clear();
1849        self
1850    }
1851}
1852
1853/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1854///
1855/// A builder for the *locations.operations.list* method supported by a *organization* resource.
1856/// It is not used directly, but through a [`OrganizationMethods`] instance.
1857///
1858/// # Example
1859///
1860/// Instantiate a resource method builder
1861///
1862/// ```test_harness,no_run
1863/// # extern crate hyper;
1864/// # extern crate hyper_rustls;
1865/// # extern crate google_assuredworkloads1 as assuredworkloads1;
1866/// # async fn dox() {
1867/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1868///
1869/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1870/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1871/// #     .with_native_roots()
1872/// #     .unwrap()
1873/// #     .https_only()
1874/// #     .enable_http2()
1875/// #     .build();
1876///
1877/// # let executor = hyper_util::rt::TokioExecutor::new();
1878/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1879/// #     secret,
1880/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1881/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1882/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1883/// #     ),
1884/// # ).build().await.unwrap();
1885///
1886/// # let client = hyper_util::client::legacy::Client::builder(
1887/// #     hyper_util::rt::TokioExecutor::new()
1888/// # )
1889/// # .build(
1890/// #     hyper_rustls::HttpsConnectorBuilder::new()
1891/// #         .with_native_roots()
1892/// #         .unwrap()
1893/// #         .https_or_http()
1894/// #         .enable_http2()
1895/// #         .build()
1896/// # );
1897/// # let mut hub = Assuredworkloads::new(client, auth);
1898/// // You can configure optional parameters by calling the respective setters at will, and
1899/// // execute the final call using `doit()`.
1900/// // Values shown here are possibly random and not representative !
1901/// let result = hub.organizations().locations_operations_list("name")
1902///              .return_partial_success(true)
1903///              .page_token("amet.")
1904///              .page_size(-20)
1905///              .filter("ipsum")
1906///              .doit().await;
1907/// # }
1908/// ```
1909pub struct OrganizationLocationOperationListCall<'a, C>
1910where
1911    C: 'a,
1912{
1913    hub: &'a Assuredworkloads<C>,
1914    _name: String,
1915    _return_partial_success: Option<bool>,
1916    _page_token: Option<String>,
1917    _page_size: Option<i32>,
1918    _filter: Option<String>,
1919    _delegate: Option<&'a mut dyn common::Delegate>,
1920    _additional_params: HashMap<String, String>,
1921    _scopes: BTreeSet<String>,
1922}
1923
1924impl<'a, C> common::CallBuilder for OrganizationLocationOperationListCall<'a, C> {}
1925
1926impl<'a, C> OrganizationLocationOperationListCall<'a, C>
1927where
1928    C: common::Connector,
1929{
1930    /// Perform the operation you have build so far.
1931    pub async fn doit(
1932        mut self,
1933    ) -> common::Result<(common::Response, GoogleLongrunningListOperationsResponse)> {
1934        use std::borrow::Cow;
1935        use std::io::{Read, Seek};
1936
1937        use common::{url::Params, ToParts};
1938        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1939
1940        let mut dd = common::DefaultDelegate;
1941        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1942        dlg.begin(common::MethodInfo {
1943            id: "assuredworkloads.organizations.locations.operations.list",
1944            http_method: hyper::Method::GET,
1945        });
1946
1947        for &field in [
1948            "alt",
1949            "name",
1950            "returnPartialSuccess",
1951            "pageToken",
1952            "pageSize",
1953            "filter",
1954        ]
1955        .iter()
1956        {
1957            if self._additional_params.contains_key(field) {
1958                dlg.finished(false);
1959                return Err(common::Error::FieldClash(field));
1960            }
1961        }
1962
1963        let mut params = Params::with_capacity(7 + self._additional_params.len());
1964        params.push("name", self._name);
1965        if let Some(value) = self._return_partial_success.as_ref() {
1966            params.push("returnPartialSuccess", value.to_string());
1967        }
1968        if let Some(value) = self._page_token.as_ref() {
1969            params.push("pageToken", value);
1970        }
1971        if let Some(value) = self._page_size.as_ref() {
1972            params.push("pageSize", value.to_string());
1973        }
1974        if let Some(value) = self._filter.as_ref() {
1975            params.push("filter", value);
1976        }
1977
1978        params.extend(self._additional_params.iter());
1979
1980        params.push("alt", "json");
1981        let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
1982        if self._scopes.is_empty() {
1983            self._scopes
1984                .insert(Scope::CloudPlatform.as_ref().to_string());
1985        }
1986
1987        #[allow(clippy::single_element_loop)]
1988        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1989            url = params.uri_replacement(url, param_name, find_this, true);
1990        }
1991        {
1992            let to_remove = ["name"];
1993            params.remove_params(&to_remove);
1994        }
1995
1996        let url = params.parse_with_url(&url);
1997
1998        loop {
1999            let token = match self
2000                .hub
2001                .auth
2002                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2003                .await
2004            {
2005                Ok(token) => token,
2006                Err(e) => match dlg.token(e) {
2007                    Ok(token) => token,
2008                    Err(e) => {
2009                        dlg.finished(false);
2010                        return Err(common::Error::MissingToken(e));
2011                    }
2012                },
2013            };
2014            let mut req_result = {
2015                let client = &self.hub.client;
2016                dlg.pre_request();
2017                let mut req_builder = hyper::Request::builder()
2018                    .method(hyper::Method::GET)
2019                    .uri(url.as_str())
2020                    .header(USER_AGENT, self.hub._user_agent.clone());
2021
2022                if let Some(token) = token.as_ref() {
2023                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2024                }
2025
2026                let request = req_builder
2027                    .header(CONTENT_LENGTH, 0_u64)
2028                    .body(common::to_body::<String>(None));
2029
2030                client.request(request.unwrap()).await
2031            };
2032
2033            match req_result {
2034                Err(err) => {
2035                    if let common::Retry::After(d) = dlg.http_error(&err) {
2036                        sleep(d).await;
2037                        continue;
2038                    }
2039                    dlg.finished(false);
2040                    return Err(common::Error::HttpError(err));
2041                }
2042                Ok(res) => {
2043                    let (mut parts, body) = res.into_parts();
2044                    let mut body = common::Body::new(body);
2045                    if !parts.status.is_success() {
2046                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2047                        let error = serde_json::from_str(&common::to_string(&bytes));
2048                        let response = common::to_response(parts, bytes.into());
2049
2050                        if let common::Retry::After(d) =
2051                            dlg.http_failure(&response, error.as_ref().ok())
2052                        {
2053                            sleep(d).await;
2054                            continue;
2055                        }
2056
2057                        dlg.finished(false);
2058
2059                        return Err(match error {
2060                            Ok(value) => common::Error::BadRequest(value),
2061                            _ => common::Error::Failure(response),
2062                        });
2063                    }
2064                    let response = {
2065                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2066                        let encoded = common::to_string(&bytes);
2067                        match serde_json::from_str(&encoded) {
2068                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2069                            Err(error) => {
2070                                dlg.response_json_decode_error(&encoded, &error);
2071                                return Err(common::Error::JsonDecodeError(
2072                                    encoded.to_string(),
2073                                    error,
2074                                ));
2075                            }
2076                        }
2077                    };
2078
2079                    dlg.finished(true);
2080                    return Ok(response);
2081                }
2082            }
2083        }
2084    }
2085
2086    /// The name of the operation's parent resource.
2087    ///
2088    /// Sets the *name* path property to the given value.
2089    ///
2090    /// Even though the property as already been set when instantiating this call,
2091    /// we provide this method for API completeness.
2092    pub fn name(mut self, new_value: &str) -> OrganizationLocationOperationListCall<'a, C> {
2093        self._name = new_value.to_string();
2094        self
2095    }
2096    /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
2097    ///
2098    /// Sets the *return partial success* query property to the given value.
2099    pub fn return_partial_success(
2100        mut self,
2101        new_value: bool,
2102    ) -> OrganizationLocationOperationListCall<'a, C> {
2103        self._return_partial_success = Some(new_value);
2104        self
2105    }
2106    /// The standard list page token.
2107    ///
2108    /// Sets the *page token* query property to the given value.
2109    pub fn page_token(mut self, new_value: &str) -> OrganizationLocationOperationListCall<'a, C> {
2110        self._page_token = Some(new_value.to_string());
2111        self
2112    }
2113    /// The standard list page size.
2114    ///
2115    /// Sets the *page size* query property to the given value.
2116    pub fn page_size(mut self, new_value: i32) -> OrganizationLocationOperationListCall<'a, C> {
2117        self._page_size = Some(new_value);
2118        self
2119    }
2120    /// The standard list filter.
2121    ///
2122    /// Sets the *filter* query property to the given value.
2123    pub fn filter(mut self, new_value: &str) -> OrganizationLocationOperationListCall<'a, C> {
2124        self._filter = Some(new_value.to_string());
2125        self
2126    }
2127    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2128    /// while executing the actual API request.
2129    ///
2130    /// ````text
2131    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2132    /// ````
2133    ///
2134    /// Sets the *delegate* property to the given value.
2135    pub fn delegate(
2136        mut self,
2137        new_value: &'a mut dyn common::Delegate,
2138    ) -> OrganizationLocationOperationListCall<'a, C> {
2139        self._delegate = Some(new_value);
2140        self
2141    }
2142
2143    /// Set any additional parameter of the query string used in the request.
2144    /// It should be used to set parameters which are not yet available through their own
2145    /// setters.
2146    ///
2147    /// Please note that this method must not be used to set any of the known parameters
2148    /// which have their own setter method. If done anyway, the request will fail.
2149    ///
2150    /// # Additional Parameters
2151    ///
2152    /// * *$.xgafv* (query-string) - V1 error format.
2153    /// * *access_token* (query-string) - OAuth access token.
2154    /// * *alt* (query-string) - Data format for response.
2155    /// * *callback* (query-string) - JSONP
2156    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2157    /// * *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.
2158    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2159    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2160    /// * *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.
2161    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2162    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2163    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationOperationListCall<'a, C>
2164    where
2165        T: AsRef<str>,
2166    {
2167        self._additional_params
2168            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2169        self
2170    }
2171
2172    /// Identifies the authorization scope for the method you are building.
2173    ///
2174    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2175    /// [`Scope::CloudPlatform`].
2176    ///
2177    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2178    /// tokens for more than one scope.
2179    ///
2180    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2181    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2182    /// sufficient, a read-write scope will do as well.
2183    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationOperationListCall<'a, C>
2184    where
2185        St: AsRef<str>,
2186    {
2187        self._scopes.insert(String::from(scope.as_ref()));
2188        self
2189    }
2190    /// Identifies the authorization scope(s) for the method you are building.
2191    ///
2192    /// See [`Self::add_scope()`] for details.
2193    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationOperationListCall<'a, C>
2194    where
2195        I: IntoIterator<Item = St>,
2196        St: AsRef<str>,
2197    {
2198        self._scopes
2199            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2200        self
2201    }
2202
2203    /// Removes all scopes, and no default scope will be used either.
2204    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2205    /// for details).
2206    pub fn clear_scopes(mut self) -> OrganizationLocationOperationListCall<'a, C> {
2207        self._scopes.clear();
2208        self
2209    }
2210}
2211
2212/// This endpoint creates a new operation to apply the given update.
2213///
2214/// A builder for the *locations.workloads.updates.apply* method supported by a *organization* resource.
2215/// It is not used directly, but through a [`OrganizationMethods`] instance.
2216///
2217/// # Example
2218///
2219/// Instantiate a resource method builder
2220///
2221/// ```test_harness,no_run
2222/// # extern crate hyper;
2223/// # extern crate hyper_rustls;
2224/// # extern crate google_assuredworkloads1 as assuredworkloads1;
2225/// use assuredworkloads1::api::GoogleCloudAssuredworkloadsV1ApplyWorkloadUpdateRequest;
2226/// # async fn dox() {
2227/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2228///
2229/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2230/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2231/// #     .with_native_roots()
2232/// #     .unwrap()
2233/// #     .https_only()
2234/// #     .enable_http2()
2235/// #     .build();
2236///
2237/// # let executor = hyper_util::rt::TokioExecutor::new();
2238/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2239/// #     secret,
2240/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2241/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2242/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2243/// #     ),
2244/// # ).build().await.unwrap();
2245///
2246/// # let client = hyper_util::client::legacy::Client::builder(
2247/// #     hyper_util::rt::TokioExecutor::new()
2248/// # )
2249/// # .build(
2250/// #     hyper_rustls::HttpsConnectorBuilder::new()
2251/// #         .with_native_roots()
2252/// #         .unwrap()
2253/// #         .https_or_http()
2254/// #         .enable_http2()
2255/// #         .build()
2256/// # );
2257/// # let mut hub = Assuredworkloads::new(client, auth);
2258/// // As the method needs a request, you would usually fill it with the desired information
2259/// // into the respective structure. Some of the parts shown here might not be applicable !
2260/// // Values shown here are possibly random and not representative !
2261/// let mut req = GoogleCloudAssuredworkloadsV1ApplyWorkloadUpdateRequest::default();
2262///
2263/// // You can configure optional parameters by calling the respective setters at will, and
2264/// // execute the final call using `doit()`.
2265/// // Values shown here are possibly random and not representative !
2266/// let result = hub.organizations().locations_workloads_updates_apply(req, "name")
2267///              .doit().await;
2268/// # }
2269/// ```
2270pub struct OrganizationLocationWorkloadUpdateApplyCall<'a, C>
2271where
2272    C: 'a,
2273{
2274    hub: &'a Assuredworkloads<C>,
2275    _request: GoogleCloudAssuredworkloadsV1ApplyWorkloadUpdateRequest,
2276    _name: String,
2277    _delegate: Option<&'a mut dyn common::Delegate>,
2278    _additional_params: HashMap<String, String>,
2279    _scopes: BTreeSet<String>,
2280}
2281
2282impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadUpdateApplyCall<'a, C> {}
2283
2284impl<'a, C> OrganizationLocationWorkloadUpdateApplyCall<'a, C>
2285where
2286    C: common::Connector,
2287{
2288    /// Perform the operation you have build so far.
2289    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
2290        use std::borrow::Cow;
2291        use std::io::{Read, Seek};
2292
2293        use common::{url::Params, ToParts};
2294        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2295
2296        let mut dd = common::DefaultDelegate;
2297        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2298        dlg.begin(common::MethodInfo {
2299            id: "assuredworkloads.organizations.locations.workloads.updates.apply",
2300            http_method: hyper::Method::POST,
2301        });
2302
2303        for &field in ["alt", "name"].iter() {
2304            if self._additional_params.contains_key(field) {
2305                dlg.finished(false);
2306                return Err(common::Error::FieldClash(field));
2307            }
2308        }
2309
2310        let mut params = Params::with_capacity(4 + self._additional_params.len());
2311        params.push("name", self._name);
2312
2313        params.extend(self._additional_params.iter());
2314
2315        params.push("alt", "json");
2316        let mut url = self.hub._base_url.clone() + "v1/{+name}:apply";
2317        if self._scopes.is_empty() {
2318            self._scopes
2319                .insert(Scope::CloudPlatform.as_ref().to_string());
2320        }
2321
2322        #[allow(clippy::single_element_loop)]
2323        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2324            url = params.uri_replacement(url, param_name, find_this, true);
2325        }
2326        {
2327            let to_remove = ["name"];
2328            params.remove_params(&to_remove);
2329        }
2330
2331        let url = params.parse_with_url(&url);
2332
2333        let mut json_mime_type = mime::APPLICATION_JSON;
2334        let mut request_value_reader = {
2335            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2336            common::remove_json_null_values(&mut value);
2337            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2338            serde_json::to_writer(&mut dst, &value).unwrap();
2339            dst
2340        };
2341        let request_size = request_value_reader
2342            .seek(std::io::SeekFrom::End(0))
2343            .unwrap();
2344        request_value_reader
2345            .seek(std::io::SeekFrom::Start(0))
2346            .unwrap();
2347
2348        loop {
2349            let token = match self
2350                .hub
2351                .auth
2352                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2353                .await
2354            {
2355                Ok(token) => token,
2356                Err(e) => match dlg.token(e) {
2357                    Ok(token) => token,
2358                    Err(e) => {
2359                        dlg.finished(false);
2360                        return Err(common::Error::MissingToken(e));
2361                    }
2362                },
2363            };
2364            request_value_reader
2365                .seek(std::io::SeekFrom::Start(0))
2366                .unwrap();
2367            let mut req_result = {
2368                let client = &self.hub.client;
2369                dlg.pre_request();
2370                let mut req_builder = hyper::Request::builder()
2371                    .method(hyper::Method::POST)
2372                    .uri(url.as_str())
2373                    .header(USER_AGENT, self.hub._user_agent.clone());
2374
2375                if let Some(token) = token.as_ref() {
2376                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2377                }
2378
2379                let request = req_builder
2380                    .header(CONTENT_TYPE, json_mime_type.to_string())
2381                    .header(CONTENT_LENGTH, request_size as u64)
2382                    .body(common::to_body(
2383                        request_value_reader.get_ref().clone().into(),
2384                    ));
2385
2386                client.request(request.unwrap()).await
2387            };
2388
2389            match req_result {
2390                Err(err) => {
2391                    if let common::Retry::After(d) = dlg.http_error(&err) {
2392                        sleep(d).await;
2393                        continue;
2394                    }
2395                    dlg.finished(false);
2396                    return Err(common::Error::HttpError(err));
2397                }
2398                Ok(res) => {
2399                    let (mut parts, body) = res.into_parts();
2400                    let mut body = common::Body::new(body);
2401                    if !parts.status.is_success() {
2402                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2403                        let error = serde_json::from_str(&common::to_string(&bytes));
2404                        let response = common::to_response(parts, bytes.into());
2405
2406                        if let common::Retry::After(d) =
2407                            dlg.http_failure(&response, error.as_ref().ok())
2408                        {
2409                            sleep(d).await;
2410                            continue;
2411                        }
2412
2413                        dlg.finished(false);
2414
2415                        return Err(match error {
2416                            Ok(value) => common::Error::BadRequest(value),
2417                            _ => common::Error::Failure(response),
2418                        });
2419                    }
2420                    let response = {
2421                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2422                        let encoded = common::to_string(&bytes);
2423                        match serde_json::from_str(&encoded) {
2424                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2425                            Err(error) => {
2426                                dlg.response_json_decode_error(&encoded, &error);
2427                                return Err(common::Error::JsonDecodeError(
2428                                    encoded.to_string(),
2429                                    error,
2430                                ));
2431                            }
2432                        }
2433                    };
2434
2435                    dlg.finished(true);
2436                    return Ok(response);
2437                }
2438            }
2439        }
2440    }
2441
2442    ///
2443    /// Sets the *request* property to the given value.
2444    ///
2445    /// Even though the property as already been set when instantiating this call,
2446    /// we provide this method for API completeness.
2447    pub fn request(
2448        mut self,
2449        new_value: GoogleCloudAssuredworkloadsV1ApplyWorkloadUpdateRequest,
2450    ) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C> {
2451        self._request = new_value;
2452        self
2453    }
2454    /// Required. The resource name of the update. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}/updates/{update_id}
2455    ///
2456    /// Sets the *name* path property to the given value.
2457    ///
2458    /// Even though the property as already been set when instantiating this call,
2459    /// we provide this method for API completeness.
2460    pub fn name(mut self, new_value: &str) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C> {
2461        self._name = new_value.to_string();
2462        self
2463    }
2464    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2465    /// while executing the actual API request.
2466    ///
2467    /// ````text
2468    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2469    /// ````
2470    ///
2471    /// Sets the *delegate* property to the given value.
2472    pub fn delegate(
2473        mut self,
2474        new_value: &'a mut dyn common::Delegate,
2475    ) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C> {
2476        self._delegate = Some(new_value);
2477        self
2478    }
2479
2480    /// Set any additional parameter of the query string used in the request.
2481    /// It should be used to set parameters which are not yet available through their own
2482    /// setters.
2483    ///
2484    /// Please note that this method must not be used to set any of the known parameters
2485    /// which have their own setter method. If done anyway, the request will fail.
2486    ///
2487    /// # Additional Parameters
2488    ///
2489    /// * *$.xgafv* (query-string) - V1 error format.
2490    /// * *access_token* (query-string) - OAuth access token.
2491    /// * *alt* (query-string) - Data format for response.
2492    /// * *callback* (query-string) - JSONP
2493    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2494    /// * *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.
2495    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2496    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2497    /// * *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.
2498    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2499    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2500    pub fn param<T>(
2501        mut self,
2502        name: T,
2503        value: T,
2504    ) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C>
2505    where
2506        T: AsRef<str>,
2507    {
2508        self._additional_params
2509            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2510        self
2511    }
2512
2513    /// Identifies the authorization scope for the method you are building.
2514    ///
2515    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2516    /// [`Scope::CloudPlatform`].
2517    ///
2518    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2519    /// tokens for more than one scope.
2520    ///
2521    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2522    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2523    /// sufficient, a read-write scope will do as well.
2524    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C>
2525    where
2526        St: AsRef<str>,
2527    {
2528        self._scopes.insert(String::from(scope.as_ref()));
2529        self
2530    }
2531    /// Identifies the authorization scope(s) for the method you are building.
2532    ///
2533    /// See [`Self::add_scope()`] for details.
2534    pub fn add_scopes<I, St>(
2535        mut self,
2536        scopes: I,
2537    ) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C>
2538    where
2539        I: IntoIterator<Item = St>,
2540        St: AsRef<str>,
2541    {
2542        self._scopes
2543            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2544        self
2545    }
2546
2547    /// Removes all scopes, and no default scope will be used either.
2548    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2549    /// for details).
2550    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadUpdateApplyCall<'a, C> {
2551        self._scopes.clear();
2552        self
2553    }
2554}
2555
2556/// This endpoint lists all updates for the given workload.
2557///
2558/// A builder for the *locations.workloads.updates.list* method supported by a *organization* resource.
2559/// It is not used directly, but through a [`OrganizationMethods`] instance.
2560///
2561/// # Example
2562///
2563/// Instantiate a resource method builder
2564///
2565/// ```test_harness,no_run
2566/// # extern crate hyper;
2567/// # extern crate hyper_rustls;
2568/// # extern crate google_assuredworkloads1 as assuredworkloads1;
2569/// # async fn dox() {
2570/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2571///
2572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2574/// #     .with_native_roots()
2575/// #     .unwrap()
2576/// #     .https_only()
2577/// #     .enable_http2()
2578/// #     .build();
2579///
2580/// # let executor = hyper_util::rt::TokioExecutor::new();
2581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2582/// #     secret,
2583/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2584/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2585/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2586/// #     ),
2587/// # ).build().await.unwrap();
2588///
2589/// # let client = hyper_util::client::legacy::Client::builder(
2590/// #     hyper_util::rt::TokioExecutor::new()
2591/// # )
2592/// # .build(
2593/// #     hyper_rustls::HttpsConnectorBuilder::new()
2594/// #         .with_native_roots()
2595/// #         .unwrap()
2596/// #         .https_or_http()
2597/// #         .enable_http2()
2598/// #         .build()
2599/// # );
2600/// # let mut hub = Assuredworkloads::new(client, auth);
2601/// // You can configure optional parameters by calling the respective setters at will, and
2602/// // execute the final call using `doit()`.
2603/// // Values shown here are possibly random and not representative !
2604/// let result = hub.organizations().locations_workloads_updates_list("parent")
2605///              .page_token("gubergren")
2606///              .page_size(-75)
2607///              .doit().await;
2608/// # }
2609/// ```
2610pub struct OrganizationLocationWorkloadUpdateListCall<'a, C>
2611where
2612    C: 'a,
2613{
2614    hub: &'a Assuredworkloads<C>,
2615    _parent: String,
2616    _page_token: Option<String>,
2617    _page_size: Option<i32>,
2618    _delegate: Option<&'a mut dyn common::Delegate>,
2619    _additional_params: HashMap<String, String>,
2620    _scopes: BTreeSet<String>,
2621}
2622
2623impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadUpdateListCall<'a, C> {}
2624
2625impl<'a, C> OrganizationLocationWorkloadUpdateListCall<'a, C>
2626where
2627    C: common::Connector,
2628{
2629    /// Perform the operation you have build so far.
2630    pub async fn doit(
2631        mut self,
2632    ) -> common::Result<(
2633        common::Response,
2634        GoogleCloudAssuredworkloadsV1ListWorkloadUpdatesResponse,
2635    )> {
2636        use std::borrow::Cow;
2637        use std::io::{Read, Seek};
2638
2639        use common::{url::Params, ToParts};
2640        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2641
2642        let mut dd = common::DefaultDelegate;
2643        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2644        dlg.begin(common::MethodInfo {
2645            id: "assuredworkloads.organizations.locations.workloads.updates.list",
2646            http_method: hyper::Method::GET,
2647        });
2648
2649        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2650            if self._additional_params.contains_key(field) {
2651                dlg.finished(false);
2652                return Err(common::Error::FieldClash(field));
2653            }
2654        }
2655
2656        let mut params = Params::with_capacity(5 + self._additional_params.len());
2657        params.push("parent", self._parent);
2658        if let Some(value) = self._page_token.as_ref() {
2659            params.push("pageToken", value);
2660        }
2661        if let Some(value) = self._page_size.as_ref() {
2662            params.push("pageSize", value.to_string());
2663        }
2664
2665        params.extend(self._additional_params.iter());
2666
2667        params.push("alt", "json");
2668        let mut url = self.hub._base_url.clone() + "v1/{+parent}/updates";
2669        if self._scopes.is_empty() {
2670            self._scopes
2671                .insert(Scope::CloudPlatform.as_ref().to_string());
2672        }
2673
2674        #[allow(clippy::single_element_loop)]
2675        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2676            url = params.uri_replacement(url, param_name, find_this, true);
2677        }
2678        {
2679            let to_remove = ["parent"];
2680            params.remove_params(&to_remove);
2681        }
2682
2683        let url = params.parse_with_url(&url);
2684
2685        loop {
2686            let token = match self
2687                .hub
2688                .auth
2689                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2690                .await
2691            {
2692                Ok(token) => token,
2693                Err(e) => match dlg.token(e) {
2694                    Ok(token) => token,
2695                    Err(e) => {
2696                        dlg.finished(false);
2697                        return Err(common::Error::MissingToken(e));
2698                    }
2699                },
2700            };
2701            let mut req_result = {
2702                let client = &self.hub.client;
2703                dlg.pre_request();
2704                let mut req_builder = hyper::Request::builder()
2705                    .method(hyper::Method::GET)
2706                    .uri(url.as_str())
2707                    .header(USER_AGENT, self.hub._user_agent.clone());
2708
2709                if let Some(token) = token.as_ref() {
2710                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2711                }
2712
2713                let request = req_builder
2714                    .header(CONTENT_LENGTH, 0_u64)
2715                    .body(common::to_body::<String>(None));
2716
2717                client.request(request.unwrap()).await
2718            };
2719
2720            match req_result {
2721                Err(err) => {
2722                    if let common::Retry::After(d) = dlg.http_error(&err) {
2723                        sleep(d).await;
2724                        continue;
2725                    }
2726                    dlg.finished(false);
2727                    return Err(common::Error::HttpError(err));
2728                }
2729                Ok(res) => {
2730                    let (mut parts, body) = res.into_parts();
2731                    let mut body = common::Body::new(body);
2732                    if !parts.status.is_success() {
2733                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2734                        let error = serde_json::from_str(&common::to_string(&bytes));
2735                        let response = common::to_response(parts, bytes.into());
2736
2737                        if let common::Retry::After(d) =
2738                            dlg.http_failure(&response, error.as_ref().ok())
2739                        {
2740                            sleep(d).await;
2741                            continue;
2742                        }
2743
2744                        dlg.finished(false);
2745
2746                        return Err(match error {
2747                            Ok(value) => common::Error::BadRequest(value),
2748                            _ => common::Error::Failure(response),
2749                        });
2750                    }
2751                    let response = {
2752                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2753                        let encoded = common::to_string(&bytes);
2754                        match serde_json::from_str(&encoded) {
2755                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2756                            Err(error) => {
2757                                dlg.response_json_decode_error(&encoded, &error);
2758                                return Err(common::Error::JsonDecodeError(
2759                                    encoded.to_string(),
2760                                    error,
2761                                ));
2762                            }
2763                        }
2764                    };
2765
2766                    dlg.finished(true);
2767                    return Ok(response);
2768                }
2769            }
2770        }
2771    }
2772
2773    /// Required. organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
2774    ///
2775    /// Sets the *parent* path property to the given value.
2776    ///
2777    /// Even though the property as already been set when instantiating this call,
2778    /// we provide this method for API completeness.
2779    pub fn parent(mut self, new_value: &str) -> OrganizationLocationWorkloadUpdateListCall<'a, C> {
2780        self._parent = new_value.to_string();
2781        self
2782    }
2783    /// Page token returned from previous request.
2784    ///
2785    /// Sets the *page token* query property to the given value.
2786    pub fn page_token(
2787        mut self,
2788        new_value: &str,
2789    ) -> OrganizationLocationWorkloadUpdateListCall<'a, C> {
2790        self._page_token = Some(new_value.to_string());
2791        self
2792    }
2793    /// Page size. The default value is 20 and the max allowed value is 100.
2794    ///
2795    /// Sets the *page size* query property to the given value.
2796    pub fn page_size(
2797        mut self,
2798        new_value: i32,
2799    ) -> OrganizationLocationWorkloadUpdateListCall<'a, C> {
2800        self._page_size = Some(new_value);
2801        self
2802    }
2803    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2804    /// while executing the actual API request.
2805    ///
2806    /// ````text
2807    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2808    /// ````
2809    ///
2810    /// Sets the *delegate* property to the given value.
2811    pub fn delegate(
2812        mut self,
2813        new_value: &'a mut dyn common::Delegate,
2814    ) -> OrganizationLocationWorkloadUpdateListCall<'a, C> {
2815        self._delegate = Some(new_value);
2816        self
2817    }
2818
2819    /// Set any additional parameter of the query string used in the request.
2820    /// It should be used to set parameters which are not yet available through their own
2821    /// setters.
2822    ///
2823    /// Please note that this method must not be used to set any of the known parameters
2824    /// which have their own setter method. If done anyway, the request will fail.
2825    ///
2826    /// # Additional Parameters
2827    ///
2828    /// * *$.xgafv* (query-string) - V1 error format.
2829    /// * *access_token* (query-string) - OAuth access token.
2830    /// * *alt* (query-string) - Data format for response.
2831    /// * *callback* (query-string) - JSONP
2832    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2833    /// * *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.
2834    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2835    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2836    /// * *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.
2837    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2838    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2839    pub fn param<T>(
2840        mut self,
2841        name: T,
2842        value: T,
2843    ) -> OrganizationLocationWorkloadUpdateListCall<'a, C>
2844    where
2845        T: AsRef<str>,
2846    {
2847        self._additional_params
2848            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2849        self
2850    }
2851
2852    /// Identifies the authorization scope for the method you are building.
2853    ///
2854    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2855    /// [`Scope::CloudPlatform`].
2856    ///
2857    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2858    /// tokens for more than one scope.
2859    ///
2860    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2861    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2862    /// sufficient, a read-write scope will do as well.
2863    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadUpdateListCall<'a, C>
2864    where
2865        St: AsRef<str>,
2866    {
2867        self._scopes.insert(String::from(scope.as_ref()));
2868        self
2869    }
2870    /// Identifies the authorization scope(s) for the method you are building.
2871    ///
2872    /// See [`Self::add_scope()`] for details.
2873    pub fn add_scopes<I, St>(
2874        mut self,
2875        scopes: I,
2876    ) -> OrganizationLocationWorkloadUpdateListCall<'a, C>
2877    where
2878        I: IntoIterator<Item = St>,
2879        St: AsRef<str>,
2880    {
2881        self._scopes
2882            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2883        self
2884    }
2885
2886    /// Removes all scopes, and no default scope will be used either.
2887    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2888    /// for details).
2889    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadUpdateListCall<'a, C> {
2890        self._scopes.clear();
2891        self
2892    }
2893}
2894
2895/// Acknowledges an existing violation. By acknowledging a violation, users acknowledge the existence of a compliance violation in their workload and decide to ignore it due to a valid business justification. Acknowledgement is a permanent operation and it cannot be reverted.
2896///
2897/// A builder for the *locations.workloads.violations.acknowledge* method supported by a *organization* resource.
2898/// It is not used directly, but through a [`OrganizationMethods`] instance.
2899///
2900/// # Example
2901///
2902/// Instantiate a resource method builder
2903///
2904/// ```test_harness,no_run
2905/// # extern crate hyper;
2906/// # extern crate hyper_rustls;
2907/// # extern crate google_assuredworkloads1 as assuredworkloads1;
2908/// use assuredworkloads1::api::GoogleCloudAssuredworkloadsV1AcknowledgeViolationRequest;
2909/// # async fn dox() {
2910/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2911///
2912/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2913/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2914/// #     .with_native_roots()
2915/// #     .unwrap()
2916/// #     .https_only()
2917/// #     .enable_http2()
2918/// #     .build();
2919///
2920/// # let executor = hyper_util::rt::TokioExecutor::new();
2921/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2922/// #     secret,
2923/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2924/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2925/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2926/// #     ),
2927/// # ).build().await.unwrap();
2928///
2929/// # let client = hyper_util::client::legacy::Client::builder(
2930/// #     hyper_util::rt::TokioExecutor::new()
2931/// # )
2932/// # .build(
2933/// #     hyper_rustls::HttpsConnectorBuilder::new()
2934/// #         .with_native_roots()
2935/// #         .unwrap()
2936/// #         .https_or_http()
2937/// #         .enable_http2()
2938/// #         .build()
2939/// # );
2940/// # let mut hub = Assuredworkloads::new(client, auth);
2941/// // As the method needs a request, you would usually fill it with the desired information
2942/// // into the respective structure. Some of the parts shown here might not be applicable !
2943/// // Values shown here are possibly random and not representative !
2944/// let mut req = GoogleCloudAssuredworkloadsV1AcknowledgeViolationRequest::default();
2945///
2946/// // You can configure optional parameters by calling the respective setters at will, and
2947/// // execute the final call using `doit()`.
2948/// // Values shown here are possibly random and not representative !
2949/// let result = hub.organizations().locations_workloads_violations_acknowledge(req, "name")
2950///              .doit().await;
2951/// # }
2952/// ```
2953pub struct OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C>
2954where
2955    C: 'a,
2956{
2957    hub: &'a Assuredworkloads<C>,
2958    _request: GoogleCloudAssuredworkloadsV1AcknowledgeViolationRequest,
2959    _name: String,
2960    _delegate: Option<&'a mut dyn common::Delegate>,
2961    _additional_params: HashMap<String, String>,
2962    _scopes: BTreeSet<String>,
2963}
2964
2965impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C> {}
2966
2967impl<'a, C> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C>
2968where
2969    C: common::Connector,
2970{
2971    /// Perform the operation you have build so far.
2972    pub async fn doit(
2973        mut self,
2974    ) -> common::Result<(
2975        common::Response,
2976        GoogleCloudAssuredworkloadsV1AcknowledgeViolationResponse,
2977    )> {
2978        use std::borrow::Cow;
2979        use std::io::{Read, Seek};
2980
2981        use common::{url::Params, ToParts};
2982        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2983
2984        let mut dd = common::DefaultDelegate;
2985        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2986        dlg.begin(common::MethodInfo {
2987            id: "assuredworkloads.organizations.locations.workloads.violations.acknowledge",
2988            http_method: hyper::Method::POST,
2989        });
2990
2991        for &field in ["alt", "name"].iter() {
2992            if self._additional_params.contains_key(field) {
2993                dlg.finished(false);
2994                return Err(common::Error::FieldClash(field));
2995            }
2996        }
2997
2998        let mut params = Params::with_capacity(4 + self._additional_params.len());
2999        params.push("name", self._name);
3000
3001        params.extend(self._additional_params.iter());
3002
3003        params.push("alt", "json");
3004        let mut url = self.hub._base_url.clone() + "v1/{+name}:acknowledge";
3005        if self._scopes.is_empty() {
3006            self._scopes
3007                .insert(Scope::CloudPlatform.as_ref().to_string());
3008        }
3009
3010        #[allow(clippy::single_element_loop)]
3011        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3012            url = params.uri_replacement(url, param_name, find_this, true);
3013        }
3014        {
3015            let to_remove = ["name"];
3016            params.remove_params(&to_remove);
3017        }
3018
3019        let url = params.parse_with_url(&url);
3020
3021        let mut json_mime_type = mime::APPLICATION_JSON;
3022        let mut request_value_reader = {
3023            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3024            common::remove_json_null_values(&mut value);
3025            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3026            serde_json::to_writer(&mut dst, &value).unwrap();
3027            dst
3028        };
3029        let request_size = request_value_reader
3030            .seek(std::io::SeekFrom::End(0))
3031            .unwrap();
3032        request_value_reader
3033            .seek(std::io::SeekFrom::Start(0))
3034            .unwrap();
3035
3036        loop {
3037            let token = match self
3038                .hub
3039                .auth
3040                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3041                .await
3042            {
3043                Ok(token) => token,
3044                Err(e) => match dlg.token(e) {
3045                    Ok(token) => token,
3046                    Err(e) => {
3047                        dlg.finished(false);
3048                        return Err(common::Error::MissingToken(e));
3049                    }
3050                },
3051            };
3052            request_value_reader
3053                .seek(std::io::SeekFrom::Start(0))
3054                .unwrap();
3055            let mut req_result = {
3056                let client = &self.hub.client;
3057                dlg.pre_request();
3058                let mut req_builder = hyper::Request::builder()
3059                    .method(hyper::Method::POST)
3060                    .uri(url.as_str())
3061                    .header(USER_AGENT, self.hub._user_agent.clone());
3062
3063                if let Some(token) = token.as_ref() {
3064                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3065                }
3066
3067                let request = req_builder
3068                    .header(CONTENT_TYPE, json_mime_type.to_string())
3069                    .header(CONTENT_LENGTH, request_size as u64)
3070                    .body(common::to_body(
3071                        request_value_reader.get_ref().clone().into(),
3072                    ));
3073
3074                client.request(request.unwrap()).await
3075            };
3076
3077            match req_result {
3078                Err(err) => {
3079                    if let common::Retry::After(d) = dlg.http_error(&err) {
3080                        sleep(d).await;
3081                        continue;
3082                    }
3083                    dlg.finished(false);
3084                    return Err(common::Error::HttpError(err));
3085                }
3086                Ok(res) => {
3087                    let (mut parts, body) = res.into_parts();
3088                    let mut body = common::Body::new(body);
3089                    if !parts.status.is_success() {
3090                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3091                        let error = serde_json::from_str(&common::to_string(&bytes));
3092                        let response = common::to_response(parts, bytes.into());
3093
3094                        if let common::Retry::After(d) =
3095                            dlg.http_failure(&response, error.as_ref().ok())
3096                        {
3097                            sleep(d).await;
3098                            continue;
3099                        }
3100
3101                        dlg.finished(false);
3102
3103                        return Err(match error {
3104                            Ok(value) => common::Error::BadRequest(value),
3105                            _ => common::Error::Failure(response),
3106                        });
3107                    }
3108                    let response = {
3109                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3110                        let encoded = common::to_string(&bytes);
3111                        match serde_json::from_str(&encoded) {
3112                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3113                            Err(error) => {
3114                                dlg.response_json_decode_error(&encoded, &error);
3115                                return Err(common::Error::JsonDecodeError(
3116                                    encoded.to_string(),
3117                                    error,
3118                                ));
3119                            }
3120                        }
3121                    };
3122
3123                    dlg.finished(true);
3124                    return Ok(response);
3125                }
3126            }
3127        }
3128    }
3129
3130    ///
3131    /// Sets the *request* property to the given value.
3132    ///
3133    /// Even though the property as already been set when instantiating this call,
3134    /// we provide this method for API completeness.
3135    pub fn request(
3136        mut self,
3137        new_value: GoogleCloudAssuredworkloadsV1AcknowledgeViolationRequest,
3138    ) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C> {
3139        self._request = new_value;
3140        self
3141    }
3142    /// Required. The resource name of the Violation to acknowledge. Format: organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
3143    ///
3144    /// Sets the *name* path property to the given value.
3145    ///
3146    /// Even though the property as already been set when instantiating this call,
3147    /// we provide this method for API completeness.
3148    pub fn name(
3149        mut self,
3150        new_value: &str,
3151    ) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C> {
3152        self._name = new_value.to_string();
3153        self
3154    }
3155    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3156    /// while executing the actual API request.
3157    ///
3158    /// ````text
3159    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3160    /// ````
3161    ///
3162    /// Sets the *delegate* property to the given value.
3163    pub fn delegate(
3164        mut self,
3165        new_value: &'a mut dyn common::Delegate,
3166    ) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C> {
3167        self._delegate = Some(new_value);
3168        self
3169    }
3170
3171    /// Set any additional parameter of the query string used in the request.
3172    /// It should be used to set parameters which are not yet available through their own
3173    /// setters.
3174    ///
3175    /// Please note that this method must not be used to set any of the known parameters
3176    /// which have their own setter method. If done anyway, the request will fail.
3177    ///
3178    /// # Additional Parameters
3179    ///
3180    /// * *$.xgafv* (query-string) - V1 error format.
3181    /// * *access_token* (query-string) - OAuth access token.
3182    /// * *alt* (query-string) - Data format for response.
3183    /// * *callback* (query-string) - JSONP
3184    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3185    /// * *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.
3186    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3187    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3188    /// * *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.
3189    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3190    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3191    pub fn param<T>(
3192        mut self,
3193        name: T,
3194        value: T,
3195    ) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C>
3196    where
3197        T: AsRef<str>,
3198    {
3199        self._additional_params
3200            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3201        self
3202    }
3203
3204    /// Identifies the authorization scope for the method you are building.
3205    ///
3206    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3207    /// [`Scope::CloudPlatform`].
3208    ///
3209    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3210    /// tokens for more than one scope.
3211    ///
3212    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3213    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3214    /// sufficient, a read-write scope will do as well.
3215    pub fn add_scope<St>(
3216        mut self,
3217        scope: St,
3218    ) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C>
3219    where
3220        St: AsRef<str>,
3221    {
3222        self._scopes.insert(String::from(scope.as_ref()));
3223        self
3224    }
3225    /// Identifies the authorization scope(s) for the method you are building.
3226    ///
3227    /// See [`Self::add_scope()`] for details.
3228    pub fn add_scopes<I, St>(
3229        mut self,
3230        scopes: I,
3231    ) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C>
3232    where
3233        I: IntoIterator<Item = St>,
3234        St: AsRef<str>,
3235    {
3236        self._scopes
3237            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3238        self
3239    }
3240
3241    /// Removes all scopes, and no default scope will be used either.
3242    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3243    /// for details).
3244    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadViolationAcknowledgeCall<'a, C> {
3245        self._scopes.clear();
3246        self
3247    }
3248}
3249
3250/// Retrieves Assured Workload Violation based on ID.
3251///
3252/// A builder for the *locations.workloads.violations.get* method supported by a *organization* resource.
3253/// It is not used directly, but through a [`OrganizationMethods`] instance.
3254///
3255/// # Example
3256///
3257/// Instantiate a resource method builder
3258///
3259/// ```test_harness,no_run
3260/// # extern crate hyper;
3261/// # extern crate hyper_rustls;
3262/// # extern crate google_assuredworkloads1 as assuredworkloads1;
3263/// # async fn dox() {
3264/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3265///
3266/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3267/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3268/// #     .with_native_roots()
3269/// #     .unwrap()
3270/// #     .https_only()
3271/// #     .enable_http2()
3272/// #     .build();
3273///
3274/// # let executor = hyper_util::rt::TokioExecutor::new();
3275/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3276/// #     secret,
3277/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3278/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3279/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3280/// #     ),
3281/// # ).build().await.unwrap();
3282///
3283/// # let client = hyper_util::client::legacy::Client::builder(
3284/// #     hyper_util::rt::TokioExecutor::new()
3285/// # )
3286/// # .build(
3287/// #     hyper_rustls::HttpsConnectorBuilder::new()
3288/// #         .with_native_roots()
3289/// #         .unwrap()
3290/// #         .https_or_http()
3291/// #         .enable_http2()
3292/// #         .build()
3293/// # );
3294/// # let mut hub = Assuredworkloads::new(client, auth);
3295/// // You can configure optional parameters by calling the respective setters at will, and
3296/// // execute the final call using `doit()`.
3297/// // Values shown here are possibly random and not representative !
3298/// let result = hub.organizations().locations_workloads_violations_get("name")
3299///              .doit().await;
3300/// # }
3301/// ```
3302pub struct OrganizationLocationWorkloadViolationGetCall<'a, C>
3303where
3304    C: 'a,
3305{
3306    hub: &'a Assuredworkloads<C>,
3307    _name: String,
3308    _delegate: Option<&'a mut dyn common::Delegate>,
3309    _additional_params: HashMap<String, String>,
3310    _scopes: BTreeSet<String>,
3311}
3312
3313impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadViolationGetCall<'a, C> {}
3314
3315impl<'a, C> OrganizationLocationWorkloadViolationGetCall<'a, C>
3316where
3317    C: common::Connector,
3318{
3319    /// Perform the operation you have build so far.
3320    pub async fn doit(
3321        mut self,
3322    ) -> common::Result<(common::Response, GoogleCloudAssuredworkloadsV1Violation)> {
3323        use std::borrow::Cow;
3324        use std::io::{Read, Seek};
3325
3326        use common::{url::Params, ToParts};
3327        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3328
3329        let mut dd = common::DefaultDelegate;
3330        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3331        dlg.begin(common::MethodInfo {
3332            id: "assuredworkloads.organizations.locations.workloads.violations.get",
3333            http_method: hyper::Method::GET,
3334        });
3335
3336        for &field in ["alt", "name"].iter() {
3337            if self._additional_params.contains_key(field) {
3338                dlg.finished(false);
3339                return Err(common::Error::FieldClash(field));
3340            }
3341        }
3342
3343        let mut params = Params::with_capacity(3 + self._additional_params.len());
3344        params.push("name", self._name);
3345
3346        params.extend(self._additional_params.iter());
3347
3348        params.push("alt", "json");
3349        let mut url = self.hub._base_url.clone() + "v1/{+name}";
3350        if self._scopes.is_empty() {
3351            self._scopes
3352                .insert(Scope::CloudPlatform.as_ref().to_string());
3353        }
3354
3355        #[allow(clippy::single_element_loop)]
3356        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3357            url = params.uri_replacement(url, param_name, find_this, true);
3358        }
3359        {
3360            let to_remove = ["name"];
3361            params.remove_params(&to_remove);
3362        }
3363
3364        let url = params.parse_with_url(&url);
3365
3366        loop {
3367            let token = match self
3368                .hub
3369                .auth
3370                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3371                .await
3372            {
3373                Ok(token) => token,
3374                Err(e) => match dlg.token(e) {
3375                    Ok(token) => token,
3376                    Err(e) => {
3377                        dlg.finished(false);
3378                        return Err(common::Error::MissingToken(e));
3379                    }
3380                },
3381            };
3382            let mut req_result = {
3383                let client = &self.hub.client;
3384                dlg.pre_request();
3385                let mut req_builder = hyper::Request::builder()
3386                    .method(hyper::Method::GET)
3387                    .uri(url.as_str())
3388                    .header(USER_AGENT, self.hub._user_agent.clone());
3389
3390                if let Some(token) = token.as_ref() {
3391                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3392                }
3393
3394                let request = req_builder
3395                    .header(CONTENT_LENGTH, 0_u64)
3396                    .body(common::to_body::<String>(None));
3397
3398                client.request(request.unwrap()).await
3399            };
3400
3401            match req_result {
3402                Err(err) => {
3403                    if let common::Retry::After(d) = dlg.http_error(&err) {
3404                        sleep(d).await;
3405                        continue;
3406                    }
3407                    dlg.finished(false);
3408                    return Err(common::Error::HttpError(err));
3409                }
3410                Ok(res) => {
3411                    let (mut parts, body) = res.into_parts();
3412                    let mut body = common::Body::new(body);
3413                    if !parts.status.is_success() {
3414                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3415                        let error = serde_json::from_str(&common::to_string(&bytes));
3416                        let response = common::to_response(parts, bytes.into());
3417
3418                        if let common::Retry::After(d) =
3419                            dlg.http_failure(&response, error.as_ref().ok())
3420                        {
3421                            sleep(d).await;
3422                            continue;
3423                        }
3424
3425                        dlg.finished(false);
3426
3427                        return Err(match error {
3428                            Ok(value) => common::Error::BadRequest(value),
3429                            _ => common::Error::Failure(response),
3430                        });
3431                    }
3432                    let response = {
3433                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3434                        let encoded = common::to_string(&bytes);
3435                        match serde_json::from_str(&encoded) {
3436                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3437                            Err(error) => {
3438                                dlg.response_json_decode_error(&encoded, &error);
3439                                return Err(common::Error::JsonDecodeError(
3440                                    encoded.to_string(),
3441                                    error,
3442                                ));
3443                            }
3444                        }
3445                    };
3446
3447                    dlg.finished(true);
3448                    return Ok(response);
3449                }
3450            }
3451        }
3452    }
3453
3454    /// Required. The resource name of the Violation to fetch (ie. Violation.name). Format: organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
3455    ///
3456    /// Sets the *name* path property to the given value.
3457    ///
3458    /// Even though the property as already been set when instantiating this call,
3459    /// we provide this method for API completeness.
3460    pub fn name(mut self, new_value: &str) -> OrganizationLocationWorkloadViolationGetCall<'a, C> {
3461        self._name = new_value.to_string();
3462        self
3463    }
3464    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3465    /// while executing the actual API request.
3466    ///
3467    /// ````text
3468    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3469    /// ````
3470    ///
3471    /// Sets the *delegate* property to the given value.
3472    pub fn delegate(
3473        mut self,
3474        new_value: &'a mut dyn common::Delegate,
3475    ) -> OrganizationLocationWorkloadViolationGetCall<'a, C> {
3476        self._delegate = Some(new_value);
3477        self
3478    }
3479
3480    /// Set any additional parameter of the query string used in the request.
3481    /// It should be used to set parameters which are not yet available through their own
3482    /// setters.
3483    ///
3484    /// Please note that this method must not be used to set any of the known parameters
3485    /// which have their own setter method. If done anyway, the request will fail.
3486    ///
3487    /// # Additional Parameters
3488    ///
3489    /// * *$.xgafv* (query-string) - V1 error format.
3490    /// * *access_token* (query-string) - OAuth access token.
3491    /// * *alt* (query-string) - Data format for response.
3492    /// * *callback* (query-string) - JSONP
3493    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3494    /// * *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.
3495    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3496    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3497    /// * *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.
3498    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3499    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3500    pub fn param<T>(
3501        mut self,
3502        name: T,
3503        value: T,
3504    ) -> OrganizationLocationWorkloadViolationGetCall<'a, C>
3505    where
3506        T: AsRef<str>,
3507    {
3508        self._additional_params
3509            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3510        self
3511    }
3512
3513    /// Identifies the authorization scope for the method you are building.
3514    ///
3515    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3516    /// [`Scope::CloudPlatform`].
3517    ///
3518    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3519    /// tokens for more than one scope.
3520    ///
3521    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3522    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3523    /// sufficient, a read-write scope will do as well.
3524    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadViolationGetCall<'a, C>
3525    where
3526        St: AsRef<str>,
3527    {
3528        self._scopes.insert(String::from(scope.as_ref()));
3529        self
3530    }
3531    /// Identifies the authorization scope(s) for the method you are building.
3532    ///
3533    /// See [`Self::add_scope()`] for details.
3534    pub fn add_scopes<I, St>(
3535        mut self,
3536        scopes: I,
3537    ) -> OrganizationLocationWorkloadViolationGetCall<'a, C>
3538    where
3539        I: IntoIterator<Item = St>,
3540        St: AsRef<str>,
3541    {
3542        self._scopes
3543            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3544        self
3545    }
3546
3547    /// Removes all scopes, and no default scope will be used either.
3548    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3549    /// for details).
3550    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadViolationGetCall<'a, C> {
3551        self._scopes.clear();
3552        self
3553    }
3554}
3555
3556/// Lists the Violations in the AssuredWorkload Environment. Callers may also choose to read across multiple Workloads as per [AIP-159](https://google.aip.dev/159) by using '-' (the hyphen or dash character) as a wildcard character instead of workload-id in the parent. Format `organizations/{org_id}/locations/{location}/workloads/-`
3557///
3558/// A builder for the *locations.workloads.violations.list* method supported by a *organization* resource.
3559/// It is not used directly, but through a [`OrganizationMethods`] instance.
3560///
3561/// # Example
3562///
3563/// Instantiate a resource method builder
3564///
3565/// ```test_harness,no_run
3566/// # extern crate hyper;
3567/// # extern crate hyper_rustls;
3568/// # extern crate google_assuredworkloads1 as assuredworkloads1;
3569/// # async fn dox() {
3570/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3571///
3572/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3573/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3574/// #     .with_native_roots()
3575/// #     .unwrap()
3576/// #     .https_only()
3577/// #     .enable_http2()
3578/// #     .build();
3579///
3580/// # let executor = hyper_util::rt::TokioExecutor::new();
3581/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3582/// #     secret,
3583/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3584/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3585/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3586/// #     ),
3587/// # ).build().await.unwrap();
3588///
3589/// # let client = hyper_util::client::legacy::Client::builder(
3590/// #     hyper_util::rt::TokioExecutor::new()
3591/// # )
3592/// # .build(
3593/// #     hyper_rustls::HttpsConnectorBuilder::new()
3594/// #         .with_native_roots()
3595/// #         .unwrap()
3596/// #         .https_or_http()
3597/// #         .enable_http2()
3598/// #         .build()
3599/// # );
3600/// # let mut hub = Assuredworkloads::new(client, auth);
3601/// // You can configure optional parameters by calling the respective setters at will, and
3602/// // execute the final call using `doit()`.
3603/// // Values shown here are possibly random and not representative !
3604/// let result = hub.organizations().locations_workloads_violations_list("parent")
3605///              .page_token("invidunt")
3606///              .page_size(-47)
3607///              .interval_start_time(chrono::Utc::now())
3608///              .interval_end_time(chrono::Utc::now())
3609///              .filter("duo")
3610///              .doit().await;
3611/// # }
3612/// ```
3613pub struct OrganizationLocationWorkloadViolationListCall<'a, C>
3614where
3615    C: 'a,
3616{
3617    hub: &'a Assuredworkloads<C>,
3618    _parent: String,
3619    _page_token: Option<String>,
3620    _page_size: Option<i32>,
3621    _interval_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3622    _interval_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3623    _filter: Option<String>,
3624    _delegate: Option<&'a mut dyn common::Delegate>,
3625    _additional_params: HashMap<String, String>,
3626    _scopes: BTreeSet<String>,
3627}
3628
3629impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadViolationListCall<'a, C> {}
3630
3631impl<'a, C> OrganizationLocationWorkloadViolationListCall<'a, C>
3632where
3633    C: common::Connector,
3634{
3635    /// Perform the operation you have build so far.
3636    pub async fn doit(
3637        mut self,
3638    ) -> common::Result<(
3639        common::Response,
3640        GoogleCloudAssuredworkloadsV1ListViolationsResponse,
3641    )> {
3642        use std::borrow::Cow;
3643        use std::io::{Read, Seek};
3644
3645        use common::{url::Params, ToParts};
3646        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3647
3648        let mut dd = common::DefaultDelegate;
3649        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3650        dlg.begin(common::MethodInfo {
3651            id: "assuredworkloads.organizations.locations.workloads.violations.list",
3652            http_method: hyper::Method::GET,
3653        });
3654
3655        for &field in [
3656            "alt",
3657            "parent",
3658            "pageToken",
3659            "pageSize",
3660            "interval.startTime",
3661            "interval.endTime",
3662            "filter",
3663        ]
3664        .iter()
3665        {
3666            if self._additional_params.contains_key(field) {
3667                dlg.finished(false);
3668                return Err(common::Error::FieldClash(field));
3669            }
3670        }
3671
3672        let mut params = Params::with_capacity(8 + self._additional_params.len());
3673        params.push("parent", self._parent);
3674        if let Some(value) = self._page_token.as_ref() {
3675            params.push("pageToken", value);
3676        }
3677        if let Some(value) = self._page_size.as_ref() {
3678            params.push("pageSize", value.to_string());
3679        }
3680        if let Some(value) = self._interval_start_time.as_ref() {
3681            params.push(
3682                "interval.startTime",
3683                common::serde::datetime_to_string(&value),
3684            );
3685        }
3686        if let Some(value) = self._interval_end_time.as_ref() {
3687            params.push(
3688                "interval.endTime",
3689                common::serde::datetime_to_string(&value),
3690            );
3691        }
3692        if let Some(value) = self._filter.as_ref() {
3693            params.push("filter", value);
3694        }
3695
3696        params.extend(self._additional_params.iter());
3697
3698        params.push("alt", "json");
3699        let mut url = self.hub._base_url.clone() + "v1/{+parent}/violations";
3700        if self._scopes.is_empty() {
3701            self._scopes
3702                .insert(Scope::CloudPlatform.as_ref().to_string());
3703        }
3704
3705        #[allow(clippy::single_element_loop)]
3706        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3707            url = params.uri_replacement(url, param_name, find_this, true);
3708        }
3709        {
3710            let to_remove = ["parent"];
3711            params.remove_params(&to_remove);
3712        }
3713
3714        let url = params.parse_with_url(&url);
3715
3716        loop {
3717            let token = match self
3718                .hub
3719                .auth
3720                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3721                .await
3722            {
3723                Ok(token) => token,
3724                Err(e) => match dlg.token(e) {
3725                    Ok(token) => token,
3726                    Err(e) => {
3727                        dlg.finished(false);
3728                        return Err(common::Error::MissingToken(e));
3729                    }
3730                },
3731            };
3732            let mut req_result = {
3733                let client = &self.hub.client;
3734                dlg.pre_request();
3735                let mut req_builder = hyper::Request::builder()
3736                    .method(hyper::Method::GET)
3737                    .uri(url.as_str())
3738                    .header(USER_AGENT, self.hub._user_agent.clone());
3739
3740                if let Some(token) = token.as_ref() {
3741                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3742                }
3743
3744                let request = req_builder
3745                    .header(CONTENT_LENGTH, 0_u64)
3746                    .body(common::to_body::<String>(None));
3747
3748                client.request(request.unwrap()).await
3749            };
3750
3751            match req_result {
3752                Err(err) => {
3753                    if let common::Retry::After(d) = dlg.http_error(&err) {
3754                        sleep(d).await;
3755                        continue;
3756                    }
3757                    dlg.finished(false);
3758                    return Err(common::Error::HttpError(err));
3759                }
3760                Ok(res) => {
3761                    let (mut parts, body) = res.into_parts();
3762                    let mut body = common::Body::new(body);
3763                    if !parts.status.is_success() {
3764                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3765                        let error = serde_json::from_str(&common::to_string(&bytes));
3766                        let response = common::to_response(parts, bytes.into());
3767
3768                        if let common::Retry::After(d) =
3769                            dlg.http_failure(&response, error.as_ref().ok())
3770                        {
3771                            sleep(d).await;
3772                            continue;
3773                        }
3774
3775                        dlg.finished(false);
3776
3777                        return Err(match error {
3778                            Ok(value) => common::Error::BadRequest(value),
3779                            _ => common::Error::Failure(response),
3780                        });
3781                    }
3782                    let response = {
3783                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3784                        let encoded = common::to_string(&bytes);
3785                        match serde_json::from_str(&encoded) {
3786                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3787                            Err(error) => {
3788                                dlg.response_json_decode_error(&encoded, &error);
3789                                return Err(common::Error::JsonDecodeError(
3790                                    encoded.to_string(),
3791                                    error,
3792                                ));
3793                            }
3794                        }
3795                    };
3796
3797                    dlg.finished(true);
3798                    return Ok(response);
3799                }
3800            }
3801        }
3802    }
3803
3804    /// Required. The Workload name. Format `organizations/{org_id}/locations/{location}/workloads/{workload}`.
3805    ///
3806    /// Sets the *parent* path property to the given value.
3807    ///
3808    /// Even though the property as already been set when instantiating this call,
3809    /// we provide this method for API completeness.
3810    pub fn parent(
3811        mut self,
3812        new_value: &str,
3813    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3814        self._parent = new_value.to_string();
3815        self
3816    }
3817    /// Optional. Page token returned from previous request.
3818    ///
3819    /// Sets the *page token* query property to the given value.
3820    pub fn page_token(
3821        mut self,
3822        new_value: &str,
3823    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3824        self._page_token = Some(new_value.to_string());
3825        self
3826    }
3827    /// Optional. Page size.
3828    ///
3829    /// Sets the *page size* query property to the given value.
3830    pub fn page_size(
3831        mut self,
3832        new_value: i32,
3833    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3834        self._page_size = Some(new_value);
3835        self
3836    }
3837    /// The start of the time window.
3838    ///
3839    /// Sets the *interval.start time* query property to the given value.
3840    pub fn interval_start_time(
3841        mut self,
3842        new_value: chrono::DateTime<chrono::offset::Utc>,
3843    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3844        self._interval_start_time = Some(new_value);
3845        self
3846    }
3847    /// The end of the time window.
3848    ///
3849    /// Sets the *interval.end time* query property to the given value.
3850    pub fn interval_end_time(
3851        mut self,
3852        new_value: chrono::DateTime<chrono::offset::Utc>,
3853    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3854        self._interval_end_time = Some(new_value);
3855        self
3856    }
3857    /// Optional. A custom filter for filtering by the Violations properties.
3858    ///
3859    /// Sets the *filter* query property to the given value.
3860    pub fn filter(
3861        mut self,
3862        new_value: &str,
3863    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3864        self._filter = Some(new_value.to_string());
3865        self
3866    }
3867    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3868    /// while executing the actual API request.
3869    ///
3870    /// ````text
3871    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3872    /// ````
3873    ///
3874    /// Sets the *delegate* property to the given value.
3875    pub fn delegate(
3876        mut self,
3877        new_value: &'a mut dyn common::Delegate,
3878    ) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3879        self._delegate = Some(new_value);
3880        self
3881    }
3882
3883    /// Set any additional parameter of the query string used in the request.
3884    /// It should be used to set parameters which are not yet available through their own
3885    /// setters.
3886    ///
3887    /// Please note that this method must not be used to set any of the known parameters
3888    /// which have their own setter method. If done anyway, the request will fail.
3889    ///
3890    /// # Additional Parameters
3891    ///
3892    /// * *$.xgafv* (query-string) - V1 error format.
3893    /// * *access_token* (query-string) - OAuth access token.
3894    /// * *alt* (query-string) - Data format for response.
3895    /// * *callback* (query-string) - JSONP
3896    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3897    /// * *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.
3898    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3899    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3900    /// * *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.
3901    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3902    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3903    pub fn param<T>(
3904        mut self,
3905        name: T,
3906        value: T,
3907    ) -> OrganizationLocationWorkloadViolationListCall<'a, C>
3908    where
3909        T: AsRef<str>,
3910    {
3911        self._additional_params
3912            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3913        self
3914    }
3915
3916    /// Identifies the authorization scope for the method you are building.
3917    ///
3918    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3919    /// [`Scope::CloudPlatform`].
3920    ///
3921    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3922    /// tokens for more than one scope.
3923    ///
3924    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3925    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3926    /// sufficient, a read-write scope will do as well.
3927    pub fn add_scope<St>(
3928        mut self,
3929        scope: St,
3930    ) -> OrganizationLocationWorkloadViolationListCall<'a, C>
3931    where
3932        St: AsRef<str>,
3933    {
3934        self._scopes.insert(String::from(scope.as_ref()));
3935        self
3936    }
3937    /// Identifies the authorization scope(s) for the method you are building.
3938    ///
3939    /// See [`Self::add_scope()`] for details.
3940    pub fn add_scopes<I, St>(
3941        mut self,
3942        scopes: I,
3943    ) -> OrganizationLocationWorkloadViolationListCall<'a, C>
3944    where
3945        I: IntoIterator<Item = St>,
3946        St: AsRef<str>,
3947    {
3948        self._scopes
3949            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3950        self
3951    }
3952
3953    /// Removes all scopes, and no default scope will be used either.
3954    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3955    /// for details).
3956    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadViolationListCall<'a, C> {
3957        self._scopes.clear();
3958        self
3959    }
3960}
3961
3962/// Analyzes a hypothetical move of a source resource to a target workload to surface compliance risks. The analysis is best effort and is not guaranteed to be exhaustive.
3963///
3964/// A builder for the *locations.workloads.analyzeWorkloadMove* method supported by a *organization* resource.
3965/// It is not used directly, but through a [`OrganizationMethods`] instance.
3966///
3967/// # Example
3968///
3969/// Instantiate a resource method builder
3970///
3971/// ```test_harness,no_run
3972/// # extern crate hyper;
3973/// # extern crate hyper_rustls;
3974/// # extern crate google_assuredworkloads1 as assuredworkloads1;
3975/// # async fn dox() {
3976/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3977///
3978/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3979/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3980/// #     .with_native_roots()
3981/// #     .unwrap()
3982/// #     .https_only()
3983/// #     .enable_http2()
3984/// #     .build();
3985///
3986/// # let executor = hyper_util::rt::TokioExecutor::new();
3987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3988/// #     secret,
3989/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3990/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3991/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3992/// #     ),
3993/// # ).build().await.unwrap();
3994///
3995/// # let client = hyper_util::client::legacy::Client::builder(
3996/// #     hyper_util::rt::TokioExecutor::new()
3997/// # )
3998/// # .build(
3999/// #     hyper_rustls::HttpsConnectorBuilder::new()
4000/// #         .with_native_roots()
4001/// #         .unwrap()
4002/// #         .https_or_http()
4003/// #         .enable_http2()
4004/// #         .build()
4005/// # );
4006/// # let mut hub = Assuredworkloads::new(client, auth);
4007/// // You can configure optional parameters by calling the respective setters at will, and
4008/// // execute the final call using `doit()`.
4009/// // Values shown here are possibly random and not representative !
4010/// let result = hub.organizations().locations_workloads_analyze_workload_move("target")
4011///              .project("sed")
4012///              .page_token("ut")
4013///              .page_size(-12)
4014///              .add_asset_types("rebum.")
4015///              .doit().await;
4016/// # }
4017/// ```
4018pub struct OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C>
4019where
4020    C: 'a,
4021{
4022    hub: &'a Assuredworkloads<C>,
4023    _target: String,
4024    _project: Option<String>,
4025    _page_token: Option<String>,
4026    _page_size: Option<i32>,
4027    _asset_types: Vec<String>,
4028    _delegate: Option<&'a mut dyn common::Delegate>,
4029    _additional_params: HashMap<String, String>,
4030    _scopes: BTreeSet<String>,
4031}
4032
4033impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {}
4034
4035impl<'a, C> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C>
4036where
4037    C: common::Connector,
4038{
4039    /// Perform the operation you have build so far.
4040    pub async fn doit(
4041        mut self,
4042    ) -> common::Result<(
4043        common::Response,
4044        GoogleCloudAssuredworkloadsV1AnalyzeWorkloadMoveResponse,
4045    )> {
4046        use std::borrow::Cow;
4047        use std::io::{Read, Seek};
4048
4049        use common::{url::Params, ToParts};
4050        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4051
4052        let mut dd = common::DefaultDelegate;
4053        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4054        dlg.begin(common::MethodInfo {
4055            id: "assuredworkloads.organizations.locations.workloads.analyzeWorkloadMove",
4056            http_method: hyper::Method::GET,
4057        });
4058
4059        for &field in [
4060            "alt",
4061            "target",
4062            "project",
4063            "pageToken",
4064            "pageSize",
4065            "assetTypes",
4066        ]
4067        .iter()
4068        {
4069            if self._additional_params.contains_key(field) {
4070                dlg.finished(false);
4071                return Err(common::Error::FieldClash(field));
4072            }
4073        }
4074
4075        let mut params = Params::with_capacity(7 + self._additional_params.len());
4076        params.push("target", self._target);
4077        if let Some(value) = self._project.as_ref() {
4078            params.push("project", value);
4079        }
4080        if let Some(value) = self._page_token.as_ref() {
4081            params.push("pageToken", value);
4082        }
4083        if let Some(value) = self._page_size.as_ref() {
4084            params.push("pageSize", value.to_string());
4085        }
4086        if !self._asset_types.is_empty() {
4087            for f in self._asset_types.iter() {
4088                params.push("assetTypes", f);
4089            }
4090        }
4091
4092        params.extend(self._additional_params.iter());
4093
4094        params.push("alt", "json");
4095        let mut url = self.hub._base_url.clone() + "v1/{+target}:analyzeWorkloadMove";
4096        if self._scopes.is_empty() {
4097            self._scopes
4098                .insert(Scope::CloudPlatform.as_ref().to_string());
4099        }
4100
4101        #[allow(clippy::single_element_loop)]
4102        for &(find_this, param_name) in [("{+target}", "target")].iter() {
4103            url = params.uri_replacement(url, param_name, find_this, true);
4104        }
4105        {
4106            let to_remove = ["target"];
4107            params.remove_params(&to_remove);
4108        }
4109
4110        let url = params.parse_with_url(&url);
4111
4112        loop {
4113            let token = match self
4114                .hub
4115                .auth
4116                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4117                .await
4118            {
4119                Ok(token) => token,
4120                Err(e) => match dlg.token(e) {
4121                    Ok(token) => token,
4122                    Err(e) => {
4123                        dlg.finished(false);
4124                        return Err(common::Error::MissingToken(e));
4125                    }
4126                },
4127            };
4128            let mut req_result = {
4129                let client = &self.hub.client;
4130                dlg.pre_request();
4131                let mut req_builder = hyper::Request::builder()
4132                    .method(hyper::Method::GET)
4133                    .uri(url.as_str())
4134                    .header(USER_AGENT, self.hub._user_agent.clone());
4135
4136                if let Some(token) = token.as_ref() {
4137                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4138                }
4139
4140                let request = req_builder
4141                    .header(CONTENT_LENGTH, 0_u64)
4142                    .body(common::to_body::<String>(None));
4143
4144                client.request(request.unwrap()).await
4145            };
4146
4147            match req_result {
4148                Err(err) => {
4149                    if let common::Retry::After(d) = dlg.http_error(&err) {
4150                        sleep(d).await;
4151                        continue;
4152                    }
4153                    dlg.finished(false);
4154                    return Err(common::Error::HttpError(err));
4155                }
4156                Ok(res) => {
4157                    let (mut parts, body) = res.into_parts();
4158                    let mut body = common::Body::new(body);
4159                    if !parts.status.is_success() {
4160                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4161                        let error = serde_json::from_str(&common::to_string(&bytes));
4162                        let response = common::to_response(parts, bytes.into());
4163
4164                        if let common::Retry::After(d) =
4165                            dlg.http_failure(&response, error.as_ref().ok())
4166                        {
4167                            sleep(d).await;
4168                            continue;
4169                        }
4170
4171                        dlg.finished(false);
4172
4173                        return Err(match error {
4174                            Ok(value) => common::Error::BadRequest(value),
4175                            _ => common::Error::Failure(response),
4176                        });
4177                    }
4178                    let response = {
4179                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4180                        let encoded = common::to_string(&bytes);
4181                        match serde_json::from_str(&encoded) {
4182                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4183                            Err(error) => {
4184                                dlg.response_json_decode_error(&encoded, &error);
4185                                return Err(common::Error::JsonDecodeError(
4186                                    encoded.to_string(),
4187                                    error,
4188                                ));
4189                            }
4190                        }
4191                    };
4192
4193                    dlg.finished(true);
4194                    return Ok(response);
4195                }
4196            }
4197        }
4198    }
4199
4200    /// Required. The resource ID of the folder-based destination workload. This workload is where the source resource will hypothetically be moved to. Specify the workload's relative resource name, formatted as: "organizations/{ORGANIZATION_ID}/locations/{LOCATION_ID}/workloads/{WORKLOAD_ID}" For example: "organizations/123/locations/us-east1/workloads/assured-workload-2"
4201    ///
4202    /// Sets the *target* path property to the given value.
4203    ///
4204    /// Even though the property as already been set when instantiating this call,
4205    /// we provide this method for API completeness.
4206    pub fn target(
4207        mut self,
4208        new_value: &str,
4209    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
4210        self._target = new_value.to_string();
4211        self
4212    }
4213    /// The source type is a project. Specify the project's relative resource name, formatted as either a project number or a project ID: "projects/{PROJECT_NUMBER}" or "projects/{PROJECT_ID}" For example: "projects/951040570662" when specifying a project number, or "projects/my-project-123" when specifying a project ID.
4214    ///
4215    /// Sets the *project* query property to the given value.
4216    pub fn project(
4217        mut self,
4218        new_value: &str,
4219    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
4220        self._project = Some(new_value.to_string());
4221        self
4222    }
4223    /// Optional. The page token from the previous response. It needs to be passed in the second and following requests.
4224    ///
4225    /// Sets the *page token* query property to the given value.
4226    pub fn page_token(
4227        mut self,
4228        new_value: &str,
4229    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
4230        self._page_token = Some(new_value.to_string());
4231        self
4232    }
4233    /// Optional. Page size. If a value is not specified, the default value of 10 is used. The maximum value is 50.
4234    ///
4235    /// Sets the *page size* query property to the given value.
4236    pub fn page_size(
4237        mut self,
4238        new_value: i32,
4239    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
4240        self._page_size = Some(new_value);
4241        self
4242    }
4243    /// Optional. List of asset types to be analyzed, including and under the source resource. If empty, all assets are analyzed. The complete list of asset types is available [here](https://cloud.google.com/asset-inventory/docs/supported-asset-types).
4244    ///
4245    /// Append the given value to the *asset types* query property.
4246    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
4247    pub fn add_asset_types(
4248        mut self,
4249        new_value: &str,
4250    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
4251        self._asset_types.push(new_value.to_string());
4252        self
4253    }
4254    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4255    /// while executing the actual API request.
4256    ///
4257    /// ````text
4258    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4259    /// ````
4260    ///
4261    /// Sets the *delegate* property to the given value.
4262    pub fn delegate(
4263        mut self,
4264        new_value: &'a mut dyn common::Delegate,
4265    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
4266        self._delegate = Some(new_value);
4267        self
4268    }
4269
4270    /// Set any additional parameter of the query string used in the request.
4271    /// It should be used to set parameters which are not yet available through their own
4272    /// setters.
4273    ///
4274    /// Please note that this method must not be used to set any of the known parameters
4275    /// which have their own setter method. If done anyway, the request will fail.
4276    ///
4277    /// # Additional Parameters
4278    ///
4279    /// * *$.xgafv* (query-string) - V1 error format.
4280    /// * *access_token* (query-string) - OAuth access token.
4281    /// * *alt* (query-string) - Data format for response.
4282    /// * *callback* (query-string) - JSONP
4283    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4284    /// * *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.
4285    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4286    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4287    /// * *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.
4288    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4289    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4290    pub fn param<T>(
4291        mut self,
4292        name: T,
4293        value: T,
4294    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C>
4295    where
4296        T: AsRef<str>,
4297    {
4298        self._additional_params
4299            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4300        self
4301    }
4302
4303    /// Identifies the authorization scope for the method you are building.
4304    ///
4305    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4306    /// [`Scope::CloudPlatform`].
4307    ///
4308    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4309    /// tokens for more than one scope.
4310    ///
4311    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4312    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4313    /// sufficient, a read-write scope will do as well.
4314    pub fn add_scope<St>(
4315        mut self,
4316        scope: St,
4317    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C>
4318    where
4319        St: AsRef<str>,
4320    {
4321        self._scopes.insert(String::from(scope.as_ref()));
4322        self
4323    }
4324    /// Identifies the authorization scope(s) for the method you are building.
4325    ///
4326    /// See [`Self::add_scope()`] for details.
4327    pub fn add_scopes<I, St>(
4328        mut self,
4329        scopes: I,
4330    ) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C>
4331    where
4332        I: IntoIterator<Item = St>,
4333        St: AsRef<str>,
4334    {
4335        self._scopes
4336            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4337        self
4338    }
4339
4340    /// Removes all scopes, and no default scope will be used either.
4341    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4342    /// for details).
4343    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadAnalyzeWorkloadMoveCall<'a, C> {
4344        self._scopes.clear();
4345        self
4346    }
4347}
4348
4349/// Creates Assured Workload.
4350///
4351/// A builder for the *locations.workloads.create* method supported by a *organization* resource.
4352/// It is not used directly, but through a [`OrganizationMethods`] instance.
4353///
4354/// # Example
4355///
4356/// Instantiate a resource method builder
4357///
4358/// ```test_harness,no_run
4359/// # extern crate hyper;
4360/// # extern crate hyper_rustls;
4361/// # extern crate google_assuredworkloads1 as assuredworkloads1;
4362/// use assuredworkloads1::api::GoogleCloudAssuredworkloadsV1Workload;
4363/// # async fn dox() {
4364/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4365///
4366/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4367/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4368/// #     .with_native_roots()
4369/// #     .unwrap()
4370/// #     .https_only()
4371/// #     .enable_http2()
4372/// #     .build();
4373///
4374/// # let executor = hyper_util::rt::TokioExecutor::new();
4375/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4376/// #     secret,
4377/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4378/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4379/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4380/// #     ),
4381/// # ).build().await.unwrap();
4382///
4383/// # let client = hyper_util::client::legacy::Client::builder(
4384/// #     hyper_util::rt::TokioExecutor::new()
4385/// # )
4386/// # .build(
4387/// #     hyper_rustls::HttpsConnectorBuilder::new()
4388/// #         .with_native_roots()
4389/// #         .unwrap()
4390/// #         .https_or_http()
4391/// #         .enable_http2()
4392/// #         .build()
4393/// # );
4394/// # let mut hub = Assuredworkloads::new(client, auth);
4395/// // As the method needs a request, you would usually fill it with the desired information
4396/// // into the respective structure. Some of the parts shown here might not be applicable !
4397/// // Values shown here are possibly random and not representative !
4398/// let mut req = GoogleCloudAssuredworkloadsV1Workload::default();
4399///
4400/// // You can configure optional parameters by calling the respective setters at will, and
4401/// // execute the final call using `doit()`.
4402/// // Values shown here are possibly random and not representative !
4403/// let result = hub.organizations().locations_workloads_create(req, "parent")
4404///              .external_id("ipsum")
4405///              .doit().await;
4406/// # }
4407/// ```
4408pub struct OrganizationLocationWorkloadCreateCall<'a, C>
4409where
4410    C: 'a,
4411{
4412    hub: &'a Assuredworkloads<C>,
4413    _request: GoogleCloudAssuredworkloadsV1Workload,
4414    _parent: String,
4415    _external_id: Option<String>,
4416    _delegate: Option<&'a mut dyn common::Delegate>,
4417    _additional_params: HashMap<String, String>,
4418    _scopes: BTreeSet<String>,
4419}
4420
4421impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadCreateCall<'a, C> {}
4422
4423impl<'a, C> OrganizationLocationWorkloadCreateCall<'a, C>
4424where
4425    C: common::Connector,
4426{
4427    /// Perform the operation you have build so far.
4428    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleLongrunningOperation)> {
4429        use std::borrow::Cow;
4430        use std::io::{Read, Seek};
4431
4432        use common::{url::Params, ToParts};
4433        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4434
4435        let mut dd = common::DefaultDelegate;
4436        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4437        dlg.begin(common::MethodInfo {
4438            id: "assuredworkloads.organizations.locations.workloads.create",
4439            http_method: hyper::Method::POST,
4440        });
4441
4442        for &field in ["alt", "parent", "externalId"].iter() {
4443            if self._additional_params.contains_key(field) {
4444                dlg.finished(false);
4445                return Err(common::Error::FieldClash(field));
4446            }
4447        }
4448
4449        let mut params = Params::with_capacity(5 + self._additional_params.len());
4450        params.push("parent", self._parent);
4451        if let Some(value) = self._external_id.as_ref() {
4452            params.push("externalId", value);
4453        }
4454
4455        params.extend(self._additional_params.iter());
4456
4457        params.push("alt", "json");
4458        let mut url = self.hub._base_url.clone() + "v1/{+parent}/workloads";
4459        if self._scopes.is_empty() {
4460            self._scopes
4461                .insert(Scope::CloudPlatform.as_ref().to_string());
4462        }
4463
4464        #[allow(clippy::single_element_loop)]
4465        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4466            url = params.uri_replacement(url, param_name, find_this, true);
4467        }
4468        {
4469            let to_remove = ["parent"];
4470            params.remove_params(&to_remove);
4471        }
4472
4473        let url = params.parse_with_url(&url);
4474
4475        let mut json_mime_type = mime::APPLICATION_JSON;
4476        let mut request_value_reader = {
4477            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4478            common::remove_json_null_values(&mut value);
4479            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4480            serde_json::to_writer(&mut dst, &value).unwrap();
4481            dst
4482        };
4483        let request_size = request_value_reader
4484            .seek(std::io::SeekFrom::End(0))
4485            .unwrap();
4486        request_value_reader
4487            .seek(std::io::SeekFrom::Start(0))
4488            .unwrap();
4489
4490        loop {
4491            let token = match self
4492                .hub
4493                .auth
4494                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4495                .await
4496            {
4497                Ok(token) => token,
4498                Err(e) => match dlg.token(e) {
4499                    Ok(token) => token,
4500                    Err(e) => {
4501                        dlg.finished(false);
4502                        return Err(common::Error::MissingToken(e));
4503                    }
4504                },
4505            };
4506            request_value_reader
4507                .seek(std::io::SeekFrom::Start(0))
4508                .unwrap();
4509            let mut req_result = {
4510                let client = &self.hub.client;
4511                dlg.pre_request();
4512                let mut req_builder = hyper::Request::builder()
4513                    .method(hyper::Method::POST)
4514                    .uri(url.as_str())
4515                    .header(USER_AGENT, self.hub._user_agent.clone());
4516
4517                if let Some(token) = token.as_ref() {
4518                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4519                }
4520
4521                let request = req_builder
4522                    .header(CONTENT_TYPE, json_mime_type.to_string())
4523                    .header(CONTENT_LENGTH, request_size as u64)
4524                    .body(common::to_body(
4525                        request_value_reader.get_ref().clone().into(),
4526                    ));
4527
4528                client.request(request.unwrap()).await
4529            };
4530
4531            match req_result {
4532                Err(err) => {
4533                    if let common::Retry::After(d) = dlg.http_error(&err) {
4534                        sleep(d).await;
4535                        continue;
4536                    }
4537                    dlg.finished(false);
4538                    return Err(common::Error::HttpError(err));
4539                }
4540                Ok(res) => {
4541                    let (mut parts, body) = res.into_parts();
4542                    let mut body = common::Body::new(body);
4543                    if !parts.status.is_success() {
4544                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4545                        let error = serde_json::from_str(&common::to_string(&bytes));
4546                        let response = common::to_response(parts, bytes.into());
4547
4548                        if let common::Retry::After(d) =
4549                            dlg.http_failure(&response, error.as_ref().ok())
4550                        {
4551                            sleep(d).await;
4552                            continue;
4553                        }
4554
4555                        dlg.finished(false);
4556
4557                        return Err(match error {
4558                            Ok(value) => common::Error::BadRequest(value),
4559                            _ => common::Error::Failure(response),
4560                        });
4561                    }
4562                    let response = {
4563                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4564                        let encoded = common::to_string(&bytes);
4565                        match serde_json::from_str(&encoded) {
4566                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4567                            Err(error) => {
4568                                dlg.response_json_decode_error(&encoded, &error);
4569                                return Err(common::Error::JsonDecodeError(
4570                                    encoded.to_string(),
4571                                    error,
4572                                ));
4573                            }
4574                        }
4575                    };
4576
4577                    dlg.finished(true);
4578                    return Ok(response);
4579                }
4580            }
4581        }
4582    }
4583
4584    ///
4585    /// Sets the *request* property to the given value.
4586    ///
4587    /// Even though the property as already been set when instantiating this call,
4588    /// we provide this method for API completeness.
4589    pub fn request(
4590        mut self,
4591        new_value: GoogleCloudAssuredworkloadsV1Workload,
4592    ) -> OrganizationLocationWorkloadCreateCall<'a, C> {
4593        self._request = new_value;
4594        self
4595    }
4596    /// Required. The resource name of the new Workload's parent. Must be of the form `organizations/{org_id}/locations/{location_id}`.
4597    ///
4598    /// Sets the *parent* path property to the given value.
4599    ///
4600    /// Even though the property as already been set when instantiating this call,
4601    /// we provide this method for API completeness.
4602    pub fn parent(mut self, new_value: &str) -> OrganizationLocationWorkloadCreateCall<'a, C> {
4603        self._parent = new_value.to_string();
4604        self
4605    }
4606    /// Optional. A identifier associated with the workload and underlying projects which allows for the break down of billing costs for a workload. The value provided for the identifier will add a label to the workload and contained projects with the identifier as the value.
4607    ///
4608    /// Sets the *external id* query property to the given value.
4609    pub fn external_id(mut self, new_value: &str) -> OrganizationLocationWorkloadCreateCall<'a, C> {
4610        self._external_id = Some(new_value.to_string());
4611        self
4612    }
4613    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4614    /// while executing the actual API request.
4615    ///
4616    /// ````text
4617    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4618    /// ````
4619    ///
4620    /// Sets the *delegate* property to the given value.
4621    pub fn delegate(
4622        mut self,
4623        new_value: &'a mut dyn common::Delegate,
4624    ) -> OrganizationLocationWorkloadCreateCall<'a, C> {
4625        self._delegate = Some(new_value);
4626        self
4627    }
4628
4629    /// Set any additional parameter of the query string used in the request.
4630    /// It should be used to set parameters which are not yet available through their own
4631    /// setters.
4632    ///
4633    /// Please note that this method must not be used to set any of the known parameters
4634    /// which have their own setter method. If done anyway, the request will fail.
4635    ///
4636    /// # Additional Parameters
4637    ///
4638    /// * *$.xgafv* (query-string) - V1 error format.
4639    /// * *access_token* (query-string) - OAuth access token.
4640    /// * *alt* (query-string) - Data format for response.
4641    /// * *callback* (query-string) - JSONP
4642    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4643    /// * *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.
4644    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4645    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4646    /// * *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.
4647    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4648    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4649    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationWorkloadCreateCall<'a, C>
4650    where
4651        T: AsRef<str>,
4652    {
4653        self._additional_params
4654            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4655        self
4656    }
4657
4658    /// Identifies the authorization scope for the method you are building.
4659    ///
4660    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4661    /// [`Scope::CloudPlatform`].
4662    ///
4663    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4664    /// tokens for more than one scope.
4665    ///
4666    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4667    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4668    /// sufficient, a read-write scope will do as well.
4669    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadCreateCall<'a, C>
4670    where
4671        St: AsRef<str>,
4672    {
4673        self._scopes.insert(String::from(scope.as_ref()));
4674        self
4675    }
4676    /// Identifies the authorization scope(s) for the method you are building.
4677    ///
4678    /// See [`Self::add_scope()`] for details.
4679    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationWorkloadCreateCall<'a, C>
4680    where
4681        I: IntoIterator<Item = St>,
4682        St: AsRef<str>,
4683    {
4684        self._scopes
4685            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4686        self
4687    }
4688
4689    /// Removes all scopes, and no default scope will be used either.
4690    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4691    /// for details).
4692    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadCreateCall<'a, C> {
4693        self._scopes.clear();
4694        self
4695    }
4696}
4697
4698/// Deletes the workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail with a FAILED_PRECONDITION error. In addition to assuredworkloads.workload.delete permission, the user should also have orgpolicy.policy.set permission on the deleted folder to remove Assured Workloads OrgPolicies.
4699///
4700/// A builder for the *locations.workloads.delete* method supported by a *organization* resource.
4701/// It is not used directly, but through a [`OrganizationMethods`] instance.
4702///
4703/// # Example
4704///
4705/// Instantiate a resource method builder
4706///
4707/// ```test_harness,no_run
4708/// # extern crate hyper;
4709/// # extern crate hyper_rustls;
4710/// # extern crate google_assuredworkloads1 as assuredworkloads1;
4711/// # async fn dox() {
4712/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4713///
4714/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4715/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4716/// #     .with_native_roots()
4717/// #     .unwrap()
4718/// #     .https_only()
4719/// #     .enable_http2()
4720/// #     .build();
4721///
4722/// # let executor = hyper_util::rt::TokioExecutor::new();
4723/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4724/// #     secret,
4725/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4726/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
4727/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
4728/// #     ),
4729/// # ).build().await.unwrap();
4730///
4731/// # let client = hyper_util::client::legacy::Client::builder(
4732/// #     hyper_util::rt::TokioExecutor::new()
4733/// # )
4734/// # .build(
4735/// #     hyper_rustls::HttpsConnectorBuilder::new()
4736/// #         .with_native_roots()
4737/// #         .unwrap()
4738/// #         .https_or_http()
4739/// #         .enable_http2()
4740/// #         .build()
4741/// # );
4742/// # let mut hub = Assuredworkloads::new(client, auth);
4743/// // You can configure optional parameters by calling the respective setters at will, and
4744/// // execute the final call using `doit()`.
4745/// // Values shown here are possibly random and not representative !
4746/// let result = hub.organizations().locations_workloads_delete("name")
4747///              .etag("est")
4748///              .doit().await;
4749/// # }
4750/// ```
4751pub struct OrganizationLocationWorkloadDeleteCall<'a, C>
4752where
4753    C: 'a,
4754{
4755    hub: &'a Assuredworkloads<C>,
4756    _name: String,
4757    _etag: Option<String>,
4758    _delegate: Option<&'a mut dyn common::Delegate>,
4759    _additional_params: HashMap<String, String>,
4760    _scopes: BTreeSet<String>,
4761}
4762
4763impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadDeleteCall<'a, C> {}
4764
4765impl<'a, C> OrganizationLocationWorkloadDeleteCall<'a, C>
4766where
4767    C: common::Connector,
4768{
4769    /// Perform the operation you have build so far.
4770    pub async fn doit(mut self) -> common::Result<(common::Response, GoogleProtobufEmpty)> {
4771        use std::borrow::Cow;
4772        use std::io::{Read, Seek};
4773
4774        use common::{url::Params, ToParts};
4775        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4776
4777        let mut dd = common::DefaultDelegate;
4778        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4779        dlg.begin(common::MethodInfo {
4780            id: "assuredworkloads.organizations.locations.workloads.delete",
4781            http_method: hyper::Method::DELETE,
4782        });
4783
4784        for &field in ["alt", "name", "etag"].iter() {
4785            if self._additional_params.contains_key(field) {
4786                dlg.finished(false);
4787                return Err(common::Error::FieldClash(field));
4788            }
4789        }
4790
4791        let mut params = Params::with_capacity(4 + self._additional_params.len());
4792        params.push("name", self._name);
4793        if let Some(value) = self._etag.as_ref() {
4794            params.push("etag", value);
4795        }
4796
4797        params.extend(self._additional_params.iter());
4798
4799        params.push("alt", "json");
4800        let mut url = self.hub._base_url.clone() + "v1/{+name}";
4801        if self._scopes.is_empty() {
4802            self._scopes
4803                .insert(Scope::CloudPlatform.as_ref().to_string());
4804        }
4805
4806        #[allow(clippy::single_element_loop)]
4807        for &(find_this, param_name) in [("{+name}", "name")].iter() {
4808            url = params.uri_replacement(url, param_name, find_this, true);
4809        }
4810        {
4811            let to_remove = ["name"];
4812            params.remove_params(&to_remove);
4813        }
4814
4815        let url = params.parse_with_url(&url);
4816
4817        loop {
4818            let token = match self
4819                .hub
4820                .auth
4821                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4822                .await
4823            {
4824                Ok(token) => token,
4825                Err(e) => match dlg.token(e) {
4826                    Ok(token) => token,
4827                    Err(e) => {
4828                        dlg.finished(false);
4829                        return Err(common::Error::MissingToken(e));
4830                    }
4831                },
4832            };
4833            let mut req_result = {
4834                let client = &self.hub.client;
4835                dlg.pre_request();
4836                let mut req_builder = hyper::Request::builder()
4837                    .method(hyper::Method::DELETE)
4838                    .uri(url.as_str())
4839                    .header(USER_AGENT, self.hub._user_agent.clone());
4840
4841                if let Some(token) = token.as_ref() {
4842                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4843                }
4844
4845                let request = req_builder
4846                    .header(CONTENT_LENGTH, 0_u64)
4847                    .body(common::to_body::<String>(None));
4848
4849                client.request(request.unwrap()).await
4850            };
4851
4852            match req_result {
4853                Err(err) => {
4854                    if let common::Retry::After(d) = dlg.http_error(&err) {
4855                        sleep(d).await;
4856                        continue;
4857                    }
4858                    dlg.finished(false);
4859                    return Err(common::Error::HttpError(err));
4860                }
4861                Ok(res) => {
4862                    let (mut parts, body) = res.into_parts();
4863                    let mut body = common::Body::new(body);
4864                    if !parts.status.is_success() {
4865                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4866                        let error = serde_json::from_str(&common::to_string(&bytes));
4867                        let response = common::to_response(parts, bytes.into());
4868
4869                        if let common::Retry::After(d) =
4870                            dlg.http_failure(&response, error.as_ref().ok())
4871                        {
4872                            sleep(d).await;
4873                            continue;
4874                        }
4875
4876                        dlg.finished(false);
4877
4878                        return Err(match error {
4879                            Ok(value) => common::Error::BadRequest(value),
4880                            _ => common::Error::Failure(response),
4881                        });
4882                    }
4883                    let response = {
4884                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4885                        let encoded = common::to_string(&bytes);
4886                        match serde_json::from_str(&encoded) {
4887                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4888                            Err(error) => {
4889                                dlg.response_json_decode_error(&encoded, &error);
4890                                return Err(common::Error::JsonDecodeError(
4891                                    encoded.to_string(),
4892                                    error,
4893                                ));
4894                            }
4895                        }
4896                    };
4897
4898                    dlg.finished(true);
4899                    return Ok(response);
4900                }
4901            }
4902        }
4903    }
4904
4905    /// Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
4906    ///
4907    /// Sets the *name* path property to the given value.
4908    ///
4909    /// Even though the property as already been set when instantiating this call,
4910    /// we provide this method for API completeness.
4911    pub fn name(mut self, new_value: &str) -> OrganizationLocationWorkloadDeleteCall<'a, C> {
4912        self._name = new_value.to_string();
4913        self
4914    }
4915    /// Optional. The etag of the workload. If this is provided, it must match the server's etag.
4916    ///
4917    /// Sets the *etag* query property to the given value.
4918    pub fn etag(mut self, new_value: &str) -> OrganizationLocationWorkloadDeleteCall<'a, C> {
4919        self._etag = Some(new_value.to_string());
4920        self
4921    }
4922    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4923    /// while executing the actual API request.
4924    ///
4925    /// ````text
4926    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4927    /// ````
4928    ///
4929    /// Sets the *delegate* property to the given value.
4930    pub fn delegate(
4931        mut self,
4932        new_value: &'a mut dyn common::Delegate,
4933    ) -> OrganizationLocationWorkloadDeleteCall<'a, C> {
4934        self._delegate = Some(new_value);
4935        self
4936    }
4937
4938    /// Set any additional parameter of the query string used in the request.
4939    /// It should be used to set parameters which are not yet available through their own
4940    /// setters.
4941    ///
4942    /// Please note that this method must not be used to set any of the known parameters
4943    /// which have their own setter method. If done anyway, the request will fail.
4944    ///
4945    /// # Additional Parameters
4946    ///
4947    /// * *$.xgafv* (query-string) - V1 error format.
4948    /// * *access_token* (query-string) - OAuth access token.
4949    /// * *alt* (query-string) - Data format for response.
4950    /// * *callback* (query-string) - JSONP
4951    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4952    /// * *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.
4953    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4954    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4955    /// * *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.
4956    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4957    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4958    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationWorkloadDeleteCall<'a, C>
4959    where
4960        T: AsRef<str>,
4961    {
4962        self._additional_params
4963            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4964        self
4965    }
4966
4967    /// Identifies the authorization scope for the method you are building.
4968    ///
4969    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4970    /// [`Scope::CloudPlatform`].
4971    ///
4972    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4973    /// tokens for more than one scope.
4974    ///
4975    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4976    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4977    /// sufficient, a read-write scope will do as well.
4978    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadDeleteCall<'a, C>
4979    where
4980        St: AsRef<str>,
4981    {
4982        self._scopes.insert(String::from(scope.as_ref()));
4983        self
4984    }
4985    /// Identifies the authorization scope(s) for the method you are building.
4986    ///
4987    /// See [`Self::add_scope()`] for details.
4988    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationWorkloadDeleteCall<'a, C>
4989    where
4990        I: IntoIterator<Item = St>,
4991        St: AsRef<str>,
4992    {
4993        self._scopes
4994            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4995        self
4996    }
4997
4998    /// Removes all scopes, and no default scope will be used either.
4999    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5000    /// for details).
5001    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadDeleteCall<'a, C> {
5002        self._scopes.clear();
5003        self
5004    }
5005}
5006
5007/// This endpoint enables Assured Workloads service to offer compliance updates for the folder based assured workload. It sets up an Assured Workloads Service Agent, having permissions to read compliance controls (for example: Org Policies) applied on the workload. The caller must have `resourcemanager.folders.getIamPolicy` and `resourcemanager.folders.setIamPolicy` permissions on the assured workload folder.
5008///
5009/// A builder for the *locations.workloads.enableComplianceUpdates* method supported by a *organization* resource.
5010/// It is not used directly, but through a [`OrganizationMethods`] instance.
5011///
5012/// # Example
5013///
5014/// Instantiate a resource method builder
5015///
5016/// ```test_harness,no_run
5017/// # extern crate hyper;
5018/// # extern crate hyper_rustls;
5019/// # extern crate google_assuredworkloads1 as assuredworkloads1;
5020/// # async fn dox() {
5021/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5022///
5023/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5024/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5025/// #     .with_native_roots()
5026/// #     .unwrap()
5027/// #     .https_only()
5028/// #     .enable_http2()
5029/// #     .build();
5030///
5031/// # let executor = hyper_util::rt::TokioExecutor::new();
5032/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5033/// #     secret,
5034/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5035/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5036/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5037/// #     ),
5038/// # ).build().await.unwrap();
5039///
5040/// # let client = hyper_util::client::legacy::Client::builder(
5041/// #     hyper_util::rt::TokioExecutor::new()
5042/// # )
5043/// # .build(
5044/// #     hyper_rustls::HttpsConnectorBuilder::new()
5045/// #         .with_native_roots()
5046/// #         .unwrap()
5047/// #         .https_or_http()
5048/// #         .enable_http2()
5049/// #         .build()
5050/// # );
5051/// # let mut hub = Assuredworkloads::new(client, auth);
5052/// // You can configure optional parameters by calling the respective setters at will, and
5053/// // execute the final call using `doit()`.
5054/// // Values shown here are possibly random and not representative !
5055/// let result = hub.organizations().locations_workloads_enable_compliance_updates("name")
5056///              .doit().await;
5057/// # }
5058/// ```
5059pub struct OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C>
5060where
5061    C: 'a,
5062{
5063    hub: &'a Assuredworkloads<C>,
5064    _name: String,
5065    _delegate: Option<&'a mut dyn common::Delegate>,
5066    _additional_params: HashMap<String, String>,
5067    _scopes: BTreeSet<String>,
5068}
5069
5070impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C> {}
5071
5072impl<'a, C> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C>
5073where
5074    C: common::Connector,
5075{
5076    /// Perform the operation you have build so far.
5077    pub async fn doit(
5078        mut self,
5079    ) -> common::Result<(
5080        common::Response,
5081        GoogleCloudAssuredworkloadsV1EnableComplianceUpdatesResponse,
5082    )> {
5083        use std::borrow::Cow;
5084        use std::io::{Read, Seek};
5085
5086        use common::{url::Params, ToParts};
5087        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5088
5089        let mut dd = common::DefaultDelegate;
5090        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5091        dlg.begin(common::MethodInfo {
5092            id: "assuredworkloads.organizations.locations.workloads.enableComplianceUpdates",
5093            http_method: hyper::Method::PUT,
5094        });
5095
5096        for &field in ["alt", "name"].iter() {
5097            if self._additional_params.contains_key(field) {
5098                dlg.finished(false);
5099                return Err(common::Error::FieldClash(field));
5100            }
5101        }
5102
5103        let mut params = Params::with_capacity(3 + self._additional_params.len());
5104        params.push("name", self._name);
5105
5106        params.extend(self._additional_params.iter());
5107
5108        params.push("alt", "json");
5109        let mut url = self.hub._base_url.clone() + "v1/{+name}:enableComplianceUpdates";
5110        if self._scopes.is_empty() {
5111            self._scopes
5112                .insert(Scope::CloudPlatform.as_ref().to_string());
5113        }
5114
5115        #[allow(clippy::single_element_loop)]
5116        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5117            url = params.uri_replacement(url, param_name, find_this, true);
5118        }
5119        {
5120            let to_remove = ["name"];
5121            params.remove_params(&to_remove);
5122        }
5123
5124        let url = params.parse_with_url(&url);
5125
5126        loop {
5127            let token = match self
5128                .hub
5129                .auth
5130                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5131                .await
5132            {
5133                Ok(token) => token,
5134                Err(e) => match dlg.token(e) {
5135                    Ok(token) => token,
5136                    Err(e) => {
5137                        dlg.finished(false);
5138                        return Err(common::Error::MissingToken(e));
5139                    }
5140                },
5141            };
5142            let mut req_result = {
5143                let client = &self.hub.client;
5144                dlg.pre_request();
5145                let mut req_builder = hyper::Request::builder()
5146                    .method(hyper::Method::PUT)
5147                    .uri(url.as_str())
5148                    .header(USER_AGENT, self.hub._user_agent.clone());
5149
5150                if let Some(token) = token.as_ref() {
5151                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5152                }
5153
5154                let request = req_builder
5155                    .header(CONTENT_LENGTH, 0_u64)
5156                    .body(common::to_body::<String>(None));
5157
5158                client.request(request.unwrap()).await
5159            };
5160
5161            match req_result {
5162                Err(err) => {
5163                    if let common::Retry::After(d) = dlg.http_error(&err) {
5164                        sleep(d).await;
5165                        continue;
5166                    }
5167                    dlg.finished(false);
5168                    return Err(common::Error::HttpError(err));
5169                }
5170                Ok(res) => {
5171                    let (mut parts, body) = res.into_parts();
5172                    let mut body = common::Body::new(body);
5173                    if !parts.status.is_success() {
5174                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5175                        let error = serde_json::from_str(&common::to_string(&bytes));
5176                        let response = common::to_response(parts, bytes.into());
5177
5178                        if let common::Retry::After(d) =
5179                            dlg.http_failure(&response, error.as_ref().ok())
5180                        {
5181                            sleep(d).await;
5182                            continue;
5183                        }
5184
5185                        dlg.finished(false);
5186
5187                        return Err(match error {
5188                            Ok(value) => common::Error::BadRequest(value),
5189                            _ => common::Error::Failure(response),
5190                        });
5191                    }
5192                    let response = {
5193                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5194                        let encoded = common::to_string(&bytes);
5195                        match serde_json::from_str(&encoded) {
5196                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5197                            Err(error) => {
5198                                dlg.response_json_decode_error(&encoded, &error);
5199                                return Err(common::Error::JsonDecodeError(
5200                                    encoded.to_string(),
5201                                    error,
5202                                ));
5203                            }
5204                        }
5205                    };
5206
5207                    dlg.finished(true);
5208                    return Ok(response);
5209                }
5210            }
5211        }
5212    }
5213
5214    /// Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
5215    ///
5216    /// Sets the *name* path property to the given value.
5217    ///
5218    /// Even though the property as already been set when instantiating this call,
5219    /// we provide this method for API completeness.
5220    pub fn name(
5221        mut self,
5222        new_value: &str,
5223    ) -> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C> {
5224        self._name = new_value.to_string();
5225        self
5226    }
5227    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5228    /// while executing the actual API request.
5229    ///
5230    /// ````text
5231    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5232    /// ````
5233    ///
5234    /// Sets the *delegate* property to the given value.
5235    pub fn delegate(
5236        mut self,
5237        new_value: &'a mut dyn common::Delegate,
5238    ) -> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C> {
5239        self._delegate = Some(new_value);
5240        self
5241    }
5242
5243    /// Set any additional parameter of the query string used in the request.
5244    /// It should be used to set parameters which are not yet available through their own
5245    /// setters.
5246    ///
5247    /// Please note that this method must not be used to set any of the known parameters
5248    /// which have their own setter method. If done anyway, the request will fail.
5249    ///
5250    /// # Additional Parameters
5251    ///
5252    /// * *$.xgafv* (query-string) - V1 error format.
5253    /// * *access_token* (query-string) - OAuth access token.
5254    /// * *alt* (query-string) - Data format for response.
5255    /// * *callback* (query-string) - JSONP
5256    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5257    /// * *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.
5258    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5259    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5260    /// * *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.
5261    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5262    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5263    pub fn param<T>(
5264        mut self,
5265        name: T,
5266        value: T,
5267    ) -> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C>
5268    where
5269        T: AsRef<str>,
5270    {
5271        self._additional_params
5272            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5273        self
5274    }
5275
5276    /// Identifies the authorization scope for the method you are building.
5277    ///
5278    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5279    /// [`Scope::CloudPlatform`].
5280    ///
5281    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5282    /// tokens for more than one scope.
5283    ///
5284    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5285    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5286    /// sufficient, a read-write scope will do as well.
5287    pub fn add_scope<St>(
5288        mut self,
5289        scope: St,
5290    ) -> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C>
5291    where
5292        St: AsRef<str>,
5293    {
5294        self._scopes.insert(String::from(scope.as_ref()));
5295        self
5296    }
5297    /// Identifies the authorization scope(s) for the method you are building.
5298    ///
5299    /// See [`Self::add_scope()`] for details.
5300    pub fn add_scopes<I, St>(
5301        mut self,
5302        scopes: I,
5303    ) -> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C>
5304    where
5305        I: IntoIterator<Item = St>,
5306        St: AsRef<str>,
5307    {
5308        self._scopes
5309            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5310        self
5311    }
5312
5313    /// Removes all scopes, and no default scope will be used either.
5314    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5315    /// for details).
5316    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadEnableComplianceUpdateCall<'a, C> {
5317        self._scopes.clear();
5318        self
5319    }
5320}
5321
5322/// Enable resource violation monitoring for a workload.
5323///
5324/// A builder for the *locations.workloads.enableResourceMonitoring* method supported by a *organization* resource.
5325/// It is not used directly, but through a [`OrganizationMethods`] instance.
5326///
5327/// # Example
5328///
5329/// Instantiate a resource method builder
5330///
5331/// ```test_harness,no_run
5332/// # extern crate hyper;
5333/// # extern crate hyper_rustls;
5334/// # extern crate google_assuredworkloads1 as assuredworkloads1;
5335/// # async fn dox() {
5336/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5337///
5338/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5339/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5340/// #     .with_native_roots()
5341/// #     .unwrap()
5342/// #     .https_only()
5343/// #     .enable_http2()
5344/// #     .build();
5345///
5346/// # let executor = hyper_util::rt::TokioExecutor::new();
5347/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5348/// #     secret,
5349/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5350/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5351/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5352/// #     ),
5353/// # ).build().await.unwrap();
5354///
5355/// # let client = hyper_util::client::legacy::Client::builder(
5356/// #     hyper_util::rt::TokioExecutor::new()
5357/// # )
5358/// # .build(
5359/// #     hyper_rustls::HttpsConnectorBuilder::new()
5360/// #         .with_native_roots()
5361/// #         .unwrap()
5362/// #         .https_or_http()
5363/// #         .enable_http2()
5364/// #         .build()
5365/// # );
5366/// # let mut hub = Assuredworkloads::new(client, auth);
5367/// // You can configure optional parameters by calling the respective setters at will, and
5368/// // execute the final call using `doit()`.
5369/// // Values shown here are possibly random and not representative !
5370/// let result = hub.organizations().locations_workloads_enable_resource_monitoring("name")
5371///              .doit().await;
5372/// # }
5373/// ```
5374pub struct OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C>
5375where
5376    C: 'a,
5377{
5378    hub: &'a Assuredworkloads<C>,
5379    _name: String,
5380    _delegate: Option<&'a mut dyn common::Delegate>,
5381    _additional_params: HashMap<String, String>,
5382    _scopes: BTreeSet<String>,
5383}
5384
5385impl<'a, C> common::CallBuilder
5386    for OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C>
5387{
5388}
5389
5390impl<'a, C> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C>
5391where
5392    C: common::Connector,
5393{
5394    /// Perform the operation you have build so far.
5395    pub async fn doit(
5396        mut self,
5397    ) -> common::Result<(
5398        common::Response,
5399        GoogleCloudAssuredworkloadsV1EnableResourceMonitoringResponse,
5400    )> {
5401        use std::borrow::Cow;
5402        use std::io::{Read, Seek};
5403
5404        use common::{url::Params, ToParts};
5405        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5406
5407        let mut dd = common::DefaultDelegate;
5408        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5409        dlg.begin(common::MethodInfo {
5410            id: "assuredworkloads.organizations.locations.workloads.enableResourceMonitoring",
5411            http_method: hyper::Method::POST,
5412        });
5413
5414        for &field in ["alt", "name"].iter() {
5415            if self._additional_params.contains_key(field) {
5416                dlg.finished(false);
5417                return Err(common::Error::FieldClash(field));
5418            }
5419        }
5420
5421        let mut params = Params::with_capacity(3 + self._additional_params.len());
5422        params.push("name", self._name);
5423
5424        params.extend(self._additional_params.iter());
5425
5426        params.push("alt", "json");
5427        let mut url = self.hub._base_url.clone() + "v1/{+name}:enableResourceMonitoring";
5428        if self._scopes.is_empty() {
5429            self._scopes
5430                .insert(Scope::CloudPlatform.as_ref().to_string());
5431        }
5432
5433        #[allow(clippy::single_element_loop)]
5434        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5435            url = params.uri_replacement(url, param_name, find_this, true);
5436        }
5437        {
5438            let to_remove = ["name"];
5439            params.remove_params(&to_remove);
5440        }
5441
5442        let url = params.parse_with_url(&url);
5443
5444        loop {
5445            let token = match self
5446                .hub
5447                .auth
5448                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5449                .await
5450            {
5451                Ok(token) => token,
5452                Err(e) => match dlg.token(e) {
5453                    Ok(token) => token,
5454                    Err(e) => {
5455                        dlg.finished(false);
5456                        return Err(common::Error::MissingToken(e));
5457                    }
5458                },
5459            };
5460            let mut req_result = {
5461                let client = &self.hub.client;
5462                dlg.pre_request();
5463                let mut req_builder = hyper::Request::builder()
5464                    .method(hyper::Method::POST)
5465                    .uri(url.as_str())
5466                    .header(USER_AGENT, self.hub._user_agent.clone());
5467
5468                if let Some(token) = token.as_ref() {
5469                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5470                }
5471
5472                let request = req_builder
5473                    .header(CONTENT_LENGTH, 0_u64)
5474                    .body(common::to_body::<String>(None));
5475
5476                client.request(request.unwrap()).await
5477            };
5478
5479            match req_result {
5480                Err(err) => {
5481                    if let common::Retry::After(d) = dlg.http_error(&err) {
5482                        sleep(d).await;
5483                        continue;
5484                    }
5485                    dlg.finished(false);
5486                    return Err(common::Error::HttpError(err));
5487                }
5488                Ok(res) => {
5489                    let (mut parts, body) = res.into_parts();
5490                    let mut body = common::Body::new(body);
5491                    if !parts.status.is_success() {
5492                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5493                        let error = serde_json::from_str(&common::to_string(&bytes));
5494                        let response = common::to_response(parts, bytes.into());
5495
5496                        if let common::Retry::After(d) =
5497                            dlg.http_failure(&response, error.as_ref().ok())
5498                        {
5499                            sleep(d).await;
5500                            continue;
5501                        }
5502
5503                        dlg.finished(false);
5504
5505                        return Err(match error {
5506                            Ok(value) => common::Error::BadRequest(value),
5507                            _ => common::Error::Failure(response),
5508                        });
5509                    }
5510                    let response = {
5511                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5512                        let encoded = common::to_string(&bytes);
5513                        match serde_json::from_str(&encoded) {
5514                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5515                            Err(error) => {
5516                                dlg.response_json_decode_error(&encoded, &error);
5517                                return Err(common::Error::JsonDecodeError(
5518                                    encoded.to_string(),
5519                                    error,
5520                                ));
5521                            }
5522                        }
5523                    };
5524
5525                    dlg.finished(true);
5526                    return Ok(response);
5527                }
5528            }
5529        }
5530    }
5531
5532    /// Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
5533    ///
5534    /// Sets the *name* path property to the given value.
5535    ///
5536    /// Even though the property as already been set when instantiating this call,
5537    /// we provide this method for API completeness.
5538    pub fn name(
5539        mut self,
5540        new_value: &str,
5541    ) -> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C> {
5542        self._name = new_value.to_string();
5543        self
5544    }
5545    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5546    /// while executing the actual API request.
5547    ///
5548    /// ````text
5549    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5550    /// ````
5551    ///
5552    /// Sets the *delegate* property to the given value.
5553    pub fn delegate(
5554        mut self,
5555        new_value: &'a mut dyn common::Delegate,
5556    ) -> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C> {
5557        self._delegate = Some(new_value);
5558        self
5559    }
5560
5561    /// Set any additional parameter of the query string used in the request.
5562    /// It should be used to set parameters which are not yet available through their own
5563    /// setters.
5564    ///
5565    /// Please note that this method must not be used to set any of the known parameters
5566    /// which have their own setter method. If done anyway, the request will fail.
5567    ///
5568    /// # Additional Parameters
5569    ///
5570    /// * *$.xgafv* (query-string) - V1 error format.
5571    /// * *access_token* (query-string) - OAuth access token.
5572    /// * *alt* (query-string) - Data format for response.
5573    /// * *callback* (query-string) - JSONP
5574    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5575    /// * *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.
5576    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5577    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5578    /// * *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.
5579    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5580    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5581    pub fn param<T>(
5582        mut self,
5583        name: T,
5584        value: T,
5585    ) -> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C>
5586    where
5587        T: AsRef<str>,
5588    {
5589        self._additional_params
5590            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5591        self
5592    }
5593
5594    /// Identifies the authorization scope for the method you are building.
5595    ///
5596    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5597    /// [`Scope::CloudPlatform`].
5598    ///
5599    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5600    /// tokens for more than one scope.
5601    ///
5602    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5603    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5604    /// sufficient, a read-write scope will do as well.
5605    pub fn add_scope<St>(
5606        mut self,
5607        scope: St,
5608    ) -> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C>
5609    where
5610        St: AsRef<str>,
5611    {
5612        self._scopes.insert(String::from(scope.as_ref()));
5613        self
5614    }
5615    /// Identifies the authorization scope(s) for the method you are building.
5616    ///
5617    /// See [`Self::add_scope()`] for details.
5618    pub fn add_scopes<I, St>(
5619        mut self,
5620        scopes: I,
5621    ) -> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C>
5622    where
5623        I: IntoIterator<Item = St>,
5624        St: AsRef<str>,
5625    {
5626        self._scopes
5627            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5628        self
5629    }
5630
5631    /// Removes all scopes, and no default scope will be used either.
5632    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5633    /// for details).
5634    pub fn clear_scopes(
5635        mut self,
5636    ) -> OrganizationLocationWorkloadEnableResourceMonitoringCall<'a, C> {
5637        self._scopes.clear();
5638        self
5639    }
5640}
5641
5642/// Gets Assured Workload associated with a CRM Node
5643///
5644/// A builder for the *locations.workloads.get* method supported by a *organization* resource.
5645/// It is not used directly, but through a [`OrganizationMethods`] instance.
5646///
5647/// # Example
5648///
5649/// Instantiate a resource method builder
5650///
5651/// ```test_harness,no_run
5652/// # extern crate hyper;
5653/// # extern crate hyper_rustls;
5654/// # extern crate google_assuredworkloads1 as assuredworkloads1;
5655/// # async fn dox() {
5656/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5657///
5658/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5659/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5660/// #     .with_native_roots()
5661/// #     .unwrap()
5662/// #     .https_only()
5663/// #     .enable_http2()
5664/// #     .build();
5665///
5666/// # let executor = hyper_util::rt::TokioExecutor::new();
5667/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5668/// #     secret,
5669/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5670/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5671/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5672/// #     ),
5673/// # ).build().await.unwrap();
5674///
5675/// # let client = hyper_util::client::legacy::Client::builder(
5676/// #     hyper_util::rt::TokioExecutor::new()
5677/// # )
5678/// # .build(
5679/// #     hyper_rustls::HttpsConnectorBuilder::new()
5680/// #         .with_native_roots()
5681/// #         .unwrap()
5682/// #         .https_or_http()
5683/// #         .enable_http2()
5684/// #         .build()
5685/// # );
5686/// # let mut hub = Assuredworkloads::new(client, auth);
5687/// // You can configure optional parameters by calling the respective setters at will, and
5688/// // execute the final call using `doit()`.
5689/// // Values shown here are possibly random and not representative !
5690/// let result = hub.organizations().locations_workloads_get("name")
5691///              .doit().await;
5692/// # }
5693/// ```
5694pub struct OrganizationLocationWorkloadGetCall<'a, C>
5695where
5696    C: 'a,
5697{
5698    hub: &'a Assuredworkloads<C>,
5699    _name: String,
5700    _delegate: Option<&'a mut dyn common::Delegate>,
5701    _additional_params: HashMap<String, String>,
5702    _scopes: BTreeSet<String>,
5703}
5704
5705impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadGetCall<'a, C> {}
5706
5707impl<'a, C> OrganizationLocationWorkloadGetCall<'a, C>
5708where
5709    C: common::Connector,
5710{
5711    /// Perform the operation you have build so far.
5712    pub async fn doit(
5713        mut self,
5714    ) -> common::Result<(common::Response, GoogleCloudAssuredworkloadsV1Workload)> {
5715        use std::borrow::Cow;
5716        use std::io::{Read, Seek};
5717
5718        use common::{url::Params, ToParts};
5719        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5720
5721        let mut dd = common::DefaultDelegate;
5722        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5723        dlg.begin(common::MethodInfo {
5724            id: "assuredworkloads.organizations.locations.workloads.get",
5725            http_method: hyper::Method::GET,
5726        });
5727
5728        for &field in ["alt", "name"].iter() {
5729            if self._additional_params.contains_key(field) {
5730                dlg.finished(false);
5731                return Err(common::Error::FieldClash(field));
5732            }
5733        }
5734
5735        let mut params = Params::with_capacity(3 + self._additional_params.len());
5736        params.push("name", self._name);
5737
5738        params.extend(self._additional_params.iter());
5739
5740        params.push("alt", "json");
5741        let mut url = self.hub._base_url.clone() + "v1/{+name}";
5742        if self._scopes.is_empty() {
5743            self._scopes
5744                .insert(Scope::CloudPlatform.as_ref().to_string());
5745        }
5746
5747        #[allow(clippy::single_element_loop)]
5748        for &(find_this, param_name) in [("{+name}", "name")].iter() {
5749            url = params.uri_replacement(url, param_name, find_this, true);
5750        }
5751        {
5752            let to_remove = ["name"];
5753            params.remove_params(&to_remove);
5754        }
5755
5756        let url = params.parse_with_url(&url);
5757
5758        loop {
5759            let token = match self
5760                .hub
5761                .auth
5762                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5763                .await
5764            {
5765                Ok(token) => token,
5766                Err(e) => match dlg.token(e) {
5767                    Ok(token) => token,
5768                    Err(e) => {
5769                        dlg.finished(false);
5770                        return Err(common::Error::MissingToken(e));
5771                    }
5772                },
5773            };
5774            let mut req_result = {
5775                let client = &self.hub.client;
5776                dlg.pre_request();
5777                let mut req_builder = hyper::Request::builder()
5778                    .method(hyper::Method::GET)
5779                    .uri(url.as_str())
5780                    .header(USER_AGENT, self.hub._user_agent.clone());
5781
5782                if let Some(token) = token.as_ref() {
5783                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5784                }
5785
5786                let request = req_builder
5787                    .header(CONTENT_LENGTH, 0_u64)
5788                    .body(common::to_body::<String>(None));
5789
5790                client.request(request.unwrap()).await
5791            };
5792
5793            match req_result {
5794                Err(err) => {
5795                    if let common::Retry::After(d) = dlg.http_error(&err) {
5796                        sleep(d).await;
5797                        continue;
5798                    }
5799                    dlg.finished(false);
5800                    return Err(common::Error::HttpError(err));
5801                }
5802                Ok(res) => {
5803                    let (mut parts, body) = res.into_parts();
5804                    let mut body = common::Body::new(body);
5805                    if !parts.status.is_success() {
5806                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5807                        let error = serde_json::from_str(&common::to_string(&bytes));
5808                        let response = common::to_response(parts, bytes.into());
5809
5810                        if let common::Retry::After(d) =
5811                            dlg.http_failure(&response, error.as_ref().ok())
5812                        {
5813                            sleep(d).await;
5814                            continue;
5815                        }
5816
5817                        dlg.finished(false);
5818
5819                        return Err(match error {
5820                            Ok(value) => common::Error::BadRequest(value),
5821                            _ => common::Error::Failure(response),
5822                        });
5823                    }
5824                    let response = {
5825                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5826                        let encoded = common::to_string(&bytes);
5827                        match serde_json::from_str(&encoded) {
5828                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5829                            Err(error) => {
5830                                dlg.response_json_decode_error(&encoded, &error);
5831                                return Err(common::Error::JsonDecodeError(
5832                                    encoded.to_string(),
5833                                    error,
5834                                ));
5835                            }
5836                        }
5837                    };
5838
5839                    dlg.finished(true);
5840                    return Ok(response);
5841                }
5842            }
5843        }
5844    }
5845
5846    /// Required. The resource name of the Workload to fetch. This is the workloads's relative path in the API, formatted as "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}". For example, "organizations/123/locations/us-east1/workloads/assured-workload-1".
5847    ///
5848    /// Sets the *name* path property to the given value.
5849    ///
5850    /// Even though the property as already been set when instantiating this call,
5851    /// we provide this method for API completeness.
5852    pub fn name(mut self, new_value: &str) -> OrganizationLocationWorkloadGetCall<'a, C> {
5853        self._name = new_value.to_string();
5854        self
5855    }
5856    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5857    /// while executing the actual API request.
5858    ///
5859    /// ````text
5860    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5861    /// ````
5862    ///
5863    /// Sets the *delegate* property to the given value.
5864    pub fn delegate(
5865        mut self,
5866        new_value: &'a mut dyn common::Delegate,
5867    ) -> OrganizationLocationWorkloadGetCall<'a, C> {
5868        self._delegate = Some(new_value);
5869        self
5870    }
5871
5872    /// Set any additional parameter of the query string used in the request.
5873    /// It should be used to set parameters which are not yet available through their own
5874    /// setters.
5875    ///
5876    /// Please note that this method must not be used to set any of the known parameters
5877    /// which have their own setter method. If done anyway, the request will fail.
5878    ///
5879    /// # Additional Parameters
5880    ///
5881    /// * *$.xgafv* (query-string) - V1 error format.
5882    /// * *access_token* (query-string) - OAuth access token.
5883    /// * *alt* (query-string) - Data format for response.
5884    /// * *callback* (query-string) - JSONP
5885    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5886    /// * *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.
5887    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5888    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5889    /// * *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.
5890    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5891    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5892    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationWorkloadGetCall<'a, C>
5893    where
5894        T: AsRef<str>,
5895    {
5896        self._additional_params
5897            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5898        self
5899    }
5900
5901    /// Identifies the authorization scope for the method you are building.
5902    ///
5903    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5904    /// [`Scope::CloudPlatform`].
5905    ///
5906    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5907    /// tokens for more than one scope.
5908    ///
5909    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5910    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5911    /// sufficient, a read-write scope will do as well.
5912    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadGetCall<'a, C>
5913    where
5914        St: AsRef<str>,
5915    {
5916        self._scopes.insert(String::from(scope.as_ref()));
5917        self
5918    }
5919    /// Identifies the authorization scope(s) for the method you are building.
5920    ///
5921    /// See [`Self::add_scope()`] for details.
5922    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationWorkloadGetCall<'a, C>
5923    where
5924        I: IntoIterator<Item = St>,
5925        St: AsRef<str>,
5926    {
5927        self._scopes
5928            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5929        self
5930    }
5931
5932    /// Removes all scopes, and no default scope will be used either.
5933    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5934    /// for details).
5935    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadGetCall<'a, C> {
5936        self._scopes.clear();
5937        self
5938    }
5939}
5940
5941/// Lists Assured Workloads under a CRM Node.
5942///
5943/// A builder for the *locations.workloads.list* method supported by a *organization* resource.
5944/// It is not used directly, but through a [`OrganizationMethods`] instance.
5945///
5946/// # Example
5947///
5948/// Instantiate a resource method builder
5949///
5950/// ```test_harness,no_run
5951/// # extern crate hyper;
5952/// # extern crate hyper_rustls;
5953/// # extern crate google_assuredworkloads1 as assuredworkloads1;
5954/// # async fn dox() {
5955/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5956///
5957/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5958/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5959/// #     .with_native_roots()
5960/// #     .unwrap()
5961/// #     .https_only()
5962/// #     .enable_http2()
5963/// #     .build();
5964///
5965/// # let executor = hyper_util::rt::TokioExecutor::new();
5966/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5967/// #     secret,
5968/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5969/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
5970/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
5971/// #     ),
5972/// # ).build().await.unwrap();
5973///
5974/// # let client = hyper_util::client::legacy::Client::builder(
5975/// #     hyper_util::rt::TokioExecutor::new()
5976/// # )
5977/// # .build(
5978/// #     hyper_rustls::HttpsConnectorBuilder::new()
5979/// #         .with_native_roots()
5980/// #         .unwrap()
5981/// #         .https_or_http()
5982/// #         .enable_http2()
5983/// #         .build()
5984/// # );
5985/// # let mut hub = Assuredworkloads::new(client, auth);
5986/// // You can configure optional parameters by calling the respective setters at will, and
5987/// // execute the final call using `doit()`.
5988/// // Values shown here are possibly random and not representative !
5989/// let result = hub.organizations().locations_workloads_list("parent")
5990///              .page_token("eos")
5991///              .page_size(-86)
5992///              .filter("sed")
5993///              .doit().await;
5994/// # }
5995/// ```
5996pub struct OrganizationLocationWorkloadListCall<'a, C>
5997where
5998    C: 'a,
5999{
6000    hub: &'a Assuredworkloads<C>,
6001    _parent: String,
6002    _page_token: Option<String>,
6003    _page_size: Option<i32>,
6004    _filter: Option<String>,
6005    _delegate: Option<&'a mut dyn common::Delegate>,
6006    _additional_params: HashMap<String, String>,
6007    _scopes: BTreeSet<String>,
6008}
6009
6010impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadListCall<'a, C> {}
6011
6012impl<'a, C> OrganizationLocationWorkloadListCall<'a, C>
6013where
6014    C: common::Connector,
6015{
6016    /// Perform the operation you have build so far.
6017    pub async fn doit(
6018        mut self,
6019    ) -> common::Result<(
6020        common::Response,
6021        GoogleCloudAssuredworkloadsV1ListWorkloadsResponse,
6022    )> {
6023        use std::borrow::Cow;
6024        use std::io::{Read, Seek};
6025
6026        use common::{url::Params, ToParts};
6027        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6028
6029        let mut dd = common::DefaultDelegate;
6030        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6031        dlg.begin(common::MethodInfo {
6032            id: "assuredworkloads.organizations.locations.workloads.list",
6033            http_method: hyper::Method::GET,
6034        });
6035
6036        for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
6037            if self._additional_params.contains_key(field) {
6038                dlg.finished(false);
6039                return Err(common::Error::FieldClash(field));
6040            }
6041        }
6042
6043        let mut params = Params::with_capacity(6 + self._additional_params.len());
6044        params.push("parent", self._parent);
6045        if let Some(value) = self._page_token.as_ref() {
6046            params.push("pageToken", value);
6047        }
6048        if let Some(value) = self._page_size.as_ref() {
6049            params.push("pageSize", value.to_string());
6050        }
6051        if let Some(value) = self._filter.as_ref() {
6052            params.push("filter", value);
6053        }
6054
6055        params.extend(self._additional_params.iter());
6056
6057        params.push("alt", "json");
6058        let mut url = self.hub._base_url.clone() + "v1/{+parent}/workloads";
6059        if self._scopes.is_empty() {
6060            self._scopes
6061                .insert(Scope::CloudPlatform.as_ref().to_string());
6062        }
6063
6064        #[allow(clippy::single_element_loop)]
6065        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6066            url = params.uri_replacement(url, param_name, find_this, true);
6067        }
6068        {
6069            let to_remove = ["parent"];
6070            params.remove_params(&to_remove);
6071        }
6072
6073        let url = params.parse_with_url(&url);
6074
6075        loop {
6076            let token = match self
6077                .hub
6078                .auth
6079                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6080                .await
6081            {
6082                Ok(token) => token,
6083                Err(e) => match dlg.token(e) {
6084                    Ok(token) => token,
6085                    Err(e) => {
6086                        dlg.finished(false);
6087                        return Err(common::Error::MissingToken(e));
6088                    }
6089                },
6090            };
6091            let mut req_result = {
6092                let client = &self.hub.client;
6093                dlg.pre_request();
6094                let mut req_builder = hyper::Request::builder()
6095                    .method(hyper::Method::GET)
6096                    .uri(url.as_str())
6097                    .header(USER_AGENT, self.hub._user_agent.clone());
6098
6099                if let Some(token) = token.as_ref() {
6100                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6101                }
6102
6103                let request = req_builder
6104                    .header(CONTENT_LENGTH, 0_u64)
6105                    .body(common::to_body::<String>(None));
6106
6107                client.request(request.unwrap()).await
6108            };
6109
6110            match req_result {
6111                Err(err) => {
6112                    if let common::Retry::After(d) = dlg.http_error(&err) {
6113                        sleep(d).await;
6114                        continue;
6115                    }
6116                    dlg.finished(false);
6117                    return Err(common::Error::HttpError(err));
6118                }
6119                Ok(res) => {
6120                    let (mut parts, body) = res.into_parts();
6121                    let mut body = common::Body::new(body);
6122                    if !parts.status.is_success() {
6123                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6124                        let error = serde_json::from_str(&common::to_string(&bytes));
6125                        let response = common::to_response(parts, bytes.into());
6126
6127                        if let common::Retry::After(d) =
6128                            dlg.http_failure(&response, error.as_ref().ok())
6129                        {
6130                            sleep(d).await;
6131                            continue;
6132                        }
6133
6134                        dlg.finished(false);
6135
6136                        return Err(match error {
6137                            Ok(value) => common::Error::BadRequest(value),
6138                            _ => common::Error::Failure(response),
6139                        });
6140                    }
6141                    let response = {
6142                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6143                        let encoded = common::to_string(&bytes);
6144                        match serde_json::from_str(&encoded) {
6145                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6146                            Err(error) => {
6147                                dlg.response_json_decode_error(&encoded, &error);
6148                                return Err(common::Error::JsonDecodeError(
6149                                    encoded.to_string(),
6150                                    error,
6151                                ));
6152                            }
6153                        }
6154                    };
6155
6156                    dlg.finished(true);
6157                    return Ok(response);
6158                }
6159            }
6160        }
6161    }
6162
6163    /// Required. Parent Resource to list workloads from. Must be of the form `organizations/{org_id}/locations/{location}`.
6164    ///
6165    /// Sets the *parent* path property to the given value.
6166    ///
6167    /// Even though the property as already been set when instantiating this call,
6168    /// we provide this method for API completeness.
6169    pub fn parent(mut self, new_value: &str) -> OrganizationLocationWorkloadListCall<'a, C> {
6170        self._parent = new_value.to_string();
6171        self
6172    }
6173    /// Page token returned from previous request. Page token contains context from previous request. Page token needs to be passed in the second and following requests.
6174    ///
6175    /// Sets the *page token* query property to the given value.
6176    pub fn page_token(mut self, new_value: &str) -> OrganizationLocationWorkloadListCall<'a, C> {
6177        self._page_token = Some(new_value.to_string());
6178        self
6179    }
6180    /// Page size.
6181    ///
6182    /// Sets the *page size* query property to the given value.
6183    pub fn page_size(mut self, new_value: i32) -> OrganizationLocationWorkloadListCall<'a, C> {
6184        self._page_size = Some(new_value);
6185        self
6186    }
6187    /// A custom filter for filtering by properties of a workload. At this time, only filtering by labels is supported.
6188    ///
6189    /// Sets the *filter* query property to the given value.
6190    pub fn filter(mut self, new_value: &str) -> OrganizationLocationWorkloadListCall<'a, C> {
6191        self._filter = Some(new_value.to_string());
6192        self
6193    }
6194    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6195    /// while executing the actual API request.
6196    ///
6197    /// ````text
6198    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6199    /// ````
6200    ///
6201    /// Sets the *delegate* property to the given value.
6202    pub fn delegate(
6203        mut self,
6204        new_value: &'a mut dyn common::Delegate,
6205    ) -> OrganizationLocationWorkloadListCall<'a, C> {
6206        self._delegate = Some(new_value);
6207        self
6208    }
6209
6210    /// Set any additional parameter of the query string used in the request.
6211    /// It should be used to set parameters which are not yet available through their own
6212    /// setters.
6213    ///
6214    /// Please note that this method must not be used to set any of the known parameters
6215    /// which have their own setter method. If done anyway, the request will fail.
6216    ///
6217    /// # Additional Parameters
6218    ///
6219    /// * *$.xgafv* (query-string) - V1 error format.
6220    /// * *access_token* (query-string) - OAuth access token.
6221    /// * *alt* (query-string) - Data format for response.
6222    /// * *callback* (query-string) - JSONP
6223    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6224    /// * *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.
6225    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6226    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6227    /// * *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.
6228    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6229    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6230    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationWorkloadListCall<'a, C>
6231    where
6232        T: AsRef<str>,
6233    {
6234        self._additional_params
6235            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6236        self
6237    }
6238
6239    /// Identifies the authorization scope for the method you are building.
6240    ///
6241    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6242    /// [`Scope::CloudPlatform`].
6243    ///
6244    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6245    /// tokens for more than one scope.
6246    ///
6247    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6248    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6249    /// sufficient, a read-write scope will do as well.
6250    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadListCall<'a, C>
6251    where
6252        St: AsRef<str>,
6253    {
6254        self._scopes.insert(String::from(scope.as_ref()));
6255        self
6256    }
6257    /// Identifies the authorization scope(s) for the method you are building.
6258    ///
6259    /// See [`Self::add_scope()`] for details.
6260    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationWorkloadListCall<'a, C>
6261    where
6262        I: IntoIterator<Item = St>,
6263        St: AsRef<str>,
6264    {
6265        self._scopes
6266            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6267        self
6268    }
6269
6270    /// Removes all scopes, and no default scope will be used either.
6271    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6272    /// for details).
6273    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadListCall<'a, C> {
6274        self._scopes.clear();
6275        self
6276    }
6277}
6278
6279/// Update the permissions settings for an existing partner workload. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.
6280///
6281/// A builder for the *locations.workloads.mutatePartnerPermissions* method supported by a *organization* resource.
6282/// It is not used directly, but through a [`OrganizationMethods`] instance.
6283///
6284/// # Example
6285///
6286/// Instantiate a resource method builder
6287///
6288/// ```test_harness,no_run
6289/// # extern crate hyper;
6290/// # extern crate hyper_rustls;
6291/// # extern crate google_assuredworkloads1 as assuredworkloads1;
6292/// use assuredworkloads1::api::GoogleCloudAssuredworkloadsV1MutatePartnerPermissionsRequest;
6293/// # async fn dox() {
6294/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6295///
6296/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6297/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6298/// #     .with_native_roots()
6299/// #     .unwrap()
6300/// #     .https_only()
6301/// #     .enable_http2()
6302/// #     .build();
6303///
6304/// # let executor = hyper_util::rt::TokioExecutor::new();
6305/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6306/// #     secret,
6307/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6308/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6309/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6310/// #     ),
6311/// # ).build().await.unwrap();
6312///
6313/// # let client = hyper_util::client::legacy::Client::builder(
6314/// #     hyper_util::rt::TokioExecutor::new()
6315/// # )
6316/// # .build(
6317/// #     hyper_rustls::HttpsConnectorBuilder::new()
6318/// #         .with_native_roots()
6319/// #         .unwrap()
6320/// #         .https_or_http()
6321/// #         .enable_http2()
6322/// #         .build()
6323/// # );
6324/// # let mut hub = Assuredworkloads::new(client, auth);
6325/// // As the method needs a request, you would usually fill it with the desired information
6326/// // into the respective structure. Some of the parts shown here might not be applicable !
6327/// // Values shown here are possibly random and not representative !
6328/// let mut req = GoogleCloudAssuredworkloadsV1MutatePartnerPermissionsRequest::default();
6329///
6330/// // You can configure optional parameters by calling the respective setters at will, and
6331/// // execute the final call using `doit()`.
6332/// // Values shown here are possibly random and not representative !
6333/// let result = hub.organizations().locations_workloads_mutate_partner_permissions(req, "name")
6334///              .doit().await;
6335/// # }
6336/// ```
6337pub struct OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C>
6338where
6339    C: 'a,
6340{
6341    hub: &'a Assuredworkloads<C>,
6342    _request: GoogleCloudAssuredworkloadsV1MutatePartnerPermissionsRequest,
6343    _name: String,
6344    _delegate: Option<&'a mut dyn common::Delegate>,
6345    _additional_params: HashMap<String, String>,
6346    _scopes: BTreeSet<String>,
6347}
6348
6349impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C> {}
6350
6351impl<'a, C> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C>
6352where
6353    C: common::Connector,
6354{
6355    /// Perform the operation you have build so far.
6356    pub async fn doit(
6357        mut self,
6358    ) -> common::Result<(common::Response, GoogleCloudAssuredworkloadsV1Workload)> {
6359        use std::borrow::Cow;
6360        use std::io::{Read, Seek};
6361
6362        use common::{url::Params, ToParts};
6363        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6364
6365        let mut dd = common::DefaultDelegate;
6366        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6367        dlg.begin(common::MethodInfo {
6368            id: "assuredworkloads.organizations.locations.workloads.mutatePartnerPermissions",
6369            http_method: hyper::Method::PATCH,
6370        });
6371
6372        for &field in ["alt", "name"].iter() {
6373            if self._additional_params.contains_key(field) {
6374                dlg.finished(false);
6375                return Err(common::Error::FieldClash(field));
6376            }
6377        }
6378
6379        let mut params = Params::with_capacity(4 + self._additional_params.len());
6380        params.push("name", self._name);
6381
6382        params.extend(self._additional_params.iter());
6383
6384        params.push("alt", "json");
6385        let mut url = self.hub._base_url.clone() + "v1/{+name}:mutatePartnerPermissions";
6386        if self._scopes.is_empty() {
6387            self._scopes
6388                .insert(Scope::CloudPlatform.as_ref().to_string());
6389        }
6390
6391        #[allow(clippy::single_element_loop)]
6392        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6393            url = params.uri_replacement(url, param_name, find_this, true);
6394        }
6395        {
6396            let to_remove = ["name"];
6397            params.remove_params(&to_remove);
6398        }
6399
6400        let url = params.parse_with_url(&url);
6401
6402        let mut json_mime_type = mime::APPLICATION_JSON;
6403        let mut request_value_reader = {
6404            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6405            common::remove_json_null_values(&mut value);
6406            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6407            serde_json::to_writer(&mut dst, &value).unwrap();
6408            dst
6409        };
6410        let request_size = request_value_reader
6411            .seek(std::io::SeekFrom::End(0))
6412            .unwrap();
6413        request_value_reader
6414            .seek(std::io::SeekFrom::Start(0))
6415            .unwrap();
6416
6417        loop {
6418            let token = match self
6419                .hub
6420                .auth
6421                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6422                .await
6423            {
6424                Ok(token) => token,
6425                Err(e) => match dlg.token(e) {
6426                    Ok(token) => token,
6427                    Err(e) => {
6428                        dlg.finished(false);
6429                        return Err(common::Error::MissingToken(e));
6430                    }
6431                },
6432            };
6433            request_value_reader
6434                .seek(std::io::SeekFrom::Start(0))
6435                .unwrap();
6436            let mut req_result = {
6437                let client = &self.hub.client;
6438                dlg.pre_request();
6439                let mut req_builder = hyper::Request::builder()
6440                    .method(hyper::Method::PATCH)
6441                    .uri(url.as_str())
6442                    .header(USER_AGENT, self.hub._user_agent.clone());
6443
6444                if let Some(token) = token.as_ref() {
6445                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6446                }
6447
6448                let request = req_builder
6449                    .header(CONTENT_TYPE, json_mime_type.to_string())
6450                    .header(CONTENT_LENGTH, request_size as u64)
6451                    .body(common::to_body(
6452                        request_value_reader.get_ref().clone().into(),
6453                    ));
6454
6455                client.request(request.unwrap()).await
6456            };
6457
6458            match req_result {
6459                Err(err) => {
6460                    if let common::Retry::After(d) = dlg.http_error(&err) {
6461                        sleep(d).await;
6462                        continue;
6463                    }
6464                    dlg.finished(false);
6465                    return Err(common::Error::HttpError(err));
6466                }
6467                Ok(res) => {
6468                    let (mut parts, body) = res.into_parts();
6469                    let mut body = common::Body::new(body);
6470                    if !parts.status.is_success() {
6471                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6472                        let error = serde_json::from_str(&common::to_string(&bytes));
6473                        let response = common::to_response(parts, bytes.into());
6474
6475                        if let common::Retry::After(d) =
6476                            dlg.http_failure(&response, error.as_ref().ok())
6477                        {
6478                            sleep(d).await;
6479                            continue;
6480                        }
6481
6482                        dlg.finished(false);
6483
6484                        return Err(match error {
6485                            Ok(value) => common::Error::BadRequest(value),
6486                            _ => common::Error::Failure(response),
6487                        });
6488                    }
6489                    let response = {
6490                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6491                        let encoded = common::to_string(&bytes);
6492                        match serde_json::from_str(&encoded) {
6493                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6494                            Err(error) => {
6495                                dlg.response_json_decode_error(&encoded, &error);
6496                                return Err(common::Error::JsonDecodeError(
6497                                    encoded.to_string(),
6498                                    error,
6499                                ));
6500                            }
6501                        }
6502                    };
6503
6504                    dlg.finished(true);
6505                    return Ok(response);
6506                }
6507            }
6508        }
6509    }
6510
6511    ///
6512    /// Sets the *request* property to the given value.
6513    ///
6514    /// Even though the property as already been set when instantiating this call,
6515    /// we provide this method for API completeness.
6516    pub fn request(
6517        mut self,
6518        new_value: GoogleCloudAssuredworkloadsV1MutatePartnerPermissionsRequest,
6519    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C> {
6520        self._request = new_value;
6521        self
6522    }
6523    /// Required. The `name` field is used to identify the workload. Format: organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
6524    ///
6525    /// Sets the *name* path property to the given value.
6526    ///
6527    /// Even though the property as already been set when instantiating this call,
6528    /// we provide this method for API completeness.
6529    pub fn name(
6530        mut self,
6531        new_value: &str,
6532    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C> {
6533        self._name = new_value.to_string();
6534        self
6535    }
6536    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6537    /// while executing the actual API request.
6538    ///
6539    /// ````text
6540    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6541    /// ````
6542    ///
6543    /// Sets the *delegate* property to the given value.
6544    pub fn delegate(
6545        mut self,
6546        new_value: &'a mut dyn common::Delegate,
6547    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C> {
6548        self._delegate = Some(new_value);
6549        self
6550    }
6551
6552    /// Set any additional parameter of the query string used in the request.
6553    /// It should be used to set parameters which are not yet available through their own
6554    /// setters.
6555    ///
6556    /// Please note that this method must not be used to set any of the known parameters
6557    /// which have their own setter method. If done anyway, the request will fail.
6558    ///
6559    /// # Additional Parameters
6560    ///
6561    /// * *$.xgafv* (query-string) - V1 error format.
6562    /// * *access_token* (query-string) - OAuth access token.
6563    /// * *alt* (query-string) - Data format for response.
6564    /// * *callback* (query-string) - JSONP
6565    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6566    /// * *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.
6567    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6568    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6569    /// * *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.
6570    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6571    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6572    pub fn param<T>(
6573        mut self,
6574        name: T,
6575        value: T,
6576    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C>
6577    where
6578        T: AsRef<str>,
6579    {
6580        self._additional_params
6581            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6582        self
6583    }
6584
6585    /// Identifies the authorization scope for the method you are building.
6586    ///
6587    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6588    /// [`Scope::CloudPlatform`].
6589    ///
6590    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6591    /// tokens for more than one scope.
6592    ///
6593    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6594    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6595    /// sufficient, a read-write scope will do as well.
6596    pub fn add_scope<St>(
6597        mut self,
6598        scope: St,
6599    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C>
6600    where
6601        St: AsRef<str>,
6602    {
6603        self._scopes.insert(String::from(scope.as_ref()));
6604        self
6605    }
6606    /// Identifies the authorization scope(s) for the method you are building.
6607    ///
6608    /// See [`Self::add_scope()`] for details.
6609    pub fn add_scopes<I, St>(
6610        mut self,
6611        scopes: I,
6612    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C>
6613    where
6614        I: IntoIterator<Item = St>,
6615        St: AsRef<str>,
6616    {
6617        self._scopes
6618            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6619        self
6620    }
6621
6622    /// Removes all scopes, and no default scope will be used either.
6623    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6624    /// for details).
6625    pub fn clear_scopes(
6626        mut self,
6627    ) -> OrganizationLocationWorkloadMutatePartnerPermissionCall<'a, C> {
6628        self._scopes.clear();
6629        self
6630    }
6631}
6632
6633/// Updates an existing workload. Currently allows updating of workload display_name and labels. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.
6634///
6635/// A builder for the *locations.workloads.patch* method supported by a *organization* resource.
6636/// It is not used directly, but through a [`OrganizationMethods`] instance.
6637///
6638/// # Example
6639///
6640/// Instantiate a resource method builder
6641///
6642/// ```test_harness,no_run
6643/// # extern crate hyper;
6644/// # extern crate hyper_rustls;
6645/// # extern crate google_assuredworkloads1 as assuredworkloads1;
6646/// use assuredworkloads1::api::GoogleCloudAssuredworkloadsV1Workload;
6647/// # async fn dox() {
6648/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6649///
6650/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6651/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6652/// #     .with_native_roots()
6653/// #     .unwrap()
6654/// #     .https_only()
6655/// #     .enable_http2()
6656/// #     .build();
6657///
6658/// # let executor = hyper_util::rt::TokioExecutor::new();
6659/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6660/// #     secret,
6661/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6662/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
6663/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
6664/// #     ),
6665/// # ).build().await.unwrap();
6666///
6667/// # let client = hyper_util::client::legacy::Client::builder(
6668/// #     hyper_util::rt::TokioExecutor::new()
6669/// # )
6670/// # .build(
6671/// #     hyper_rustls::HttpsConnectorBuilder::new()
6672/// #         .with_native_roots()
6673/// #         .unwrap()
6674/// #         .https_or_http()
6675/// #         .enable_http2()
6676/// #         .build()
6677/// # );
6678/// # let mut hub = Assuredworkloads::new(client, auth);
6679/// // As the method needs a request, you would usually fill it with the desired information
6680/// // into the respective structure. Some of the parts shown here might not be applicable !
6681/// // Values shown here are possibly random and not representative !
6682/// let mut req = GoogleCloudAssuredworkloadsV1Workload::default();
6683///
6684/// // You can configure optional parameters by calling the respective setters at will, and
6685/// // execute the final call using `doit()`.
6686/// // Values shown here are possibly random and not representative !
6687/// let result = hub.organizations().locations_workloads_patch(req, "name")
6688///              .update_mask(FieldMask::new::<&str>(&[]))
6689///              .doit().await;
6690/// # }
6691/// ```
6692pub struct OrganizationLocationWorkloadPatchCall<'a, C>
6693where
6694    C: 'a,
6695{
6696    hub: &'a Assuredworkloads<C>,
6697    _request: GoogleCloudAssuredworkloadsV1Workload,
6698    _name: String,
6699    _update_mask: Option<common::FieldMask>,
6700    _delegate: Option<&'a mut dyn common::Delegate>,
6701    _additional_params: HashMap<String, String>,
6702    _scopes: BTreeSet<String>,
6703}
6704
6705impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadPatchCall<'a, C> {}
6706
6707impl<'a, C> OrganizationLocationWorkloadPatchCall<'a, C>
6708where
6709    C: common::Connector,
6710{
6711    /// Perform the operation you have build so far.
6712    pub async fn doit(
6713        mut self,
6714    ) -> common::Result<(common::Response, GoogleCloudAssuredworkloadsV1Workload)> {
6715        use std::borrow::Cow;
6716        use std::io::{Read, Seek};
6717
6718        use common::{url::Params, ToParts};
6719        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6720
6721        let mut dd = common::DefaultDelegate;
6722        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6723        dlg.begin(common::MethodInfo {
6724            id: "assuredworkloads.organizations.locations.workloads.patch",
6725            http_method: hyper::Method::PATCH,
6726        });
6727
6728        for &field in ["alt", "name", "updateMask"].iter() {
6729            if self._additional_params.contains_key(field) {
6730                dlg.finished(false);
6731                return Err(common::Error::FieldClash(field));
6732            }
6733        }
6734
6735        let mut params = Params::with_capacity(5 + self._additional_params.len());
6736        params.push("name", self._name);
6737        if let Some(value) = self._update_mask.as_ref() {
6738            params.push("updateMask", value.to_string());
6739        }
6740
6741        params.extend(self._additional_params.iter());
6742
6743        params.push("alt", "json");
6744        let mut url = self.hub._base_url.clone() + "v1/{+name}";
6745        if self._scopes.is_empty() {
6746            self._scopes
6747                .insert(Scope::CloudPlatform.as_ref().to_string());
6748        }
6749
6750        #[allow(clippy::single_element_loop)]
6751        for &(find_this, param_name) in [("{+name}", "name")].iter() {
6752            url = params.uri_replacement(url, param_name, find_this, true);
6753        }
6754        {
6755            let to_remove = ["name"];
6756            params.remove_params(&to_remove);
6757        }
6758
6759        let url = params.parse_with_url(&url);
6760
6761        let mut json_mime_type = mime::APPLICATION_JSON;
6762        let mut request_value_reader = {
6763            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6764            common::remove_json_null_values(&mut value);
6765            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6766            serde_json::to_writer(&mut dst, &value).unwrap();
6767            dst
6768        };
6769        let request_size = request_value_reader
6770            .seek(std::io::SeekFrom::End(0))
6771            .unwrap();
6772        request_value_reader
6773            .seek(std::io::SeekFrom::Start(0))
6774            .unwrap();
6775
6776        loop {
6777            let token = match self
6778                .hub
6779                .auth
6780                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6781                .await
6782            {
6783                Ok(token) => token,
6784                Err(e) => match dlg.token(e) {
6785                    Ok(token) => token,
6786                    Err(e) => {
6787                        dlg.finished(false);
6788                        return Err(common::Error::MissingToken(e));
6789                    }
6790                },
6791            };
6792            request_value_reader
6793                .seek(std::io::SeekFrom::Start(0))
6794                .unwrap();
6795            let mut req_result = {
6796                let client = &self.hub.client;
6797                dlg.pre_request();
6798                let mut req_builder = hyper::Request::builder()
6799                    .method(hyper::Method::PATCH)
6800                    .uri(url.as_str())
6801                    .header(USER_AGENT, self.hub._user_agent.clone());
6802
6803                if let Some(token) = token.as_ref() {
6804                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6805                }
6806
6807                let request = req_builder
6808                    .header(CONTENT_TYPE, json_mime_type.to_string())
6809                    .header(CONTENT_LENGTH, request_size as u64)
6810                    .body(common::to_body(
6811                        request_value_reader.get_ref().clone().into(),
6812                    ));
6813
6814                client.request(request.unwrap()).await
6815            };
6816
6817            match req_result {
6818                Err(err) => {
6819                    if let common::Retry::After(d) = dlg.http_error(&err) {
6820                        sleep(d).await;
6821                        continue;
6822                    }
6823                    dlg.finished(false);
6824                    return Err(common::Error::HttpError(err));
6825                }
6826                Ok(res) => {
6827                    let (mut parts, body) = res.into_parts();
6828                    let mut body = common::Body::new(body);
6829                    if !parts.status.is_success() {
6830                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6831                        let error = serde_json::from_str(&common::to_string(&bytes));
6832                        let response = common::to_response(parts, bytes.into());
6833
6834                        if let common::Retry::After(d) =
6835                            dlg.http_failure(&response, error.as_ref().ok())
6836                        {
6837                            sleep(d).await;
6838                            continue;
6839                        }
6840
6841                        dlg.finished(false);
6842
6843                        return Err(match error {
6844                            Ok(value) => common::Error::BadRequest(value),
6845                            _ => common::Error::Failure(response),
6846                        });
6847                    }
6848                    let response = {
6849                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6850                        let encoded = common::to_string(&bytes);
6851                        match serde_json::from_str(&encoded) {
6852                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6853                            Err(error) => {
6854                                dlg.response_json_decode_error(&encoded, &error);
6855                                return Err(common::Error::JsonDecodeError(
6856                                    encoded.to_string(),
6857                                    error,
6858                                ));
6859                            }
6860                        }
6861                    };
6862
6863                    dlg.finished(true);
6864                    return Ok(response);
6865                }
6866            }
6867        }
6868    }
6869
6870    ///
6871    /// Sets the *request* property to the given value.
6872    ///
6873    /// Even though the property as already been set when instantiating this call,
6874    /// we provide this method for API completeness.
6875    pub fn request(
6876        mut self,
6877        new_value: GoogleCloudAssuredworkloadsV1Workload,
6878    ) -> OrganizationLocationWorkloadPatchCall<'a, C> {
6879        self._request = new_value;
6880        self
6881    }
6882    /// Optional. The resource name of the workload. Format: organizations/{organization}/locations/{location}/workloads/{workload} Read-only.
6883    ///
6884    /// Sets the *name* path property to the given value.
6885    ///
6886    /// Even though the property as already been set when instantiating this call,
6887    /// we provide this method for API completeness.
6888    pub fn name(mut self, new_value: &str) -> OrganizationLocationWorkloadPatchCall<'a, C> {
6889        self._name = new_value.to_string();
6890        self
6891    }
6892    /// Required. The list of fields to be updated.
6893    ///
6894    /// Sets the *update mask* query property to the given value.
6895    pub fn update_mask(
6896        mut self,
6897        new_value: common::FieldMask,
6898    ) -> OrganizationLocationWorkloadPatchCall<'a, C> {
6899        self._update_mask = Some(new_value);
6900        self
6901    }
6902    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6903    /// while executing the actual API request.
6904    ///
6905    /// ````text
6906    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6907    /// ````
6908    ///
6909    /// Sets the *delegate* property to the given value.
6910    pub fn delegate(
6911        mut self,
6912        new_value: &'a mut dyn common::Delegate,
6913    ) -> OrganizationLocationWorkloadPatchCall<'a, C> {
6914        self._delegate = Some(new_value);
6915        self
6916    }
6917
6918    /// Set any additional parameter of the query string used in the request.
6919    /// It should be used to set parameters which are not yet available through their own
6920    /// setters.
6921    ///
6922    /// Please note that this method must not be used to set any of the known parameters
6923    /// which have their own setter method. If done anyway, the request will fail.
6924    ///
6925    /// # Additional Parameters
6926    ///
6927    /// * *$.xgafv* (query-string) - V1 error format.
6928    /// * *access_token* (query-string) - OAuth access token.
6929    /// * *alt* (query-string) - Data format for response.
6930    /// * *callback* (query-string) - JSONP
6931    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6932    /// * *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.
6933    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6934    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6935    /// * *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.
6936    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6937    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6938    pub fn param<T>(mut self, name: T, value: T) -> OrganizationLocationWorkloadPatchCall<'a, C>
6939    where
6940        T: AsRef<str>,
6941    {
6942        self._additional_params
6943            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6944        self
6945    }
6946
6947    /// Identifies the authorization scope for the method you are building.
6948    ///
6949    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6950    /// [`Scope::CloudPlatform`].
6951    ///
6952    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6953    /// tokens for more than one scope.
6954    ///
6955    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6956    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6957    /// sufficient, a read-write scope will do as well.
6958    pub fn add_scope<St>(mut self, scope: St) -> OrganizationLocationWorkloadPatchCall<'a, C>
6959    where
6960        St: AsRef<str>,
6961    {
6962        self._scopes.insert(String::from(scope.as_ref()));
6963        self
6964    }
6965    /// Identifies the authorization scope(s) for the method you are building.
6966    ///
6967    /// See [`Self::add_scope()`] for details.
6968    pub fn add_scopes<I, St>(mut self, scopes: I) -> OrganizationLocationWorkloadPatchCall<'a, C>
6969    where
6970        I: IntoIterator<Item = St>,
6971        St: AsRef<str>,
6972    {
6973        self._scopes
6974            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6975        self
6976    }
6977
6978    /// Removes all scopes, and no default scope will be used either.
6979    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6980    /// for details).
6981    pub fn clear_scopes(mut self) -> OrganizationLocationWorkloadPatchCall<'a, C> {
6982        self._scopes.clear();
6983        self
6984    }
6985}
6986
6987/// Restrict the list of resources allowed in the Workload environment. The current list of allowed products can be found at https://cloud.google.com/assured-workloads/docs/supported-products In addition to assuredworkloads.workload.update permission, the user should also have orgpolicy.policy.set permission on the folder resource to use this functionality.
6988///
6989/// A builder for the *locations.workloads.restrictAllowedResources* method supported by a *organization* resource.
6990/// It is not used directly, but through a [`OrganizationMethods`] instance.
6991///
6992/// # Example
6993///
6994/// Instantiate a resource method builder
6995///
6996/// ```test_harness,no_run
6997/// # extern crate hyper;
6998/// # extern crate hyper_rustls;
6999/// # extern crate google_assuredworkloads1 as assuredworkloads1;
7000/// use assuredworkloads1::api::GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesRequest;
7001/// # async fn dox() {
7002/// # use assuredworkloads1::{Assuredworkloads, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7003///
7004/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7005/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7006/// #     .with_native_roots()
7007/// #     .unwrap()
7008/// #     .https_only()
7009/// #     .enable_http2()
7010/// #     .build();
7011///
7012/// # let executor = hyper_util::rt::TokioExecutor::new();
7013/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7014/// #     secret,
7015/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7016/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
7017/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
7018/// #     ),
7019/// # ).build().await.unwrap();
7020///
7021/// # let client = hyper_util::client::legacy::Client::builder(
7022/// #     hyper_util::rt::TokioExecutor::new()
7023/// # )
7024/// # .build(
7025/// #     hyper_rustls::HttpsConnectorBuilder::new()
7026/// #         .with_native_roots()
7027/// #         .unwrap()
7028/// #         .https_or_http()
7029/// #         .enable_http2()
7030/// #         .build()
7031/// # );
7032/// # let mut hub = Assuredworkloads::new(client, auth);
7033/// // As the method needs a request, you would usually fill it with the desired information
7034/// // into the respective structure. Some of the parts shown here might not be applicable !
7035/// // Values shown here are possibly random and not representative !
7036/// let mut req = GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesRequest::default();
7037///
7038/// // You can configure optional parameters by calling the respective setters at will, and
7039/// // execute the final call using `doit()`.
7040/// // Values shown here are possibly random and not representative !
7041/// let result = hub.organizations().locations_workloads_restrict_allowed_resources(req, "name")
7042///              .doit().await;
7043/// # }
7044/// ```
7045pub struct OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C>
7046where
7047    C: 'a,
7048{
7049    hub: &'a Assuredworkloads<C>,
7050    _request: GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesRequest,
7051    _name: String,
7052    _delegate: Option<&'a mut dyn common::Delegate>,
7053    _additional_params: HashMap<String, String>,
7054    _scopes: BTreeSet<String>,
7055}
7056
7057impl<'a, C> common::CallBuilder for OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C> {}
7058
7059impl<'a, C> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C>
7060where
7061    C: common::Connector,
7062{
7063    /// Perform the operation you have build so far.
7064    pub async fn doit(
7065        mut self,
7066    ) -> common::Result<(
7067        common::Response,
7068        GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesResponse,
7069    )> {
7070        use std::borrow::Cow;
7071        use std::io::{Read, Seek};
7072
7073        use common::{url::Params, ToParts};
7074        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7075
7076        let mut dd = common::DefaultDelegate;
7077        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7078        dlg.begin(common::MethodInfo {
7079            id: "assuredworkloads.organizations.locations.workloads.restrictAllowedResources",
7080            http_method: hyper::Method::POST,
7081        });
7082
7083        for &field in ["alt", "name"].iter() {
7084            if self._additional_params.contains_key(field) {
7085                dlg.finished(false);
7086                return Err(common::Error::FieldClash(field));
7087            }
7088        }
7089
7090        let mut params = Params::with_capacity(4 + self._additional_params.len());
7091        params.push("name", self._name);
7092
7093        params.extend(self._additional_params.iter());
7094
7095        params.push("alt", "json");
7096        let mut url = self.hub._base_url.clone() + "v1/{+name}:restrictAllowedResources";
7097        if self._scopes.is_empty() {
7098            self._scopes
7099                .insert(Scope::CloudPlatform.as_ref().to_string());
7100        }
7101
7102        #[allow(clippy::single_element_loop)]
7103        for &(find_this, param_name) in [("{+name}", "name")].iter() {
7104            url = params.uri_replacement(url, param_name, find_this, true);
7105        }
7106        {
7107            let to_remove = ["name"];
7108            params.remove_params(&to_remove);
7109        }
7110
7111        let url = params.parse_with_url(&url);
7112
7113        let mut json_mime_type = mime::APPLICATION_JSON;
7114        let mut request_value_reader = {
7115            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7116            common::remove_json_null_values(&mut value);
7117            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7118            serde_json::to_writer(&mut dst, &value).unwrap();
7119            dst
7120        };
7121        let request_size = request_value_reader
7122            .seek(std::io::SeekFrom::End(0))
7123            .unwrap();
7124        request_value_reader
7125            .seek(std::io::SeekFrom::Start(0))
7126            .unwrap();
7127
7128        loop {
7129            let token = match self
7130                .hub
7131                .auth
7132                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7133                .await
7134            {
7135                Ok(token) => token,
7136                Err(e) => match dlg.token(e) {
7137                    Ok(token) => token,
7138                    Err(e) => {
7139                        dlg.finished(false);
7140                        return Err(common::Error::MissingToken(e));
7141                    }
7142                },
7143            };
7144            request_value_reader
7145                .seek(std::io::SeekFrom::Start(0))
7146                .unwrap();
7147            let mut req_result = {
7148                let client = &self.hub.client;
7149                dlg.pre_request();
7150                let mut req_builder = hyper::Request::builder()
7151                    .method(hyper::Method::POST)
7152                    .uri(url.as_str())
7153                    .header(USER_AGENT, self.hub._user_agent.clone());
7154
7155                if let Some(token) = token.as_ref() {
7156                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7157                }
7158
7159                let request = req_builder
7160                    .header(CONTENT_TYPE, json_mime_type.to_string())
7161                    .header(CONTENT_LENGTH, request_size as u64)
7162                    .body(common::to_body(
7163                        request_value_reader.get_ref().clone().into(),
7164                    ));
7165
7166                client.request(request.unwrap()).await
7167            };
7168
7169            match req_result {
7170                Err(err) => {
7171                    if let common::Retry::After(d) = dlg.http_error(&err) {
7172                        sleep(d).await;
7173                        continue;
7174                    }
7175                    dlg.finished(false);
7176                    return Err(common::Error::HttpError(err));
7177                }
7178                Ok(res) => {
7179                    let (mut parts, body) = res.into_parts();
7180                    let mut body = common::Body::new(body);
7181                    if !parts.status.is_success() {
7182                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7183                        let error = serde_json::from_str(&common::to_string(&bytes));
7184                        let response = common::to_response(parts, bytes.into());
7185
7186                        if let common::Retry::After(d) =
7187                            dlg.http_failure(&response, error.as_ref().ok())
7188                        {
7189                            sleep(d).await;
7190                            continue;
7191                        }
7192
7193                        dlg.finished(false);
7194
7195                        return Err(match error {
7196                            Ok(value) => common::Error::BadRequest(value),
7197                            _ => common::Error::Failure(response),
7198                        });
7199                    }
7200                    let response = {
7201                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7202                        let encoded = common::to_string(&bytes);
7203                        match serde_json::from_str(&encoded) {
7204                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7205                            Err(error) => {
7206                                dlg.response_json_decode_error(&encoded, &error);
7207                                return Err(common::Error::JsonDecodeError(
7208                                    encoded.to_string(),
7209                                    error,
7210                                ));
7211                            }
7212                        }
7213                    };
7214
7215                    dlg.finished(true);
7216                    return Ok(response);
7217                }
7218            }
7219        }
7220    }
7221
7222    ///
7223    /// Sets the *request* property to the given value.
7224    ///
7225    /// Even though the property as already been set when instantiating this call,
7226    /// we provide this method for API completeness.
7227    pub fn request(
7228        mut self,
7229        new_value: GoogleCloudAssuredworkloadsV1RestrictAllowedResourcesRequest,
7230    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C> {
7231        self._request = new_value;
7232        self
7233    }
7234    /// Required. The resource name of the Workload. This is the workloads's relative path in the API, formatted as "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}". For example, "organizations/123/locations/us-east1/workloads/assured-workload-1".
7235    ///
7236    /// Sets the *name* path property to the given value.
7237    ///
7238    /// Even though the property as already been set when instantiating this call,
7239    /// we provide this method for API completeness.
7240    pub fn name(
7241        mut self,
7242        new_value: &str,
7243    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C> {
7244        self._name = new_value.to_string();
7245        self
7246    }
7247    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7248    /// while executing the actual API request.
7249    ///
7250    /// ````text
7251    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7252    /// ````
7253    ///
7254    /// Sets the *delegate* property to the given value.
7255    pub fn delegate(
7256        mut self,
7257        new_value: &'a mut dyn common::Delegate,
7258    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C> {
7259        self._delegate = Some(new_value);
7260        self
7261    }
7262
7263    /// Set any additional parameter of the query string used in the request.
7264    /// It should be used to set parameters which are not yet available through their own
7265    /// setters.
7266    ///
7267    /// Please note that this method must not be used to set any of the known parameters
7268    /// which have their own setter method. If done anyway, the request will fail.
7269    ///
7270    /// # Additional Parameters
7271    ///
7272    /// * *$.xgafv* (query-string) - V1 error format.
7273    /// * *access_token* (query-string) - OAuth access token.
7274    /// * *alt* (query-string) - Data format for response.
7275    /// * *callback* (query-string) - JSONP
7276    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7277    /// * *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.
7278    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7279    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7280    /// * *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.
7281    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7282    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7283    pub fn param<T>(
7284        mut self,
7285        name: T,
7286        value: T,
7287    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C>
7288    where
7289        T: AsRef<str>,
7290    {
7291        self._additional_params
7292            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7293        self
7294    }
7295
7296    /// Identifies the authorization scope for the method you are building.
7297    ///
7298    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7299    /// [`Scope::CloudPlatform`].
7300    ///
7301    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7302    /// tokens for more than one scope.
7303    ///
7304    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7305    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7306    /// sufficient, a read-write scope will do as well.
7307    pub fn add_scope<St>(
7308        mut self,
7309        scope: St,
7310    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C>
7311    where
7312        St: AsRef<str>,
7313    {
7314        self._scopes.insert(String::from(scope.as_ref()));
7315        self
7316    }
7317    /// Identifies the authorization scope(s) for the method you are building.
7318    ///
7319    /// See [`Self::add_scope()`] for details.
7320    pub fn add_scopes<I, St>(
7321        mut self,
7322        scopes: I,
7323    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C>
7324    where
7325        I: IntoIterator<Item = St>,
7326        St: AsRef<str>,
7327    {
7328        self._scopes
7329            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7330        self
7331    }
7332
7333    /// Removes all scopes, and no default scope will be used either.
7334    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7335    /// for details).
7336    pub fn clear_scopes(
7337        mut self,
7338    ) -> OrganizationLocationWorkloadRestrictAllowedResourceCall<'a, C> {
7339        self._scopes.clear();
7340        self
7341    }
7342}